use an adapter pattern to customize notice list item output

This commit is contained in:
Evan Prodromou
2011-04-19 15:43:06 -04:00
parent 138ca38b6f
commit efabb002e4
2 changed files with 118 additions and 2 deletions

View File

@@ -281,6 +281,32 @@ abstract class MicroAppPlugin extends Plugin
return true;
}
$adapter = $this->adaptNoticeListItem($nli);
if (!empty($adapter)) {
$adapter->show();
} else {
$this->oldShowNotice($nli);
}
return false;
}
/**
* Given a notice list item, returns an adapter specific
* to this plugin.
*
* @param NoticeListItem $nli item to adapt
*
* @return NoticeListItemAdapter adapter or null
*/
function adaptNoticeListItem($nli)
{
return null;
}
function oldShowNotice($nli)
{
$out = $nli->out;
$notice = $nli->notice;
@@ -303,8 +329,6 @@ abstract class MicroAppPlugin extends Plugin
$out->elementEnd('div');
$nli->showNoticeOptions();
return false;
}
/**
@@ -535,4 +559,21 @@ abstract class MicroAppPlugin extends Plugin
return true;
}
/**
* Custom HTML output for your special notice; called when a
* matching notice turns up in a NoticeListItem.
*
* All micro-app classes must override this method.
*
* @param Notice $notice
* @param HTMLOutputter $out
*
* @fixme WARNING WARNING WARNING base plugin stuff below tries to close
* a div that this function opens in the BookmarkPlugin child class.
* This is probably wrong.
*/
abstract function showNotice($notice, $out);
}