From 4cc09aaf7e95c1c293c33e344dfb1522fad62ffe Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Fri, 24 May 2013 09:57:09 -0700 Subject: [PATCH] Issue #1896060 by shanethehat, Cottser, joelpittet, disasm, ParisLiakos, Floydm, stevector, jenlampton, c4rl, mr.baileys, thedavidmeister, jwilson3: aggregator.module - Convert PHPTemplate templates to Twig. --- core/modules/aggregator/aggregator.module | 2 +- core/modules/aggregator/aggregator.pages.inc | 41 ++++++++++++---- .../aggregator-feed-source.html.twig | 35 ++++++++++++++ .../templates/aggregator-feed-source.tpl.php | 36 -------------- .../templates/aggregator-item.html.twig | 44 +++++++++++++++++ .../templates/aggregator-item.tpl.php | 47 ------------------- .../aggregator-summary-items.html.twig | 24 ++++++++++ .../aggregator-summary-items.tpl.php | 24 ---------- .../templates/aggregator-wrapper.tpl.php | 20 -------- 9 files changed, 137 insertions(+), 136 deletions(-) create mode 100644 core/modules/aggregator/templates/aggregator-feed-source.html.twig delete mode 100644 core/modules/aggregator/templates/aggregator-feed-source.tpl.php create mode 100644 core/modules/aggregator/templates/aggregator-item.html.twig delete mode 100644 core/modules/aggregator/templates/aggregator-item.tpl.php create mode 100644 core/modules/aggregator/templates/aggregator-summary-items.html.twig delete mode 100644 core/modules/aggregator/templates/aggregator-summary-items.tpl.php delete mode 100644 core/modules/aggregator/templates/aggregator-wrapper.tpl.php diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index bd65f4fae031..221b921bd914 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -539,7 +539,7 @@ function aggregator_filter_xss($value) { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. */ function aggregator_preprocess_block(&$variables) { if ($variables['configuration']['module'] == 'aggregator') { diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc index 10ba125fba53..32509ce71140 100644 --- a/core/modules/aggregator/aggregator.pages.inc +++ b/core/modules/aggregator/aggregator.pages.inc @@ -281,9 +281,14 @@ function theme_aggregator_summary_item($variables) { } /** - * Processes variables for aggregator-item.tpl.php. + * Prepares variables for aggregator item templates. * - * @see aggregator-item.tpl.php + * Default template: aggregator-item.html.twig. + * + * @param array $variables + * An associative array containing: + * - aggregator_item: An individual feed item for display on the aggregator + * page. */ function template_preprocess_aggregator_item(&$variables) { $item = $variables['aggregator_item']; @@ -309,6 +314,8 @@ function template_preprocess_aggregator_item(&$variables) { foreach ($item->categories as $category) { $variables['categories'][$category->cid] = l($category->title, 'aggregator/categories/' . $category->cid); } + + $variables['attributes']['class'][] = 'feed-item'; } /** @@ -515,9 +522,15 @@ function theme_aggregator_page_opml($variables) { } /** - * Processes variables for aggregator-summary-items.tpl.php. + * Prepares variables for aggregator summary templates. * - * @see aggregator-summary-items.tpl.php + * Default template: aggregator-summary-items.html.twig. + * + * @param array $variables + * An associative array containing: + * - source: A Drupal\aggregator\Plugin\Core\Entity\Feed instance representing + * the feed source. + * - summary_items: An array of feed items. */ function template_preprocess_aggregator_summary_items(&$variables) { $variables['title'] = check_plain($variables['source'] instanceof EntityInterface ? $variables['source']->label() : $variables['source']->title); @@ -533,9 +546,14 @@ function template_preprocess_aggregator_summary_items(&$variables) { } /** - * Processes variables for aggregator-summary-item.tpl.php. + * Processes 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: The feed item. + * - view_mode: How the item is being displayed. */ function template_preprocess_aggregator_summary_item(&$variables) { $item = $variables['aggregator_item']; @@ -556,9 +574,14 @@ function template_preprocess_aggregator_summary_item(&$variables) { } /** - * Processes variables for aggregator-feed-source.tpl.php. + * Prepares variables for aggregator feed source templates. + * + * Default template: aggregator-feed-source.html.twig. * - * @see aggregator-feed-source.tpl.php + * @param array $variables + * An associative array containing: + * - aggregator_feed: A Drupal\aggregator\Plugin\Core\Entity\Feed instance + * representing the feed source. */ function template_preprocess_aggregator_feed_source(&$variables) { $feed = $variables['aggregator_feed']; @@ -584,4 +607,6 @@ function template_preprocess_aggregator_feed_source(&$variables) { if (user_access('administer news feeds')) { $variables['last_checked'] = l($variables['last_checked'], 'admin/config/services/aggregator'); } + + $variables['attributes']['class'][] = 'feed-source'; } diff --git a/core/modules/aggregator/templates/aggregator-feed-source.html.twig b/core/modules/aggregator/templates/aggregator-feed-source.html.twig new file mode 100644 index 000000000000..0bb2ddb98893 --- /dev/null +++ b/core/modules/aggregator/templates/aggregator-feed-source.html.twig @@ -0,0 +1,35 @@ +{# +/** + * @file + * Default theme implementation to present the source of the feed. + * + * The contents are rendered above feed listings when browsing source feeds. + * For example, "example.com/aggregator/sources/1". + * + * Available variables: + * - source_icon: Feed icon linked to the source. Rendered through + * feed-icon.html.twig. + * - source_image: Image set by the feed source. + * - source_description: Description set by the feed source. + * - source_url: URL to the feed source. + * - last_checked: How long ago the feed was checked locally. + * + * @see template_preprocess() + * @see template_preprocess_aggregator_feed_source() + * + * @ingroup themeable + */ +#} +<div{{ attributes}}> + {{ source_icon }} + {{ source_image }} + <div class="feed-description"> + {{ source_description }} + </div> + <div class="feed-url"> + <em>{{ 'URL'|t }}:</em> <a href="{{ source_url }}">{{ source_url }}</a> + </div> + <div class="feed-updated"> + <em>{{ 'Updated'|t }}:</em> {{ last_checked }} + </div> +</div> diff --git a/core/modules/aggregator/templates/aggregator-feed-source.tpl.php b/core/modules/aggregator/templates/aggregator-feed-source.tpl.php deleted file mode 100644 index f9cfa55561ec..000000000000 --- a/core/modules/aggregator/templates/aggregator-feed-source.tpl.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -/** - * @file - * Default theme implementation to present the source of the feed. - * - * The contents are rendered above feed listings when browsing source feeds. - * For example, "example.com/aggregator/sources/1". - * - * Available variables: - * - $source_icon: Feed icon linked to the source. Rendered through - * theme_feed_icon(). - * - $source_image: Image set by the feed source. - * - $source_description: Description set by the feed source. - * - $source_url: URL to the feed source. - * - $last_checked: How long ago the feed was checked locally. - * - * @see template_preprocess() - * @see template_preprocess_aggregator_feed_source() - * - * @ingroup themeable - */ -?> -<div class="feed-source"> - <?php print $source_icon; ?> - <?php print $source_image; ?> - <div class="feed-description"> - <?php print $source_description; ?> - </div> - <div class="feed-url"> - <em><?php print t('URL:'); ?></em> <a href="<?php print $source_url; ?>"><?php print $source_url; ?></a> - </div> - <div class="feed-updated"> - <em><?php print t('Updated:'); ?></em> <?php print $last_checked; ?> - </div> -</div> diff --git a/core/modules/aggregator/templates/aggregator-item.html.twig b/core/modules/aggregator/templates/aggregator-item.html.twig new file mode 100644 index 000000000000..6a0185bceaff --- /dev/null +++ b/core/modules/aggregator/templates/aggregator-item.html.twig @@ -0,0 +1,44 @@ +{# +/** + * @file + * Default theme implementation to present a feed item in an aggregator page. + * + * Available variables: + * - feed_url: URL to the originating feed item. + * - feed_title: Title of the feed item. + * - source_url: Link to the local source section. + * - source_title: Title of the remote source. + * - source_date: Date the feed was posted on the remote source. + * - content: Feed item content. + * - categories: Linked categories assigned to the feed. + * + * @see template_preprocess() + * @see template_preprocess_aggregator_item() + * + * @ingroup themeable + */ +#} +<div{{ attributes }}> + <h3 class="feed-item-title"> + <a href="{{ feed_url }}">{{ feed_title }}</a> + </h3> + + <div class="feed-item-meta"> + {% if source_url %} + <a href="{{ source_url }}" class="feed-item-source">{{ source_title }}</a> - + {% endif %} + <span class="feed-item-date">{{ source_date }}</span> + </div> + + {% if content %} + <div class="feed-item-body"> + {{ content }} + </div> + {% endif %} + + {% if categories %} + <div class="feed-item-categories"> + {{ 'Categories'|t }}: {{ categories|join(', ') }} + </div> + {% endif %} +</div> diff --git a/core/modules/aggregator/templates/aggregator-item.tpl.php b/core/modules/aggregator/templates/aggregator-item.tpl.php deleted file mode 100644 index 74b2284cbe38..000000000000 --- a/core/modules/aggregator/templates/aggregator-item.tpl.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -/** - * @file - * Default theme implementation to format an individual feed item for display - * on the aggregator page. - * - * Available variables: - * - $feed_url: URL to the originating feed item. - * - $feed_title: Title of the feed item. - * - $source_url: Link to the local source section. - * - $source_title: Title of the remote source. - * - $source_date: Date the feed was posted on the remote source. - * - $content: Feed item content. - * - $categories: Linked categories assigned to the feed. - * - * @see template_preprocess() - * @see template_preprocess_aggregator_item() - * - * @ingroup themeable - */ -?> -<div class="feed-item"> - <h3 class="feed-item-title"> - <a href="<?php print $feed_url; ?>"><?php print $feed_title; ?></a> - </h3> - - <div class="feed-item-meta"> - <?php if ($source_url): ?> - <a href="<?php print $source_url; ?>" class="feed-item-source"><?php print $source_title; ?></a> - - <?php endif; ?> - <span class="feed-item-date"><?php print $source_date; ?></span> - </div> - -<?php if ($content): ?> - <div class="feed-item-body"> - <?php print $content; ?> - </div> -<?php endif; ?> - -<?php if ($categories): ?> - <div class="feed-item-categories"> - <?php print t('Categories'); ?>: <?php print implode(', ', $categories); ?> - </div> -<?php endif ;?> - -</div> diff --git a/core/modules/aggregator/templates/aggregator-summary-items.html.twig b/core/modules/aggregator/templates/aggregator-summary-items.html.twig new file mode 100644 index 000000000000..5376fda50c87 --- /dev/null +++ b/core/modules/aggregator/templates/aggregator-summary-items.html.twig @@ -0,0 +1,24 @@ +{# +/** + * @file + * Default theme implementation to present feeds as list items. + * + * Each iteration generates a single feed source or category. + * + * Available variables: + * - title: Title of the feed or category. + * - summary_list: Unordered list of linked feed items generated through + * theme_item_list(). + * - source_url: URL to the local source or category. + * + * @see template_preprocess() + * @see template_preprocess_aggregator_summary_items() + * + * @ingroup themeable + */ +#} +<h3>{{ title }}</h3> +{{ summary_list }} +<div class="links"> + <a href="{{ source_url }}">{{ 'More<span class="element-invisible"> posts about %title</span>'|t({ '%title': title }) }}</a> +</div> diff --git a/core/modules/aggregator/templates/aggregator-summary-items.tpl.php b/core/modules/aggregator/templates/aggregator-summary-items.tpl.php deleted file mode 100644 index 8f19fe176a19..000000000000 --- a/core/modules/aggregator/templates/aggregator-summary-items.tpl.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -/** - * @file - * Default theme implementation to present feeds as list items. - * - * Each iteration generates a single feed source or category. - * - * Available variables: - * - $title: Title of the feed or category. - * - $summary_list: Render array of unordered feed items list. - * - $source_url: URL to the local source or category. - * - * @see template_preprocess() - * @see template_preprocess_aggregator_summary_items() - * - * @ingroup themeable - */ -?> -<h3><?php print $title; ?></h3> -<?php print render($summary_list); ?> -<div class="links"> - <a href="<?php print $source_url; ?>"><?php print t("More<span class=\"element-invisible\"> posts about %title</span>", array('%title' => $title)); ?></a> -</div> diff --git a/core/modules/aggregator/templates/aggregator-wrapper.tpl.php b/core/modules/aggregator/templates/aggregator-wrapper.tpl.php deleted file mode 100644 index 0e97ba4d20b4..000000000000 --- a/core/modules/aggregator/templates/aggregator-wrapper.tpl.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -/** - * @file - * Default theme implementation to wrap aggregator content. - * - * Available variables: - * - $content: All aggregator content. - * - $page: Pager links rendered through theme_pager(). - * - * @see template_preprocess() - * @see template_preprocess_aggregator_wrapper() - * - * @ingroup themeable - */ -?> -<div class="<?php print $attributes['class']; ?>"> - <?php print $content; ?> - <?php print $pager; ?> -</div> -- GitLab