use a subclass for single notice items to show attachments

This commit is contained in:
Evan Prodromou 2009-06-23 07:25:18 -07:00
parent 7bcaa858af
commit e2becdb251
2 changed files with 27 additions and 14 deletions

View File

@ -209,7 +209,7 @@ class ShownoticeAction extends Action
function showContent() function showContent()
{ {
$this->elementStart('ol', array('class' => 'notices xoxo')); $this->elementStart('ol', array('class' => 'notices xoxo'));
$nli = new NoticeListItem($this->notice, $this); $nli = new SingleNoticeItem($this->notice, $this);
$nli->show(); $nli->show();
$this->elementEnd('ol'); $this->elementEnd('ol');
} }
@ -264,3 +264,29 @@ class ShownoticeAction extends Action
} }
} }
} }
class SingleNoticeItem extends NoticeListItem
{
/**
* recipe function for displaying a single notice.
*
* We overload to show attachments.
*
* @return void
*/
function show()
{
$this->showStart();
$this->showNotice();
$this->showNoticeAttachments();
$this->showNoticeInfo();
$this->showNoticeOptions();
$this->showEnd();
}
function showNoticeAttachments() {
$al = new AttachmentList($this->notice, $this->out);
$al->show();
}
}

View File

@ -179,7 +179,6 @@ class NoticeListItem extends Widget
{ {
$this->showStart(); $this->showStart();
$this->showNotice(); $this->showNotice();
$this->showNoticeAttachments();
$this->showNoticeInfo(); $this->showNoticeInfo();
$this->showNoticeOptions(); $this->showNoticeOptions();
$this->showEnd(); $this->showEnd();
@ -193,18 +192,6 @@ class NoticeListItem extends Widget
$this->out->elementEnd('div'); $this->out->elementEnd('div');
} }
function showNoticeAttachments() {
if ($this->isUsedInList()) {
return;
}
$al = new AttachmentList($this->notice, $this->out);
$al->show();
}
function isUsedInList() {
return 'shownotice' !== $this->out->args['action'];
}
function showNoticeInfo() function showNoticeInfo()
{ {
$this->out->elementStart('div', 'entry-content'); $this->out->elementStart('div', 'entry-content');