forked from GNUsocial/gnu-social
use an adapter pattern to customize notice list item output
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user