]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/ShareNotice/ShareNoticePlugin.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / ShareNotice / ShareNoticePlugin.php
index d44e234529fe4bd64cac235623840341748fa861..2c199efec09c2175369cc7e8a6e006171672365b 100644 (file)
@@ -32,12 +32,12 @@ class ShareNoticePlugin extends Plugin
         array('StatusNet', array('baseurl' => 'http://identi.ca'))
     );
 
-    function onEndShowStatusNetStyles($action) {
-        $action->cssLink('plugins/ShareNotice/css/sharenotice.css');
+    public function onEndShowStylesheets(Action $action) {
+        $action->cssLink($this->path('css/sharenotice.css'));
         return true;
     }
 
-    function onStartShowNoticeItem($item)
+    function onStartShowNoticeItem(NoticeListItem $item)
     {
         $notice = $item->notice;
         $out = $item->out;
@@ -102,14 +102,18 @@ abstract class GenericNoticeShareTarget extends NoticeShareTarget
 
     protected function statusText()
     {
+        // TRANS: %s is notice content that is shared on Twitter, Facebook or another platform.
         $pattern = _m('"%s"');
-        $url = $this->notice->bestUrl();
+        $url = $this->notice->getUrl();
         $suffix = ' ' . $url;
         $room = $this->maxLength() - mb_strlen($suffix) - (mb_strlen($pattern) - mb_strlen('%s'));
 
         $content = $this->notice->content;
+        // TRANS: Truncation symbol.
+        $truncation_symbol = _m('…');
+        $truncation_symbol_length = mb_strlen($truncation_symbol);
         if (mb_strlen($content) > $room) {
-            $content = mb_substr($content, 0, $room - 1) . '…';
+            $content = mb_substr($content, 0, $room - $truncation_symbol_length) . $truncation_symbol;
         }
 
         return sprintf($pattern, $content) . $suffix;
@@ -125,6 +129,7 @@ class TwitterShareTarget extends GenericNoticeShareTarget
 
     public function getText()
     {
+        // TRANS: Tooltip for image to share a notice on Twitter.
         return _m('Share on Twitter');
     }
 
@@ -156,6 +161,8 @@ class StatusNetShareTarget extends GenericNoticeShareTarget
     public function getText()
     {
         $host = parse_url($this->baseurl, PHP_URL_HOST);
+        // TRANS: Tooltip for image to share a notice on another platform (other than Twitter or Facebook).
+        // TRANS: %s is a host name.
         return sprintf(_m('Share on %s'), $host);
     }
 
@@ -167,7 +174,6 @@ class StatusNetShareTarget extends GenericNoticeShareTarget
         return $this->baseurl . '/notice/new?' .
                 http_build_query($args, null, '&');
     }
-
 }
 
 class FacebookShareTarget extends NoticeShareTarget
@@ -179,16 +185,42 @@ class FacebookShareTarget extends NoticeShareTarget
 
     public function getText()
     {
+        // TRANS: Tooltip for image to share a notice on Facebook.
         return _m('Share on Facebook');
     }
 
     public function targetUrl()
     {
         $args = array(
-            'u' => $this->notice->bestUrl(),
+            'u' => $this->notice->getUrl(),
+            // TRANS: %s is notice content that is shared on Twitter, Facebook or another platform.
             't' => sprintf(_m('"%s"'), $this->notice->content),
         );
         return 'http://www.facebook.com/sharer.php?' .
             http_build_query($args, null, '&');
     }
-}
\ No newline at end of file
+
+    /**
+     * Provide plugin version information.
+     *
+     * This data is used when showing the version page.
+     *
+     * @param array &$versions array of version data arrays; see EVENTS.txt
+     *
+     * @return boolean hook value
+     */
+    function onPluginVersion(array &$versions)
+    {
+        $url = 'http://status.net/wiki/Plugin:ShareNotice';
+
+        $versions[] = array('name' => 'ShareNotice',
+            'version' => GNUSOCIAL_VERSION,
+            'author' => 'Brion Vibber',
+            'homepage' => $url,
+            'rawdescription' =>
+            // TRANS: Plugin description.
+            _m('This plugin allows sharing of notices to Twitter, Facebook and other platforms.'));
+
+        return true;
+    }
+}