+
+ public function onStartOpenNoticeListItemElement(NoticeListItem $nli)
+ {
+ if (!$this->isMyNotice($nli->notice)) {
+ return true;
+ }
+
+ $this->openNoticeListItemElement($nli);
+
+ Event::handle('EndOpenNoticeListItemElement', array($nli));
+ return false;
+ }
+
+ public function onStartCloseNoticeListItemElement(NoticeListItem $nli)
+ {
+ if (!$this->isMyNotice($nli->notice)) {
+ return true;
+ }
+
+ $this->closeNoticeListItemElement($nli);
+
+ Event::handle('EndCloseNoticeListItemElement', array($nli));
+ return false;
+ }
+
+ protected function openNoticeListItemElement(NoticeListItem $nli)
+ {
+ $id = (empty($nli->repeat)) ? $nli->notice->id : $nli->repeat->id;
+ $class = 'h-entry notice ' . $this->tag();
+ if ($nli->notice->scope != 0 && $nli->notice->scope != 1) {
+ $class .= ' limited-scope';
+ }
+ try {
+ $class .= ' notice-source-'.common_to_alphanumeric($nli->notice->source);
+ } catch (Exception $e) {
+ // either source or what we filtered out was a zero-length string
+ }
+ $nli->out->elementStart('li', array('class' => $class,
+ 'id' => 'notice-' . $id));
+ }
+
+ protected function closeNoticeListItemElement(NoticeListItem $nli)
+ {
+ $nli->out->elementEnd('li');
+ }
+
+
+ // FIXME: This is overriden in MicroAppPlugin but shouldn't have to be
+ public function onStartShowNoticeItem(NoticeListItem $nli)
+ {
+ if (!$this->isMyNotice($nli->notice)) {
+ return true;
+ }
+
+ try {
+ $this->showNoticeListItem($nli);
+ } catch (Exception $e) {
+ common_log(LOG_ERR, 'Error showing notice '.$nli->getNotice()->getID().': ' . $e->getMessage());
+ $nli->out->element('p', 'error', sprintf(_('Error showing notice: %s'), $e->getMessage()));
+ }
+
+ Event::handle('EndShowNoticeItem', array($nli));
+ return false;
+ }
+
+ protected function showNoticeListItem(NoticeListItem $nli)
+ {
+ $nli->showNoticeHeaders();
+ $nli->showContent();
+ $nli->showNoticeFooter();
+ }
+
+ public function onStartShowNoticeItemNotice(NoticeListItem $nli)
+ {
+ if (!$this->isMyNotice($nli->notice)) {
+ return true;
+ }
+
+ $this->showNoticeItemNotice($nli);
+
+ Event::handle('EndShowNoticeItemNotice', array($nli));
+ return false;
+ }
+
+ protected function showNoticeItemNotice(NoticeListItem $nli)
+ {
+ $nli->showNoticeTitle();
+ $nli->showAuthor();
+ $nli->showAddressees();
+ $nli->showContent();
+ }
+
+ public function onStartShowNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped=null)
+ {
+ if (!$this->isMyNotice($stored)) {
+ return true;
+ }
+
+ try {
+ $this->showNoticeContent($stored, $out, $scoped);
+ } catch (Exception $e) {
+ $out->element('div', 'error', $e->getMessage());
+ }
+ return false;
+ }
+
+ protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped=null)
+ {
+ $out->text($stored->getContent());
+ }