summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-10-02 13:58:01 +0100
committerAlex Pott2013-10-02 13:58:01 +0100
commit4a189ea22b928d3bd3c24bd8b1ddcadf87eb94b7 (patch)
tree743d5e29bda30487ed8da3a5a2d7382625a6e03c
parente4314ec6be18ec7021f26875e5d8ca2483e2b821 (diff)
Issue #1987390 by drupalninja99, mdrummond, Cottser, joelpittet, vinmassaro, azinoman, gnugeti, carsonevans, ezeedub: Aggregator.module - Convert theme_ functions to Twig.
-rw-r--r--core/modules/aggregator/aggregator.module15
-rw-r--r--core/modules/aggregator/aggregator.pages.inc22
-rw-r--r--core/modules/aggregator/templates/aggregator-block-item.html.twig15
-rw-r--r--core/modules/aggregator/templates/aggregator-summary-item.html.twig15
4 files changed, 42 insertions, 25 deletions
diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module
index 06e3cb2..7238278 100644
--- a/core/modules/aggregator/aggregator.module
+++ b/core/modules/aggregator/aggregator.module
@@ -59,6 +59,7 @@ function aggregator_theme() {
),
'aggregator_block_item' => array(
'variables' => array('item' => NULL, 'feed' => 0),
+ 'template' => 'aggregator-block-item',
),
'aggregator_summary_items' => array(
'variables' => array('summary_items' => NULL, 'source' => NULL),
@@ -68,6 +69,7 @@ function aggregator_theme() {
'aggregator_summary_item' => array(
'variables' => array('aggregator_item' => NULL, 'view_mode' => NULL),
'file' => 'aggregator.pages.inc',
+ 'template' => 'aggregator-summary-item',
),
'aggregator_item' => array(
'variables' => array('aggregator_item' => NULL, 'view_mode' => NULL),
@@ -435,18 +437,19 @@ function aggregator_category_load($cid) {
}
/**
- * Returns HTML for an individual feed item for display in the block.
+ * Prepares variables for individual feed item block templates.
*
- * @param $variables
+ * Default template: aggregator-block-item.html.twig.
+ *
+ * @param array $variables
* An associative array containing:
* - item: The item to be displayed.
* - feed: Not used.
- *
- * @ingroup themeable
*/
-function theme_aggregator_block_item($variables) {
+function template_preprocess_aggregator_block_item(&$variables) {
// Display the external link to the item.
- return '<a href="' . check_url($variables['item']->link) . '">' . check_plain($variables['item']->title) . "</a>\n";
+ $variables['url'] = check_url($variables['item']->link);
+ $variables['title'] = check_plain($variables['item']->title);
}
/**
diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc
index cd938e7..a711c18 100644
--- a/core/modules/aggregator/aggregator.pages.inc
+++ b/core/modules/aggregator/aggregator.pages.inc
@@ -51,21 +51,6 @@ function aggregator_load_feed_items($type, $data = NULL, $limit = 20) {
}
/**
- * Default theme implementation to present a linked feed item for summaries.
- *
- * @param $variables
- * An associative array containing:
- * - item_link: Link to item.
- * - item_age: Age of the item.
- *
- * @see template_preprocess()
- * @see template_preprocess_aggregator_summary_item()
- */
-function theme_aggregator_summary_item($variables) {
- return $variables['item_url'] . ' ' . $variables['item_age'];
-}
-
-/**
* Prepares variables for aggregator item templates.
*
* Default template: aggregator-item.html.twig.
@@ -200,21 +185,20 @@ function template_preprocess_aggregator_summary_items(&$variables) {
function template_preprocess_aggregator_summary_item(&$variables) {
$item = $variables['aggregator_item'];
- $variables['item_url'] = l(check_plain($item->label()), check_url(url($item->link->value, array('absolute' => TRUE))), array(
+ $variables['url'] = l(check_plain($item->label()), check_url(url($item->link->value, array('absolute' => TRUE))), array(
'attributes' => array(
'class' => array('feed-item-url',),
),
));
- $datetime = array(
+ $variables['age'] = array(
'#theme' => 'datetime',
'#attributes' => array(
'datetime' => format_date($item->timestamp->value, 'html_datetime', '', 'UTC'),
- 'class' => array('feed-item-age',),
+ 'class' => array('feed-item-age'),
),
'#text' => t('%age old', array('%age' => format_interval(REQUEST_TIME - $item->timestamp->value))),
'#html' => TRUE,
);
- $variables['item_age'] = drupal_render($datetime);
}
/**
diff --git a/core/modules/aggregator/templates/aggregator-block-item.html.twig b/core/modules/aggregator/templates/aggregator-block-item.html.twig
new file mode 100644
index 0000000..c5a7f3c
--- /dev/null
+++ b/core/modules/aggregator/templates/aggregator-block-item.html.twig
@@ -0,0 +1,15 @@
+{#
+/**
+ * @file
+ * Default theme implementation for feed item for display in the block.
+ *
+ * Available variables:
+ * - url: URL to the feed item.
+ * - title: Title of the feed item.
+ *
+ * @see template_preprocess_aggregator_block_item()
+ *
+ * @ingroup themeable
+ */
+#}
+<a href="{{ url }}">{{ title }}</a>
diff --git a/core/modules/aggregator/templates/aggregator-summary-item.html.twig b/core/modules/aggregator/templates/aggregator-summary-item.html.twig
new file mode 100644
index 0000000..74ad997
--- /dev/null
+++ b/core/modules/aggregator/templates/aggregator-summary-item.html.twig
@@ -0,0 +1,15 @@
+{#
+/**
+ * @file
+ * Default theme implementation for a single feed in a list of feed items.
+ *
+ * Available variables:
+ * - link: Link to item.
+ * - age: Age of the item.
+ *
+ * @see template_preprocess_aggregator_summary_item()
+ *
+ * @ingroup themeable
+ */
+#}
+{{ url }} {{ age }}