r72339 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72338‎ | r72339 | r72340 >
Date:00:49, 4 September 2010
Author:kaldari
Status:resolved (Comments)
Tags:
Comment:
adding support for stand alone banner loading
Modified paths:
  • /trunk/extensions/CentralNotice/BannerLoader.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/BannerLoader.php
@@ -22,14 +22,17 @@
2323 $this->sendHeaders();
2424
2525 // Get user language from the query string
26 - $this->language = $wgRequest->getText( 'language', 'en' );
 26+ $this->language = $wgRequest->getText( 'userlang', 'en' );
2727
2828 // Get site name from the query string
29 - $this->siteName = $wgRequest->getText( 'site', 'Wikipedia' );
 29+ $this->siteName = $wgRequest->getText( 'sitename', 'Wikipedia' );
3030
 31+ // If we're not pulling the banner into another page, we'll need to add some extra HTML
 32+ $standAlone = $wgRequest->getBool( 'standalone' );
 33+
3134 if ( $wgRequest->getText( 'banner' ) ) {
3235 $bannerName = $wgRequest->getText( 'banner' );
33 - $content = $this->getHtmlNotice( $bannerName );
 36+ $content = $this->getHtmlNotice( $bannerName, $standAlone );
3437 if ( strlen( $content ) == 0 ) {
3538 // Hack for IE/Mac 0-length keepalive problem, see RawPage.php
3639 echo "/* Empty */";
@@ -52,15 +55,32 @@
5356 /**
5457 * Generate the HTML for the requested banner
5558 */
56 - function getHtmlNotice( $bannerName ) {
 59+ function getHtmlNotice( $bannerName, $standAlone = false ) {
5760 // Make sure the banner exists
5861 if ( SpecialNoticeTemplate::templateExists( $bannerName ) ) {
5962 $this->bannerName = $bannerName;
60 - return preg_replace_callback(
 63+ $bannerHtml = '';
 64+ if ( $standAlone ) {
 65+ $bannerHtml .= <<<EOT
 66+<html>
 67+<head>
 68+ <script type="text/javascript" src="http://bits.wikimedia.org/skins-1.5/common/jquery.min.js"></script>
 69+</head>
 70+<body>
 71+EOT;
 72+ }
 73+ $bannerHtml .= preg_replace_callback(
6174 '/{{{(.*?)}}}/',
6275 array( $this, 'getNoticeField' ),
6376 $this->getNoticeTemplate()
6477 );
 78+ if ( $standAlone ) {
 79+ $bannerHtml .= <<<EOT
 80+</body>
 81+</html>
 82+EOT;
 83+ }
 84+ return $bannerHtml;
6585 }
6686 }
6787

Follow-up revisions

RevisionCommit summaryAuthorDate
r72613fixing script call per comment at r72339kaldari22:09, 8 September 2010

Comments

#Comment by Catrope (talk | contribs)   17:53, 8 September 2010
+	<script type="text/javascript" src="[http://bits.wikimedia.org/skins-1.5/common/jquery.min.js http://bits.wikimedia.org/skins-1.5/common/jquery.min.js]"></script>

Don't hardcode the URL like that, use $wgStylePath.

#Comment by Kaldari (talk | contribs)   22:10, 8 September 2010

fixed in r72613.

Status & tagging log