]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/noticelistitem.php
Add direct link to parent notice
[quix0rs-gnu-social.git] / lib / noticelistitem.php
index 282ace3724afdd3985b4bdce030a6eca5df35236..f38c7eb0ba8955585b7dfe677d8ecd7223df1d4a 100644 (file)
@@ -63,6 +63,7 @@ class NoticeListItem extends Widget
     protected $id_prefix = null;
     protected $options = true;
     protected $maxchars = 0;   // if <= 0 it means use full posts
+    protected $item_tag = 'li';
 
     /**
      * constructor
@@ -101,7 +102,7 @@ class NoticeListItem extends Widget
             }
         }
         // string preferences
-        foreach(array('id_prefix') as $key) {
+        foreach(array('id_prefix', 'item_tag') as $key) {
             if (array_key_exists($key, $prefs)) {
                 $this->$key = $prefs[$key];
             }
@@ -149,7 +150,13 @@ class NoticeListItem extends Widget
         $this->elementStart('section', array('class'=>'notice-headers'));
         $this->showNoticeTitle();
         $this->showAuthor();
-        if ($this->addressees) { $this->showAddressees(); }
+
+        if (!empty($this->notice->reply_to) || $this->addressees) {
+            $this->elementStart('div', array('class' => 'parents'));
+            if (!empty($this->notice->reply_to)) { $this->showParent(); }
+            if ($this->addressees) { $this->showAddressees(); }
+            $this->elementEnd('div');
+        }
         $this->elementEnd('section');
     }
 
@@ -179,7 +186,6 @@ class NoticeListItem extends Widget
             $this->showNoticeSource();
             $this->showNoticeLocation();
             $this->showPermalink();
-            $this->showRepeat();
             Event::handle('EndShowNoticeInfo', array($this));
         }
     }
@@ -192,7 +198,6 @@ class NoticeListItem extends Widget
                 $this->out->elementStart('div', 'notice-options');
                 if (Event::handle('StartShowNoticeOptionItems', array($this))) {
                     $this->showReplyLink();
-                    $this->showRepeatForm();
                     $this->showDeleteLink();
                     Event::handle('EndShowNoticeOptionItems', array($this));
                 }
@@ -219,7 +224,7 @@ class NoticeListItem extends Widget
                 $class .= ' notice-source-'.$this->notice->source;
             }
             $id_prefix = (strlen($this->id_prefix) ? $this->id_prefix . '-' : '');
-            $this->out->elementStart('li', array('class' => $class,
+            $this->out->elementStart($this->item_tag, array('class' => $class,
                                                  'id' => "${id_prefix}notice-${id}"));
             Event::handle('EndOpenNoticeListItemElement', array($this));
         }
@@ -248,6 +253,19 @@ class NoticeListItem extends Widget
         }
     }
 
+    function showParent()
+    {
+        $this->out->element(
+            'a',
+            array(
+                'href' => $this->notice->getParent()->getUrl(),
+                'class' => 'u-in-reply-to',
+                'rel' => 'in-reply-to'
+            ),
+            'in reply to'
+        );
+    }
+
     function showAddressees()
     {
         $pa = $this->getProfileAddressees();
@@ -369,18 +387,19 @@ class NoticeListItem extends Widget
      */
     function showNoticeLocation()
     {
-        $id = $this->notice->id;
-
-        $location = $this->notice->getLocation();
-
-        if (empty($location)) {
+        return;
+        try {
+            $location = Notice_location::locFromStored($this->notice);
+        } catch (NoResultException $e) {
+            return;
+        } catch (ServerException $e) {
             return;
         }
 
         $name = $location->getName();
 
-        $lat = $this->notice->lat;
-        $lon = $this->notice->lon;
+        $lat = $location->lat;
+        $lon = $location->lon;
         $latlon = (!empty($lat) && !empty($lon)) ? $lat.';'.$lon : '';
 
         if (empty($name)) {
@@ -527,32 +546,6 @@ class NoticeListItem extends Widget
         }
     }
 
-    /**
-     * show a link to the author of repeat
-     *
-     * @return void
-     */
-    function showRepeat()
-    {
-        if (!empty($this->repeat)) {
-
-            $repeater = Profile::getKV('id', $this->repeat->profile_id);
-
-            $attrs = array('href' => $repeater->profileurl,
-                           'class' => 'h-card p-author',
-                           'title' => $repeater->getFancyName());
-
-            $this->out->elementStart('span', 'repeat h-entry');
-
-            // TRANS: Addition in notice list item if notice was repeated. Followed by a span with a nickname.
-            $this->out->raw(_('Repeated by').' ');
-
-            $this->out->element('a', $attrs, $repeater->getNickname());
-
-            $this->out->elementEnd('span');
-        }
-    }
-
     /**
      * show a link to reply to the current notice
      *
@@ -604,34 +597,6 @@ class NoticeListItem extends Widget
         }
     }
 
-    /**
-     * show the form to repeat a notice
-     *
-     * @return void
-     */
-    function showRepeatForm()
-    {
-        if ($this->notice->scope == Notice::PUBLIC_SCOPE ||
-            $this->notice->scope == Notice::SITE_SCOPE) {
-            $user = common_current_user();
-            if (!empty($user) &&
-                $user->id != $this->notice->profile_id) {
-                $this->out->text(' ');
-                $profile = $user->getProfile();
-                if ($profile->hasRepeated($this->notice)) {
-                    $this->out->element('span', array('class' => 'repeated',
-                                                      // TRANS: Title for repeat form status in notice list when a notice has been repeated.
-                                                      'title' => _('Notice repeated.')),
-                                        // TRANS: Repeat form status in notice list when a notice has been repeated.
-                                        _('Repeated'));
-                } else {
-                    $rf = new RepeatForm($this->out, $this->notice);
-                    $rf->show();
-                }
-            }
-        }
-    }
-
     /**
      * finish the notice
      *