]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add hooks to the feedlist widget to give fine-grained control over feed links
authorEvan Prodromou <evan@status.net>
Wed, 29 Sep 2010 17:23:46 +0000 (19:23 +0200)
committerEvan Prodromou <evan@status.net>
Wed, 29 Sep 2010 17:23:46 +0000 (19:23 +0200)
EVENTS.txt
lib/feedlist.php

index fd2bdb9d566dffe123d8ad6a12cd72d480aeaec8..cad93a7121bf04c053fec2cea6df5ad9b1972018 100644 (file)
@@ -1086,3 +1086,19 @@ StartDeleteOwnNotice: when a user starts to delete their own notice
 EndDeleteOwnNotice: when a user has deleted their own notice
 - $user: the user doing the delete
 - $notice: the notice being deleted
+
+StartShowFeedLinkList: before showing the feed list in the sidebar
+- $action: action being executed
+- $feeds: list of feeds to show
+
+EndShowFeedLinkList: after showing the feed list in the sidebar
+- $action: action being executed
+- $feeds: list of feeds shown
+
+StartShowFeedLink: before showing an individual feed item
+- $action: action being executed
+- $feed: feed to show
+
+EndShowFeedLink: after showing an individual feed
+- $action: action being executed
+- $feed: feed to show
index 7493e3575ed6666d3fd13ad9602cede8a1314f78..4aacf0b3d84ac4f3a9a327c3be8c8ebe584015b9 100644 (file)
@@ -59,42 +59,50 @@ class FeedList extends Widget
 
     function show($feeds)
     {
-        $this->out->elementStart('div', array('id' => 'export_data',
-                                              'class' => 'section'));
-        $this->out->element('h2', null, _('Feeds'));
-        $this->out->elementStart('ul', array('class' => 'xoxo'));
+        if (Event::handle('StartShowFeedLinkList', array($this->action, &$feeds))) {
+            if (!empty($feeds)) {
+                $this->out->elementStart('div', array('id' => 'export_data',
+                                                      'class' => 'section'));
+                $this->out->element('h2', null, _('Feeds'));
+                $this->out->elementStart('ul', array('class' => 'xoxo'));
 
-        foreach ($feeds as $feed) {
-            $this->feedItem($feed);
-        }
+                foreach ($feeds as $feed) {
+                    $this->feedItem($feed);
+                }
 
-        $this->out->elementEnd('ul');
-        $this->out->elementEnd('div');
+                $this->out->elementEnd('ul');
+                $this->out->elementEnd('div');
+            }
+            Event::handle('EndShowFeedLinkList', array($this->action, &$feeds));
+        }
     }
 
     function feedItem($feed)
     {
-        $classname = null;
+        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;
-        }
+            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');
+            $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));
+        }
     }
 }