http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95795
Revision: 95795
Author: preilly
Date: 2011-08-30 17:22:49 +0000 (Tue, 30 Aug 2011)
Log Message:
-----------
mft r95549 through r95794
Modified Paths:
--------------
branches/wmf/1.17wmf1/extensions/MobileFrontend/DeviceDetection.php
branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php
branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_footmenu_default.html.php
branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_search_webkit.html.php
Modified: branches/wmf/1.17wmf1/extensions/MobileFrontend/DeviceDetection.php
===================================================================
--- branches/wmf/1.17wmf1/extensions/MobileFrontend/DeviceDetection.php
2011-08-30 17:20:09 UTC (rev 95794)
+++ branches/wmf/1.17wmf1/extensions/MobileFrontend/DeviceDetection.php
2011-08-30 17:22:49 UTC (rev 95795)
@@ -16,8 +16,7 @@
public function availableFormats() {
$formats = array (
- 'html' =>
- array (
+ 'html' => array (
'view_format' => 'html',
'search_bar' => 'default',
'footmenu' => 'default',
@@ -27,9 +26,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'capable' =>
- array (
+ ),
+ 'capable' => array (
'view_format' => 'html',
'search_bar' => 'default',
'footmenu' => 'default',
@@ -39,9 +37,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'simplehtml' =>
- array (
+ ),
+ 'simplehtml' => array (
'view_format' => 'html',
'search_bar' => 'simple',
'footmenu' => 'simple',
@@ -51,9 +48,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'webkit' =>
- array (
+ ),
+ 'webkit' => array (
'view_format' => 'html',
'search_bar' => 'webkit',
'footmenu' => 'default',
@@ -63,9 +59,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'webkit_old' =>
- array (
+ ),
+ 'webkit_old' => array (
'view_format' => 'html',
'search_bar' => 'default',
'footmenu' => 'default',
@@ -75,9 +70,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'android' =>
- array (
+ ),
+ 'android' => array (
'view_format' => 'html',
'search_bar' => 'default',
'footmenu' => 'default',
@@ -87,9 +81,8 @@
'disable_zoom' => false,
'parser' => 'html',
'disable_links' => true,
- ),
- 'iphone' =>
- array (
+ ),
+ 'iphone' => array (
'view_format' => 'html',
'search_bar' => 'webkit',
'footmenu' => 'default',
@@ -99,9 +92,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'iphone2' =>
- array (
+ ),
+ 'iphone2' => array (
'view_format' => 'html',
'search_bar' => 'default',
'footmenu' => 'default',
@@ -111,9 +103,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'native_iphone' =>
- array (
+ ),
+ 'native_iphone' => array (
'view_format' => 'html',
'search_bar' => false,
'footmenu' => 'default',
@@ -123,9 +114,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => false,
- ),
- 'palm_pre' =>
- array (
+ ),
+ 'palm_pre' => array (
'view_format' => 'html',
'search_bar' => 'default',
'footmenu' => 'default',
@@ -135,9 +125,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'kindle' =>
- array (
+ ),
+ 'kindle' => array (
'view_format' => 'html',
'search_bar' => 'kindle',
'footmenu' => 'default',
@@ -147,9 +136,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'kindle2' =>
- array (
+ ),
+ 'kindle2' => array (
'view_format' => 'html',
'search_bar' => 'kindle',
'footmenu' => 'default',
@@ -159,9 +147,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'blackberry' =>
- array (
+ ),
+ 'blackberry' => array (
'view_format' => 'html',
'search_bar' => 'default',
'footmenu' => 'default',
@@ -171,9 +158,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'netfront' =>
- array (
+ ),
+ 'netfront' => array (
'view_format' => 'html',
'search_bar' => 'simple',
'footmenu' => 'simple',
@@ -183,9 +169,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'wap2' =>
- array (
+ ),
+ 'wap2' => array (
'view_format' => 'html',
'search_bar' => 'simple',
'footmenu' => 'simple',
@@ -195,9 +180,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'psp' =>
- array (
+ ),
+ 'psp' => array (
'view_format' => 'html',
'search_bar' => 'simple',
'footmenu' => 'simple',
@@ -207,9 +191,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'ps3' =>
- array (
+ ),
+ 'ps3' => array (
'view_format' => 'html',
'search_bar' => 'simple',
'footmenu' => 'simple',
@@ -219,9 +202,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'wii' =>
- array (
+ ),
+ 'wii' => array (
'view_format' => 'html',
'search_bar' => 'wii',
'footmenu' => 'default',
@@ -231,9 +213,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'operamini' =>
- array (
+ ),
+ 'operamini' => array (
'view_format' => 'html',
'search_bar' => 'simple',
'footmenu' => 'simple',
@@ -243,9 +224,8 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'nokia' =>
- array (
+ ),
+ 'nokia' => array (
'view_format' => 'html',
'search_bar' => 'webkit',
'footmenu' => 'default',
@@ -255,15 +235,14 @@
'disable_zoom' => true,
'parser' => 'html',
'disable_links' => true,
- ),
- 'wml' =>
- array (
+ ),
+ 'wml' => array (
'view_format' => 'wml',
'search_bar' => 'wml',
'supports_javascript' => false,
'parser' => 'wml',
- ),
- );
+ ),
+ );
return $formats;
}
@@ -315,6 +294,9 @@
if ( preg_match( '/Android/', $userAgent ) ) {
$formatName = 'android';
+ if ( strpos( $userAgent, 'Opera Mini' ) !== false ) {
+ $formatName = 'operamini';
+ }
} elseif ( preg_match( '/iPhone.* Safari/', $userAgent ) ) {
if ( strpos( $userAgent, 'iPhone OS 2' ) !== false ) {
$formatName = 'iphone2';
@@ -362,7 +344,7 @@
} elseif ( preg_match( '/PLAYSTATION 3/', $userAgent ) ) {
$formatName = 'ps3';
} elseif ( preg_match( '/SAMSUNG/', $userAgent ) ) {
- $formatName = 'capable';
+ $formatName = 'capable';
} elseif ( preg_match( '/BlackBerry/', $userAgent ) ) {
$formatName = 'blackberry';
}
Modified: branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php
===================================================================
--- branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php
2011-08-30 17:20:09 UTC (rev 95794)
+++ branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php
2011-08-30 17:22:49 UTC (rev 95795)
@@ -65,7 +65,7 @@
);
class ExtMobileFrontend {
- const VERSION = '0.5.46';
+ const VERSION = '0.5.50';
/**
* @var DOMDocument
@@ -103,6 +103,36 @@
public static $disableMobileSiteURL;
public static $viewNormalSiteURL;
public static $currentURL;
+
+ public static $messageKeys = array(
+ 'mobile-frontend-show-button',
+ 'mobile-frontend-hide-button',
+ 'mobile-frontend-back-to-top-of-section',
+ 'mobile-frontend-regular-site',
+ 'mobile-frontend-perm-stop-redirect',
+ 'mobile-frontend-home-button',
+ 'mobile-frontend-random-button',
+ 'mobile-frontend-are-you-sure',
+ 'mobile-frontend-explain-disable',
+ 'mobile-frontend-disable-button',
+ 'mobile-frontend-back-button',
+ 'mobile-frontend-opt-in-message',
+ 'mobile-frontend-opt-in-yes-button',
+ 'mobile-frontend-opt-in-no-button',
+ 'mobile-frontend-opt-in-title',
+ 'mobile-frontend-opt-out-message',
+ 'mobile-frontend-opt-out-yes-button',
+ 'mobile-frontend-opt-out-no-button',
+ 'mobile-frontend-opt-out-title',
+ 'mobile-frontend-opt-in-explain',
+ 'mobile-frontend-opt-out-explain',
+ 'mobile-frontend-disable-images',
+ 'mobile-frontend-wml-continue',
+ 'mobile-frontend-wml-back',
+ 'mobile-frontend-enable-images',
+ 'mobile-frontend-featured-article',
+ 'mobile-frontend-news-items',
+ );
public $itemsToRemove = array(
'#contentSub', # redirection notice
@@ -118,7 +148,7 @@
'form',
'div.sister-project',
'script',
- 'div.magnify', # stupid magnify thing
+ 'div.magnify', # magnify object
'.editsection',
'span.t',
'sup[style*="help"]',
@@ -139,18 +169,20 @@
public function addMobileFooter( &$obj, &$tpl ) {
global $wgRequest;
+ wfProfileIn( __METHOD__ );
$footerlinks = $tpl->data['footerlinks'];
$mobileViewUrl = $wgRequest->escapeAppendQuery(
'useformat=mobile' );
$tpl->set('mobileview', "<a href='{$mobileViewUrl}'>".wfMsg(
'mobile-frontend-view')."</a>");
$footerlinks['places'][] = 'mobileview';
$tpl->set('footerlinks', $footerlinks);
-
+ wfProfileOut( __METHOD__ );
return true;
}
public function getMsg() {
global $wgUser, $wgContLang, $wgRequest;
+ wfProfileIn( __METHOD__ );
self::$disableImagesURL = $wgRequest->escapeAppendQuery(
'disableImages=1' );
self::$enableImagesURL = $wgRequest->escapeAppendQuery(
'enableImages=1' );
@@ -162,40 +194,19 @@
$copyright = $skin->getCopyright();
// Need to stash the results of the "wfMsg" call before the
Output Buffering handler
// because at this point the database connection is shut down,
etc.
- self::$messages['mobile-frontend-show'] = wfMsg(
'mobile-frontend-show-button' );
- self::$messages['mobile-frontend-hide'] = wfMsg(
'mobile-frontend-hide-button' );
- self::$messages['mobile-frontend-back-to-top'] = wfMsg(
'mobile-frontend-back-to-top-of-section' );
- self::$messages['mobile-frontend-regular-site'] = wfMsg(
'mobile-frontend-regular-site' );
- self::$messages['mobile-frontend-perm-stop-redirect'] = wfMsg(
'mobile-frontend-perm-stop-redirect' );
+
self::$messages['mobile-frontend-copyright'] = $copyright;
- self::$messages['mobile-frontend-home-button'] = wfMsg(
'mobile-frontend-home-button' );
- self::$messages['mobile-frontend-random-button'] = wfMsg(
'mobile-frontend-random-button' );
- self::$messages['mobile-frontend-are-you-sure'] = wfMsg(
'mobile-frontend-are-you-sure' );
- self::$messages['mobile-frontend-explain-disable'] = wfMsg(
'mobile-frontend-explain-disable' );
- self::$messages['mobile-frontend-disable-button'] = wfMsg(
'mobile-frontend-disable-button' );
- self::$messages['mobile-frontend-back-button'] = wfMsg(
'mobile-frontend-back-button' );
- self::$messages['mobile-frontend-opt-in-message'] = wfMsg(
'mobile-frontend-opt-in-message' );
- self::$messages['mobile-frontend-opt-in-yes-button'] = wfMsg(
'mobile-frontend-opt-in-yes-button' );
- self::$messages['mobile-frontend-opt-in-no-button'] = wfMsg(
'mobile-frontend-opt-in-no-button' );
- self::$messages['mobile-frontend-opt-in-title'] = wfMsg(
'mobile-frontend-opt-in-title' );
- self::$messages['mobile-frontend-opt-out-message'] = wfMsg(
'mobile-frontend-opt-out-message' );
- self::$messages['mobile-frontend-opt-out-yes-button'] = wfMsg(
'mobile-frontend-opt-out-yes-button' );
- self::$messages['mobile-frontend-opt-out-no-button'] = wfMsg(
'mobile-frontend-opt-out-no-button' );
- self::$messages['mobile-frontend-opt-out-title'] = wfMsg(
'mobile-frontend-opt-out-title' );
- self::$messages['mobile-frontend-opt-in-explain'] = wfMsg(
'mobile-frontend-opt-in-explain' );
- self::$messages['mobile-frontend-opt-out-explain'] = wfMsg(
'mobile-frontend-opt-out-explain' );
- self::$messages['mobile-frontend-disable-images'] = wfMsg(
'mobile-frontend-disable-images' );
- self::$messages['mobile-frontend-wml-continue'] = wfMsg(
'mobile-frontend-wml-continue' );
- self::$messages['mobile-frontend-wml-back'] = wfMsg(
'mobile-frontend-wml-back' );
- self::$messages['mobile-frontend-enable-images'] = wfMsg(
'mobile-frontend-enable-images' );
- self::$messages['mobile-frontend-featured-article'] = wfMsg(
'mobile-frontend-featured-article' );
- self::$messages['mobile-frontend-news-items'] = wfMsg(
'mobile-frontend-news-items' );
+
+ foreach ( self::$messageKeys as $messageKey ) {
+ self::$messages[$messageKey] = wfMsg( $messageKey );
+ }
self::$dir = $wgContLang->getDir();
self::$code = $wgContLang->getCode();
self::$mainPageUrl = Title::newMainPage()->getLocalUrl();
self::$randomPageUrl = SpecialPage::getTitleFor( 'Randompage'
)->getLocalUrl();
+ wfProfileOut( __METHOD__ );
}
/**
@@ -205,7 +216,7 @@
*/
public function beforePageDisplayHTML( &$out, &$text ) {
global $wgContLang, $wgRequest, $wgMemc, $wgUser;
-
+ wfProfileIn( __METHOD__ );
// The title
self::$title = $out->getTitle();
@@ -281,10 +292,18 @@
self::$search = $wgRequest->getText( 'search' );
self::$callback = $wgRequest->getText( 'callback' );
self::$searchField = $wgRequest->getText( 'search', '' );
+
+ $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ?
$_SERVER['HTTP_X_DEVICE'] : '';
$acceptHeader = $_SERVER["HTTP_ACCEPT"];
$device = new DeviceDetection();
- $formatName = $device->formatName( $userAgent, $acceptHeader );
+
+ if ( !empty( $xDevice ) ) {
+ $formatName = $xDevice;
+ } else {
+ $formatName = $device->formatName( $userAgent,
$acceptHeader );
+ }
+
self::$device = $device->format( $formatName );
if ( self::$device['view_format'] === 'wml' ) {
@@ -300,6 +319,7 @@
if ( $mobileAction == 'disable_mobile_site' ) {
if ( $this->contentFormat == 'XHTML' ) {
echo $this->renderDisableMobileSiteXHTML();
+ wfProfileOut( __METHOD__ );
exit();
}
}
@@ -307,6 +327,7 @@
if ( $mobileAction == 'opt_in_mobile_site' ) {
if ( $this->contentFormat == 'XHTML' ) {
echo $this->renderOptInMobileSiteXHTML();
+ wfProfileOut( __METHOD__ );
exit();
}
}
@@ -314,6 +335,7 @@
if ( $mobileAction == 'opt_out_mobile_site' ) {
if ( $this->contentFormat == 'XHTML' ) {
echo $this->renderOptOutMobileSiteXHTML();
+ wfProfileOut( __METHOD__ );
exit();
}
}
@@ -321,7 +343,7 @@
if ( $mobileAction == 'opt_in_cookie' ) {
$this->setOptInOutCookie( '1' );
$this->disableCaching();
- $location = Title::newMainPage()->getFullURL();
+ $location = wfExpandUrl(
Title::newMainPage()->getFullURL(), PROTO_CURRENT );
$wgRequest->response()->header( 'Location: ' .
$location );
}
@@ -352,8 +374,6 @@
// Determine
- $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ?
$_SERVER['HTTP_X_DEVICE'] : '';
-
if (self::$useFormat === 'mobile' ||
self::$useFormat === 'mobile-wap' ||
!empty( $xDevice ) ) {
@@ -366,49 +386,59 @@
}
}
+ wfProfileOut( __METHOD__ );
return true;
}
private function setOptInOutCookie( $value ) {
global $wgCookieDomain, $wgRequest;
+ wfProfileIn( __METHOD__ );
$tempWgCookieDomain = $wgCookieDomain;
$wgCookieDomain = $this->getBaseDomain();
$wgRequest->response()->setcookie( 'optin', $value );
$wgCookieDomain = $tempWgCookieDomain;
+ wfProfileOut( __METHOD__ );
}
private function getBaseDomain() {
+ wfProfileIn( __METHOD__ );
//Validates value as IP address
if( !IP::isValid( $_SERVER['HTTP_HOST'] ) ) {
$domainParts = explode( '.', $_SERVER['HTTP_HOST'] );
$domainParts = array_reverse( $domainParts );
//Although some browsers will accept cookies without
the initial ., ยป RFC 2109 requires it to be included.
+ wfProfileOut( __METHOD__ );
return '.' . $domainParts[1] . '.' . $domainParts[0];
} else {
+ wfProfileOut( __METHOD__ );
return $_SERVER['HTTP_HOST'];
}
}
private function disableCaching() {
global $wgRequest;
+ wfProfileIn( __METHOD__ );
if ( isset( $_SERVER['HTTP_VIA'] ) &&
stripos( $_SERVER['HTTP_VIA'], '.wikimedia.org:3128' )
!== false ) {
$wgRequest->response()->header( 'Cache-Control:
no-cache, must-revalidate' );
$wgRequest->response()->header( 'Expires: Sat, 26 Jul
1997 05:00:00 GMT' );
$wgRequest->response()->header( 'Pragma: no-cache' );
}
+ wfProfileOut( __METHOD__ );
}
private function sendXDeviceVaryHeader() {
global $wgOut, $wgRequest;
-
+ wfProfileIn( __METHOD__ );
if ( !empty( $_SERVER['HTTP_X_DEVICE'] ) ) {
$wgRequest->response()->header( 'X-Device: ' .
$_SERVER['HTTP_X_DEVICE'] );
$wgOut->addVaryHeader( 'X-Device' );
}
+ wfProfileOut( __METHOD__ );
}
private function renderOptInMobileSiteXHTML() {
+ wfProfileIn( __METHOD__ );
if ( $this->contentFormat == 'XHTML' ) {
$this->getMsg();
$yesButton =
self::$messages['mobile-frontend-opt-in-yes-button'];
@@ -421,12 +451,15 @@
require( 'views/information/optin.html.php' );
$contentHtml = $optInHtml;
require( 'views/layout/application.html.php' );
+ wfProfileOut( __METHOD__ );
return $applicationHtml;
}
+ wfProfileOut( __METHOD__ );
return '';
}
private function renderOptOutMobileSiteXHTML() {
+ wfProfileIn( __METHOD__ );
if ( $this->contentFormat == 'XHTML' ) {
$this->getMsg();
$yesButton =
self::$messages['mobile-frontend-opt-out-yes-button'];
@@ -439,12 +472,15 @@
require( 'views/information/optout.html.php' );
$contentHtml = $optOutHtml;
require( 'views/layout/application.html.php' );
+ wfProfileOut( __METHOD__ );
return $applicationHtml;
}
+ wfProfileOut( __METHOD__ );
return '';
}
private function renderDisableMobileSiteXHTML() {
+ wfProfileIn( __METHOD__ );
if ( $this->contentFormat == 'XHTML' ) {
$this->getMsg();
$areYouSure =
self::$messages['mobile-frontend-are-you-sure'];
@@ -458,12 +494,15 @@
require( 'views/information/disable.html.php' );
$contentHtml = $disableHtml;
require( 'views/layout/application.html.php' );
+ wfProfileOut( __METHOD__ );
return $applicationHtml;
}
+ wfProfileOut( __METHOD__ );
return '';
}
private function headingTransformCallbackWML( $matches ) {
+ wfProfileIn( __METHOD__ );
static $headings = 0;
++$headings;
@@ -471,12 +510,12 @@
"<h2 class='section_heading'
id='section_{$headings}'>{$matches[2]}</h2>";
self::$headings = $headings;
-
+ wfProfileOut( __METHOD__ );
return $base;
}
private function headingTransformCallbackXHTML( $matches ) {
-
+ wfProfileIn( __METHOD__ );
if ( isset( $matches[0] ) ) {
preg_match('/id="([^"]*)"/', $matches[0],
$headlineMatches);
}
@@ -484,27 +523,48 @@
$headlineId = ( isset( $headlineMatches[1] ) ) ?
$headlineMatches[1] : '';
static $headings = 0;
- $show = self::$messages['mobile-frontend-show'];
- $hide = self::$messages['mobile-frontend-hide'];
- $backToTop = self::$messages['mobile-frontend-back-to-top'];
+ $show = self::$messages['mobile-frontend-show-button'];
+ $hide = self::$messages['mobile-frontend-hide-button'];
+ $backToTop =
self::$messages['mobile-frontend-back-to-top-of-section'];
++$headings;
// Back to top link
- $base = "<div class='section_anchors' id='anchor_" . intval(
$headings - 1 ) .
- "'><a href='#section_" . intval( $headings - 1 ) .
- "' class='back_to_top'>↑ {$backToTop}</a></div>";
+ $base = Html::openElement( 'div',
+ array(
'id' => 'anchor_' . intval( $headings - 1 ),
+
'class' => 'section_anchors', )
+ ) .
+ Html::rawElement( 'a',
+ array( 'href' => '#section_' .
intval( $headings - 1 ),
+ 'class' =>
'back_to_top' ),
+ '↑' .
$backToTop ) .
+ Html::closeElement( 'div' );
// generate the HTML we are going to inject
- $buttons = "<button class='section_heading show'
section_id='{$headings}'>{$show}</button>" .
- "<button class='section_heading hide'
section_id='{$headings}'>{$hide}</button>";
- $base .= "<h2 class='section_heading'
id='section_{$headings}'{$matches[1]}{$buttons} <span id='{$headlineId}'>" .
- "{$matches[2]}</span></h2><div class='content_block'
id='content_{$headings}'>";
+ $buttons = Html::element( 'button',
+ array('class' =>
'section_heading show',
+ 'section_id' =>
$headings ),
+ $show ) .
+ Html::element( 'button',
+ array('class' =>
'section_heading hide',
+ 'section_id' =>
$headings ),
+ $hide );
+ $base .= Html::openElement( 'h2',
+ array('class' =>
'section_heading',
+ 'id' =>
'section_' . $headings) ) .
+ $buttons .
+ Html::element( 'span',
+ array( 'id' => $headlineId),
+ $matches[2] ) .
+ Html::closeElement( 'h2' ) .
+ Html::openElement( 'div',
+ array('class' =>
'content_block',
+ 'id' =>
'content_' . $headings) );
if ( $headings > 1 ) {
// Close it up here
- $base = '</div>' . $base;
+ $base = Html::closeElement( 'div' ) . $base;
}
self::$headings = $headings;
-
+ wfProfileOut( __METHOD__ );
return $base;
}
@@ -513,6 +573,7 @@
* @return string
*/
public function headingTransform( $s ) {
+ wfProfileIn( __METHOD__ );
$callback = 'headingTransformCallback';
$callback .= $this->contentFormat;
@@ -533,15 +594,16 @@
$s
);
}
-
+ wfProfileOut( __METHOD__ );
return $s;
}
private function createWMLCard( $s ) {
+ wfProfileIn( __METHOD__ );
$segments = explode( $this->WMLSectionSeperator, $s );
$card = '';
$idx = 0;
- $requestedSegment = self::$requestedSegment;
+ $requestedSegment = htmlspecialchars( self::$requestedSegment );
$title = htmlspecialchars( self::$title->getText() );
$card .= "<card id='{$idx}'
title='{$title}'><p>{$segments[$requestedSegment]}</p>";
@@ -563,11 +625,13 @@
}
$card .= '</card>';
+ wfProfileOut( __METHOD__ );
return $card;
}
private function parseItemsToRemove() {
global $wgMFRemovableClasses;
+ wfProfileIn( __METHOD__ );
$itemToRemoveRecords = array();
foreach ( array_merge( $this->itemsToRemove,
$wgMFRemovableClasses )
@@ -578,11 +642,13 @@
CssDetection::detectIdCssOrTag( $itemToRemove, $type,
$rawName );
$itemToRemoveRecords[$type][] = $rawName;
}
-
+
+ wfProfileOut( __METHOD__ );
return $itemToRemoveRecords;
}
public function DOMParseMainPage( $html ) {
+ wfProfileIn( __METHOD__ );
$html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
libxml_use_internal_errors( true );
$this->mainPage = new DOMDocument();
@@ -613,13 +679,13 @@
}
$contentHtml = $this->mainPage->saveXML( $content,
LIBXML_NOEMPTYTAG );
-
+ wfProfileOut( __METHOD__ );
return $contentHtml;
}
public function DOMParse( $html ) {
global $wgSitename;
-
+ wfProfileIn( __METHOD__ );
$html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
libxml_use_internal_errors( true );
$this->doc = new DOMDocument();
@@ -756,18 +822,20 @@
header( 'Content-Type: application/json' );
header( 'Content-Disposition: attachment;
filename="data.js";' );
$json_data = array();
- $json_data['title'] = self::$title->getText();
+ $json_data['title'] = htmlspecialchars (
self::$title->getText() );
$json_data['html'] = $contentHtml;
- $json = json_encode( $json_data );
+ $json = FormatJson::encode( $json_data );
if ( !empty( self::$callback ) ) {
- $json = urlencode( self::$callback ) . '(' .
$json . ')';
+ $json = urlencode( htmlspecialchars(
self::$callback ) ) . '(' . $json . ')';
}
+ wfProfileOut( __METHOD__ );
return $json;
}
-
+
+ wfProfileOut( __METHOD__ );
return $applicationHtml;
}
@@ -776,8 +844,10 @@
*/
public function setDefaultLogo() {
global $wgMobileFrontendLogo, $wgExtensionAssetsPath;
+ wfProfileIn( __METHOD__ );
if ( $wgMobileFrontendLogo === false ) {
$wgMobileFrontendLogo = $wgExtensionAssetsPath .
'/MobileFrontend/stylesheets/images/mw.png';
}
+ wfProfileOut( __METHOD__ );
}
}
Modified:
branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_footmenu_default.html.php
===================================================================
---
branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_footmenu_default.html.php
2011-08-30 17:20:09 UTC (rev 95794)
+++
branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_footmenu_default.html.php
2011-08-30 17:22:49 UTC (rev 95795)
@@ -6,15 +6,15 @@
$disableImages = self::$messages['mobile-frontend-disable-images'];
$enableImages = self::$messages['mobile-frontend-enable-images'];
-$disableMobileSiteURL = self::$disableMobileSiteURL;
-$viewNormalSiteURL = self::$viewNormalSiteURL;
+$disableMobileSiteURL = htmlspecialchars( self::$disableMobileSiteURL );
+$viewNormalSiteURL = htmlspecialchars( self::$viewNormalSiteURL );
if ( self::$disableImages == 0 ) {
$imagesToggle = $disableImages;
- $imagesURL = self::$disableImagesURL;
+ $imagesURL = htmlspecialchars( self::$disableImagesURL );
} else {
$imagesToggle = $enableImages;
- $imagesURL = self::$enableImagesURL;
+ $imagesURL = htmlspecialchars( self::$enableImagesURL );
}
$footerHtml = <<<EOD
Modified:
branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_search_webkit.html.php
===================================================================
---
branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_search_webkit.html.php
2011-08-30 17:20:09 UTC (rev 95794)
+++
branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_search_webkit.html.php
2011-08-30 17:22:49 UTC (rev 95795)
@@ -1,7 +1,7 @@
<?php
global $wgExtensionAssetsPath, $wgMobileFrontendLogo;
-$searchField = self::$searchField;
+$searchField = htmlspecialchars( self::$searchField );
$mainPageUrl = self::$mainPageUrl;
$randomPageUrl = self::$randomPageUrl;
$homeButton = self::$messages['mobile-frontend-home-button'];
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs