/** * Get a notice title based on the notice * * @param Notice $notice Notice to fetch a title for * * @return string title of the notice, or null if none */ static function fromNotice($notice) { $nt = Notice_title::getKV('notice_id', $notice->id); if (empty($nt)) { return null; } else { return $nt->title; } }
/** * 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; }
/** * If a notice has a title, show it in the <h1> element * * @param Notice $notice Notice we're getting the title for * @param string $title Reference to the variable which we set to the notice's title * * @return boolean hook value */ function onGetNoticeTitle(Notice $notice, &$title) { $title = Notice_title::fromNotice($notice); if (!is_null($title)) { return false; } return true; }