*/
abstract function appTitle();
- /**
- * Returns a key string which represents this micro-app in HTML
- * ids etc, as when offering selection of what type of post to make.
- * This is paired with the user-visible localizable $this->appTitle().
- *
- * All micro-app classes must override this method.
- */
- abstract function tag();
-
/**
* When building the primary notice form, we'll fetch also some
* alternate forms for specialized types -- that's you!
* @param NoticeListItem $nli The list item being shown.
*
* @return boolean hook value
- *
- * @fixme WARNING WARNING WARNING this closes a 'div' that is implicitly opened in BookmarkPlugin's showNotice implementation
*/
- function onStartShowNoticeItem($nli)
+ function onStartShowNoticeItem(NoticeListItem $nli)
{
if (!$this->isMyNotice($nli->notice)) {
return true;
}
- $adapter = $this->adaptNoticeListItem($nli);
+ // Legacy use was creating a "NoticeListItemAdapter", but
+ // nowadays we solve that using event handling for microapps.
+ // This section will remain until all plugins are fixed.
+ $adapter = $this->adaptNoticeListItem($nli) ?: $nli;
- if (!empty($adapter)) {
- $adapter->showNotice();
- $adapter->showNoticeAttachments();
- $adapter->showNoticeInfo();
- $adapter->showNoticeOptions();
- } else {
- $this->oldShowNotice($nli);
- }
+ $adapter->showNotice();
+ $adapter->showNoticeAttachments();
+ $adapter->showNoticeFooter();
return false;
}
return null;
}
- function oldShowNotice($nli)
- {
- $out = $nli->out;
- $notice = $nli->notice;
-
- try {
- $this->showNotice($notice, $out);
- } catch (Exception $e) {
- common_log(LOG_ERR, $e->getMessage());
- // try to fall back
- $out->elementStart('div');
- $nli->showAuthor();
- $nli->showContent();
- }
-
- $nli->showNoticeLink();
- $nli->showNoticeSource();
- $nli->showNoticeLocation();
- $nli->showContext();
- $nli->showRepeat();
-
- $out->elementEnd('div');
-
- $nli->showNoticeOptions();
- }
-
function onStartShowEntryForms(&$tabs)
{
$tabs[$this->tag()] = array('title' => $this->appTitle(),
return true;
}
-
- function showNotice($notice, $out)
- {
- // TRANS: Server exception thrown when a micro app plugin developer has not done his job too well.
- throw new ServerException(_('You must implement either adaptNoticeListItem() or showNotice().'));
- }
}