Issue #1987390 by drupalninja99, mdrummond, Cottser, joelpittet, vinmassaro, azinoman, gnugeti, carsonevans, ezeedub: Aggregator.module - Convert theme_ functions to Twig.
parent
e4314ec6be
commit
4a189ea22b
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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>
|
|
@ -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 }}
|
Loading…
Reference in New Issue