I didn't left compatibility functions since there's no other call to these functions in core or extensions.
'SiteNoticeBefore': Before the sitenotice/anonnotice is composed
&$siteNotice: HTML returned as the sitenotice
+$skin: Skin object
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
+$skin: Skin object
Alter the contents of $siteNotice to add to/alter the sitenotice/anonnotice.
'SkinAfterBottomScripts': At the end of Skin::bottomScripts()
$y = $z;
}
-function wfGetCachedNotice( $name ) {
- global $wgOut, $wgRenderHashAppend, $parserMemc;
- $fname = 'wfGetCachedNotice';
- wfProfileIn( $fname );
-
- $needParse = false;
-
- if( $name === 'default' ) {
- // special case
- global $wgSiteNotice;
- $notice = $wgSiteNotice;
- if( empty( $notice ) ) {
- wfProfileOut( $fname );
- return false;
- }
- } else {
- $msg = wfMessage( $name )->inContentLanguage();
- if( $msg->isDisabled() ) {
- wfProfileOut( $fname );
- return( false );
- }
- $notice = $msg->plain();
- }
-
- // Use the extra hash appender to let eg SSL variants separately cache.
- $key = wfMemcKey( $name . $wgRenderHashAppend );
- $cachedNotice = $parserMemc->get( $key );
- if( is_array( $cachedNotice ) ) {
- if( md5( $notice ) == $cachedNotice['hash'] ) {
- $notice = $cachedNotice['html'];
- } else {
- $needParse = true;
- }
- } else {
- $needParse = true;
- }
-
- if( $needParse ) {
- if( is_object( $wgOut ) ) {
- $parsed = $wgOut->parse( $notice );
- $parserMemc->set( $key, array( 'html' => $parsed, 'hash' => md5( $notice ) ), 600 );
- $notice = $parsed;
- } else {
- wfDebug( 'wfGetCachedNotice called for ' . $name . ' with no $wgOut available' . "\n" );
- $notice = '';
- }
- }
- $notice = '<div id="localNotice">' .$notice . '</div>';
- wfProfileOut( $fname );
- return $notice;
-}
-
-function wfGetNamespaceNotice() {
- global $wgTitle;
-
- # Paranoia
- if ( !isset( $wgTitle ) || !is_object( $wgTitle ) ) {
- return '';
- }
-
- $fname = 'wfGetNamespaceNotice';
- wfProfileIn( $fname );
-
- $key = 'namespacenotice-' . $wgTitle->getNsText();
- $namespaceNotice = wfGetCachedNotice( $key );
- if ( $namespaceNotice && substr( $namespaceNotice, 0, 7 ) != '<p><' ) {
- $namespaceNotice = '<div id="namespacebanner">' . $namespaceNotice . '</div>';
- } else {
- $namespaceNotice = '';
- }
-
- wfProfileOut( $fname );
- return $namespaceNotice;
-}
-
-function wfGetSiteNotice() {
- global $wgUser;
- $fname = 'wfGetSiteNotice';
- wfProfileIn( $fname );
- $siteNotice = '';
-
- if( wfRunHooks( 'SiteNoticeBefore', array( &$siteNotice ) ) ) {
- if( is_object( $wgUser ) && $wgUser->isLoggedIn() ) {
- $siteNotice = wfGetCachedNotice( 'sitenotice' );
- } else {
- $anonNotice = wfGetCachedNotice( 'anonnotice' );
- if( !$anonNotice ) {
- $siteNotice = wfGetCachedNotice( 'sitenotice' );
- } else {
- $siteNotice = $anonNotice;
- }
- }
- if( !$siteNotice ) {
- $siteNotice = wfGetCachedNotice( 'default' );
- }
- }
-
- wfRunHooks( 'SiteNoticeAfter', array( &$siteNotice ) );
- wfProfileOut( $fname );
- return $siteNotice;
-}
-
/**
* BC wrapper for MimeMagic::singleton()
* @deprecated No longer needed as of 1.17 (r68836). Remove in 1.19.
return $ntl;
}
+
+ /**
+ * Get a cached notice
+ *
+ * @param $name String: message name, or 'default' for $wgSiteNotice
+ * @return String: HTML fragment
+ */
+ private function getCachedNotice( $name ) {
+ global $wgOut, $wgRenderHashAppend, $parserMemc;
+
+ wfProfileIn( __METHOD__ );
+
+ $needParse = false;
+
+ if( $name === 'default' ) {
+ // special case
+ global $wgSiteNotice;
+ $notice = $wgSiteNotice;
+ if( empty( $notice ) ) {
+ wfProfileOut( __METHOD__ );
+ return false;
+ }
+ } else {
+ $msg = wfMessage( $name )->inContentLanguage();
+ if( $msg->isDisabled() ) {
+ wfProfileOut( __METHOD__ );
+ return false;
+ }
+ $notice = $msg->plain();
+ }
+
+ // Use the extra hash appender to let eg SSL variants separately cache.
+ $key = wfMemcKey( $name . $wgRenderHashAppend );
+ $cachedNotice = $parserMemc->get( $key );
+ if( is_array( $cachedNotice ) ) {
+ if( md5( $notice ) == $cachedNotice['hash'] ) {
+ $notice = $cachedNotice['html'];
+ } else {
+ $needParse = true;
+ }
+ } else {
+ $needParse = true;
+ }
+
+ if ( $needParse ) {
+ if( is_object( $wgOut ) ) {
+ $parsed = $wgOut->parse( $notice );
+ $parserMemc->set( $key, array( 'html' => $parsed, 'hash' => md5( $notice ) ), 600 );
+ $notice = $parsed;
+ } else {
+ wfDebug( 'wfGetCachedNotice called for ' . $name . ' with no $wgOut available' . "\n" );
+ $notice = '';
+ }
+ }
+
+ $notice = '<div id="localNotice">' .$notice . '</div>';
+ wfProfileOut( __METHOD__ );
+ return $notice;
+ }
+
+ /**
+ * Get a notice based on page's namespace
+ *
+ * @return String: HTML fragment
+ */
+ function getNamespaceNotice() {
+ wfProfileIn( __METHOD__ );
+
+ $key = 'namespacenotice-' . $this->mTitle->getNsText();
+ $namespaceNotice = wfGetCachedNotice( $key );
+ if ( $namespaceNotice && substr( $namespaceNotice, 0, 7 ) != '<p><' ) {
+ $namespaceNotice = '<div id="namespacebanner">' . $namespaceNotice . '</div>';
+ } else {
+ $namespaceNotice = '';
+ }
+
+ wfProfileOut( $fname );
+ return $namespaceNotice;
+ }
+
+ /**
+ * Get the site notice
+ *
+ * @return String: HTML fragment
+ */
+ function getSiteNotice() {
+ global $wgUser;
+
+ wfProfileIn( __METHOD__ );
+ $siteNotice = '';
+
+ if ( wfRunHooks( 'SiteNoticeBefore', array( &$siteNotice, $this ) ) ) {
+ if ( is_object( $wgUser ) && $wgUser->isLoggedIn() ) {
+ $siteNotice = $this->getCachedNotice( 'sitenotice' );
+ } else {
+ $anonNotice = $this->getCachedNotice( 'anonnotice' );
+ if ( !$anonNotice ) {
+ $siteNotice = $this->getCachedNotice( 'sitenotice' );
+ } else {
+ $siteNotice = $anonNotice;
+ }
+ }
+ if ( !$siteNotice ) {
+ $siteNotice = $this->getCachedNotice( 'default' );
+ }
+ }
+
+ wfRunHooks( 'SiteNoticeAfter', array( &$siteNotice, $this ) );
+ wfProfileOut( __METHOD__ );
+ return $siteNotice;
+}
}
$s .= "</tr>\n</table>\n</div>\n";
$s .= "\n<div id='article'>\n";
- $notice = wfGetSiteNotice();
+ $notice = $this->getSkin()->getSiteNotice();
if ( $notice ) {
$s .= "\n<div id='siteNotice'>$notice</div>\n";
}
$tpl->set( 'reporttime', wfReportTime() );
- $tpl->set( 'sitenotice', wfGetSiteNotice() );
+ $tpl->set( 'sitenotice', $this->getSiteNotice() );
$tpl->set( 'bottomscripts', $this->bottomScripts( $out ) );
$printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
$s .= "\n</div>\n<div id='article'>";
- $notice = wfGetSiteNotice();
+ $notice = $this->getSkin()->getSiteNotice();
if( $notice ) {
$s .= "\n<div id='siteNotice'>$notice</div>\n";
}
$s .= '<div id="topbar">';
$s .= $this->topLinks() . "\n<br />";
- $notice = wfGetSiteNotice();
+ $notice = $this->getSkin()->getSiteNotice();
if( $notice ) {
$s .= "\n<div id='siteNotice'>$notice</div>\n";
}