]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
split out InlineAttachmentList from AttachmentList
authorBrion Vibber <brion@status.net>
Tue, 9 Nov 2010 18:45:19 +0000 (10:45 -0800)
committerBrion Vibber <brion@status.net>
Tue, 9 Nov 2010 18:45:19 +0000 (10:45 -0800)
actions/shownotice.php
lib/attachmentlist.php
lib/inlineattachmentlist.php [new file with mode: 0644]
lib/noticelist.php
theme/base/css/display.css

index 7a11787b664b24c58fef368b2ab3e40318450db2..b4af7dbaa272d814a7058ee70506a93939a772b7 100644 (file)
@@ -331,6 +331,15 @@ class SingleNoticeItem extends DoFollowListItem
         $this->showEnd();
     }
 
+    /**
+     * For our zoomed-in special case we'll use a fuller list
+     * for the attachment info.
+     */
+    function showNoticeAttachments() {
+        $al = new AttachmentList($this->notice, $this->out);
+        $al->show();
+    }
+
     /**
      * show the avatar of the notice's author
      *
index 8e6ad038a3a8679e94b614970ac518e926614da3..f9ef7499e1f791172d56391188b66a60d3ca2f3b 100644 (file)
@@ -79,23 +79,33 @@ class AttachmentList extends Widget
         $atts = new File;
         $att = $atts->getAttachments($this->notice->id);
         if (empty($att)) return 0;
+        $this->showListStart();
+
+        foreach ($att as $n=>$attachment) {
+            $item = $this->newListItem($attachment);
+            $item->show();
+        }
+
+        $this->showListEnd();
+
+        return count($att);
+    }
+
+    function showListStart()
+    {
         $this->out->elementStart('dl', array('id' =>'attachments',
                                              'class' => 'entry-content'));
         // TRANS: DT element label in attachment list.
         $this->out->element('dt', null, _('Attachments'));
         $this->out->elementStart('dd');
         $this->out->elementStart('ol', array('class' => 'attachments'));
+    }
 
-        foreach ($att as $n=>$attachment) {
-            $item = $this->newListItem($attachment);
-            $item->show();
-        }
-
+    function showListEnd()
+    {
         $this->out->elementEnd('dd');
         $this->out->elementEnd('ol');
         $this->out->elementEnd('dl');
-
-        return count($att);
     }
 
     /**
@@ -181,11 +191,9 @@ class AttachmentListItem extends Widget
      */
     function show()
     {
-        if ($this->attachment->isEnclosure()) {
-            $this->showStart();
-            $this->showNoticeAttachment();
-            $this->showEnd();
-        }
+        $this->showStart();
+        $this->showNoticeAttachment();
+        $this->showEnd();
     }
 
     function linkAttr() {
diff --git a/lib/inlineattachmentlist.php b/lib/inlineattachmentlist.php
new file mode 100644 (file)
index 0000000..8b1a1cd
--- /dev/null
@@ -0,0 +1,97 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * widget for displaying notice attachments thumbnails
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category  UI
+ * @package   StatusNet
+ * @author    Brion Vibber <brion@status.net>
+ * @copyright 2010 StatusNet, Inc.
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link      http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+    exit(1);
+}
+
+class InlineAttachmentList extends AttachmentList
+{
+    function showListStart()
+    {
+        $this->out->elementStart('div', array('class' => 'entry-content thumbnails'));
+    }
+
+    function showListEnd()
+    {
+        $this->out->elementEnd('div');
+    }
+
+    /**
+     * returns a new list item for the current attachment
+     *
+     * @param File $notice the current attachment
+     *
+     * @return ListItem a list item for displaying the attachment
+     */
+    function newListItem($attachment)
+    {
+        return new InlineAttachmentListItem($attachment, $this->out);
+    }
+}
+
+class InlineAttachmentListItem extends AttachmentListItem
+{
+    function show()
+    {
+        if ($this->attachment->isEnclosure()) {
+            parent::show();
+        }
+    }
+
+    function showLink() {
+        $this->out->elementStart('a', $this->linkAttr());
+        $this->showRepresentation();
+        $this->out->elementEnd('a');
+    }
+
+    /**
+     * start a single notice.
+     *
+     * @return void
+     */
+    function showStart()
+    {
+        // XXX: RDFa
+        // TODO: add notice_type class e.g., notice_video, notice_image
+        $this->out->elementStart('span', array('class' => 'inline-attachment'));
+    }
+
+    /**
+     * finish the notice
+     *
+     * Close the last elements in the notice list item
+     *
+     * @return void
+     */
+    function showEnd()
+    {
+        $this->out->elementEnd('span');
+    }
+}
index fb5db2374c1ccfd40c7e19260e42deb4686a4982..d2ac7ed84a59c90c754b09f68601587a4e154086 100644 (file)
@@ -385,7 +385,7 @@ class NoticeListItem extends Widget
     }
 
     function showNoticeAttachments() {
-        $al = new AttachmentList($this->notice, $this->out);
+        $al = new InlineAttachmentList($this->notice, $this->out);
         $al->show();
     }
 
index 29f7d0ae0d9ffccfdc6769cbc2a3e803c10ea5e1..6615e13eb4715a88bb4fffd4a3dd8ff4a828568c 100644 (file)
@@ -1728,6 +1728,12 @@ width:auto;
 min-width:0;
 }
 
+.inline-attachment img {
+    /* Why on earth is this changed to block at the top? */
+    display: inline;
+    border: solid 1px #aaa;
+    padding: 1px;
+}
 }/*end of @media screen, projection, tv*/