Commit 15ddad3b authored by alexpott's avatar alexpott

Issue #2359161 by olli, damiankloip: Fixed Feed icons missing in views blocks and pages.

parent 29817e45
......@@ -2178,7 +2178,7 @@ public function elementPreRender(array $element) {
$element['#empty'] = $empty ? $view->display_handler->renderArea('empty', $empty) : array();
$element['#exposed'] = !empty($view->exposed_widgets) ? $view->exposed_widgets : array();
$element['#more'] = $view->display_handler->renderMoreLink();
$element['#feed_icon'] = !empty($view->feed_icon) ? $view->feed_icon : array();
$element['#feed_icons'] = !empty($view->feedIcons) ? $view->feedIcons : array();
if ($view->display_handler->renderPager()) {
$exposed_input = isset($view->exposed_raw_input) ? $view->exposed_raw_input : NULL;
......@@ -2213,7 +2213,7 @@ public function elementPreRender(array $element) {
$element['#pager'] = array();
$element['#footer'] = array();
$element['#more'] = array();
$element['#feed_icon'] = array();
$element['#feed_icons'] = array();
}
$element['#rows'] = $form;
......
......@@ -269,6 +269,9 @@ public function attachTo(ViewExecutable $clone, $display_id, array &$build) {
$clone->buildTitle();
if ($plugin = $clone->display_handler->getPlugin('style')) {
$plugin->attachTo($build, $display_id, $this->getPath(), $clone->getTitle());
foreach ($clone->feedIcons as $feed_icon) {
$this->view->feedIcons[] = $feed_icon;
}
}
// Clean up.
......
......@@ -48,12 +48,11 @@ public function attachTo(array &$build, $display_id, $path, $title) {
}
}
else {
$feed_icon = array(
$this->view->feedIcons[] = array(
'#theme' => 'feed_icon',
'#url' => $url,
'#title' => $title,
);
$this->view->feed_icon = $feed_icon;
}
}
......
......@@ -43,7 +43,7 @@ public function attachTo(array &$build, $display_id, $path, $title) {
$url = _url($this->view->getUrl(NULL, $path), $url_options);
// Add the RSS icon to the view.
$this->view->feed_icon = [
$this->view->feedIcons[] = [
'#theme' => 'feed_icon',
'#url' => $url,
'#title' => $title,
......
......@@ -42,6 +42,7 @@ protected function setUp() {
* Tests the rendered output.
*/
public function testFeedOutput() {
$this->drupalCreateContentType(['type' => 'page']);
$this->drupalCreateNode();
// Test the site name setting.
......@@ -60,6 +61,17 @@ public function testFeedOutput() {
$this->drupalGet('test-feed-display.xml');
$result = $this->xpath('//title');
$this->assertEqual($result[0], 'test_display_feed', 'The display title is used for the feed title.');
// Add a block display and attach the feed.
$view->getExecutable()->newDisplay('block', NULL, 'test');
$display = &$view->getDisplay('feed_1');
$display['display_options']['displays']['test'] = 'test';
$view->save();
// Test the feed display adds a feed icon to the block display.
$this->drupalPlaceBlock('views_block:test_display_feed-test');
$this->drupalGet('<front>');
$feed_icon = $this->cssSelect('div.view-id-test_display_feed a.feed-icon');
$this->assertTrue(strpos($feed_icon[0]['href'], 'test-feed-display.xml'), 'The feed icon was found.');
}
}
......@@ -74,6 +74,7 @@ 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]']);
......
......@@ -125,6 +125,13 @@ class ViewExecutable {
*/
public $attachment_after = array();
/**
* Feed icons attached to the view.
*
* @var array
*/
public $feedIcons = array();
// Exposed widget input
/**
......
......@@ -20,7 +20,7 @@
* - empty: The content to display if there are no rows.
* - pager: The optional pager next/prev links to display.
* - exposed: Exposed widget form/info to display.
* - feed_icon: An optional feed icon to display.
* - feed_icons: Optional feed icons to display.
* - more: An optional link to the next page of results.
* - title: Title of the view, only used when displaying in the admin preview.
* - title_prefix: Additional output populated by modules, intended to be
......@@ -85,9 +85,9 @@
{{ footer }}
</div>
{% endif %}
{% if feed_icon %}
<div class="feed-icon">
{{ feed_icon }}
{% if feed_icons %}
<div class="feed-icons">
{{ feed_icons }}
</div>
{% endif %}
</div>
......@@ -20,7 +20,7 @@
* - empty: The content to display if there are no rows.
* - pager: The optional pager next/prev links to display.
* - exposed: Exposed widget form/info to display.
* - feed_icon: An optional feed icon to display.
* - feed_icons: Optional feed icons to display.
* - more: An optional link to the next page of results.
* - title: Title of the view, only used when displaying in the admin preview.
* - title_prefix: Additional output populated by modules, intended to be
......@@ -80,9 +80,9 @@
{{ footer }}
</div>
{% endif %}
{% if feed_icon %}
<div class="feed-icon">
{{ feed_icon }}
{% if feed_icons %}
<div class="feed-icons">
{{ feed_icons }}
</div>
{% endif %}
</div>
......@@ -110,7 +110,7 @@ function views_theme($existing, $type, $theme, $path) {
'empty' => array(),
'exposed' => array(),
'more' => array(),
'feed_icon' => array(),
'feed_icons' => array(),
'pager' => array(),
'title' => '',
'attachment_before' => array(),
......
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