diff --git a/classes/File.php b/classes/File.php index 029ff487a4..210e758419 100644 --- a/classes/File.php +++ b/classes/File.php @@ -541,4 +541,11 @@ class File extends Managed_DataObject // And finally remove the entry from the database return parent::delete($useWhere); } + + public function getTitle() + { + $title = $this->title ?: $this->filename; + + return $title ?: null; + } } diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 6609cb40da..d6cfda6f95 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -74,18 +74,28 @@ class AttachmentList extends Widget */ function show() { - $att = $this->notice->attachments(); - if (empty($att)) return 0; + $attachments = $this->notice->attachments(); + $representable = false; + foreach ($attachments as $key=>$att) { + // Only show attachments representable with a title + if ($att->getTitle() === null) { + unset($attachments[$key]); + } + } + if (!count($attachments)) { + return 0; + } + $this->showListStart(); - foreach ($att as $n=>$attachment) { - $item = $this->newListItem($attachment); + foreach ($attachments as $att) { + $item = $this->newListItem($att); $item->show(); } $this->showListEnd(); - return count($att); + return count($attachments); } function showListStart() diff --git a/lib/attachmentlistitem.php b/lib/attachmentlistitem.php index 025ffa9fd6..3764c827cb 100644 --- a/lib/attachmentlistitem.php +++ b/lib/attachmentlistitem.php @@ -63,7 +63,7 @@ class AttachmentListItem extends Widget } function title() { - return $this->attachment->title ?: $this->attachment->filename; + return $this->attachment->getTitle(); } function linkTitle() { diff --git a/lib/inlineattachmentlist.php b/lib/inlineattachmentlist.php index b68701fb31..d760400487 100644 --- a/lib/inlineattachmentlist.php +++ b/lib/inlineattachmentlist.php @@ -35,12 +35,8 @@ class InlineAttachmentList extends AttachmentList { function showListStart() { - $this->out->elementStart('div', array('class' => 'attachments')); - } - - function showListEnd() - { - $this->out->elementEnd('div'); + $this->out->element('h2', null, _('Attachments')); + parent::showListStart(); } /** @@ -72,7 +68,7 @@ class InlineAttachmentListItem extends AttachmentListItem { // XXX: RDFa // TODO: add notice_type class e.g., notice_video, notice_image - $this->out->elementStart('span', array('class' => 'inline-attachment')); + $this->out->elementStart('li', array('class' => 'inline-attachment')); } /** @@ -84,6 +80,6 @@ class InlineAttachmentListItem extends AttachmentListItem */ function showEnd() { - $this->out->elementEnd('span'); + $this->out->elementEnd('li'); } }