diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module
index 1a5ed47..78468ed 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),
@@ -77,10 +79,12 @@ function aggregator_theme() {
'aggregator_page_opml' => array(
'variables' => array('feeds' => NULL),
'file' => 'aggregator.pages.inc',
+ 'template' => 'aggregator-page-opml',
),
'aggregator_page_rss' => array(
'variables' => array('feeds' => NULL, 'category' => NULL),
'file' => 'aggregator.pages.inc',
+ 'template' => 'aggregator-page-rss',
),
);
}
@@ -516,18 +520,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 '' . check_plain($variables['item']->title) . "\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 6248012..24adefb 100644
--- a/core/modules/aggregator/aggregator.pages.inc
+++ b/core/modules/aggregator/aggregator.pages.inc
@@ -282,21 +282,6 @@ function aggregator_categorize_items_submit($form, &$form_state) {
}
/**
- * 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'];
-}
-
-/**
* Processes variables for aggregator-item.tpl.php.
*
* @see aggregator-item.tpl.php
@@ -425,55 +410,77 @@ function aggregator_page_rss() {
}
$feeds = $result->fetchAll();
- return theme('aggregator_page_rss', array('feeds' => $feeds, 'category' => $category));
+ return array(
+ '#theme' => 'aggregator_page_rss',
+ '#feeds' => $feeds,
+ '#category' => $category,
+ );
}
/**
- * Prints the RSS page for a feed.
+ * Prepares variables for a RSS feed page template.
+ *
+ * Default template: aggregator-page-rss.html.twig.
*
- * @param $variables
+ * @param array $variables
* An associative array containing:
* - feeds: An array of the feeds to theme.
* - category: A common category, if any, for all the feeds.
- *
- * @return void
- *
- * @ingroup themeable
*/
-function theme_aggregator_page_rss($variables) {
+function template_preprocess_aggregator_page_rss(&$variables) {
$feeds = $variables['feeds'];
$category = $variables['category'];
drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
- $items = '';
+ $items = array();
$feed_length = config('system.rss')->get('items.view_mode');
foreach ($feeds as $feed) {
- switch ($feed_length) {
- case 'teaser':
- $summary = text_summary($feed->description, NULL, config('aggregator.settings')->get('items.teaser_length'));
- if ($summary != $feed->description) {
- $summary .= '
' . t('read more') . "
\n";
- }
+ switch ($feed_length) {
+ case 'teaser':
+ $summary = text_summary($feed->description, NULL, config('aggregator.settings')->get('items.teaser_length'));
+ if ($summary != $feed->description) {
+ $summary = array(
+ $summary,
+ array(
+ '#prefix' => '',
+ '#suffix' => "
\n",
+ '#theme' => 'link',
+ '#path' => check_url($feed->link),
+ '#title' => t('read more'),
+ ),
+ );
+ }
$feed->description = $summary;
break;
case 'title':
$feed->description = '';
break;
}
- $items .= format_rss_item($feed->ftitle . ': ' . $feed->title, $feed->link, $feed->description, array('pubDate' => date('r', $feed->timestamp)));
+ $items[] = format_rss_item($feed->ftitle . ': ' . $feed->title, $feed->link, $feed->description, array('pubDate' => date('r', $feed->timestamp)));
}
$site_name = config('system.site')->get('name');
$url = url((isset($category) ? 'aggregator/categories/' . $category->cid : 'aggregator'), array('absolute' => TRUE));
$description = isset($category) ? t('@site_name - aggregated feeds in category @title', array('@site_name' => $site_name, '@title' => $category->title)) : t('@site_name - aggregated feeds', array('@site_name' => $site_name));
- $output = "\n";
- $output .= "\n";
- $output .= format_rss_channel(t('@site_name aggregator', array('@site_name' => $site_name)), $url, $description, $items);
- $output .= "\n";
-
- print $output;
+ $variables['title'] = t('@site_name aggregator', array('@site_name' => $site_name));
+ $variables['link'] = check_url($url);
+ // The RSS 2.0 "spec" doesn't indicate HTML can be used in the description.
+ // We strip all HTML tags, but need to prevent double encoding from properly
+ // escaped source data (such as & becoming &).
+ $variables['description'] = check_plain(decode_entities(strip_tags($description)));
+ $variables['items'] = $items;
+
+ $langcode = (isset($category['langcode']) ? $category['langcode'] : language(LANGUAGE_TYPE_CONTENT)->langcode);
+ $variables['langcode'] = check_plain($langcode);
+
+ // Pass along any channel args to be rendered after the language code.
+ if (isset($category['args']) && is_array($category['args'])) {
+ $variables['args'] = format_xml_elements($category['args']);
+ } else {
+ $variables['args'] = '';
+ }
}
/**
@@ -501,33 +508,27 @@ function aggregator_page_opml($cid = NULL) {
}
/**
- * Prints the OPML page for the feed.
+ * Prepares variables for an OPML feed page template.
+ *
+ * Default template: aggregator-page-opml.html.twig.
*
* @param array $variables
* An associative array containing:
* - feeds: An array of the feeds to theme.
- *
- * @ingroup themeable
*/
-function theme_aggregator_page_opml($variables) {
+function template_preprocess_aggregator_page_opml(&$variables) {
$feeds = $variables['feeds'];
drupal_add_http_header('Content-Type', 'text/xml; charset=utf-8');
- $output = "\n";
- $output .= "\n";
- $output .= "\n";
- $output .= '' . check_plain(config('system.site')->get('name')) . "\n";
- $output .= '' . gmdate(DATE_RFC2822, REQUEST_TIME) . "\n";
- $output .= "\n";
- $output .= "\n";
- foreach ($feeds as $feed) {
- $output .= '\n";
- }
- $output .= "\n";
- $output .= "\n";
+ $variables['title'] = check_plain(config('system.site')->get('name'));
+ $variables['date'] = gmdate(DATE_RFC2822, REQUEST_TIME);
+ $variables['feeds'] = array();
- print $output;
+ foreach ($feeds as $key => $feed) {
+ $variables['feeds'][$key]['title'] = check_plain($feed->title);
+ $variables['feeds'][$key]['url'] = check_url($feed->url);
+ }
}
/**
@@ -549,19 +550,23 @@ function template_preprocess_aggregator_summary_items(&$variables) {
}
/**
- * Processes variables for aggregator-summary-item.tpl.php.
+ * Prepares variables for aggregator summary item templates.
*
- * @see aggregator-summary-item.tpl.php
+ * Default template: aggregator-summary-item.html.twig.
+ *
+ * @param array $variables
+ * An associative array containing:
+ * - aggregator_item: A feed item.
*/
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',),
),
));
- $variables['item_age'] = theme('datetime', array(
+ $variables['age'] = theme('datetime', array(
'attributes' => array(
'datetime' => format_date($item->timestamp->value, 'html_datetime', '', 'UTC'),
'class' => array('feed-item-age',),
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..10bc490
--- /dev/null
+++ b/core/modules/aggregator/templates/aggregator-block-item.html.twig
@@ -0,0 +1,16 @@
+{#
+/**
+ * @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()
+ * @see template_preprocess_aggregator_block_item()
+ *
+ * @ingroup themeable
+ */
+#}
+{{ title }}
diff --git a/core/modules/aggregator/templates/aggregator-page-opml.html.twig b/core/modules/aggregator/templates/aggregator-page-opml.html.twig
new file mode 100644
index 0000000..035d76c
--- /dev/null
+++ b/core/modules/aggregator/templates/aggregator-page-opml.html.twig
@@ -0,0 +1,30 @@
+{#
+/**
+ * @file
+ * Default theme implementation to present @todo.
+ *
+ * Available variables:
+ * - title: @todo.
+ * - date: @todo.
+ * - feeds: @todo.
+ * - feed.title: @todo.
+ * - feed.url: @todo.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_aggregator_page_opml()
+ *
+ * @ingroup themeable
+ */
+#}
+
+
+
+ {{ title }}
+ {{ date }}
+
+
+ {% for feed in feeds %}
+
+ {% endfor %}
+
+
diff --git a/core/modules/aggregator/templates/aggregator-page-rss.html.twig b/core/modules/aggregator/templates/aggregator-page-rss.html.twig
new file mode 100644
index 0000000..9ad37ea
--- /dev/null
+++ b/core/modules/aggregator/templates/aggregator-page-rss.html.twig
@@ -0,0 +1,31 @@
+{#
+/**
+ * @file
+ * Default theme implementation for an RSS feed page.
+ *
+ * Available variables:
+ * - title: RSS channel title.
+ * - link: RSS channel link.
+ * - description: RSS channel description.
+ * - language: RSS channel language code.
+ * - items: RSS feed items.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_aggregator_page_rss()
+ *
+ * @ingroup themeable
+ */
+#}
+
+
+
+ {{ title }}
+ {{ link }}
+ {{ description }}
+ {{ langcode }}
+ {{ args }}
+ {% for item in items %}
+ {{ item }}
+ {% endfor %}
+
+
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..6e2d8b1
--- /dev/null
+++ b/core/modules/aggregator/templates/aggregator-summary-item.html.twig
@@ -0,0 +1,16 @@
+{#
+/**
+ * @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()
+ * @see template_preprocess_aggregator_summary_item()
+ *
+ * @ingroup themeable
+ */
+#}
+{{ url }} {{ age }}