function getSource()
{
+ if (empty($this->source)) {
+ return false;
+ }
+
$ns = new Notice_source();
- if (!empty($this->source)) {
- switch ($this->source) {
- case 'web':
- case 'xmpp':
- case 'mail':
- case 'omb':
- case 'system':
- case 'api':
+ switch ($this->source) {
+ case 'web':
+ case 'xmpp':
+ case 'mail':
+ case 'omb':
+ case 'system':
+ case 'api':
+ $ns->code = $this->source;
+ break;
+ default:
+ $ns = Notice_source::getKV($this->source);
+ if (!$ns instanceof Notice_source) {
+ $ns = new Notice_source();
$ns->code = $this->source;
- break;
- default:
- $ns = Notice_source::getKV($this->source);
- if (!$ns) {
- $ns = new Notice_source();
- $ns->code = $this->source;
- $app = Oauth_application::getKV('name', $this->source);
- if ($app) {
- $ns->name = $app->name;
- $ns->url = $app->source_url;
- }
+ $app = Oauth_application::getKV('name', $this->source);
+ if ($app) {
+ $ns->name = $app->name;
+ $ns->url = $app->source_url;
}
- break;
}
+ break;
}
return $ns;
}
$source = $this->getSource();
- if ($source) {
+ if ($source instanceof Notice_source) {
$act->generator = ActivityObject::fromNoticeSource($source);
}
*/
function getSource()
{
+ if (empty($this->source)) {
+ return false;
+ }
+
$ns = new Notice_source();
- if (!empty($this->source)) {
- switch ($this->source) {
- case 'web':
- case 'xmpp':
- case 'mail':
- case 'omb':
- case 'system':
- case 'api':
+ switch ($this->source) {
+ case 'web':
+ case 'xmpp':
+ case 'mail':
+ case 'omb':
+ case 'system':
+ case 'api':
+ $ns->code = $this->source;
+ break;
+ default:
+ $ns = Notice_source::getKV($this->source);
+ if (!$ns) {
+ $ns = new Notice_source();
$ns->code = $this->source;
- break;
- default:
- $ns = Notice_source::getKV($this->source);
- if (!$ns) {
- $ns = new Notice_source();
- $ns->code = $this->source;
- $app = Oauth_application::getKV('name', $this->source);
- if ($app) {
- $ns->name = $app->name;
- $ns->url = $app->source_url;
- }
+ $app = Oauth_application::getKV('name', $this->source);
+ if ($app) {
+ $ns->name = $app->name;
+ $ns->url = $app->source_url;
}
- break;
}
+ break;
}
+
return $ns;
}
{
$ns = $this->notice->getSource();
- if ($ns) {
- // TRANS: A possible notice source (web interface).
- $source_name = (empty($ns->name)) ? ($ns->code ? _($ns->code) : _m('SOURCE','web')) : _($ns->name);
- $this->out->text(' ');
- $this->out->elementStart('span', 'source');
- // @todo FIXME: probably i18n issue. If "from" is followed by text, that should be a parameter to "from" (from %s).
- // TRANS: Followed by notice source.
- $this->out->text(_('from'));
- $this->out->text(' ');
+ if (!$ns instanceof Notice_source) {
+ return false;
+ }
- $name = $source_name;
- $url = $ns->url;
- $title = null;
+ // TRANS: A possible notice source (web interface).
+ $source_name = (empty($ns->name)) ? ($ns->code ? _($ns->code) : _m('SOURCE','web')) : _($ns->name);
+ $this->out->text(' ');
+ $this->out->elementStart('span', 'source');
+ // @todo FIXME: probably i18n issue. If "from" is followed by text, that should be a parameter to "from" (from %s).
+ // TRANS: Followed by notice source.
+ $this->out->text(_('from'));
+ $this->out->text(' ');
- if (Event::handle('StartNoticeSourceLink', array($this->notice, &$name, &$url, &$title))) {
- $name = $source_name;
- $url = $ns->url;
- }
- Event::handle('EndNoticeSourceLink', array($this->notice, &$name, &$url, &$title));
+ $name = $source_name;
+ $url = $ns->url;
+ $title = null;
- // 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');
+ if (Event::handle('StartNoticeSourceLink', array($this->notice, &$name, &$url, &$title))) {
+ $name = $source_name;
+ $url = $ns->url;
+ }
+ Event::handle('EndNoticeSourceLink', array($this->notice, &$name, &$url, &$title));
- $attrs = array(
- 'href' => $url,
- 'rel' => 'external'
- );
+ // 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');
- if (!empty($title)) {
- $attrs['title'] = $title;
- }
+ $attrs = array(
+ 'href' => $url,
+ 'rel' => 'external'
+ );
- $this->out->element('a', $attrs, $name);
- $this->out->elementEnd('span');
- } else {
- $this->out->element('span', 'device', $name);
+ if (!empty($title)) {
+ $attrs['title'] = $title;
}
+ $this->out->element('a', $attrs, $name);
$this->out->elementEnd('span');
+ } else {
+ $this->out->element('span', 'device', $name);
}
+
+ $this->out->elementEnd('span');
}
/**