forked from GNUsocial/gnu-social
add hooks to the feedlist widget to give fine-grained control over feed links
This commit is contained in:
parent
3839627a6f
commit
d2ef0cf233
16
EVENTS.txt
16
EVENTS.txt
@ -1086,3 +1086,19 @@ StartDeleteOwnNotice: when a user starts to delete their own notice
|
|||||||
EndDeleteOwnNotice: when a user has deleted their own notice
|
EndDeleteOwnNotice: when a user has deleted their own notice
|
||||||
- $user: the user doing the delete
|
- $user: the user doing the delete
|
||||||
- $notice: the notice being deleted
|
- $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
|
||||||
|
@ -59,42 +59,50 @@ class FeedList extends Widget
|
|||||||
|
|
||||||
function show($feeds)
|
function show($feeds)
|
||||||
{
|
{
|
||||||
$this->out->elementStart('div', array('id' => 'export_data',
|
if (Event::handle('StartShowFeedLinkList', array($this->action, &$feeds))) {
|
||||||
'class' => 'section'));
|
if (!empty($feeds)) {
|
||||||
$this->out->element('h2', null, _('Feeds'));
|
$this->out->elementStart('div', array('id' => 'export_data',
|
||||||
$this->out->elementStart('ul', array('class' => 'xoxo'));
|
'class' => 'section'));
|
||||||
|
$this->out->element('h2', null, _('Feeds'));
|
||||||
|
$this->out->elementStart('ul', array('class' => 'xoxo'));
|
||||||
|
|
||||||
foreach ($feeds as $feed) {
|
foreach ($feeds as $feed) {
|
||||||
$this->feedItem($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)
|
function feedItem($feed)
|
||||||
{
|
{
|
||||||
$classname = null;
|
if (Event::handle('StartShowFeedLink', array($this->action, &$feed))) {
|
||||||
|
$classname = null;
|
||||||
|
|
||||||
switch ($feed->type) {
|
switch ($feed->type) {
|
||||||
case Feed::RSS1:
|
case Feed::RSS1:
|
||||||
case Feed::RSS2:
|
case Feed::RSS2:
|
||||||
$classname = 'rss';
|
$classname = 'rss';
|
||||||
break;
|
break;
|
||||||
case Feed::ATOM:
|
case Feed::ATOM:
|
||||||
$classname = 'atom';
|
$classname = 'atom';
|
||||||
break;
|
break;
|
||||||
case Feed::FOAF:
|
case Feed::FOAF:
|
||||||
$classname = 'foaf';
|
$classname = 'foaf';
|
||||||
break;
|
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->url,
|
|
||||||
'class' => $classname,
|
|
||||||
'type' => $feed->mimeType(),
|
|
||||||
'title' => $feed->title),
|
|
||||||
$feed->typeName());
|
|
||||||
$this->out->elementEnd('li');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user