diff options
author | Evan Prodromou <evan@status.net> | 2010-09-29 19:23:46 +0200 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-09-29 19:23:46 +0200 |
commit | d2ef0cf233e7e3f4567aff6ff7c94e666da5ee95 (patch) | |
tree | 7b79f6d173e5064ab656645e3e8aa7a41a6e9290 /lib/feedlist.php | |
parent | 3839627a6f70b04c1c8f44319f44abeb21589ba7 (diff) |
add hooks to the feedlist widget to give fine-grained control over feed links
Diffstat (limited to 'lib/feedlist.php')
-rw-r--r-- | lib/feedlist.php | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/lib/feedlist.php b/lib/feedlist.php index 7493e3575..4aacf0b3d 100644 --- a/lib/feedlist.php +++ b/lib/feedlist.php @@ -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)); + } } } |