Add hooks to manipulate the sitenotice/anonnotice:
authorRob Church <robchurch@users.mediawiki.org>
Sun, 4 Jun 2006 16:55:19 +0000 (16:55 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sun, 4 Jun 2006 16:55:19 +0000 (16:55 +0000)
* SiteNoticeBefore
* SiteNoticeAfter

docs/hooks.txt
includes/GlobalFunctions.php

index ec8ce7f..f148312 100644 (file)
@@ -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
index f8ef126..d729f0a 100644 (file)
@@ -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,