]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/noticelist.php
Merge branch '0.8.x' into userdesign
[quix0rs-gnu-social.git] / lib / noticelist.php
index a521321719b1bc6a9287838419d31d8cbd7af724..c00942af4998226b3bdee957b29f849486005b1f 100644 (file)
@@ -34,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
@@ -49,7 +50,6 @@ require_once INSTALLDIR.'/lib/disfavorform.php';
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://laconi.ca/
  * @see      Notice
- * @see      StreamAction
  * @see      NoticeListItem
  * @see      ProfileNoticeList
  */
@@ -85,7 +85,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;
 
@@ -100,7 +100,7 @@ class NoticeList extends Widget
             $item->show();
         }
 
-        $this->out->elementEnd('ul');
+        $this->out->elementEnd('ol');
         $this->out->elementEnd('div');
 
         return $cnt;
@@ -193,52 +193,36 @@ class NoticeListItem extends Widget
         $this->out->elementEnd('div');
     }
 
-    function showNoticeAttachments()
-    {
-        $f2p = new File_to_post;
-        $f2p->post_id = $this->notice->id;
-        $file = new File;
-        $file->joinAdd($f2p);
-        $file->selectAdd();
-        $file->selectAdd('file.id as id');
-        $count = $file->find(true);
-        if (!$count) return;
-        if (1 === $count) {
-            $href = common_local_url('attachment', array('attachment' => $file->id));
-            $att_class = 'attachment';
-        } else {
-            $href = common_local_url('attachments', array('notice' => $this->notice->id));
-            $att_class = 'attachments';
+    function showNoticeAttachments() {
+        if ($this->isUsedInList()) {
+            return;
         }
+        $al = new AttachmentList($this->notice, $this->out);
+        $al->show();
+    }
 
-        $clip = theme_path('images/icons/clip', 'base');
-        if ('shownotice' === $this->out->args['action']) {
-            $height = '96px';
-            $width = '83%';
-            $width_att = '15%';
-            $clip .= '-big.png';
-            $top = '70px';
-        } else {
-            $height = '48px';
-            $width = '90%';
-            $width_att = '8%';
-            $clip .= '.png';
-            $top = '20px';
-        }
-if(0)
-        $this->out->elementStart('div', 'entry-attachments');
-else
-        $this->out->elementStart('p', array('class' => 'entry-attachments', 'style' => "float: right; width: $width_att; background: url($clip) no-repeat; text-align: right; height: $height;"));
-        $this->out->element('a', array('class' => $att_class, 'style' => "text-decoration: none; padding-top: $top; display: block; height: $height;", 'href' => $href, 'title' => "# of attachments: $count"), $count === 1 ? '' : $count);
+    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);
+    }
+*/
 
-        $this->out->elementEnd('p');
+    function showWithAttachment() {
     }
 
     function showNoticeInfo()
     {
         $this->out->elementStart('div', 'entry-content');
         $this->showNoticeLink();
+//        $this->showWithAttachment();
         $this->showNoticeSource();
         $this->showContext();
         $this->out->elementEnd('div');
@@ -379,6 +363,10 @@ else
             // versions (>> 0.4.x)
             $this->out->raw(common_render_content($this->notice->content, $this->notice));
         }
+        $uploaded = $this->notice->getUploadedAttachment();
+        if ($uploaded) {
+            $this->out->element('a', array('href' => $uploaded, 'class' => 'attachment'), $uploaded);
+        }
         $this->out->elementEnd('p');
     }
 
@@ -409,6 +397,7 @@ else
         $this->out->element('abbr', array('class' => 'published',
                                           'title' => $dt),
                             common_date_string($this->notice->created));
+
         $this->out->elementEnd('a');
         $this->out->elementEnd('dd');
         $this->out->elementEnd('dl');