/**
  * 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::getKV($source);
             if ($ns instanceof Notice_source) {
                 $source_name = '<a href="' . $ns->url . '">' . $ns->name . '</a>';
             }
             break;
     }
     return $source_name;
 }
Пример #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;
 }
Пример #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 = _m('SOURCE', $source);
     switch ($source) {
         case 'web':
         case 'xmpp':
         case 'mail':
         case 'omb':
         case 'api':
             $this->out->element('span', 'device', $source_name);
             break;
         default:
             $ns = Notice_source::getKV($source);
             if ($ns) {
                 $this->out->elementStart('span', 'device');
                 $this->out->element('a', array('href' => $ns->url, 'rel' => 'external'), $ns->name);
                 $this->out->elementEnd('span');
             } else {
                 $this->out->element('span', 'device', $source_name);
             }
             break;
     }
     return;
 }