From 22b10399aaa97061ed940f92f5b15f6aacfb1093 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 11 Feb 2009 11:37:50 -0500 Subject: Unify feeds definition in actions I got a little sick of trying to keep the export data and links synched in actions, so I made a common method, getFeeds(), which gets the feeds for both. It returns an array of Feed objects, which know about what their mime type is, title, location, all that jazz. I changed the FeedList class so it handles the new Feed objects instead of the old array of data. I changed all the actions that show feeds (I think...) so that they now use getFeeds() for all their feed needs. --- actions/noticesearch.php | 62 ++++++++---------------------------------------- 1 file changed, 10 insertions(+), 52 deletions(-) (limited to 'actions/noticesearch.php') diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 2d94a7906..dc58d7528 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -57,11 +57,11 @@ class NoticesearchAction extends SearchAction return true; } - + /** * Get instructions - * - * @return string instruction text + * + * @return string instruction text */ function getInstructions() { @@ -70,7 +70,7 @@ class NoticesearchAction extends SearchAction /** * Get title - * + * * @return string title */ function title() @@ -78,62 +78,20 @@ class NoticesearchAction extends SearchAction return _('Text search'); } - - function showExportData() + function getFeeds() { $q = $this->trimmed('q'); - if (!$q) { - return; - } - $fl = new FeedList($this); - $fl->show(array(0 => array('href' => common_local_url('noticesearchrss', array('q' => $q)), - 'type' => 'rss', - 'version' => 'RSS 1.0', - 'item' => 'noticesearchrss'))); - } - - - function showFeeds() - { - $q = $this->trimmed('q'); if (!$q) { - return; + return null; } - $this->element('link', array('rel' => 'alternate', - 'href' => common_local_url('noticesearchrss', - array('q' => $q)), - 'type' => 'application/rss+xml', - 'title' => _('Search Stream Feed'))); + return array(new Feed(Feed::RSS1, common_local_url('noticesearchrss', + array('q' => $q)), + sprintf(_('Search results for "%s" on %s'), + $q, common_config('site', 'name')))); } - - /** - * Show header - * - * @param array $arr array containing the query - * - * @return void - */ - - function extraHead2() - { - $q = $this->trimmed('q'); - if ($q) { - $this->element('link', array('rel' => 'alternate', - 'href' => common_local_url('noticesearchrss', - array('q' => $q)), - 'type' => 'application/rss+xml', - 'title' => _('Search Stream Feed'))); - } - } - - - - - - /** * Show results * -- cgit v1.2.3-54-g00ecf