Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Mediawiki-CVS

SVN: [114888] branches/wmf/1.19wmf1/extensions/MobileFrontend

 

 

Wikipedia mediawiki-cvs RSS feed   Index | Next | Previous | View Threaded


awjrichards at svn

Apr 13, 2012, 1:19 PM

Post #1 of 1 (29 views)
Permalink
SVN: [114888] branches/wmf/1.19wmf1/extensions/MobileFrontend

https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114888

Revision: 114888
Author: awjrichards
Date: 2012-04-13 20:19:46 +0000 (Fri, 13 Apr 2012)
Log Message:
-----------
Revert r114885, r114886, r114887

Modified Paths:
--------------
branches/wmf/1.19wmf1/extensions/MobileFrontend/DeviceDetection.php
branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.php
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.min.js
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.min.js
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/filepage.css
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/hacks.css
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/header.css
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/SearchTemplate.php
branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/MobileFrontendTest.php

Removed Paths:
-------------
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/images/blank.gif

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/DeviceDetection.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/DeviceDetection.php 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/DeviceDetection.php 2012-04-13 20:19:46 UTC (rev 114888)
@@ -17,7 +17,7 @@
/**
* @return array
*/
- public function getAvailableFormats() {
+ public function availableFormats() {
$formats = array (
'html' => array (
'view_format' => 'html',
@@ -247,21 +247,11 @@
}

/**
- * @param $userAgent
- * @param string $acceptHeader
- * @return array
- */
- public function detectDevice( $userAgent, $acceptHeader = '' ) {
- $formatName = $this->detectFormatName( $userAgent, $acceptHeader );
- return $this->getDevice( $formatName );
- }
-
- /**
* @param $formatName
* @return array
*/
- public function getDevice( $formatName ) {
- $format = $this->getAvailableFormats();
+ public function format( $formatName ) {
+ $format = $this->availableFormats();
return ( isset( $format[$formatName] ) ) ? $format[$formatName] : array();
}

@@ -270,7 +260,7 @@
* @param $acceptHeader string
* @return string
*/
- public function detectFormatName( $userAgent, $acceptHeader = '' ) {
+ public function formatName( $userAgent, $acceptHeader = '' ) {
$formatName = '';

if ( preg_match( '/Android/', $userAgent ) ) {
@@ -344,18 +334,4 @@
}
return $formatName;
}
-
- /**
- * @return array: List of all device-specific stylesheets
- */
- public function getCssFiles() {
- $devices = $this->getAvailableFormats();
- $files = array();
- foreach ( $devices as $dev ) {
- if ( isset( $dev['css_file_name'] ) ) {
- $files[] = $dev['css_file_name'];
- }
- }
- return array_unique( $files );
- }
}

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php 2012-04-13 20:19:46 UTC (rev 114888)
@@ -8,7 +8,9 @@
* @var Title
*/
public static $title;
+ public static $messages = array();
public static $htmlTitle;
+ public static $device;
public static $randomPageUrl;
public static $format;
public static $search;
@@ -24,6 +26,7 @@
public static $languageUrls;
public static $wsLoginToken = '';
public static $wsLoginFormAction = '';
+ public static $isFilePage;
public static $zeroRatedBanner;
public static $useFormatCookieName;

@@ -52,7 +55,6 @@

private $forceMobileView = false;
private $contentTransformations = true;
- private $device;

public function __construct() {
global $wgMFConfigProperties;
@@ -340,6 +342,10 @@
$acceptHeader = isset( $_SERVER["HTTP_ACCEPT"] ) ? $_SERVER["HTTP_ACCEPT"] : '';
self::$title = $out->getTitle();

+ if ( self::$title->getNamespace() == NS_FILE ) {
+ self::$isFilePage = true;
+ }
+
self::$htmlTitle = $out->getHTMLTitle();
$this->disableImages = $wgRequest->getCookie( 'disableImages' );
self::$displayNoticeId = $wgRequest->getText( 'noticeid', '' );
@@ -349,20 +355,20 @@
self::$search = $wgRequest->getText( 'search' );
self::$searchField = $wgRequest->getText( 'search', '' );

- $detector = new DeviceDetection();
+ $device = new DeviceDetection();

if ( $xDevice ) {
$formatName = $xDevice;
} else {
- $formatName = $detector->detectFormatName( $userAgent, $acceptHeader );
+ $formatName = $device->formatName( $userAgent, $acceptHeader );
}

- $this->device = $detector->getDevice( $formatName );
+ self::$device = $device->format( $formatName );
$this->checkUserStatus();
$this->setDefaultLogo();

// honor useformat=mobile-wap if it's set, otherwise determine by device
- $viewFormat = ( $this->getUseFormat() == 'mobile-wap' ) ? 'mobile-wap' : $this->device['view_format'];
+ $viewFormat = ( $this->getUseFormat() == 'mobile-wap' ) ? 'mobile-wap' : self::$device['view_format'];
$this->contentFormat = self::parseContentFormat( $viewFormat );

$this->getMsg();
@@ -806,7 +812,7 @@
wfProfileIn( __METHOD__ . '-getText' );
$formatter->setIsMainPage( self::$title->isMainPage() );
if ( $this->contentFormat == 'XHTML'
- && $this->device['supports_javascript'] === true
+ && self::$device['supports_javascript'] === true
&& empty( self::$search ) )
{
$formatter->enableExpandableSections();
@@ -843,6 +849,7 @@
if ( !empty( self::$displayNoticeId ) ) {
if ( intval( self::$displayNoticeId ) === 2 ) {
$sopaNoticeTemplate = new SopaNoticeTemplate();
+ $sopaNoticeTemplate->set( 'messages', self::$messages );
$noticeHtml = $sopaNoticeTemplate->getHTML();
}
}
@@ -901,6 +908,7 @@
}
$footerTemplate = new FooterTemplate();
$options = array(
+ 'messages' => self::$messages,
'leaveFeedbackURL' => SpecialPage::getTitleFor( 'MobileFeedback' )
->getLocalURL( array( 'returnto' => self::$title->getPrefixedText() ) ),
'viewNormalSiteURL' => self::$viewNormalSiteURL,
@@ -931,10 +939,11 @@
'searchField' => self::$searchField,
'mainPageUrl' => Title::newMainPage()->getLocalUrl(),
'randomPageUrl' => self::$randomPageUrl,
+ 'messages' => self::$messages,
'hideSearchBox' => self::$hideSearchBox,
'hideLogo' => self::$hideLogo,
'buildLanguageSelection' => self::buildLanguageSelection(),
- 'device' => $this->device,
+ 'device' => self::$device,
'wgExtensionAssetsPath' => $wgExtensionAssetsPath,
'wgMobileFrontendLogo' => $wgMobileFrontendLogo,
);
@@ -951,27 +960,21 @@
} else {
$wgOut->addModuleStyles( 'ext.mobileFrontend' );
}
- $wgOut->addModuleStyles( "ext.mobileFrontend.{$this->device['css_file_name']}" );
- $isFilePage = self::$title->getNamespace() == NS_FILE;
- if ( $isFilePage ) {
- $wgOut->addModuleStyles( 'ext.mobileFrontend.filePage' );
- }
$cssLinks = $wgOut->buildCssLinks();
$applicationTemplate = new ApplicationTemplate();
$options = array(
'dir' => $wgContLang->getDir(),
'code' => $wgContLang->getCode(),
- 'title' => self::$title,
'placeholder' => wfMsg( 'mobile-frontend-placeholder' ),
'dismissNotification' => wfMsg( 'mobile-frontend-dismiss-notification' ),
'wgAppleTouchIcon' => $wgAppleTouchIcon,
'isBetaGroupMember' => self::$isBetaGroupMember,
'minifyJS' => self::$minifyJS,
- 'device' => $this->device,
+ 'device' => self::$device,
'cssLinks' => $cssLinks,
'wgExtensionAssetsPath' => $wgExtensionAssetsPath,
'wgScriptPath' => $wgScriptPath,
- 'isFilePage' => $isFilePage,
+ 'isFilePage' => self::$isFilePage,
'zeroRatedBanner' => self::$zeroRatedBanner,
'showText' => wfMsg( 'mobile-frontend-show-button' ),
'hideText' => wfMsg( 'mobile-frontend-hide-button' ),
@@ -1099,9 +1102,7 @@
public function getDesktopUrl( $url ) {
$parsedUrl = wfParseUrl( $url );
$this->updateDesktopUrlHost( $parsedUrl );
- $this->updateDesktopUrlQuery( $parsedUrl );
- $desktopUrl = wfAssembleUrl( $parsedUrl );
- return $desktopUrl;
+ return wfAssembleUrl( $parsedUrl );
}

/**
@@ -1154,19 +1155,6 @@
}

/**
- * Update the query portion of a given URL to remove any 'useformat' params
- * @param $parsedUrl array
- * Result of parseUrl() or wfParseUrl()
- */
- protected function updateDesktopUrlQuery( &$parsedUrl ) {
- if ( strpos( $parsedUrl['query'], 'useformat' ) !== false ) {
- $query = wfCgiToArray( html_entity_decode( $parsedUrl['query'] ) );
- unset( $query['useformat'] );
- $parsedUrl['query'] = wfArrayToCgi( $query );
- }
- }
-
- /**
* Update path of given URL to conform to mobile URL template.
*
* NB: this is not actually being used anywhere at the moment. It will
@@ -1548,26 +1536,6 @@
}
}

- /**
- * ResourceLoaderRegisterModules hook handler
- * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderRegisterModules
- * @param array $modules
- * @return bool
- */
- public function resourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) {
- $detector = new DeviceDetection();
- foreach ( $detector->getCssFiles() as $file ) {
- $resourceLoader->register("ext.mobileFrontend.$file",
- array(
- 'styles' => array( "stylesheets/{$file}.css" ),
- 'localBasePath' => dirname( __FILE__ ),
- 'remoteExtPath' => 'MobileFrontend',
- )
- );
- }
- return true;
- }
-
public function getVersion() {
return __CLASS__ . ': $Id$';
}

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.php 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.php 2012-04-13 20:19:46 UTC (rev 114888)
@@ -162,7 +162,6 @@
$wgHooks['TestCanonicalRedirect'][] = array( &$wgExtMobileFrontend, 'testCanonicalRedirect' );
$wgHooks['ResourceLoaderTestModules'][] = array( &$wgExtMobileFrontend, 'addTestModules' );
$wgHooks['GetCacheVaryCookies'][] = array( &$wgExtMobileFrontend, 'getCacheVaryCookies' );
- $wgHooks['ResourceLoaderRegisterModules'][] = array( &$wgExtMobileFrontend, 'resourceLoaderRegisterModules' );
}

/**
@@ -215,8 +214,3 @@
'localBasePath' => dirname( __FILE__ ),
'remoteExtPath' => 'MobileFrontend',
);
-$wgResourceModules['ext.mobileFrontend.filePage'] = array(
- 'styles' => array( 'stylesheets/filepage.css' ),
- 'localBasePath' => dirname( __FILE__ ),
- 'remoteExtPath' => 'MobileFrontend',
-);

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js 2012-04-13 20:19:46 UTC (rev 114888)
@@ -7,7 +7,6 @@
sb = document.getElementById( 'searchbox' ),
content = document.getElementById( 'content' ),
footer = document.getElementById( 'footer' ),
- blankImg = MobileFrontend.setting('scriptPath') + '/extensions/MobileFrontend/stylesheets/images/blank.gif',
clearSearch = document.getElementById( 'clearsearch' ),
focused = false,
u = MobileFrontend.utils;
@@ -15,7 +14,7 @@
apiUrl = MobileFrontend.setting( 'scriptPath' ) + apiUrl;

function onfocus() {
- var rrd;
+ var rrd, rrdD;
sb = document.getElementById( 'searchbox' );
header = document.getElementById( 'header' );
content = document.getElementById( 'content' );
@@ -26,11 +25,13 @@

rrd = document.getElementById( 'remove-results' );
if ( !rrd ) {
- rrd = document.createElement( 'img' );
+ rrd = document.createElement( 'a' );
+ rrd.setAttribute( 'href', '#' );
rrd.setAttribute( 'id', 'remove-results' );
- u( rrd ).bind( 'click', removeResults );
- rrd.setAttribute( 'src', blankImg );
- rrd.setAttribute( 'alt', MobileFrontend.message( 'remove-results' ) );
+ u( rrd ).bind( 'click', removeResults );
+ rrdD = document.createElement( 'div' );
+ rrdD.setAttribute( 'id', 'left-arrow' );
+ rrd.appendChild( rrdD );
header.insertBefore( rrd, header.firstChild );
}
focused = true;
@@ -137,6 +138,9 @@
term = htmlEntities( document.getElementById( 'search' ).value ),
section, escapedTerm, suggestionsResult, link, label;

+ if ( search ) {
+ search.focus();
+ }
if ( !sections || sections.length < 1 ) {
results.innerHTML = '<ul class="suggestions-results" title="No Results"><li class="suggestions-result">No Results</li></div>';
} else {

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.min.js
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.min.js 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.min.js 2012-04-13 20:19:46 UTC (rev 114888)
@@ -1 +1 @@
-MobileFrontend.opensearch=(function(){var b="/api.php",k=-1,c=500,x=15,p,i=document.getElementById("search"),a=document.getElementById("searchbox"),q=document.getElementById("content"),n=document.getElementById("footer"),w=MobileFrontend.setting("scriptPath")+"/extensions/MobileFrontend/stylesheets/images/blank.gif",t=document.getElementById("clearsearch"),h=false,l=MobileFrontend.utils;b=MobileFrontend.setting("scriptPath")+b;function y(){var u;a=document.getElementById("searchbox");header=document.getElementById("header");q=document.getElementById("content");n=document.getElementById("footer");if(!h){MobileFrontend.utils(document.body).addClass("full-screen-search");u=document.getElementById("remove-results");if(!u){u=document.createElement("img");u.setAttribute("id","remove-results");l(u).bind("click",v);u.setAttribute("src",w);u.setAttribute("alt",MobileFrontend.message("remove-results"));header.insertBefore(u,header.firstChild)}h=true}}l(i).bind("focus",y);function v(){MobileFrontend.utils(document.body).removeClass("full-screen-search");if(h){h=false}}var j=function(u){if(u){u.preventDefault()}clearTimeout(k);p=i.value;if(p.length>1){p=encodeURIComponent(p);k=setTimeout(function(){g(p)},c)}};var m;window.setInterval(function(){var u=i.value;if(u.length>1&&u!==m){m=u;l(a).addClass("notEmpty");j()}else{if(!u){l(a).removeClass("notEmpty")}}},c);l(document.getElementById("searchForm")).bind("submit",function(B){var u,C,A=l(".suggestions-result a")[0];if(A){if("fireEvent" in A){A.fireEvent("click")}else{C=document.createEvent("HTMLEvents");C.initEvent("click",true,true);A.dispatchEvent(C)}B.preventDefault()}else{j(B)}});function z(u){if(i.value.length===0){v()}else{j(u)}}l(i).bind("blur",z);function g(u){l(i).addClass("searching");url=b+"?action=opensearch&limit="+x+"&namespace=0&format=xml&search="+u;l.ajax({url:url,success:function(A){if(l(document.body).hasClass("full-screen-search")){o(f(A));l(i).removeClass("searching")}}})}function f(D){var E=[],A,B,C,u=D.getElementsByTagName("Item");for(A=0;A<u.length;A++){B=u[A];C={label:B.getElementsByTagName("Text")[0].textContent,value:B.getElementsByTagName("Url")[0].textContent};E.push(C)}return E}function d(B){var A=document.createTextNode(B),u=document.createElement("div");u.appendChild(A);return u.innerHTML}function s(u){return u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}function o(I){var C=document.getElementById("results"),E,D,B=d(document.getElementById("search").value),H,A,u,F,G;if(!I||I.length<1){C.innerHTML='<ul class="suggestions-results" title="No Results"><li class="suggestions-result">No Results</li></div>'}else{if(C.firstChild){C.removeChild(C.firstChild)}E=document.createElement("ul");E.className="suggestions-results";C.appendChild(E);for(D=0;D<I.length;D++){H=I[D];u=document.createElement("li");u.setAttribute("title",H.label);u.className="suggestions-result";F=document.createElement("a");F.setAttribute("href",H.value.replace(/^(?:\/\/|[^\/]+)*\//,"/"));F.className="search-result-item";G=document.createTextNode(H.label);F.appendChild(G);u.appendChild(F);E.appendChild(u);A=s(B);F.innerHTML=F.innerHTML.replace(new RegExp("("+A+")","ig"),"<strong>$1</strong>")}}}function e(){var C=document.getElementById("clearsearch"),u=document.getElementById("search");function A(D){window.setTimeout(function(){u.value=""},100);results.innerHTML="";D.preventDefault()}function B(){u.select()}l(C).bind("mousedown",A);l(u).bind("click",B)}function r(){if(document.activeElement&&document.activeElement.id==="search"){y()}}r();e();return{init:r,initClearSearch:e,writeResults:o,createObjectArray:f,removeResults:v}}());
\ No newline at end of file
+MobileFrontend.opensearch=(function(){var b="/api.php",k=-1,c=500,w=15,p,i=document.getElementById("search"),a=document.getElementById("searchbox"),q=document.getElementById("content"),n=document.getElementById("footer"),t=document.getElementById("clearsearch"),h=false,l=MobileFrontend.utils;b=MobileFrontend.setting("scriptPath")+b;function x(){var u,z;a=document.getElementById("searchbox");header=document.getElementById("header");q=document.getElementById("content");n=document.getElementById("footer");if(!h){MobileFrontend.utils(document.body).addClass("full-screen-search");u=document.getElementById("remove-results");if(!u){u=document.createElement("a");u.setAttribute("href","#");u.setAttribute("id","remove-results");l(u).bind("click",v);z=document.createElement("div");z.setAttribute("id","left-arrow");u.appendChild(z);header.insertBefore(u,header.firstChild)}h=true}}l(i).bind("focus",x);function v(){MobileFrontend.utils(document.body).removeClass("full-screen-search");if(h){h=false}}var j=function(u){if(u){u.preventDefault()}clearTimeout(k);p=i.value;if(p.length>1){p=encodeURIComponent(p);k=setTimeout(function(){g(p)},c)}};var m;window.setInterval(function(){var u=i.value;if(u.length>1&&u!==m){m=u;l(a).addClass("notEmpty");j()}else{if(!u){l(a).removeClass("notEmpty")}}},c);l(document.getElementById("searchForm")).bind("submit",function(A){var u,B,z=l(".suggestions-result a")[0];if(z){if("fireEvent" in z){z.fireEvent("click")}else{B=document.createEvent("HTMLEvents");B.initEvent("click",true,true);z.dispatchEvent(B)}A.preventDefault()}else{j(A)}});function y(u){if(i.value.length===0){v()}else{j(u)}}l(i).bind("blur",y);function g(u){l(i).addClass("searching");url=b+"?action=opensearch&limit="+w+"&namespace=0&format=xml&search="+u;l.ajax({url:url,success:function(z){if(l(document.body).hasClass("full-screen-search")){o(f(z));l(i).removeClass("searching")}}})}function f(C){var D=[],z,A,B,u=C.getElementsByTagName("Item");for(z=0;z<u.length;z++){A=u[z];B={label:A.getElementsByTagName("Text")[0].textContent,value:A.getElementsByTagName("Url")[0].textContent};D.push(B)}return D}function d(A){var z=document.createTextNode(A),u=document.createElement("div");u.appendChild(z);return u.innerHTML}function s(u){return u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}function o(H){var B=document.getElementById("results"),D,C,A=d(document.getElementById("search").value),G,z,u,E,F;if(i){i.focus()}if(!H||H.length<1){B.innerHTML='<ul class="suggestions-results" title="No Results"><li class="suggestions-result">No Results</li></div>'}else{if(B.firstChild){B.removeChild(B.firstChild)}D=document.createElement("ul");D.className="suggestions-results";B.appendChild(D);for(C=0;C<H.length;C++){G=H[C];u=document.createElement("li");u.setAttribute("title",G.label);u.className="suggestions-result";E=document.createElement("a");E.setAttribute("href",G.value.replace(/^(?:\/\/|[^\/]+)*\//,"/"));E.className="search-result-item";F=document.createTextNode(G.label);E.appendChild(F);u.appendChild(E);D.appendChild(u);z=s(A);E.innerHTML=E.innerHTML.replace(new RegExp("("+z+")","ig"),"<strong>$1</strong>")}}}function e(){var B=document.getElementById("clearsearch"),u=document.getElementById("search");function z(C){window.setTimeout(function(){u.value=""},100);results.innerHTML="";C.preventDefault()}function A(){u.select()}l(B).bind("mousedown",z);l(u).bind("click",A)}function r(){if(document.activeElement&&document.activeElement.id==="search"){x()}}r();e();return{init:r,initClearSearch:e,writeResults:o,createObjectArray:f,removeResults:v}}());
\ No newline at end of file

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js 2012-04-13 20:19:46 UTC (rev 114888)
@@ -57,7 +57,7 @@
}
}
checkHash();
- for ( a = document.getElementsByTagName( 'a' ), i = 0; i < a.length; i++ ) {
+ for ( a = u( '.content_block a' ) || [], i = 0; i < a.length; i++ ) {
u( a[i] ).bind( 'click', checkHash );
}
}

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.min.js
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.min.js 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.min.js 2012-04-13 20:19:46 UTC (rev 114888)
@@ -1 +1 @@
-MobileFrontend.toggle=(function(){var a=MobileFrontend.utils;function c(){var g,m,p,h,f=[],j,l=[];h=document.getElementsByTagName("H2");for(g=0;g<h.length;g++){p=h[g];if(a(p).hasClass("section_heading")){l.push(p);j=p.getElementsByTagName("button");for(m=0;m<j.length;m++){f.push(j[m])}}}window.wm_toggle_section=b;for(g=0;g<f.length;g++){a(f[g]).remove()}function k(){var i=this.id?this.id.split("_")[1]:-1;if(i!==-1){b(i)}}function n(r){var q,i;q=document.createElement("button");i=document.createTextNode(MobileFrontend.message(r?"expand-section":"collapse-section"));q.className=r?"show":"hide";q.appendChild(i);return q}a(document.body).addClass("togglingEnabled");for(g=0;g<l.length;g++){p=l[g];p.removeAttribute("onclick");p.insertBefore(n(true),p.firstChild);p.insertBefore(n(false),p.firstChild);a(p).bind("click",k)}function o(){var i=this.hash||document.location.hash;if(i.indexOf("#")===0){e(i)}}o();for(m=document.getElementsByTagName("a"),g=0;g<m.length;g++){a(m[g]).bind("click",o)}}function e(i){var g=document.getElementById(i.substr(1)),h,f;if(g){h=g;while(h&&!a(h).hasClass("content_block")&&!a(h).hasClass("section_heading")){h=h.parentNode}if(h&&!a(h).hasClass("openSection")){f=h.id.split("_")[1];b(f)}}}function b(n){var m=document.getElementById("section_"+n),f,l=m.getElementsByTagName("button"),g,o,k,j,h=[];if(a(m).hasClass("openSection")){a(m).removeClass("togglefix");a(m).removeClass("openSection");j=true}else{h.push(m);a(m).addClass("openSection")}for(g=0,d=["content_","anchor_"];g<=1;g++){k=document.getElementById(d[g]+n);if(k&&a(k).hasClass("openSection")){a(k).removeClass("togglefix");a(k).removeClass("openSection")}else{if(k){h.push(k);a(k).addClass("openSection")}}}f="section_"+n;k=document.getElementById(f);k.removeAttribute("id");window.location.hash=j?"#_":"#"+f;k.setAttribute("id",f);window.setTimeout(function(){var p;for(p=0;p<h.length;p++){a(h[p]).addClass("togglefix")}},400)}c();return{wm_reveal_for_hash:e,wm_toggle_section:b,init:c}}());
\ No newline at end of file
+MobileFrontend.toggle=(function(){var a=MobileFrontend.utils;function c(){var g,m,p,h,f=[],j,l=[];h=document.getElementsByTagName("H2");for(g=0;g<h.length;g++){p=h[g];if(a(p).hasClass("section_heading")){l.push(p);j=p.getElementsByTagName("button");for(m=0;m<j.length;m++){f.push(j[m])}}}window.wm_toggle_section=b;for(g=0;g<f.length;g++){a(f[g]).remove()}function k(){var i=this.id?this.id.split("_")[1]:-1;if(i!==-1){b(i)}}function n(r){var q,i;q=document.createElement("button");i=document.createTextNode(MobileFrontend.message(r?"expand-section":"collapse-section"));q.className=r?"show":"hide";q.appendChild(i);return q}a(document.body).addClass("togglingEnabled");for(g=0;g<l.length;g++){p=l[g];p.removeAttribute("onclick");p.insertBefore(n(true),p.firstChild);p.insertBefore(n(false),p.firstChild);a(p).bind("click",k)}function o(){var i=this.hash||document.location.hash;if(i.indexOf("#")===0){e(i)}}o();for(m=a(".content_block a")||[],g=0;g<m.length;g++){a(m[g]).bind("click",o)}}function e(i){var g=document.getElementById(i.substr(1)),h,f;if(g){h=g;while(h&&!a(h).hasClass("content_block")&&!a(h).hasClass("section_heading")){h=h.parentNode}if(h&&!a(h).hasClass("openSection")){f=h.id.split("_")[1];b(f)}}}function b(n){var m=document.getElementById("section_"+n),f,l=m.getElementsByTagName("button"),g,o,k,j,h=[];if(a(m).hasClass("openSection")){a(m).removeClass("togglefix");a(m).removeClass("openSection");j=true}else{h.push(m);a(m).addClass("openSection")}for(g=0,d=["content_","anchor_"];g<=1;g++){k=document.getElementById(d[g]+n);if(k&&a(k).hasClass("openSection")){a(k).removeClass("togglefix");a(k).removeClass("openSection")}else{if(k){h.push(k);a(k).addClass("openSection")}}}f="section_"+n;k=document.getElementById(f);k.removeAttribute("id");window.location.hash=j?"#_":"#"+f;k.setAttribute("id",f);window.setTimeout(function(){var p;for(p=0;p<h.length;p++){a(h[p]).addClass("togglefix")}},400)}c();return{wm_reveal_for_hash:e,wm_toggle_section:b,init:c}}());
\ No newline at end of file

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css 2012-04-13 20:19:46 UTC (rev 114888)
@@ -108,12 +108,6 @@
border: 1px solid gray;
}

-table {
- display: block;
- overflow-x: auto;
- -webkit-overflow-scrolling: touch;
-}
-
table table {
border: 0;
margin-bottom: 0;

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css 2012-04-13 20:19:46 UTC (rev 114888)
@@ -229,11 +229,28 @@
}

table {
- display: block;
- overflow-x: auto;
- -webkit-overflow-scrolling: touch;
+ border-spacing: 0 !important;
+ max-width: 100%;
+ border-collapse: collapse !important;
+ border: 1px solid #cccccc;
+ padding: 3px;
+ margin-bottom: 15px;
}

+table.gallery .thumb[style] {
+ border: 0;
+ padding: 0 !important;
+ width: auto !important;
+ margin: 0 auto;
+}
+
+table.geography[style] td[style*="text-align"],
+table.geography[style] td[colspan="2"] {
+ text-align: left !important;
+ margin-left: 0 !important;
+ margin-right: 0 !important;
+}
+
table.toc h2 {
border: 0;
padding: 0;
@@ -247,6 +264,12 @@
border-bottom: 1px solid #cccccc;
}

+table[style] {
+ float: none !important;
+ margin-left: 0 !important;
+ width: 100% !important;
+}
+
table.navbox td.navbox-group {
background: #ddddff;
width: 25%;
@@ -258,6 +281,11 @@
border-bottom: 0;
}

+table.navbox {
+ font-size: 0.9em;
+ width: 100% !important;
+}
+
table.gallery .gallerytext {
margin-top: -12px;
text-align: center;
@@ -268,6 +296,16 @@
padding: 5px;
}

+table.navbox div[style*="padding"] {
+ padding-left: 0 !important;
+ padding-right: 0 !important;
+}
+
+table.gallery .gallerybox[style] {
+ width: auto !important;
+ margin-bottom: -16px;
+}
+
table td,
table th {
border: 1px solid #cccccc;
@@ -351,6 +389,14 @@
padding: 3px;
}

+table.navbox div[style*="padding"] a {
+ white-space: pre-wrap;
+}
+
+table.navbox span[style*="white"] {
+ white-space: pre-wrap !important;
+}
+
table.navbox td,
table.navbox th {
padding: 0;
@@ -378,6 +424,15 @@
border: 1px solid #cccccc;
}

+table.geography[style] th {
+ text-align: left;
+}
+
+table.geography[style] td[style*="text-align"] div[style],
+table.geography[style] td[colspan="2"] div[style] {
+ text-align: left !important;
+}
+
table.admin {
width: 300px;
}
@@ -485,6 +540,24 @@
text-align: center;
}

+.thumb .thumbinner[style] {
+ margin: 5px auto;
+ max-width: 100%;
+ width: auto !important;
+}
+
+.thumb img {
+ max-width: 100% !important;
+ width: auto !important;
+}
+
+.thumb .thumbcaption {
+ width: 100%;
+ margin: 5px 10px 0;
+ text-align: center;
+ width: auto !important;
+}
+
img.thumbborder {
border: 1px solid #cccccc;
}
@@ -507,7 +580,6 @@
}

#content_wrapper {
- margin-top: 10px;
clear: both;
margin: 0 8px;
}

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/filepage.css
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/filepage.css 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/filepage.css 2012-04-13 20:19:46 UTC (rev 114888)
@@ -8,10 +8,15 @@
background-image: linear-gradient(center top, #3E3E3E 0%, #393939 14%, #2E2E2E 32%, #151515 64%, #080808 84%, #010101 100%);
color: white;
text-align: center;
+
padding: 0;
margin: 0;
}

+#filetoc a {
+ color: white;
+}
+
#filetoc li {
display: inline-block;
padding: 8px;
@@ -22,3 +27,5 @@
max-width: 100%;
height: auto;
}
+
+

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/hacks.css
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/hacks.css 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/hacks.css 2012-04-13 20:19:46 UTC (rev 114888)
@@ -2,7 +2,6 @@
present in wikitext
and MediaWiki:Common.css definitions
This file should not need to exist
-IMPORTANT: do not use selectors of the form [style*=padding] as they are known to damage the ios app
*/

.navbox .hlist dd,
@@ -27,7 +26,7 @@
margin: 0 auto;
}

-table.geography[style] td[style],
+table.geography[style] td[style*="text-align"],
table.geography[style] td[colspan="2"] {
text-align: left !important;
margin-left: 0 !important;
@@ -45,7 +44,7 @@
width: 100% !important;
}

-table.navbox div[style] {
+table.navbox div[style*="padding"] {
padding-left: 0 !important;
padding-right: 0 !important;
}
@@ -55,8 +54,11 @@
margin-bottom: -16px;
}

-table.navbox div[style] a,
-table.navbox span[style] {
+table.navbox div[style*="padding"] a {
+ white-space: pre-wrap;
+}
+
+table.navbox span[style*="white"] {
white-space: pre-wrap !important;
}

@@ -65,6 +67,15 @@
border: 1px solid #cccccc;
}

+table.geography[style] th {
+ text-align: left;
+}
+
+table.geography[style] td[style*="text-align"] div[style],
+table.geography[style] td[colspan="2"] div[style] {
+ text-align: left !important;
+}
+
.thumb .thumbinner[style] {
margin: 5px auto;
max-width: 100%;
@@ -82,11 +93,3 @@
text-align: center;
width: auto !important;
}
-
-/* avoid float issues in fennec caused by MediaWiki:Common.css definiton */
-div.tright,
-div.floatright,
-table.floatright {
- clear: none !important;
- float: none !important;
-}

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/header.css
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/header.css 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/header.css 2012-04-13 20:19:46 UTC (rev 114888)
@@ -14,7 +14,7 @@
.clearlink {
top: 9px;
right: -18px;
- width: 24px;
+ width: 18px;
height: 20px;
background: url(images/close-button-beta.png) no-repeat scroll 0 0 transparent;
margin: 0;
@@ -125,25 +125,10 @@
height: 40px;
width: 27px;
padding-bottom: 0;
+ text-indent: -999px;
cursor: pointer;
}

-.goButton img {
- position: absolute;
- top: 0;
- left: 0;
- height: 40px;
- width: 27px;
-}
-
-/* for browsers with images disabled
-reduce font size so alt text more legible */
-#remove-results,
-.goButton img,
-.clearlink {
- font-size: 8px;
-}
-
html[dir="rtl"] .goButton {
right: auto;
left: 0;
@@ -324,7 +309,7 @@
#remove-results {
display: none;
position: absolute;
- width: 30px;
+ width: 18px;
height: 40px;
text-align: center;
line-height: 40px;
@@ -339,6 +324,7 @@
margin-top: -6px;
z-index: 99;
border: 0px solid;
+ text-indent: -999px;
overflow: hidden;
}

@@ -349,10 +335,3 @@
.full-screen-search #nav {
display: none !important;
}
-
-/* samsung galaxy s gt-19000 */
- [at] medi all and (max-width:240px) {
- #search {
- font-size: 0.8em;
- }
-}

Deleted: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/images/blank.gif
===================================================================
(Binary files differ)

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php 2012-04-13 20:19:46 UTC (rev 114888)
@@ -28,6 +28,8 @@

$noticeHtml = ( isset( $this->data['noticeHtml'] ) ) ? $this->data['noticeHtml'] : '';

+ $cssFileName = ( isset( $this->data['device']['css_file_name'] ) ) ? $this->data['device']['css_file_name'] : 'default';
+
$startScriptTag = '<script type="text/javascript" src="';
$endScriptTag = '"></script>';
$javaScriptPath = $this->data['wgExtensionAssetsPath'] . '/MobileFrontend/javascripts/';
@@ -36,6 +38,9 @@
$jQueryScript = $jQuerySupport ? $startScriptTag . $javaScriptPath . 'jquery-1.7.1.min.js' . $endScriptTag : '';
$filePageScript = ( $this->data['isFilePage'] ) ? $startScriptTag . $javaScriptPath . 'filepage.js?version=' . $wgMobileResourceVersion . $endScriptTag : '';

+ $startLinkTag = "<link href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/";
+ $endLinkTag = "' media='all' rel='Stylesheet' type='text/css' />";
+ $filePageStyle = ( $this->data['isFilePage'] ) ? $startLinkTag . 'filepage.css' . $endLinkTag : '';
$buttonHideText = Xml::escapeJsString( $this->data['hideText'] );
$buttonShowText = Xml::escapeJsString( $this->data['showText'] );
$configureHomepage = $this->data['configure-empty-homepage'];
@@ -46,7 +51,6 @@
'expand-section' => $buttonShowText,
'collapse-section' => $buttonHideText,
'empty-homepage' => $configureHomepage,
- 'remove-results' => wfMsg( 'mobile-frontend-wml-back' ),
),
'settings' => array(
'scriptPath' => ( $this->data['wgScriptPath'] ),
@@ -72,8 +76,10 @@
<title>{$this->data['htmlTitle']}</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />{$robots}
{$this->data['cssLinks']}
+ <link href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/{$cssFileName}.css?version={$wgMobileResourceVersion}' media='all' rel='Stylesheet' type='text/css' />
+ {$filePageStyle}
<meta name="viewport" content="initial-scale=1.0, user-scalable=yes">
- <meta name="robots" content="noindex, nofollow">
+ <meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
{$appleTouchIconTag}
{$jQueryScript}
<script type="text/javascript">
@@ -85,7 +91,6 @@
{$this->data['searchWebkitHtml']}
<div class='show' id='content_wrapper'>
{$noticeHtml}
- <h1 id="firstHeading">{$this->data['title']}</h1>
{$this->data['contentHtml']}
</div>
{$this->data['footerHtml']}

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/SearchTemplate.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/SearchTemplate.php 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/SearchTemplate.php 2012-04-13 20:19:46 UTC (rev 114888)
@@ -15,7 +15,6 @@
$randomButton = wfMessage( 'mobile-frontend-random-button' )->escaped();
$clearText = Sanitizer::encodeAttribute( wfMsg( 'mobile-frontend-clear-search' ) );
$placeholder = Sanitizer::encodeAttribute( wfMsg( 'mobile-frontend-placeholder' ) );
- $goButton = wfMessage( 'mobile-frontend-search-submit' );

$scriptUrl = wfScript();
$searchBoxDisplayNone = ( $this->data['hideSearchBox'] ) ? ' style="display: none;" ' : '';
@@ -36,14 +35,9 @@
<input type="hidden" value="Special:Search" name="title" />
<div id="sq" class="divclearable">
<input type="search" name="search" id="search" size="22" value="{$searchField}" autocomplete="off" maxlength="1024" class="search" placeholder="{$placeholder}" />
- <img src="{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/images/blank.gif"
- alt="{$clearText}"
- class="clearlink" id="clearsearch" title="{$clearText}">
+ <div class="clearlink" id="clearsearch" title="{$clearText}"></div>
</div>
- <button id='goButton' class='goButton' type='submit'>
- <img src="{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/images/blank.gif"
- alt="{$goButton}" title="{$goButton}">
- </button>
+ <button id='goButton' class='goButton' type='submit'></button>
</form>
</div>
<div class='nav' id='nav' {$logoDisplayNone}>

Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/MobileFrontendTest.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/MobileFrontendTest.php 2012-04-13 19:39:57 UTC (rev 114887)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/MobileFrontendTest.php 2012-04-13 20:19:46 UTC (rev 114888)
@@ -47,7 +47,7 @@
public function testDisableCaching() {
global $wgRequest, $wgExtMobileFrontend, $wgSquidServers;
$disableCaching = self::getMethod( 'disableCaching' );
-
+
$wgSquidServers = array( '10.64.0.131' );
$_SERVER['REMOTE_ADDR'] = '10.64.0.131';
$disableCaching->invokeArgs( $wgExtMobileFrontend, array() );
@@ -63,21 +63,21 @@
$sendXDeviceVaryHeader->invokeArgs( $wgExtMobileFrontend, array() );
$this->assertEquals( $_SERVER['HTTP_X_DEVICE'], $wgRequest->response()->getheader( 'X-Device' ) );
}
-
+
public function testGetMobileUrl() {
global $wgMobileUrlTemplate, $wgExtMobileFrontend;
$wgMobileUrlTemplate = "%h0.m.%h1.%h2";
$this->assertEquals( 'http://en.m.wikipedia.org/wiki/Article', $wgExtMobileFrontend->getMobileUrl( 'http://en.wikipedia.org/wiki/Article' ) );
}
-
+
public function testParseMobileUrlTemplate() {
global $wgMobileUrlTemplate, $wgExtMobileFrontend;
$wgMobileUrlTemplate = "%h0.m.%h1.%h2/path/morepath";
$this->assertEquals( '%h0.m.%h1.%h2', $wgExtMobileFrontend->parseMobileUrlTemplate( 'host' ) );
$this->assertEquals( '/path/morepath', $wgExtMobileFrontend->parseMobileUrlTemplate( 'path' ) );
- $this->assertEquals( array( 'host' => '%h0.m.%h1.%h2', 'path' => '/path/morepath' ), $wgExtMobileFrontend->parseMobileUrlTemplate() );
+ $this->assertEquals( array( 'host' => '%h0.m.%h1.%h2', 'path' => '/path/morepath' ), $wgExtMobileFrontend->parseMobileUrlTemplate());
}
-
+
public function testUpdateMobileUrlHost() {
global $wgMobileUrlTemplate, $wgExtMobileFrontend;
$updateMobileUrlHost = self::getMethod( "updateMobileUrlHost" );
@@ -86,26 +86,8 @@
$updateMobileUrlHost->invokeArgs( $wgExtMobileFrontend, array( &$parsedUrl ) );
$this->assertEquals( "http://en.m.wikipedia.org/wiki/Gustavus_Airport", wfAssembleUrl( $parsedUrl ) );
}
-
+
/**
- * @dataProvider updateDesktopUrlQueryProvider
- */
- public function testUpdateDesktopUrlQuery( $mobile, $desktop ) {
- global $wgExtMobileFrontend;
- $updateDesktopUrlQuery = self::getMethod( "updateDesktopUrlQuery" );
- $parsedUrl = wfParseUrl( $mobile );
- $updateDesktopUrlQuery->invokeArgs( $wgExtMobileFrontend, array( &$parsedUrl ) );
- $url = wfAssembleUrl( $parsedUrl );
- $this->assertEquals( $desktop, $url );
- }
-
- public function updateDesktopUrlQueryProvider() {
- return array(
- array( 'http://en.m.wikipedia.org/wiki/Gustavus_Airport?useformat=mobile&mobileaction=toggle_desktop_view', 'http://en.m.wikipedia.org/wiki/Gustavus_Airport?mobileaction=toggle_desktop_view' ),
- );
- }
-
- /**
* @dataProvider updateDesktopUrlHostProvider
*/
public function testUpdateDesktopUrlHost( $mobile, $desktop ) {
@@ -123,44 +105,44 @@
array( 'http://bm.m.wikipedia.org/wiki/Nyɛ_fɔlɔ', 'http://bm.wikipedia.org/wiki/Nyɛ_fɔlɔ' ),
);
}
-
+
public function testUpdateMobileUrlPath() {
global $wgMobileUrlTemplate, $wgExtMobileFrontend, $wgScriptPath;
$wgScriptPath = '/wiki';
$updateMobileUrlHost = self::getMethod( "updateMobileUrlPath" );
$wgMobileUrlTemplate = "/mobile/%p";
-
+
// check for constructing a templated URL
$parsedUrl = wfParseUrl( "http://en.wikipedia.org/wiki/Gustavus_Airport" );
$updateMobileUrlHost->invokeArgs( $wgExtMobileFrontend, array( &$parsedUrl ) );
$this->assertEquals( "http://en.wikipedia.org/wiki/mobile/Gustavus_Airport", wfAssembleUrl( $parsedUrl ) );
-
+
// check for maintaining an already templated URL
$parsedUrl = wfParseUrl( "http://en.wikipedia.org/wiki/mobile/Gustavus_Airport" );
$updateMobileUrlHost->invokeArgs( $wgExtMobileFrontend, array( &$parsedUrl ) );
$this->assertEquals( "http://en.wikipedia.org/wiki/mobile/Gustavus_Airport", wfAssembleUrl( $parsedUrl ) );
}
-
+
/**
* @dataProvider updateMobileUrlQueryStringProvider
*/
public function testUpdateMobileUrlQueryString( $assert, $useFormat ) {
global $wgRequest, $wgExtMobileFrontend;
-
+
$testMethod = ( $assert ) ? 'assertTrue' : 'assertFalse';
$url = 'http://en.wikipedia.org/wiki/Article/?something=bananas';
if ( !empty( $useFormat ) ) $url .= "&useformat=" . $useFormat;
$wgExtMobileFrontend->setUseFormat( $useFormat );
-
+
$parsedUrl = wfParseUrl( $url );
-
+
$updateMobileUrlQueryString = self::getMethod( 'updateMobileUrlQueryString' );
- $updateMobileUrlQueryString->invokeArgs( $wgExtMobileFrontend, array( &$parsedUrl ) );
-
+ $updateMobileUrlQueryString->invokeArgs( $wgExtMobileFrontend, array( &$parsedUrl) );
+
$targetUrl = wfAssembleUrl( $parsedUrl );
$this->$testMethod( $url == $targetUrl, $targetUrl );
}
-
+
public function updateMobileUrlQueryStringProvider() {
return array(
array( true, 'mobile' ),
@@ -168,43 +150,43 @@
array( true, '' ),
);
}
-
+
/**
* @dataProvider isMobileDeviceProvider
*/
public function testIsMobileDevice( $isDevice, $msg, $xDevice = null ) {
global $wgReqeust, $wgExtMobileFrontend;
$isMobileDevice = self::getMethod( 'isMobileDevice' );
-
+
$testMethod = ( $isDevice ) ? 'assertTrue' : 'assertFalse';
-
- if ( !is_null( $xDevice ) ) {
+
+ if ( !is_null( $xDevice )) {
$_SERVER[ 'HTTP_X_DEVICE' ] = $xDevice;
}
-
+
$this->$testMethod( $isMobileDevice->invokeArgs( $wgExtMobileFrontend, array() ), $msg );
}
-
+
public function isMobileDeviceProvider() {
return array(
array( false, 'Nothing set' ),
array( true, 'HTTP_X_DEVICE = webkit', 'webkit' ),
);
}
-
+
/**
* @dataProvider isFauxMobileDeviceProvider
*/
- public function testIsFauxMobileDevice( $isFauxDevice, $msg, $useformat = null ) {
+ public function testIsFauxMobileDevice( $isFauxDevice, $msg, $useformat=null ) {
global $wgRequest, $wgExtMobileFrontend;
$isFauxMobileDevice = self::getMethod( 'isFauxMobileDevice' );
-
+
$testMethod = ( $isFauxDevice ) ? 'assertTrue' : 'assertFalse';
-
+
$wgExtMobileFrontend->setUseFormat( $useformat );
$this->$testMethod( $isFauxMobileDevice->invokeArgs( $wgExtMobileFrontend, array() ), $msg );
}
-
+
public function isFauxMobileDeviceProvider() {
return array(
array( false, 'Nothing set' ),
@@ -213,17 +195,17 @@
array( false, 'useformat=yourmom', 'yourmom' ),
);
}
-
+
/**
* @dataProvider shouldDisplayMobileViewProvider
*/
- public function testShouldDisplayMobileView( $shouldDisplay, $xDevice = null, $requestVal = array(), $msg = null ) {
+ public function testShouldDisplayMobileView( $shouldDisplay, $xDevice=null, $requestVal=array(), $msg=null ) {
global $wgRequest, $wgExtMobileFrontend;
$shouldDisplayMobileView = self::getMethod( 'shouldDisplayMobileView' );
-
+
$testMethod = ( $shouldDisplay ) ? 'assertTrue' : 'assertFalse';
-
- if ( count( $requestVal ) ) {
+
+ if ( count( $requestVal )) {
foreach ( $requestVal as $key => $val ) {
if ( $key == 'useformat' ) {
$wgExtMobileFrontend->setUseFormat( $val );
@@ -232,15 +214,15 @@
}
}
}
-
- if ( !is_null( $xDevice ) ) {
+
+ if ( !is_null( $xDevice )) {
$_SERVER[ 'HTTP_X_DEVICE' ] = $xDevice;
}
-
+
$this->$testMethod( $shouldDisplayMobileView->invokeArgs( $wgExtMobileFrontend, array() ), $msg );
-
+
// clean up
- if ( count( $requestVal ) ) {
+ if ( count( $requestVal )) {
foreach ( $requestVal as $key => $val ) {
if ( $key == 'useformat' ) {
continue;
@@ -250,7 +232,7 @@
}
}
}
-
+
public function shouldDisplayMobileViewProvider() {
return array(
array( false, null, array() ),
@@ -266,11 +248,11 @@
array( false, null, array( 'useformat' => 'mobile', 'action' => 'history' ) ),
);
}
-
+
/**
* @dataProvider getXDeviceProvider
*/
- public function testGetXDevice( $xDevice = null ) {
+ public function testGetXDevice( $xDevice=null ) {
global $wgExtMobileFrontend;
if ( is_null( $xDevice ) ) {
$assert = '';
@@ -283,21 +265,21 @@
}
$this->assertEquals( $assert, $wgExtMobileFrontend->getXDevice() );
}
-
+
public function getXDeviceProvider() {
return array(
array( 'webkit' ),
array( null ),
);
}
-
+
/**
* @dataProvider getMobileActionProvider
*/
- public function testGetMobileAction( $mobileaction = null ) {
+ public function testGetMobileAction( $mobileaction=null ) {
global $wgRequest, $wgExtMobileFrontend;

- if ( is_null( $mobileaction ) ) {
+ if ( is_null( $mobileaction )) {
$assert = '';
$wgRequest->unsetVal( 'mobileaction' );
} else {
@@ -307,38 +289,38 @@

$this->assertEquals( $assert, $wgExtMobileFrontend->getMobileAction() );
}
-
+
public function getMobileActionProvider() {
return array(
array( null ),
array( 'view_normal_site' ),
);
}
-
+
/**
* @dataProvider getActionProvider
*/
- public function testGetAction( $action = null ) {
+ public function testGetAction( $action=null ) {
global $wgRequest, $wgExtMobileFrontend;
-
- if ( is_null( $action ) ) {
+
+ if ( is_null( $action )) {
$assert = '';
$wgRequest->unsetVal( 'action' );
} else {
$wgRequest->setVal( 'action', $action );
$assert = $action;
}
-
+
$this->assertEquals( $assert, $wgExtMobileFrontend->getAction() );
}
-
+
public function getActionProvider() {
return array(
array( null ),
array( 'edit' ),
);
}
-
+
/**
* @dataProvider getUseFormatProvider
*/
@@ -348,7 +330,7 @@
$wgExtMobileFrontend->setUseFormat( $explicit );
$this->assertEquals( $expected, $wgExtMobileFrontend->getUseFormat() );
}
-
+
public function getUseFormatProvider() {
return array(
array( 'mobile', null, 'mobile' ),
@@ -357,17 +339,17 @@
array( 'desktop', 'mobile', 'desktop' ),
);
}
-
+
public function testGetUseFormatCookieExpiry() {
global $wgExtMobileFrontend, $wgCookieExpiration, $wgMobileFrontendFormatCookieExpiry;
$getUseFormatCookieExpiry = self::getMethod( 'getUseFormatCookieExpiry' );
-
+
$origMFCookieExpiry = $wgMobileFrontendFormatCookieExpiry;
$startTime = time();
$wgMobileFrontendFormatCookieExpiry = 60;
$mfCookieExpected = $startTime + 60;
$this->assertTrue( $mfCookieExpected == $getUseFormatCookieExpiry->invokeArgs( $wgExtMobileFrontend, array( $startTime ) ), 'Using MobileFrontend expiry.' );
-
+
$wgMobileFrontendFormatCookieExpiry = null;
$defaultMWCookieExpected = $startTime + $wgCookieExpiration;
$this->assertTrue( $defaultMWCookieExpected == $getUseFormatCookieExpiry->invokeArgs( $wgExtMobileFrontend, array( $startTime ) ), 'Using default MediaWiki cookie expiry.' );
@@ -375,21 +357,21 @@
// reset global back to original value
$wgMobileFrontendFormatCookieExpiry = $origMFCookieExpiry;
}
-
+
public function testSetPropertiesFromArray() {
global $wgExtMobileFrontend;
$props = array(
'xDevice' => 'android',
- 'blargh' => 'bananas',
+ 'blargh' => 'bananas',
'minifyJS' => false,
);
$wgExtMobileFrontend->setPropertiesFromArray( $props );
$this->assertEquals( $wgExtMobileFrontend::$minifyJS, false );
$this->assertEquals( $wgExtMobileFrontend->getXDevice(), 'android' );
// ensure 'balrgh' didnt get set since it was not a pre-defined property
- $this->assertFalse( property_exists( $wgExtMobileFrontend, 'blargh' ) );
+ $this->assertFalse( property_exists( $wgExtMobileFrontend, 'blargh' ));
}
-
+
/**
* @outputBuffering enabled
*/
@@ -400,7 +382,7 @@
setcookie( 'foobar', 'pants' );
$this->asertEquals( $_COOKIE[ 'foobar' ], 'pants' );
}
-
+
/**
* NB this will not work as PHPUnit seems to not make it possible to set
* and retrieve cookies. Note above test, testCookie() - both assertions
@@ -410,7 +392,7 @@
* @outputBuffering enabled
*/
/*public function testCheckUseFormatCookie() {
-
+
}
*/
}


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS [at] lists
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Wikipedia mediawiki-cvs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.