]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/noticelist.php
fix ModPlus 'remote profile options' popup for Realtime
[quix0rs-gnu-social.git] / lib / noticelist.php
index dbc5bfb519afb5bd7a2b8d418ec972e555120850..7b2fbb1e7cad51a7fb22b164c25a72496587c4b6 100644 (file)
@@ -208,6 +208,7 @@ class NoticeListItem extends Widget
         $this->showStart();
         if (Event::handle('StartShowNoticeItem', array($this))) {
             $this->showNotice();
+            $this->showNoticeAttachments();
             $this->showNoticeInfo();
             $this->showNoticeOptions();
             Event::handle('EndShowNoticeItem', array($this));
@@ -226,24 +227,31 @@ class NoticeListItem extends Widget
     function showNoticeInfo()
     {
         $this->out->elementStart('div', 'entry-content');
-        $this->showNoticeLink();
-        $this->showNoticeSource();
-        $this->showNoticeLocation();
-        $this->showContext();
-        $this->showRepeat();
+        if (Event::handle('StartShowNoticeInfo', array($this))) {
+            $this->showNoticeLink();
+            $this->showNoticeSource();
+            $this->showNoticeLocation();
+            $this->showContext();
+            $this->showRepeat();
+            Event::handle('EndShowNoticeInfo', array($this));
+        }
+
         $this->out->elementEnd('div');
     }
 
     function showNoticeOptions()
     {
-        $user = common_current_user();
-        if ($user) {
-            $this->out->elementStart('div', 'notice-options');
-            $this->showFaveForm();
-            $this->showReplyLink();
-            $this->showRepeatForm();
-            $this->showDeleteLink();
-            $this->out->elementEnd('div');
+        if (Event::handle('StartShowNoticeOptions', array($this))) {
+            $user = common_current_user();
+            if ($user) {
+                $this->out->elementStart('div', 'notice-options');
+                $this->showFaveForm();
+                $this->showReplyLink();
+                $this->showRepeatForm();
+                $this->showDeleteLink();
+                $this->out->elementEnd('div');
+            }
+            Event::handle('EndShowNoticeOptions', array($this));
         }
     }
 
@@ -255,11 +263,12 @@ class NoticeListItem extends Widget
 
     function showStart()
     {
-        // XXX: RDFa
-        // TODO: add notice_type class e.g., notice_video, notice_image
-        $id = (empty($this->repeat)) ? $this->notice->id : $this->repeat->id;
-        $this->out->elementStart('li', array('class' => 'hentry notice',
-                                             'id' => 'notice-' . $id));
+        if (Event::handle('StartOpenNoticeListItemElement', array($this))) {
+            $id = (empty($this->repeat)) ? $this->notice->id : $this->repeat->id;
+            $this->out->elementStart('li', array('class' => 'hentry notice',
+                                                 'id' => 'notice-' . $id));
+            Event::handle('EndOpenNoticeListItemElement', array($this));
+        }
     }
 
     /**
@@ -270,15 +279,18 @@ class NoticeListItem extends Widget
 
     function showFaveForm()
     {
-        $user = common_current_user();
-        if ($user) {
-            if ($user->hasFave($this->notice)) {
-                $disfavor = new DisfavorForm($this->out, $this->notice);
-                $disfavor->show();
-            } else {
-                $favor = new FavorForm($this->out, $this->notice);
-                $favor->show();
+        if (Event::handle('StartShowFaveForm', array($this))) {
+            $user = common_current_user();
+            if ($user) {
+                if ($user->hasFave($this->notice)) {
+                    $disfavor = new DisfavorForm($this->out, $this->notice);
+                    $disfavor->show();
+                } else {
+                    $favor = new FavorForm($this->out, $this->notice);
+                    $favor->show();
+                }
             }
+            Event::handle('EndShowFaveForm', array($this));
         }
     }
 
@@ -296,7 +308,7 @@ class NoticeListItem extends Widget
         $attrs = array('href' => $this->profile->profileurl,
                        'class' => 'url');
         if (!empty($this->profile->fullname)) {
-            $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ')';
+            $attrs['title'] = $this->profile->getFancyName();
         }
         $this->out->elementStart('a', $attrs);
         $this->showAvatar();
@@ -317,11 +329,8 @@ class NoticeListItem extends Widget
 
     function showAvatar()
     {
-        if ('shownotice' === $this->out->trimmed('action')) {
-            $avatar_size = AVATAR_PROFILE_SIZE;
-        } else {
-            $avatar_size = AVATAR_STREAM_SIZE;
-        }
+       $avatar_size = AVATAR_STREAM_SIZE;
+
         $avatar = $this->profile->getAvatar($avatar_size);
 
         $this->out->element('img', array('src' => ($avatar) ?
@@ -376,6 +385,13 @@ class NoticeListItem extends Widget
         $this->out->elementEnd('p');
     }
 
+    function showNoticeAttachments() {
+        if (common_config('attachments', 'show_thumbs')) {
+            $al = new InlineAttachmentList($this->notice, $this->out);
+            $al->show();
+        }
+    }
+
     /**
      * show the link to the main page for the notice
      *
@@ -499,7 +515,7 @@ class NoticeListItem extends Widget
         $ns = $this->notice->getSource();
 
         if ($ns) {
-            $source_name = (empty($ns->name)) ? _($ns->code) : _($ns->name);
+            $source_name = (empty($ns->name)) ? ($ns->code ? _($ns->code) : _('web')) : _($ns->name);
             $this->out->text(' ');
             $this->out->elementStart('span', 'source');
             // FIXME: probably i18n issue. If "from" is followed by text, that should be a parameter to "from" (from %s).
@@ -691,6 +707,9 @@ class NoticeListItem extends Widget
 
     function showEnd()
     {
-        $this->out->elementEnd('li');
+        if (Event::handle('StartCloseNoticeListItemElement', array($this))) {
+            $this->out->elementEnd('li');
+            Event::handle('EndCloseNoticeListItemElement', array($this));
+        }
     }
 }