]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/noticelist.php
Changed ul to ol and added xoxo for notice lists.
[quix0rs-gnu-social.git] / lib / noticelist.php
index 07912c552dd345ae9c2cd630ade76d9ec187e35c..0e80a9778ef6568a288fa444b4058af9aa46a02f 100644 (file)
@@ -22,6 +22,7 @@
  * @category  UI
  * @package   Laconica
  * @author    Evan Prodromou <evan@controlyourself.ca>
+ * @author    Sarven Capadisli <csarven@controlyourself.ca>
  * @copyright 2008 Control Yourself, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link      http://laconi.ca/
@@ -33,6 +34,7 @@ if (!defined('LACONICA')) {
 
 require_once INSTALLDIR.'/lib/favorform.php';
 require_once INSTALLDIR.'/lib/disfavorform.php';
+require_once INSTALLDIR.'/lib/attachmentlist.php';
 
 /**
  * widget for displaying a list of notices
@@ -84,7 +86,7 @@ class NoticeList extends Widget
     {
         $this->out->elementStart('div', array('id' =>'notices_primary'));
         $this->out->element('h2', null, _('Notices'));
-        $this->out->elementStart('ul', array('class' => 'notices'));
+        $this->out->elementStart('ol', array('class' => 'notices xoxo'));
 
         $cnt = 0;
 
@@ -99,7 +101,7 @@ class NoticeList extends Widget
             $item->show();
         }
 
-        $this->out->elementEnd('ul');
+        $this->out->elementEnd('ol');
         $this->out->elementEnd('div');
 
         return $cnt;
@@ -178,6 +180,7 @@ class NoticeListItem extends Widget
     {
         $this->showStart();
         $this->showNotice();
+        $this->showNoticeAttachments();
         $this->showNoticeInfo();
         $this->showNoticeOptions();
         $this->showEnd();
@@ -191,22 +194,45 @@ class NoticeListItem extends Widget
         $this->out->elementEnd('div');
     }
 
+    function showNoticeAttachments() {
+        if ($this->isUsedInList()) {
+            return;
+        }
+        $al = new AttachmentList($this->notice, $this->out);
+        $al->show();
+    }
+
+    function isUsedInList() {
+        return 'shownotice' !== $this->out->args['action'];
+    }
+
+    function attachmentCount($discriminant = true) {
+        $file_oembed = new File_oembed;
+        $query = "select count(*) as c from file_oembed join file_to_post on file_oembed.file_id = file_to_post.file_id where post_id=" . $this->notice->id;
+        $file_oembed->query($query);
+        $file_oembed->fetch();
+        return intval($file_oembed->c);
+    }
+
     function showNoticeInfo()
     {
         $this->out->elementStart('div', 'entry-content');
         $this->showNoticeLink();
         $this->showNoticeSource();
-        $this->showReplyTo();
+        $this->showContext();
         $this->out->elementEnd('div');
     }
 
     function showNoticeOptions()
     {
-        $this->out->elementStart('div', 'notice-options');
-        $this->showFaveForm();
-        $this->showReplyLink();
-        $this->showDeleteLink();
-        $this->out->elementEnd('div');
+        $user = common_current_user();
+        if ($user) {
+            $this->out->elementStart('div', 'notice-options');
+            $this->showFaveForm();
+            $this->showReplyLink();
+            $this->showDeleteLink();
+            $this->out->elementEnd('div');
+        }
     }
 
     /**
@@ -254,8 +280,12 @@ class NoticeListItem extends Widget
     function showAuthor()
     {
         $this->out->elementStart('span', 'vcard author');
-        $this->out->elementStart('a', array('href' => $this->profile->profileurl,
-                                            'class' => 'url'));
+        $attrs = array('href' => $this->profile->profileurl,
+                       'class' => 'url');
+        if (!empty($this->profile->fullname)) {
+            $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ') ';
+        }
+        $this->out->elementStart('a', $attrs);
         $this->showAvatar();
         $this->showNickname();
         $this->out->elementEnd('a');
@@ -273,14 +303,19 @@ class NoticeListItem extends Widget
 
     function showAvatar()
     {
-        $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
+        if ('shownotice' === $this->out->trimmed('action')) {
+            $avatar_size = AVATAR_PROFILE_SIZE;
+        } else {
+            $avatar_size = AVATAR_STREAM_SIZE;
+        }
+        $avatar = $this->profile->getAvatar($avatar_size);
 
         $this->out->element('img', array('src' => ($avatar) ?
-                                         common_avatar_display_url($avatar) :
-                                         common_default_avatar(AVATAR_STREAM_SIZE),
+                                         $avatar->displayUrl() :
+                                         Avatar::defaultImage($avatar_size),
                                          'class' => 'avatar photo',
-                                         'width' => AVATAR_STREAM_SIZE,
-                                         'height' => AVATAR_STREAM_SIZE,
+                                         'width' => $avatar_size,
+                                         'height' => $avatar_size,
                                          'alt' =>
                                          ($this->profile->fullname) ?
                                          $this->profile->fullname :
@@ -378,6 +413,7 @@ class NoticeListItem extends Widget
              case 'xmpp':
              case 'mail':
              case 'omb':
+             case 'system':
              case 'api':
                 $this->out->element('dd', null, $source_name);
                 break;
@@ -407,17 +443,18 @@ class NoticeListItem extends Widget
      * @return void
      */
 
-    function showReplyTo()
+    function showContext()
     {
-        if ($this->notice->reply_to) {
-            $replyurl = common_local_url('shownotice',
-                                         array('notice' => $this->notice->reply_to));
+        // XXX: also show context if there are replies to this notice
+        if (!empty($this->notice->conversation)
+            && $this->notice->conversation != $this->notice->id) {
+            $convurl = common_local_url('conversation',
+                                         array('id' => $this->notice->conversation));
             $this->out->elementStart('dl', 'response');
             $this->out->element('dt', null, _('To'));
             $this->out->elementStart('dd');
-            $this->out->element('a', array('href' => $replyurl,
-                                           'rel' => 'in-reply-to'),
-                                _('in reply to'));
+            $this->out->element('a', array('href' => $convurl),
+                                _('in context'));
             $this->out->elementEnd('dd');
             $this->out->elementEnd('dl');
         }
@@ -434,16 +471,21 @@ class NoticeListItem extends Widget
 
     function showReplyLink()
     {
-        $reply_url = common_local_url('newnotice',
-                                      array('replyto' => $this->profile->nickname));
-
-        $this->out->elementStart('dl', 'notice_reply');
-        $this->out->element('dt', null, _('Reply to this notice'));
-        $this->out->elementStart('dd');
-        $this->out->element('a', array('href' => $reply_url,
-                                       'title' => _('Reply to this notice')), _('Reply'));
-        $this->out->elementEnd('dd');
-        $this->out->elementEnd('dl');
+        if (common_logged_in()) {
+            $reply_url = common_local_url('newnotice',
+                                          array('replyto' => $this->profile->nickname));
+
+            $this->out->elementStart('dl', 'notice_reply');
+            $this->out->element('dt', null, _('Reply to this notice'));
+            $this->out->elementStart('dd');
+            $this->out->elementStart('a', array('href' => $reply_url,
+                                                'title' => _('Reply to this notice')));
+            $this->out->text(_('Reply'));
+            $this->out->element('span', 'notice_id', $this->notice->id);
+            $this->out->elementEnd('a');
+            $this->out->elementEnd('dd');
+            $this->out->elementEnd('dl');
+        }
     }
 
     /**