diff options
author | Brion Vibber <brion@pobox.com> | 2010-05-19 10:59:14 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-05-19 10:59:14 -0700 |
commit | a39a934dd4a133bad6e76fa9a5018cedcb70225c (patch) | |
tree | f82b4248da5447780df322c35ca041956bcd887e /lib/noticelist.php | |
parent | d0ba34e0f32ac71b552302ec875943e0e9236720 (diff) | |
parent | 74a89b1fc37067d91d31bd66922053361eb4e616 (diff) |
Merge branch 'master' of gitorious.org:statusnet/mainline into testing
Diffstat (limited to 'lib/noticelist.php')
-rw-r--r-- | lib/noticelist.php | 72 |
1 files changed, 32 insertions, 40 deletions
diff --git a/lib/noticelist.php b/lib/noticelist.php index 4f997a328..81da9edc0 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -480,54 +480,46 @@ class NoticeListItem extends Widget function showNoticeSource() { - if ($this->notice->source) { + $ns = $this->notice->getSource(); + + if ($ns) { + $source_name = _($ns->code); $this->out->text(' '); $this->out->elementStart('span', 'source'); $this->out->text(_('from')); - $source_name = _($this->notice->source); $this->out->text(' '); - switch ($this->notice->source) { - case 'web': - case 'xmpp': - case 'mail': - case 'omb': - case 'system': - case 'api': - $this->out->element('span', 'device', $source_name); - break; - default: + $name = $source_name; + $url = $ns->url; + $title = null; + + if (Event::handle('StartNoticeSourceLink', array($this->notice, &$name, &$url, &$title))) { $name = $source_name; - $url = null; - - if (Event::handle('StartNoticeSourceLink', array($this->notice, &$name, &$url, &$title))) { - $ns = Notice_source::staticGet($this->notice->source); - - if ($ns) { - $name = $ns->name; - $url = $ns->url; - } else { - $app = Oauth_application::staticGet('name', $this->notice->source); - if ($app) { - $name = $app->name; - $url = $app->source_url; - } - } - } - Event::handle('EndNoticeSourceLink', array($this->notice, &$name, &$url, &$title)); - - if (!empty($name) && !empty($url)) { - $this->out->elementStart('span', 'device'); - $this->out->element('a', array('href' => $url, - 'rel' => 'external', - 'title' => $title), - $name); - $this->out->elementEnd('span'); - } else { - $this->out->element('span', 'device', $name); + $url = $ns->url; + } + Event::handle('EndNoticeSourceLink', array($this->notice, &$name, &$url, &$title)); + + // if $ns->name and $ns->url are populated we have + // configured a source attr somewhere + if (!empty($name) && !empty($url)) { + + $this->out->elementStart('span', 'device'); + + $attrs = array( + 'href' => $url, + 'rel' => 'external' + ); + + if (!empty($title)) { + $attrs['title'] = $title; } - break; + + $this->out->element('a', $attrs, $name); + $this->out->elementEnd('span'); + } else { + $this->out->element('span', 'device', $name); } + $this->out->elementEnd('span'); } } |