Loading CHANGELOG.txt +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ Views RSS 8.x-2.x-dev, 2022-xx-xx #3303702 by DamienMcKenna: Fix site slogan option on channel description. #3305462 by DamienMcKenna: Test coverage for the channel output. #3306603 by DamienMcKenna: Test coverage for channel link. #3306799 by DamienMcKenna: Pubdate values use the wrong format. Views RSS 8.x-2.0-rc1, 2022-04-29 Loading modules/views_rss_core/views_rss_core.module +5 −3 Original line number Diff line number Diff line Loading @@ -312,10 +312,11 @@ function views_rss_core_preprocess_views_view_rss(&$variables) { foreach ($variables['rows'] as $row) { foreach ($row['#row']->elements as $element) { if ($element['key'] === 'pubDate') { $this_pub_date = (string) $element['value']; if (!$max_pub_date || strtotime($this_pub_date) > strtotime($max_pub_date)) { $this_pub_date = strtotime((string) $element['value']); if (!$max_pub_date || $this_pub_date > $max_pub_date) { $max_pub_date = $this_pub_date; } $element['value'] = views_rss_format_date($this_pub_date); break; } } Loading @@ -324,7 +325,8 @@ function views_rss_core_preprocess_views_view_rss(&$variables) { $variables['channel_elements']['pubDate'] = [ '#type' => 'html_tag', '#tag' => 'pubDate', '#value' => $max_pub_date, // Convert the date value to RFC-822 format. '#value' => views_rss_format_date($max_pub_date), ]; } } Loading tests/src/Functional/DisplayFeedTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ class DisplayFeedTest extends BrowserTestBase { $this->assertStringContainsString('views-rss.xml?field_tags_target_id=1', $this->getSession()->getDriver()->getText('//item/source/@url')); // Verify the channel pubDate matches the highest node pubDate. $this->assertEquals(gmdate('r', $node->getCreatedTime()), $this->getSession()->getDriver()->getText('//channel/pubDate')); $this->assertEquals(date('r', $node->getCreatedTime()), $this->getSession()->getDriver()->getText('//channel/pubDate')); $this->assertGreaterThanOrEqual($this->testStartTime, strtotime($this->getSession()->getDriver()->getText('//channel/lastBuildDate'))); } Loading Loading @@ -145,7 +145,7 @@ class DisplayFeedTest extends BrowserTestBase { $this->drupalGet('views-rss.xml'); $this->assertSession()->statusCodeEquals(200); $driver = $this->getSession()->getDriver(); dump($this->getSession()->getDriver()->getContent()); // dump($this->getSession()->getDriver()->getContent()); // Verify the basic structure. // In order to select the root element you have to specify "any element at Loading views_rss.module +13 −0 Original line number Diff line number Diff line Loading @@ -177,3 +177,16 @@ function views_rss_link_to_front_page() { } return $url; } /** * Output a timestamp in the format required for RSS. * * @param int $timestamp * A timestamp value. * * @return string * The timestamp value in the required format. */ function views_rss_format_date($timestamp) { return date('r', $timestamp); } Loading
CHANGELOG.txt +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ Views RSS 8.x-2.x-dev, 2022-xx-xx #3303702 by DamienMcKenna: Fix site slogan option on channel description. #3305462 by DamienMcKenna: Test coverage for the channel output. #3306603 by DamienMcKenna: Test coverage for channel link. #3306799 by DamienMcKenna: Pubdate values use the wrong format. Views RSS 8.x-2.0-rc1, 2022-04-29 Loading
modules/views_rss_core/views_rss_core.module +5 −3 Original line number Diff line number Diff line Loading @@ -312,10 +312,11 @@ function views_rss_core_preprocess_views_view_rss(&$variables) { foreach ($variables['rows'] as $row) { foreach ($row['#row']->elements as $element) { if ($element['key'] === 'pubDate') { $this_pub_date = (string) $element['value']; if (!$max_pub_date || strtotime($this_pub_date) > strtotime($max_pub_date)) { $this_pub_date = strtotime((string) $element['value']); if (!$max_pub_date || $this_pub_date > $max_pub_date) { $max_pub_date = $this_pub_date; } $element['value'] = views_rss_format_date($this_pub_date); break; } } Loading @@ -324,7 +325,8 @@ function views_rss_core_preprocess_views_view_rss(&$variables) { $variables['channel_elements']['pubDate'] = [ '#type' => 'html_tag', '#tag' => 'pubDate', '#value' => $max_pub_date, // Convert the date value to RFC-822 format. '#value' => views_rss_format_date($max_pub_date), ]; } } Loading
tests/src/Functional/DisplayFeedTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ class DisplayFeedTest extends BrowserTestBase { $this->assertStringContainsString('views-rss.xml?field_tags_target_id=1', $this->getSession()->getDriver()->getText('//item/source/@url')); // Verify the channel pubDate matches the highest node pubDate. $this->assertEquals(gmdate('r', $node->getCreatedTime()), $this->getSession()->getDriver()->getText('//channel/pubDate')); $this->assertEquals(date('r', $node->getCreatedTime()), $this->getSession()->getDriver()->getText('//channel/pubDate')); $this->assertGreaterThanOrEqual($this->testStartTime, strtotime($this->getSession()->getDriver()->getText('//channel/lastBuildDate'))); } Loading Loading @@ -145,7 +145,7 @@ class DisplayFeedTest extends BrowserTestBase { $this->drupalGet('views-rss.xml'); $this->assertSession()->statusCodeEquals(200); $driver = $this->getSession()->getDriver(); dump($this->getSession()->getDriver()->getContent()); // dump($this->getSession()->getDriver()->getContent()); // Verify the basic structure. // In order to select the root element you have to specify "any element at Loading
views_rss.module +13 −0 Original line number Diff line number Diff line Loading @@ -177,3 +177,16 @@ function views_rss_link_to_front_page() { } return $url; } /** * Output a timestamp in the format required for RSS. * * @param int $timestamp * A timestamp value. * * @return string * The timestamp value in the required format. */ function views_rss_format_date($timestamp) { return date('r', $timestamp); }