Fixed RSS feed link for category/tag feeds

- The RSS feed link was always the blog's root URL, even for category/tag feeds. FIXED
- Changed the return type documented for category() and tag() to include string for the case where an RSS feed is returned (addresses the "Scrutinizer" issues)
This commit is contained in:
ksdhans 2016-06-14 18:08:31 +12:00 committed by GitHub
parent 95e14e5496
commit d42b3ca57c

View File

@ -826,7 +826,7 @@ class Blog_Controller extends Page_Controller
/** /**
* Renders the blog posts for a given tag. * Renders the blog posts for a given tag.
* *
* @return null|SS_HTTPResponse * @return null|SS_HTTPResponse|string
*/ */
public function tag() public function tag()
{ {
@ -836,7 +836,7 @@ class Blog_Controller extends Page_Controller
$this->blogPosts = $tag->BlogPosts(); $this->blogPosts = $tag->BlogPosts();
if($this->isRSS()) { if($this->isRSS()) {
return $this->rssFeed($this->blogPosts); return $this->rssFeed($this->blogPosts, $tag->getLink());
} else { } else {
return $this->render(); return $this->render();
} }
@ -870,7 +870,7 @@ class Blog_Controller extends Page_Controller
/** /**
* Renders the blog posts for a given category. * Renders the blog posts for a given category.
* *
* @return null|SS_HTTPResponse * @return null|SS_HTTPResponse|string
*/ */
public function category() public function category()
{ {
@ -880,7 +880,7 @@ class Blog_Controller extends Page_Controller
$this->blogPosts = $category->BlogPosts(); $this->blogPosts = $category->BlogPosts();
if($this->isRSS()) { if($this->isRSS()) {
return $this->rssFeed($this->blogPosts); return $this->rssFeed($this->blogPosts, $category->getLink());
} else { } else {
return $this->render(); return $this->render();
} }
@ -1058,7 +1058,7 @@ class Blog_Controller extends Page_Controller
$this->blogPosts = $dataRecord->getBlogPosts(); $this->blogPosts = $dataRecord->getBlogPosts();
return $this->rssFeed($this->blogPosts); return $this->rssFeed($this->blogPosts, $this->Link());
} }
/** /**
@ -1102,11 +1102,14 @@ class Blog_Controller extends Page_Controller
/** /**
* Displays an RSS feed of the given blog posts. * Displays an RSS feed of the given blog posts.
* *
* @param DataList $blogPosts
* @param string $link
*
* @return string * @return string
*/ */
protected function rssFeed($blogPosts) protected function rssFeed($blogPosts, $link)
{ {
$rss = new RSSFeed($blogPosts, $this->Link(), $this->MetaTitle, $this->MetaDescription); $rss = new RSSFeed($blogPosts, $link, $this->MetaTitle, $this->MetaDescription);
$this->extend('updateRss', $rss); $this->extend('updateRss', $rss);