*
* @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;
*/
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()
{
- $this->out->elementStart('ol', array('class' => 'attachments entry-content'));
+ $this->out->elementStart('ol', array('class' => 'attachments'));
}
function showListEnd()