r113743 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113742‎ | r113743 | r113744 >
Date:18:30, 13 March 2012
Author:preilly
Status:ok (Comments)
Tags:todo 
Comment:
add custom banner text and main page redirection to landing page for zero
Modified paths:
  • /trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.body.php
@@ -34,6 +34,7 @@
3535 private static $formatMobileUrl = '//%s.m.wikipedia.org/';
3636 private static $title;
3737 private static $isFilePage;
 38+ public static $isMainPage = false;
3839 private static $acceptBilling;
3940 private static $carrier;
4041 private static $renderZeroRatedRedirect;
@@ -80,6 +81,10 @@
8182 self::$acceptBilling = $wgRequest->getVal( 'acceptbilling' );
8283 self::$title = $out->getTitle();
8384
 85+ if ( self::$title->isMainPage() ) {
 86+ self::$isMainPage = true;
 87+ }
 88+
8489 $carrier = $wgRequest->getHeader( 'X-CARRIER' );
8590 if ( $carrier !== '(null)' && $carrier ) {
8691 self::$renderZeroRatedBanner = true;
@@ -142,6 +147,10 @@
143148 if ( $wgZeroDisableImages === 1 ) {
144149 self::$forceClickToViewImages = $wgZeroDisableImages;
145150 }
 151+ if ( self::$isMainPage ) {
 152+ $redirect = SpecialPage::getTitleFor( 'ZeroRatedMobileAccess' )->getLocalUrl();
 153+ $wgRequest->response()->header( 'Location: ' . $redirect );
 154+ }
146155 $html = $out->getHTML();
147156 $parsedHtml = $this->parseLinksForZeroQueryString( $html );
148157 $out->clearHTML();
@@ -149,7 +158,7 @@
150159 $carrierLink = ( isset( self::$carrier['link'] ) ) ? self::$carrier['link'] : '';
151160 $bannerText = Html::rawElement( 'span',
152161 array( 'id' => 'zero-rated-banner-text' ),
153 - wfMsg( 'zero-rated-mobile-access-banner-text', $carrierLink ) );
 162+ $carrierLink );
154163 $banner = Html::rawElement( 'div',
155164 array( 'style' => 'display:none;', 'id' => 'zero-rated-banner' ), $bannerText );
156165 $output .= $banner;
@@ -446,9 +455,11 @@
447456 }
448457
449458 public function createUrlCallback( $url, $name ) {
 459+ $carrier = strtolower( $name );
 460+ $linkText = wfMsg( 'zero-rated-mobile-access-banner-text-' . $carrier, $name );
450461 $carrierLink = Html::rawElement( 'a',
451462 array( 'href' => $url ),
452 - $name );
 463+ $linkText );
453464 return $carrierLink;
454465 }
455466

Follow-up revisions

RevisionCommit summaryAuthorDate
r1137441.19wmf: MFT r113741 - r113743preilly18:31, 13 March 2012

Comments

#Comment by MaxSem (talk | contribs)   18:45, 20 March 2012

TODO: exit after redirecting.

Status & tagging log