From 925381707b921315ba76418ed0d1dd50f9548e80 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 2 Sep 2010 17:16:10 -0400 Subject: [PATCH] show notice title on shownotice page --- plugins/NoticeTitle/NoticeTitlePlugin.php | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/plugins/NoticeTitle/NoticeTitlePlugin.php b/plugins/NoticeTitle/NoticeTitlePlugin.php index f7fb1e4d00..9f53173db2 100644 --- a/plugins/NoticeTitle/NoticeTitlePlugin.php +++ b/plugins/NoticeTitle/NoticeTitlePlugin.php @@ -278,5 +278,54 @@ class NoticeTitlePlugin extends Plugin return true; } + + /** + * If a notice has a title, show it in the element + * + * @param Action $action Action being executed + * + * @return boolean hook value + */ + + function onStartShowHeadTitle($action) + { + $actionName = $action->trimmed('action'); + + if ($actionName == 'shownotice') { + $title = Notice_title::fromNotice($action->notice); + if (!empty($title)) { + $action->element('title', null, + // TRANS: Page title. %1$s is the title, %2$s is the site name. + sprintf(_("%1\$s - %2\$s"), + $title, + common_config('site', 'name'))); + } + } + + return true; + } + + /** + * If a notice has a title, show it in the <h1> element + * + * @param Action $action Action being executed + * + * @return boolean hook value + */ + + function onStartShowPageTitle($action) + { + $actionName = $action->trimmed('action'); + + if ($actionName == 'shownotice') { + $title = Notice_title::fromNotice($action->notice); + if (!empty($title)) { + $action->element('h1', null, $title); + return false; + } + } + + return true; + } }