From f25accc43ea1e66f290c8bc1d284ae04b4bf004f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 9 Nov 2010 10:45:19 -0800 Subject: [PATCH] split out InlineAttachmentList from AttachmentList --- actions/shownotice.php | 9 ++++ lib/attachmentlist.php | 32 +++++++----- lib/inlineattachmentlist.php | 97 ++++++++++++++++++++++++++++++++++++ lib/noticelist.php | 2 +- theme/base/css/display.css | 6 +++ 5 files changed, 133 insertions(+), 13 deletions(-) create mode 100644 lib/inlineattachmentlist.php diff --git a/actions/shownotice.php b/actions/shownotice.php index 7a11787b66..b4af7dbaa2 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -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 * diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 8e6ad038a3..f9ef7499e1 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -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 index 0000000000..8b1a1cd9bb --- /dev/null +++ b/lib/inlineattachmentlist.php @@ -0,0 +1,97 @@ +. + * + * @category UI + * @package StatusNet + * @author Brion Vibber + * @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'); + } +} diff --git a/lib/noticelist.php b/lib/noticelist.php index fb5db2374c..d2ac7ed84a 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -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(); } diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 29f7d0ae0d..6615e13eb4 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -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*/ -- 2.39.5