Index: trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.body.php |
— | — | @@ -34,6 +34,7 @@ |
35 | 35 | private static $formatMobileUrl = '//%s.m.wikipedia.org/'; |
36 | 36 | private static $title; |
37 | 37 | private static $isFilePage; |
| 38 | + public static $isMainPage = false; |
38 | 39 | private static $acceptBilling; |
39 | 40 | private static $carrier; |
40 | 41 | private static $renderZeroRatedRedirect; |
— | — | @@ -80,6 +81,10 @@ |
81 | 82 | self::$acceptBilling = $wgRequest->getVal( 'acceptbilling' ); |
82 | 83 | self::$title = $out->getTitle(); |
83 | 84 | |
| 85 | + if ( self::$title->isMainPage() ) { |
| 86 | + self::$isMainPage = true; |
| 87 | + } |
| 88 | + |
84 | 89 | $carrier = $wgRequest->getHeader( 'X-CARRIER' ); |
85 | 90 | if ( $carrier !== '(null)' && $carrier ) { |
86 | 91 | self::$renderZeroRatedBanner = true; |
— | — | @@ -142,6 +147,10 @@ |
143 | 148 | if ( $wgZeroDisableImages === 1 ) { |
144 | 149 | self::$forceClickToViewImages = $wgZeroDisableImages; |
145 | 150 | } |
| 151 | + if ( self::$isMainPage ) { |
| 152 | + $redirect = SpecialPage::getTitleFor( 'ZeroRatedMobileAccess' )->getLocalUrl(); |
| 153 | + $wgRequest->response()->header( 'Location: ' . $redirect ); |
| 154 | + } |
146 | 155 | $html = $out->getHTML(); |
147 | 156 | $parsedHtml = $this->parseLinksForZeroQueryString( $html ); |
148 | 157 | $out->clearHTML(); |
— | — | @@ -149,7 +158,7 @@ |
150 | 159 | $carrierLink = ( isset( self::$carrier['link'] ) ) ? self::$carrier['link'] : ''; |
151 | 160 | $bannerText = Html::rawElement( 'span', |
152 | 161 | array( 'id' => 'zero-rated-banner-text' ), |
153 | | - wfMsg( 'zero-rated-mobile-access-banner-text', $carrierLink ) ); |
| 162 | + $carrierLink ); |
154 | 163 | $banner = Html::rawElement( 'div', |
155 | 164 | array( 'style' => 'display:none;', 'id' => 'zero-rated-banner' ), $bannerText ); |
156 | 165 | $output .= $banner; |
— | — | @@ -446,9 +455,11 @@ |
447 | 456 | } |
448 | 457 | |
449 | 458 | public function createUrlCallback( $url, $name ) { |
| 459 | + $carrier = strtolower( $name ); |
| 460 | + $linkText = wfMsg( 'zero-rated-mobile-access-banner-text-' . $carrier, $name ); |
450 | 461 | $carrierLink = Html::rawElement( 'a', |
451 | 462 | array( 'href' => $url ), |
452 | | - $name ); |
| 463 | + $linkText ); |
453 | 464 | return $carrierLink; |
454 | 465 | } |
455 | 466 | |