]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/noticelistitem.php
updated and moved jquery-cookie
[quix0rs-gnu-social.git] / lib / noticelistitem.php
index 8fc2f13ca26c6c84e13adbc697b3afa5445fe5e5..f829f963ee3f8ddb30ab61a7158941625416b50f 100644 (file)
@@ -73,7 +73,7 @@ class NoticeListItem extends Widget
     {
         parent::__construct($out);
         if (!empty($notice->repeat_of)) {
-            $original = Notice::staticGet('id', $notice->repeat_of);
+            $original = Notice::getKV('id', $notice->repeat_of);
             if (empty($original)) { // could have been deleted
                 $this->notice = $notice;
             } else {
@@ -144,10 +144,13 @@ class NoticeListItem extends Widget
             $user = common_current_user();
             if ($user) {
                 $this->out->elementStart('div', 'notice-options');
-                $this->showFaveForm();
-                $this->showReplyLink();
-                $this->showRepeatForm();
-                $this->showDeleteLink();
+                if (Event::handle('StartShowNoticeOptionItems', array($this))) {
+                    $this->showFaveForm();
+                    $this->showReplyLink();
+                    $this->showRepeatForm();
+                    $this->showDeleteLink();
+                    Event::handle('EndShowNoticeOptionItems', array($this));
+                }
                 $this->out->elementEnd('div');
             }
             Event::handle('EndShowNoticeOptions', array($this));
@@ -167,6 +170,9 @@ class NoticeListItem extends Widget
             if ($this->notice->scope != 0 && $this->notice->scope != 1) {
                 $class .= ' limited-scope';
             }
+            if (!empty($this->notice->source)) {
+                $class .= ' notice-source-'.$this->notice->source;
+            }
             $this->out->elementStart('li', array('class' => $class,
                                                  'id' => 'notice-' . $id));
             Event::handle('EndOpenNoticeListItemElement', array($this));
@@ -216,8 +222,14 @@ class NoticeListItem extends Widget
         $this->out->elementStart('a', $attrs);
         $this->showAvatar();
         $this->out->text(' ');
-        $this->out->element('span',array('class' => 'fn'),
-                            $this->profile->getBestName());
+        $user = common_current_user();
+        if (!empty($user) && $user->streamNicknames()) {
+            $this->out->element('span',array('class' => 'fn'),
+                                $this->profile->nickname);
+        } else {
+            $this->out->element('span',array('class' => 'fn'),
+                                $this->profile->getBestName());
+        }
         $this->out->elementEnd('a');
 
         $this->out->elementEnd('span');
@@ -259,11 +271,15 @@ class NoticeListItem extends Widget
 
         $groups = $this->getGroups();
 
+        $user = common_current_user();
+
+        $streamNicknames = !empty($user) && $user->streamNicknames();
+
         foreach ($groups as $group) {
             $ga[] = array('href' => $group->homeUrl(),
                           'title' => $group->nickname,
                           'class' => 'addressee group',
-                          'text' => $group->getBestName());
+                          'text' => ($streamNicknames) ? $group->nickname : $group->getBestName());
         }
 
         return $ga;
@@ -280,11 +296,15 @@ class NoticeListItem extends Widget
 
         $replies = $this->getReplyProfiles();
 
+        $user = common_current_user();
+
+        $streamNicknames = !empty($user) && $user->streamNicknames();
+
         foreach ($replies as $reply) {
             $pa[] = array('href' => $reply->profileurl,
                           'title' => $reply->nickname,
                           'class' => 'addressee account',
-                          'text' => $reply->getBestName());
+                          'text' => ($streamNicknames) ? $reply->nickname : $reply->getBestName());
         }
 
         return $pa;
@@ -551,7 +571,7 @@ class NoticeListItem extends Widget
     function showContext()
     {
         if ($this->notice->hasConversation()) {
-            $conv = Conversation::staticGet(
+            $conv = Conversation::getKV(
                 'id',
                 $this->notice->conversation
             );
@@ -587,7 +607,7 @@ class NoticeListItem extends Widget
     {
         if (!empty($this->repeat)) {
 
-            $repeater = Profile::staticGet('id', $this->repeat->profile_id);
+            $repeater = Profile::getKV('id', $this->repeat->profile_id);
 
             $attrs = array('href' => $repeater->profileurl,
                            'class' => 'url');
@@ -600,6 +620,7 @@ class NoticeListItem extends Widget
 
             // TRANS: Addition in notice list item if notice was repeated. Followed by a span with a nickname.
             $this->out->raw(_('Repeated by'));
+            $this->out->raw(' ');
 
             $this->out->elementStart('a', $attrs);
             $this->out->element('span', 'fn nickname', $repeater->nickname);
@@ -702,4 +723,17 @@ class NoticeListItem extends Widget
             Event::handle('EndCloseNoticeListItemElement', array($this));
         }
     }
+
+    /**
+     * Get the notice in question
+     *
+     * For hooks, etc., this may be useful
+     *
+     * @return Notice The notice we're showing
+     */
+
+    function getNotice()
+    {
+        return $this->notice;
+    }
 }