]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/feedlist.php
Removed plugin Google-Analytics as this is free/libre and decentralized
[quix0rs-gnu-social.git] / lib / feedlist.php
index 8bfcb9c5ab37bd53f174efbc0cdcee13620d282b..cc0f55249394352268c6bb869a711500163dc16b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Laconica, the distributed open-source microblogging tool
+ * StatusNet, the distributed open-source microblogging tool
  *
  * Widget for showing a list of feeds
  *
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * @category  Widget
- * @package   Laconica
- * @author    Evan Prodromou <evan@controlyourself.ca>
- * @author    Sarven Capadisli <csarven@controlyourself.ca>
- * @copyright 2008 Control Yourself, Inc.
+ * @package   StatusNet
+ * @author    Evan Prodromou <evan@status.net>
+ * @author    Sarven Capadisli <csarven@status.net>
+ * @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')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Widget for showing a list of feeds
@@ -38,128 +36,77 @@ if (!defined('LACONICA')) {
  * Typically used for Action::showExportList()
  *
  * @category Widget
- * @package  Laconica
- * @author   Evan Prodromou <evan@controlyourself.ca>
- * @author   Sarven Capadisli <csarven@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Evan Prodromou <evan@status.net>
+ * @author   Sarven Capadisli <csarven@status.net>
  * @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)
+
+    protected $feeds = null;
+
+    public function __construct(Action $action=null, array $feeds=array())
     {
-       parent::__construct($action);
-       $this->action = $action;
+        parent::__construct($action);
+        $this->action = $action;
+        $this->feeds  = $feeds;
     }
 
-    function show($feeds)
+    public function show()
     {
-        $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, &$this->feeds))) {
+            if (!empty($this->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 ($this->feeds as $feed) {
+                    $this->feedItem($feed);
+                }
+
+                $this->out->elementEnd('ul');
+                $this->out->elementEnd('div');
+            }
+            Event::handle('EndShowFeedLinkList', array($this->action, &$this->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;
+            case Feed::JSON:
+                $classname = 'json';
+                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');
     }
 }