X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fattachmentlist.php;h=0ce19b0b1ed38c66859d34113a18932ba269ce4d;hb=dd8e17a3874aa99063b62b51e9a637a5abb0b923;hp=6609cb40daecc66c64492d02bcbf7338b3772d4d;hpb=414a95a784294d63f4c636ef17e468db9428a446;p=quix0rs-gnu-social.git diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 6609cb40da..0ce19b0b1e 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -58,7 +58,7 @@ class AttachmentList extends Widget * * @param Notice $notice stream of notices from DB_DataObject */ - function __construct($notice, $out=null) + function __construct(Notice $notice, $out=null) { parent::__construct($out); $this->notice = $notice; @@ -74,18 +74,33 @@ class AttachmentList extends Widget */ function show() { - $att = $this->notice->attachments(); - if (empty($att)) return 0; + $attachments = $this->notice->attachments(); + foreach ($attachments as $key=>$att) { + // Remove attachments which are not representable with neither a title nor thumbnail + if ($att->getTitle() === null && !$att->hasThumbnail()) { + unset($attachments[$key]); + } + } + if (!count($attachments)) { + return 0; + } + + if ($this->notice->getProfile()->isSilenced()) { + // TRANS: Message for inline attachments list in notices when the author has been silenced. + $this->element('div', ['class'=>'error'], _('Attachments are hidden because this profile has been silenced.')); + 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()