commit f9c021652b010ced82ec641e6503ccb430d49be7 Author: Joel Pittet Date: Mon Jun 10 21:33:29 2013 -0700 remove theme function and aggregator-page-* conversions diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index ab80236..2e1d364 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -79,12 +79,10 @@ 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', ), ); } diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc index 7cd12a8..5eef73c 100644 --- a/core/modules/aggregator/aggregator.pages.inc +++ b/core/modules/aggregator/aggregator.pages.inc @@ -267,21 +267,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']; -} - -/** * Prepares variables for aggregator item templates. * * Default template: aggregator-item.html.twig. @@ -377,78 +362,55 @@ function aggregator_page_rss() { } $feeds = $result->fetchAll(); - - return array( - '#theme' => 'aggregator_page_rss', - '#feeds' => $feeds, - '#category' => $category, - ); + return theme('aggregator_page_rss', array('feeds' => $feeds, 'category' => $category)); } /** - * Prepares variables for a RSS feed page template. - * - * Default template: aggregator-page-rss.html.twig. + * Prints the RSS page for a feed. * - * @param array $variables + * @param $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 template_preprocess_aggregator_page_rss(&$variables) { +function theme_aggregator_page_rss($variables) { $feeds = $variables['feeds']; $category = $variables['category']; drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8'); - $items = array(); + $items = ''; $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 = array( - $summary, - array( - '#prefix' => '

', - '#suffix' => "

\n", - '#theme' => 'link', - '#path' => check_url($feed->link), - '#title' => t('read more'), - ), - ); - } + 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"; + } $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)); - $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'] = ''; - } + $output = "\n"; + $output .= "\n"; + $output .= format_rss_channel(t('@site_name aggregator', array('@site_name' => $site_name)), $url, $description, $items); + $output .= "\n"; + + print $output; } /** @@ -472,34 +434,37 @@ function aggregator_page_opml($cid = NULL) { } $feeds = $result->fetchAll(); - return array( - '#theme' => 'aggregator_page_opml', - '#feeds' => $feeds, - ); + return theme('aggregator_page_opml', array('feeds' => $feeds)); } /** - * Prepares variables for an OPML feed page template. - * - * Default template: aggregator-page-opml.html.twig. + * Prints the OPML page for the feed. * * @param array $variables * An associative array containing: * - feeds: An array of the feeds to theme. + * + * @ingroup themeable */ -function template_preprocess_aggregator_page_opml(&$variables) { +function theme_aggregator_page_opml($variables) { $feeds = $variables['feeds']; drupal_add_http_header('Content-Type', 'text/xml; charset=utf-8'); - $variables['title'] = check_plain(config('system.site')->get('name')); - $variables['date'] = gmdate(DATE_RFC2822, REQUEST_TIME); - $variables['feeds'] = array(); - - foreach ($feeds as $key => $feed) { - $variables['feeds'][$key]['title'] = check_plain($feed->title); - $variables['feeds'][$key]['url'] = check_url($feed->url); + $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"; + + print $output; } /** @@ -544,14 +509,15 @@ function template_preprocess_aggregator_summary_item(&$variables) { 'class' => array('feed-item-url',), ), )); - $variables['age'] = theme('datetime', array( - 'attributes' => 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, - )); + '#text' => t('%age old', array('%age' => format_interval(REQUEST_TIME - $item->timestamp->value))), + '#html' => TRUE, + ); } /** diff --git a/core/modules/aggregator/templates/aggregator-page-opml.html.twig b/core/modules/aggregator/templates/aggregator-page-opml.html.twig deleted file mode 100644 index 8132624..0000000 --- a/core/modules/aggregator/templates/aggregator-page-opml.html.twig +++ /dev/null @@ -1,30 +0,0 @@ -{# -/** - * @file - * Default theme implementation to present @todo. - * - * Available variables: - * - title: Title of the feed. - * - date: Last date feed was modified. - * - feeds: An associative array of feed items containing: - * - feed.title: Title of the feed item. - * - feed.url: URL to the feed item. - * - * @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 deleted file mode 100644 index 9c121c5..0000000 --- a/core/modules/aggregator/templates/aggregator-page-rss.html.twig +++ /dev/null @@ -1,32 +0,0 @@ -{# -/** - * @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. - * - args: Any channel args to be rendered after the language code. - * - * @see template_preprocess() - * @see template_preprocess_aggregator_page_rss() - * - * @ingroup themeable - */ -#} - - - - {{ title }} - {{ link }} - {{ description }} - {{ langcode }} - {{ args }} - {% for item in items %} - {{ item }} - {% endfor %} - -