- $atts = new File;
- $att = $atts->getAttachments($this->notice->id);
- if (empty($att)) return 0;
- $this->out->elementStart('dl', array('id' =>'attachments'));
- $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();
- }
-
- $this->out->elementEnd('dd');
- $this->out->elementEnd('ol');
- $this->out->elementEnd('dl');
-
- return count($att);
- }
-
- /**
- * returns a new list item for the current notice
- *
- * Recipe (factory?) method; overridden by sub-classes to give
- * a different list item class.
- *
- * @param Notice $notice the current notice
- *
- * @return NoticeListItem a list item for displaying the notice
- */
-
- function newListItem($attachment)
- {
- return new AttachmentListItem($attachment, $this->out);
- }
-}
-
-/**
- * widget for displaying a single notice
- *
- * This widget has the core smarts for showing a single notice: what to display,
- * where, and under which circumstances. Its key method is show(); this is a recipe
- * that calls all the other show*() methods to build up a single notice. The
- * ProfileNoticeListItem subclass, for example, overrides showAuthor() to skip
- * author info (since that's implicit by the data in the page).
- *
- * @category UI
- * @package Laconica
- * @author Evan Prodromou <evan@controlyourself.ca>
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://laconi.ca/
- * @see NoticeList
- * @see ProfileNoticeListItem
- */
-
-class AttachmentListItem extends Widget
-{
- /** The attachment this item will show. */
-
- var $attachment = null;
-
- var $oembed = null;
-
- /**
- * constructor
- *
- * Also initializes the profile attribute.
- *
- * @param Notice $notice The notice we'll display
- */
-
- function __construct($attachment, $out=null)
- {
- parent::__construct($out);
- $this->attachment = $attachment;
- $this->oembed = File_oembed::staticGet('file_id', $this->attachment->id);
- }
-
- function title() {
- if (empty($this->attachment->title)) {
- if (empty($this->oembed->title)) {
- $title = $this->attachment->url;
- } else {
- $title = $this->oembed->title;