diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 06e3cb27141d80fffbddb3f25649331403e19b98..7238278fb7c0f9342ff82a4c08e3761a03fd5db0 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 '' . 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 cd938e7a816bfa7405bbc93e644916a34d6fe90c..a711c18ae12ccfb22ab356b676f240c5c2197bac 100644 --- a/core/modules/aggregator/aggregator.pages.inc +++ b/core/modules/aggregator/aggregator.pages.inc @@ -50,21 +50,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. * @@ -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 0000000000000000000000000000000000000000..c5a7f3c155e083fa1c3d8214f2f1be90831f2f78 --- /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 + */ +#} +{{ title }} 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 0000000000000000000000000000000000000000..74ad9970244c0b2f2342ccaa2acb6f63e7a8a2d2 --- /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 }}