Commit 2acc93b9 authored by catch's avatar catch

Issue #2357937 by Wim Leers: Remove {{ feed_icons }} from page template (page.html.twig).

parent 3e53bf23
......@@ -233,39 +233,6 @@ function drupal_get_html_head($render = TRUE) {
}
}
/**
* Adds a feed URL for the current page.
*
* This function can be called as long the HTML header hasn't been sent.
*
* @param $url
* An internal system path or a fully qualified external URL of the feed.
* @param $title
* The title of the feed.
*
* @deprecated in Drupal 8.0.x, will be removed before Drupal 8.0.0
* Use #attached on render arrays.
*/
function _drupal_add_feed($url = NULL, $title = '') {
$stored_feed_links = &drupal_static(__FUNCTION__, array());
if (isset($url)) {
$stored_feed_links[$url] = array('url' => $url, 'title' => $title);
}
return $stored_feed_links;
}
/**
* Gets the feed URLs for the current page.
*
* @deprecated in Drupal 8.0.x, will be removed before Drupal 8.0.0
* Use #attached on render arrays.
*/
function drupal_get_feeds() {
$feeds = _drupal_add_feed();
return $feeds;
}
/**
* Prepares a 'destination' URL query parameter for use with url().
*
......@@ -1870,7 +1837,13 @@ function drupal_process_attached($elements, $dependency_check = FALSE) {
call_user_func_array('_drupal_add_html_head', $args);
break;
case 'feed':
call_user_func_array('_drupal_add_feed', $args);
$args = [[
'href' => $args[0],
'rel' => 'alternate',
'title' => $args[1],
'type' => 'application/rss+xml',
]];
call_user_func_array('_drupal_add_html_head_link', $args);
break;
case 'html_head_link':
call_user_func_array('_drupal_add_html_head_link', $args);
......
......@@ -17,7 +17,6 @@
use Drupal\Core\Config\StorageException;
use Drupal\Core\Extension\Extension;
use Drupal\Core\Extension\ExtensionNameLengthException;
use Drupal\Core\Page\FeedLinkElement;
use Drupal\Core\Page\LinkElement;
use Drupal\Core\Page\MetaElement;
use Drupal\Core\Template\Attribute;
......@@ -1776,24 +1775,10 @@ function template_preprocess_page(&$variables) {
if (!defined('MAINTENANCE_MODE')) {
$variables['action_links'] = menu_get_local_actions();
$variables['tabs'] = menu_local_tabs();
// Convert drupal_get_feeds to feed links on the page object.
/** @var \Drupal\Core\Page\HtmlPage $page */
$page = $variables['page']['#page'];
// Render the feed icons.
$variables['feed_icons'] = array();
foreach ($page->getFeedLinkElements() as $link) {
$variables['feed_icons'][] = array(
'#theme' => 'feed_icon',
'#url' => $link->getAttributes()['href'],
'#title' => $link->getAttributes()['title'],
);
}
}
else {
$variables['action_links'] = array();
$variables['tabs'] = array();
$variables['feed_icons'] = '';
}
if ($node = \Drupal::routeMatch()->getParameter('node')) {
......
......@@ -109,15 +109,6 @@ public function preparePage(HtmlPage $page, &$page_array) {
$this->setDefaultMetaTags($page);
// @todo: collect feed links from #attached rather than a static once
// http://drupal.org/node/2256365 is completed.
foreach (drupal_get_feeds() as $feed) {
// Force the URL to be absolute, for consistency with other <link> tags
// output by Drupal.
$link = new FeedLinkElement($feed['title'], _url($feed['url'], array('absolute' => TRUE)));
$page->addLinkElement($link);
}
// Add libraries and CSS used by this theme.
$active_theme = \Drupal::theme()->getActiveTheme();
foreach ($active_theme->getLibraries() as $library) {
......
......@@ -12,13 +12,14 @@
use Drupal\simpletest\WebTestBase;
/**
* Make sure that _drupal_add_feed() works correctly with various constructs.
* Make sure that attaching feeds works correctly with various constructs.
*
* @group Common
*/
class AddFeedTest extends WebTestBase {
/**
* Tests _drupal_add_feed() with paths, URLs, and titles.
* Tests attaching feeds with paths, URLs, and titles.
*/
function testBasicFeedAddNoTitle() {
$path = $this->randomMachineName(12);
......
......@@ -39,7 +39,6 @@
* view and edit tabs when displaying a node).
* - action_links: Actions local to the page, such as "Add menu" on the menu
* administration interface.
* - feed_icons: All feed icons for the current page.
* - node: Fully loaded node, if there is an automatically-loaded node
* associated with the page and the node ID is the second argument in the
* page's path (e.g. node/12345 and node/12345/revisions, but not
......@@ -122,8 +121,6 @@
{% endif %}
{{ page.content }}
{{ feed_icons }}
</div>{# /.layout-content #}
{% if page.sidebar_first %}
......
......@@ -33,7 +33,6 @@ class Rss extends StylePluginBase {
protected $usesRowPlugin = TRUE;
public function attachTo(array &$build, $display_id, $path, $title) {
$display = $this->view->displayHandlers->get($display_id);
$url_options = array();
$input = $this->view->getExposedInput();
if ($input) {
......@@ -42,29 +41,21 @@ public function attachTo(array &$build, $display_id, $path, $title) {
$url_options['absolute'] = TRUE;
$url = _url($this->view->getUrl(NULL, $path), $url_options);
if ($display->hasPath()) {
if (empty($this->preview)) {
// Add a call for _drupal_add_feed to the view attached data.
$build['#attached']['feed'][] = array($url, $title);
}
}
else {
// Add the RSS icon to the view.
$feed_icon = array(
'#theme' => 'feed_icon',
'#url' => $url,
'#title' => $title,
);
$this->view->feed_icon = $feed_icon;
// Attach a link to the RSS feed, which is an alternate representation.
$build['#attached']['html_head_link'][][] = array(
'rel' => 'alternate',
'type' => 'application/rss+xml',
'title' => $title,
'href' => $url,
);
}
// Add the RSS icon to the view.
$this->view->feed_icon = [
'#theme' => 'feed_icon',
'#url' => $url,
'#title' => $title,
];
// Attach a link to the RSS feed, which is an alternate representation.
$build['#attached']['html_head_link'][][] = array(
'rel' => 'alternate',
'type' => 'application/rss+xml',
'title' => $title,
'href' => $url,
);
}
protected function defineOptions() {
......
......@@ -74,7 +74,8 @@ function testViewsWizardAndListing() {
$this->assertText($node2->label());
// Check if we have the feed.
$this->assertLinkByHref(_url($view2['page[feed_properties][path]']));
$elements = $this->cssSelect('link[href="' . _url($view2['page[feed_properties][path]'], ['absolute' => TRUE]) . '"]');
$this->assertEqual(count($elements), 1, 'Feed found.');
$this->drupalGet($view2['page[feed_properties][path]']);
$this->assertRaw('<rss version="2.0"');
// The feed should have the same title and nodes as the page.
......
......@@ -46,7 +46,6 @@
* view and edit tabs when displaying a node).
* - action_links: Actions local to the page, such as "Add menu" on the menu
* administration interface.
* - feed_icons: All feed icons for the current page.
* - node: Fully loaded node, if there is an automatically-loaded node
* associated with the page and the node ID is the second argument in the
* page's path (e.g. node/12345 and node/12345/revisions, but not
......@@ -155,7 +154,6 @@
</ul>
{% endif %}
{{ page.content }}
{{ feed_icons }}
</section></main> <!-- /.section, /#content -->
{% if page.sidebar_first %}
......
......@@ -40,7 +40,6 @@
* view and edit tabs when displaying a node).
* - action_links: Actions local to the page, such as "Add menu" on the menu
* administration interface.
* - feed_icons: All feed icons for the current page.
* - node: Fully loaded node, if there is an automatically-loaded node
* associated with the page and the node ID is the second argument in the
* page's path (e.g. node/12345 and node/12345/revisions, but not
......@@ -95,10 +94,5 @@
{% endif %}
{{ page.content }}
</main>
{% if feed_icons %}
<footer role="contentinfo" class="footer layout-column">
{{ feed_icons }}
</footer>
{% endif %}
</div>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment