From 710f298b4dcad7b8fe9bd24d054e31b833c94e19 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Sun, 4 Jun 2006 16:55:19 +0000 Subject: [PATCH] Add hooks to manipulate the sitenotice/anonnotice: * SiteNoticeBefore * SiteNoticeAfter --- docs/hooks.txt | 9 +++++++++ includes/GlobalFunctions.php | 20 ++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index ec8ce7fe3f..f1483127d3 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -386,6 +386,15 @@ my talk page, my contributions" etc). &$personal_urls: Array of link specifiers (see SkinTemplate.php) &$title: Title object representing the current page +'SiteNoticeBefore': Before the sitenotice/anonnotice is composed +&$siteNotice: HTML returned as the sitenotice +Return true to allow the normal method of notice selection/rendering to work, +or change the value of $siteNotice and return false to alter it. + +'SiteNoticeAfter': After the sitenotice/anonnotice is composed +&$siteNotice: HTML sitenotice +Alter the contents of $siteNotice to add to/alter the sitenotice/anonnotice. + 'TitleMoveComplete': after moving an article (title) $old: old title $nt: new title diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index f8ef126ace..d729f0a33d 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1470,22 +1470,26 @@ function wfGetSiteNotice() { global $wgUser, $wgSiteNotice; $fname = 'wfGetSiteNotice'; wfProfileIn( $fname ); + $siteNotice = ''; - if( is_object( $wgUser ) && $wgUser->isLoggedIn() ) { - $siteNotice = wfGetCachedNotice( 'sitenotice' ); - $siteNotice = !$siteNotice ? $wgSiteNotice : $siteNotice; - } else { - $anonNotice = wfGetCachedNotice( 'anonnotice' ); - if( !$anonNotice ) { + if( wfRunHooks( 'SiteNoticeBefore', array( &$siteNotice ) ) ) { + if( is_object( $wgUser ) && $wgUser->isLoggedIn() ) { $siteNotice = wfGetCachedNotice( 'sitenotice' ); $siteNotice = !$siteNotice ? $wgSiteNotice : $siteNotice; } else { - $siteNotice = $anonNotice; + $anonNotice = wfGetCachedNotice( 'anonnotice' ); + if( !$anonNotice ) { + $siteNotice = wfGetCachedNotice( 'sitenotice' ); + $siteNotice = !$siteNotice ? $wgSiteNotice : $siteNotice; + } else { + $siteNotice = $anonNotice; + } } } + wfRunHooks( 'SiteNoticeAfter', array( &$siteNotice ) ); wfProfileOut( $fname ); - return( $siteNotice ); + return $siteNotice; } /** Global singleton instance of MimeMagic. This is initialized on demand, -- 2.20.1