]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/messagelistitem.php
more flexible oEmbed handling
[quix0rs-gnu-social.git] / lib / messagelistitem.php
index 2907eab2744284a3b5c8e03c6225abb0b0fd7fc8..ba8cf834afd5cde02a694e422f811233e885ae69 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2011, StatusNet, Inc.
  *
  * A single list item for showing in a message list
- * 
+ *
  * PHP version 5
  *
  * This program is free software: you can redistribute it and/or modify
@@ -65,7 +65,6 @@ abstract class MessageListItem extends Widget
      *
      * @return void
      */
-
     function show()
     {
         $this->out->elementStart('li', array('class' => 'hentry notice',
@@ -120,8 +119,9 @@ abstract class MessageListItem extends Widget
         if ($this->message->source) {
             $this->out->elementStart('span', 'source');
             // FIXME: bad i18n. Device should be a parameter (from %s).
+            // TRANS: Followed by notice source (usually the client used to send the notice).
             $this->out->text(_('from'));
-            $this->out->element('span', 'device', $this->out->showSource($this->message->source));
+            $this->showSource($this->message->source);
             $this->out->elementEnd('span');
         }
         $this->out->elementEnd('div');
@@ -129,6 +129,67 @@ abstract class MessageListItem extends Widget
         $this->out->elementEnd('li');
     }
 
+    /**
+     * Dummy method. Serves no other purpose than to make strings available used
+     * in self::showSource() through xgettext.
+     *
+     * @return void
+     */
+    function messageListItemDummyMessages()
+    {
+        // A dummy array with messages. These will get extracted by xgettext and
+        // are used in self::showSource().
+        $dummy_messages = array(
+            // TRANS: A possible notice source (web interface).
+            _m('SOURCE','web'),
+            // TRANS: A possible notice source (XMPP).
+            _m('SOURCE','xmpp'),
+            // TRANS: A possible notice source (e-mail).
+            _m('SOURCE','mail'),
+            // TRANS: A possible notice source (OpenMicroBlogging).
+            _m('SOURCE','omb'),
+            // TRANS: A possible notice source (Application Programming Interface).
+            _m('SOURCE','api'),
+        );
+    }
+
+    /**
+     * 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::staticGet($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;
+    }
+
     /**
      * Return the profile to show in the message item
      *