r107031 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107030‎ | r107031 | r107032 >
Date:01:27, 22 December 2011
Author:preilly
Status:deferred
Tags:mobile 
Comment:
basic layout of landing page
Modified paths:
  • /trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.php
@@ -60,16 +60,17 @@
6161 self::$renderZeroRatedLandingPage = $wgRequest->getInt( 'renderZeroRatedLandingPage' );
6262 if ( self::$renderZeroRatedLandingPage === 1 ) {
6363 echo wfMsg( 'zero-rated-mobile-access-desc' );
 64+ $languageNames = Language::getLanguageNames();
6465 $country = $wgRequest->getVal( 'country' );
6566 $ip = ( $wgRequest->getVal( 'ip') ) ? $wgRequest->getVal( 'ip' ) : wfGetIP();
6667 // Temporary hack to allow for testing on localhost
6768 $countryIps = array(
68 - 'GERMANY' => '80.237.226.75',
69 - 'MEXICO' => '187.184.240.247',
70 - 'THAILAND' => '180.180.150.104',
71 - 'FRANCE' => '90.6.70.28',
 69+ 'GERMANY' => '80.237.226.75',
 70+ 'MEXICO' => '187.184.240.247',
 71+ 'THAILAND' => '180.180.150.104',
 72+ 'FRANCE' => '90.6.70.28',
7273 );
73 - $ip = ( strpos( $ip, '192.168.' ) === 0 ) ? $countryIps['FRANCE'] : $ip;
 74+ $ip = ( strpos( $ip, '192.168.' ) === 0 ) ? $countryIps['THAILAND'] : $ip;
7475 if ( IP::isValid( $ip ) ) {
7576 // If no country was passed, try to do GeoIP lookup
7677 // Requires php5-geoip package
@@ -80,11 +81,35 @@
8182 }
8283 $languageOptions = self::createLanguageOptionsFromWikiText();
8384 //self::$displayDebugOutput = true;
 85+ $languagesForCountry = $languageOptions[self::getFullCountryNameFromCode( $country )];
8486 //self::addDebugOutput( $languageOptions );
8587 self::addDebugOutput( self::getFullCountryNameFromCode( $country ) );
86 - self::addDebugOutput( $languageOptions[self::getFullCountryNameFromCode( $country )] );
 88+ self::addDebugOutput( $languagesForCountry );
8789 self::writeDebugOutput();
 90+
 91+ if ( is_array( $languagesForCountry ) ) {
 92+ foreach( $languagesForCountry as $language ) {
 93+ echo Html::element( 'h3',
 94+ array( 'id' => 'lang_' . $language['language'],
 95+ ),
 96+ $languageNames[$language['language']]);
 97+ echo Html::element( 'hr',
 98+ array(), '');
 99+ echo self::getSearchFormHtml( $language['language'] );
 100+ }
 101+ }
88102 }
 103+ $output = Html::openElement( 'select',
 104+ array( 'id' => 'languageselection',
 105+ 'onchange' => 'javascript:window.location = this.options[this.selectedIndex].value;' ) );
 106+ foreach ( $languageNames as $languageCode => $languageName ) {
 107+ $output .= Html::element( 'option',
 108+ array( 'value' => '//' . $languageCode . '.m.wikipedia.org/' ),
 109+ $languageName );
 110+ }
 111+ $output .= Html::closeElement( 'select', array() );
 112+ echo $output;
 113+
89114 wfProfileOut( __METHOD__ );
90115 exit();
91116 return true;
@@ -92,7 +117,9 @@
93118
94119 private static function addDebugOutput( $object ) {
95120 wfProfileIn( __METHOD__ );
96 - self::$debugOutput[] = $object;
 121+ if ( is_array( self::$debugOutput ) ) {
 122+ self::$debugOutput[] = $object;
 123+ }
97124 wfProfileOut( __METHOD__ );
98125 return true;
99126 }
@@ -390,4 +417,18 @@
391418 wfProfileOut( __METHOD__ );
392419 return ( isset( $countries[strtoupper( $code )] ) ) ? $countries[strtoupper( $code )] : null;
393420 }
 421+
 422+ private static function getSearchFormHtml( $langCode ) {
 423+ $formHtml = <<<HTML
 424+ <form action="//{$langCode}.wikipedia.org/w/index.php" class="search_bar" method="get">
 425+ <input type="hidden" value="Special:Search" name="title">
 426+ <div id="sq" class="divclearable">
 427+ <input type="text" name="search" id="search" size="22" value="" autocorrect="off" autocomplete="off" autocapitalize="off" maxlength="1024">
 428+ <div class="clearlink" id="clearsearch" title="Clear"></div>
 429+ </div>
 430+ <button id="goButton" type="submit">Search</button>
 431+ </form>
 432+HTML;
 433+ return $formHtml;
 434+ }
394435 }
\ No newline at end of file

Status & tagging log