/**
  * Show the source of the notice
  *
  * Either the name (and link) of the API client that posted the notice,
  * or one of other other channels.
  *
  * @param string $source the source of the Notice
  *
  * @return string a fully rendered source of the Notice
  */
 function getSourceLink($source)
 {
     // Gettext translations for the below source types are available.
     $source_name = _($source);
     switch ($source) {
         case 'web':
         case 'xmpp':
         case 'mail':
         case 'omb':
         case 'api':
             break;
         default:
             $ns = Notice_source::staticGet($source);
             if ($ns) {
                 $source_name = '<a href="' . $ns->url . '">' . $ns->name . '</a>';
             }
             break;
     }
     return $source_name;
 }
Example #2
0
 /**
  * Get the source of the notice
  *
  * @return Notice_source $ns A notice source object. 'code' is the only attribute
  *                           guaranteed to be populated.
  */
 function getSource()
 {
     if (empty($this->source)) {
         return false;
     }
     $ns = new Notice_source();
     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;
                 $app = Oauth_application::getKV('name', $this->source);
                 if ($app) {
                     $ns->name = $app->name;
                     $ns->url = $app->source_url;
                 }
             }
             break;
     }
     return $ns;
 }
Example #3
0
 /**
  * Show the source of the message
  *
  * Returns either the name (and link) of the API client that posted the notice,
  * or one of other other channels.
  *
  * @param string $source the source of the message
  *
  * @return void
  */
 function showSource($source)
 {
     $source_name = _($source);
     switch ($source) {
         case 'web':
         case 'xmpp':
         case 'mail':
         case 'omb':
         case 'api':
             $this->element('span', 'device', $source_name);
             break;
         default:
             $ns = Notice_source::staticGet($source);
             if ($ns) {
                 $this->elementStart('span', 'device');
                 $this->element('a', array('href' => $ns->url, 'rel' => 'external'), $ns->name);
                 $this->elementEnd('span');
             } else {
                 $this->element('span', 'device', $source_name);
             }
             break;
     }
     return;
 }
 function sourceLink($source)
 {
     $source_name = _($source);
     switch ($source) {
         case 'web':
         case 'xmpp':
         case 'mail':
         case 'omb':
         case 'api':
             break;
         default:
             $name = null;
             $url = null;
             $ns = Notice_source::staticGet($source);
             if ($ns) {
                 $name = $ns->name;
                 $url = $ns->url;
             } else {
                 $app = Oauth_application::staticGet('name', $source);
                 if ($app) {
                     $name = $app->name;
                     $url = $app->source_url;
                 }
             }
             if (!empty($name) && !empty($url)) {
                 $source_name = '<a href="' . $url . '">' . $name . '</a>';
             }
             break;
     }
     return $source_name;
 }
 /**
  * Show the source of the notice
  *
  * Either the name (and link) of the API client that posted the notice,
  * or one of other other channels.
  *
  * @param string $source the source of the Notice
  *
  * @return string a fully rendered source of the Notice
  */
 function getSourceLink($source)
 {
     $source_name = _($source);
     switch ($source) {
         case 'web':
         case 'xmpp':
         case 'mail':
         case 'omb':
         case 'api':
             break;
         default:
             $ns = Notice_source::staticGet($source);
             if ($ns) {
                 $source_name = '<a href="' . $ns->url . '">' . $ns->name . '</a>';
             }
             break;
     }
     return $source_name;
 }
Example #6
0
 /**
  * Show the source of the notice
  *
  * Either the name (and link) of the API client that posted the notice,
  * or one of other other channels.
  *
  * @return void
  */
 function showNoticeSource()
 {
     if ($this->notice->source) {
         $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 = 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);
                 }
                 break;
         }
         $this->out->elementEnd('span');
     }
 }
Example #7
0
 /**
  * Show the source of the notice
  *
  * Either the name (and link) of the API client that posted the notice,
  * or one of other other channels.
  *
  * @return void
  */
 function showNoticeSource()
 {
     if ($this->notice->source) {
         $this->out->elementStart('dl', 'device');
         $this->out->element('dt', null, _('From'));
         $source_name = _($this->notice->source);
         switch ($this->notice->source) {
             case 'web':
             case 'xmpp':
             case 'mail':
             case 'omb':
             case 'api':
                 $this->out->element('dd', null, $source_name);
                 break;
             default:
                 $ns = Notice_source::staticGet($this->notice->source);
                 if ($ns) {
                     $this->out->elementStart('dd', null);
                     $this->out->element('a', array('href' => $ns->url, 'rel' => 'external'), $ns->name);
                     $this->out->elementEnd('dd');
                 } else {
                     $this->out->element('dd', null, $source_name);
                 }
                 break;
         }
         $this->out->elementEnd('dl');
     }
 }