tosfos has uploaded a new change for review. https://gerrit.wikimedia.org/r/178997
Change subject: Remove deprecated msg functions, only show on action=view ...................................................................... Remove deprecated msg functions, only show on action=view Change-Id: I3d13f04899785155aa768e94998bde2c52875037 --- M PageNotice.php 1 file changed, 32 insertions(+), 23 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageNotice refs/changes/97/178997/1 diff --git a/PageNotice.php b/PageNotice.php index dddad48..e3fec53 100644 --- a/PageNotice.php +++ b/PageNotice.php @@ -6,52 +6,61 @@ * For page Foo, MediaWiki:top-notice-Foo and MediaWiki:bottom-notice-Foo can be used to defined a header * or footer respectively. For namespace 6, MediaWiki:top-notice-ns-6 and MediaWiki:bottom-notice-ns-6 can * be used to defined a header or footer respectively. Mind the capitalization. - * + * * For more info see http://mediawiki.org/wiki/Extension:PageNotice * * @file * @ingroup Extensions * @author Daniel Kinzler, brightbyte.de + * @author Ike Hecht * @copyright © 2007 Daniel Kinzler * @licence GNU General Public Licence 2.0 or later */ if( !defined( 'MEDIAWIKI' ) ) { - echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); + echo ("This file is an extension to the MediaWiki software and cannot be used standalone.\n"); die( 1 ); } -$wgExtensionCredits['other'][] = array( +$wgExtensionCredits['other'][] = array( 'path' => __FILE__, - 'name' => 'PageNotice', - 'author' => 'Daniel Kinzler', + 'name' => 'PageNotice', + 'author' => 'Daniel Kinzler', 'url' => 'http://mediawiki.org/wiki/Extension:PageNotice', 'description' => 'lets you define a fixed header or footer message for each page or namespace.', + 'version' => '0.2' ); $wgHooks['OutputPageBeforeHTML'][] = 'wfPageNoticeHook'; -function wfPageNoticeHook( &$out, &$text ) { +function wfPageNoticeHook( OutputPage &$out, &$text ) { + if ( Action::getActionName( $out->getContext() ) !== 'view' ) { + return true; + } $name = $out->getTitle()->getPrefixedDBKey(); $ns = $out->getTitle()->getNamespace(); - - $opt = array( - 'parseinline', - ); - - $header = wfMsgExt("top-notice-$name", $opt); - $nsheader = wfMsgExt("top-notice-ns-$ns", $opt); - - $footer = wfMsgExt("bottom-notice-$name", $opt); - $nsfooter = wfMsgExt("bottom-notice-ns-$ns", $opt); - - if (!wfEmptyMsg("top-notice-$name", $header)) $text = "<div>$header</div>\n$text"; - if (!wfEmptyMsg("top-notice-ns-$ns", $nsheader)) $text = "<div>$nsheader</div>\n$text"; - - if (!wfEmptyMsg("bottom-notice-$name", $footer)) $text = "$text\n<div>$footer</div>"; - if (!wfEmptyMsg("bottom-notice-ns-$ns", $nsfooter)) $text = "$text\n<div>$nsfooter</div>"; - + + $messageTopKeys = array( "top-notice-$name", "top-notice-ns-$ns" ); + $messageBottomKeys = array("bottom-notice-$name", "bottom-notice-ns-$ns"); + foreach ( $messageTopKeys as $messageKey ) { + $text = parseIfExists( $messageKey ) . $text; + } + foreach ( $messageBottomKeys as $messageKey ) { + $text .= parseIfExists( $messageKey ); + } + return true; } +/** + * If the message exists return it, parsed as a block element + * + * @param string $messageKey + * @return string HTML + */ +function parseIfExists( $messageKey ) { + if ( wfMessage( $messageKey )->exists() ) { + return wfMessage( $messageKey )->parseAsBlock(); + } +} -- To view, visit https://gerrit.wikimedia.org/r/178997 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3d13f04899785155aa768e94998bde2c52875037 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/PageNotice Gerrit-Branch: master Gerrit-Owner: tosfos <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
