https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114695
Revision: 114695
Author: preilly
Date: 2012-04-04 01:38:11 +0000 (Wed, 04 Apr 2012)
Log Message:
-----------
1.19wmf: MFG Change-Id: I5ae19aa25c24c16008b7456165cc9337ecc4dece
Modified Paths:
--------------
branches/wmf/1.19wmf1/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.body.php
Modified:
branches/wmf/1.19wmf1/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.body.php
===================================================================
---
branches/wmf/1.19wmf1/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.body.php
2012-04-04 01:19:19 UTC (rev 114694)
+++
branches/wmf/1.19wmf1/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.body.php
2012-04-04 01:38:11 UTC (rev 114695)
@@ -25,20 +25,17 @@
}
class ExtZeroRatedMobileAccess {
- const VERSION = '0.0.9';
public static $renderZeroRatedLandingPage;
public static $renderZeroRatedBanner;
- private static $debugOutput = array();
- private static $displayDebugOutput = false;
- private static $formatMobileUrl = '//%s.m.wikipedia.org/';
+ private static $formatMobileUrl = '//%s.zero.wikipedia.org/';
/**
* @var Title
*/
private static $title;
- private static $isFilePage;
+ private static $isFilePage = false;
public static $isMainPage = false;
private static $acceptBilling;
private static $carrier;
@@ -51,7 +48,6 @@
return $ext->beforePageDisplayHTML( $out, $text );
}
-
/**
* Handler for the BeforePageDisplay hook
*
@@ -180,21 +176,12 @@
$languageNames = Language::getLanguageNames();
$country = $wgRequest->getVal( 'country' );
$ip = $wgRequest->getVal( 'ip', wfGetIP() );
- // Temporary hack to allow for testing on
localhost
- $countryIps = array(
-
'GERMANY' => '80.237.226.75',
-
'MEXICO' => '187.184.240.247',
-
'THAILAND' => '180.180.150.104',
-
'FRANCE' => '90.6.70.28',
- );
- $ip = ( strpos( $ip, '192.168.' ) === 0 ) ?
$countryIps['THAILAND'] : $ip;
if ( IP::isValid( $ip ) ) {
// If no country was passed, try to do
GeoIP lookup
// Requires php5-geoip package
if ( !$country && function_exists(
'geoip_country_code_by_name' ) ) {
$country =
geoip_country_code_by_name( $ip );
}
- self::addDebugOutput( $country );
}
if ( isset( self::$carrier['name'] ) &&
stristr( self::$carrier['name'], 'DIGI' ) !== FALSE ) {
@@ -202,12 +189,8 @@
}
$languageOptions =
$this->createLanguageOptionsFromWikiText();
- // self::$displayDebugOutput = true;
$languagesForCountry = ( isset(
$languageOptions[self::getFullCountryNameFromCode( $country )] ) ) ?
$languageOptions[self::getFullCountryNameFromCode( $country )] : null;
- self::addDebugOutput(
self::getFullCountryNameFromCode( $country ) );
- self::addDebugOutput( $languagesForCountry );
- self::writeDebugOutput();
if ( is_array( $languagesForCountry ) ) {
$sizeOfLanguagesForCountry = sizeof(
$languagesForCountry );
@@ -349,39 +332,6 @@
}
/**
- * Adds object to debugOutput Array
- *
- * @param Object $object: any valid PHP object
- * @return bool
- */
- private static function addDebugOutput( $object ) {
- wfProfileIn( __METHOD__ );
- if ( is_array( self::$debugOutput ) ) {
- self::$debugOutput[] = $object;
- }
- wfProfileOut( __METHOD__ );
- return true;
- }
-
- /**
- * Writes objects from the debugOutput Array to buffer
- *
- * @return bool
- */
- private static function writeDebugOutput() {
- wfProfileIn( __METHOD__ );
- if ( self::$debugOutput && self::$displayDebugOutput === true )
{
- echo "<pre>";
- foreach ( self::$debugOutput as $debugOutput ) {
- var_dump( $debugOutput );
- }
- echo "</pre>";
- }
- wfProfileOut( __METHOD__ );
- return true;
- }
-
- /**
* @param $formatter array
* @param $wikiText string
* @param $nChild bool
@@ -394,7 +344,7 @@
}
wfProfileIn( __METHOD__ );
$data = explode( PHP_EOL, $wikiText );
- if( $nChild ) {
+ if ( $nChild ) {
foreach ( $data as $key => $rawData ) {
if ( strpos( $rawData, '*' ) === 0 && strpos(
$rawData, '**' ) !== 0 && $key >= 0 ) {
$data = trim( str_replace( '*', '',
$rawData ) );
@@ -914,30 +864,7 @@
return ( $code && isset( $countries[$code] ) ) ?
$countries[$code] : null;
}
- /**
- * Search form for various languages
- *
- * @param string $langCode: alpha-2 code for language
- * @return String
- */
- private static function getSearchFormHtml( $langCode ) {
- wfProfileIn( __METHOD__ );
- $searchValue = wfMessage( 'zero-rated-mobile-access-search'
)->inLanguage( $langCode );
- $formHtml = <<<HTML
- <form id="zero-language-search"
action="//{$langCode}.wikipedia.org/w/index.php" class="search_bar"
method="get">
- <input type="hidden" value="Special:Search"
name="title">
- <div class="sq">
- <input type="text" name="search" class="search"
size="22" value="" autocorrect="off" autocomplete="off" autocapitalize="off"
maxlength="1024">
- <div class="clearlink" class="clearsearch"
title="Clear"></div>
- </div>
- <button class="goButton" type="submit">{$searchValue}</button>
- </form>
-HTML;
- wfProfileOut( __METHOD__ );
- return $formHtml;
- }
-
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
+}
\ No newline at end of file
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs