diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 221b921..364ea18 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', ), ); } @@ -511,18 +515,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 - * An associative array containing: - * - item: The item to be displayed. - * - feed: Not used. + * Default template: aggregator-block-item.html.twig. * - * @ingroup themeable + * @param array $variables + * An associative array containing: + * - url: URL to the feed item. + * - title: Title of the feed item. */ -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 32509ce..67cb6e8 100644 --- a/core/modules/aggregator/aggregator.pages.inc +++ b/core/modules/aggregator/aggregator.pages.inc @@ -7,6 +7,7 @@ use Drupal\aggregator\Plugin\Core\Entity\Feed; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Language\Language; /** * Page callback: Displays all the items captured from the particular feed. @@ -416,55 +417,81 @@ function aggregator_page_rss() { } $feeds = $result->fetchAll(); - return theme('aggregator_page_rss', array('feeds' => $feeds, 'category' => $category)); + + print theme('aggregator_page_rss', array('feeds' => $feeds, 'category' => $category)); + exit; } /** - * Prints the RSS page for a feed. + * Prepares variables for a RSS feed page template. * - * @param $variables + * Default template: aggregator-page-rss.html.twig. + * + * @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 .= '
\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 .= "