X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Ffeedlist.php;h=bbe66b2e74af62470b05bb020f1199f9ece32c26;hb=bbba1f6e168463b6994460568778e7a7df5941a1;hp=8bfcb9c5ab37bd53f174efbc0cdcee13620d282b;hpb=2fb8c58c84ef02766364e605d28ecaf90c5fc25f;p=quix0rs-gnu-social.git diff --git a/lib/feedlist.php b/lib/feedlist.php index 8bfcb9c5ab..bbe66b2e74 100644 --- a/lib/feedlist.php +++ b/lib/feedlist.php @@ -1,6 +1,6 @@ . * * @category Widget - * @package Laconica - * @author Evan Prodromou - * @author Sarven Capadisli - * @copyright 2008 Control Yourself, Inc. + * @package StatusNet + * @author Evan Prodromou + * @author Sarven Capadisli + * @copyright 2008 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } @@ -38,19 +38,18 @@ if (!defined('LACONICA')) { * Typically used for Action::showExportList() * * @category Widget - * @package Laconica - * @author Evan Prodromou - * @author Sarven Capadisli + * @package StatusNet + * @author Evan Prodromou + * @author Sarven Capadisli * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ * * @see Action::showExportList() */ - class FeedList extends Widget { var $action = null; - + function __construct($action=null) { parent::__construct($action); @@ -59,107 +58,51 @@ class FeedList extends Widget function show($feeds) { - $this->out->elementStart('div', array('id' => 'export_data', - 'class' => 'section')); - $this->out->element('h2', null, _('Export data')); - $this->out->elementStart('ul', array('class' => 'xoxo')); - - foreach ($feeds as $key => $value) { - $this->feedItem($feeds[$key]); + if (Event::handle('StartShowFeedLinkList', array($this->action, &$feeds))) { + if (!empty($feeds)) { + $this->out->elementStart('div', array('id' => 'export_data', + 'class' => 'section')); + // TRANS: Header for feed links (h2). + $this->out->element('h2', null, _('Feeds')); + $this->out->elementStart('ul', array('class' => 'xoxo')); + + foreach ($feeds as $feed) { + $this->feedItem($feed); + } + + $this->out->elementEnd('ul'); + $this->out->elementEnd('div'); + } + Event::handle('EndShowFeedLinkList', array($this->action, &$feeds)); } - - $this->out->elementEnd('ul'); - $this->out->elementEnd('div'); } function feedItem($feed) { - $nickname = $this->action->trimmed('nickname'); - - switch($feed['item']) { - case 'notices': default: - $feed_classname = $feed['type']; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = "$nickname's ".$feed['version']." notice feed"; - $feed['textContent'] = "RSS"; - break; - - case 'allrss': - $feed_classname = $feed['type']; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = $feed['version']." feed for $nickname and friends"; - $feed['textContent'] = "RSS"; - break; - - case 'repliesrss': - $feed_classname = $feed['type']; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = $feed['version']." feed for replies to $nickname"; - $feed['textContent'] = "RSS"; - break; - - case 'publicrss': - $feed_classname = $feed['type']; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = "Public timeline ".$feed['version']." feed"; - $feed['textContent'] = "RSS"; - break; - - case 'publicatom': - $feed_classname = "atom"; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = "Public timeline ".$feed['version']." feed"; - $feed['textContent'] = "Atom"; - break; - - case 'noticesearchrss': - $feed_classname = $feed['type']; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = $feed['version']." feed for this notice search"; - $feed['textContent'] = "RSS"; - break; - - case 'tagrss': - $feed_classname = $feed['type']; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = $feed['version']." feed for this tag"; - $feed['textContent'] = "RSS"; - break; - - case 'favoritedrss': - $feed_classname = $feed['type']; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = "Favorited ".$feed['version']." feed"; - $feed['textContent'] = "RSS"; - break; - - case 'foaf': - $feed_classname = "foaf"; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = "$nickname's FOAF file"; - $feed['textContent'] = "FOAF"; - break; - - case 'favoritesrss': - $feed_classname = "favorites"; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = "Feed for favorites of $nickname"; - $feed['textContent'] = "RSS"; - break; - - case 'usertimeline': - $feed_classname = "atom"; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = "$nickname's ".$feed['version']." notice feed"; - $feed['textContent'] = "Atom"; - break; + if (Event::handle('StartShowFeedLink', array($this->action, &$feed))) { + $classname = null; + + switch ($feed->type) { + case Feed::RSS1: + case Feed::RSS2: + $classname = 'rss'; + break; + case Feed::ATOM: + $classname = 'atom'; + break; + case Feed::FOAF: + $classname = 'foaf'; + break; + } + + $this->out->elementStart('li'); + $this->out->element('a', array('href' => $feed->url, + 'class' => $classname, + 'type' => $feed->mimeType(), + 'title' => $feed->title), + $feed->typeName()); + $this->out->elementEnd('li'); + Event::handle('EndShowFeedLink', array($this->action, $feed)); } - $this->out->elementStart('li'); - $this->out->element('a', array('href' => $feed['href'], - 'class' => $feed_classname, - 'type' => $feed_mimetype, - 'title' => $feed_title), - $feed['textContent']); - $this->out->elementEnd('li'); } }