r95795 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95794‎ | r95795 | r95796 >
Date:17:22, 30 August 2011
Author:preilly
Status:old
Tags:
Comment:
mft r95549 through r95794
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/DeviceDetection.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_footmenu_default.html.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_search_webkit.html.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/DeviceDetection.php
@@ -16,8 +16,7 @@
1717
1818 public function availableFormats() {
1919 $formats = array (
20 - 'html' =>
21 - array (
 20+ 'html' => array (
2221 'view_format' => 'html',
2322 'search_bar' => 'default',
2423 'footmenu' => 'default',
@@ -27,9 +26,8 @@
2827 'disable_zoom' => true,
2928 'parser' => 'html',
3029 'disable_links' => true,
31 - ),
32 - 'capable' =>
33 - array (
 30+ ),
 31+ 'capable' => array (
3432 'view_format' => 'html',
3533 'search_bar' => 'default',
3634 'footmenu' => 'default',
@@ -39,9 +37,8 @@
4038 'disable_zoom' => true,
4139 'parser' => 'html',
4240 'disable_links' => true,
43 - ),
44 - 'simplehtml' =>
45 - array (
 41+ ),
 42+ 'simplehtml' => array (
4643 'view_format' => 'html',
4744 'search_bar' => 'simple',
4845 'footmenu' => 'simple',
@@ -51,9 +48,8 @@
5249 'disable_zoom' => true,
5350 'parser' => 'html',
5451 'disable_links' => true,
55 - ),
56 - 'webkit' =>
57 - array (
 52+ ),
 53+ 'webkit' => array (
5854 'view_format' => 'html',
5955 'search_bar' => 'webkit',
6056 'footmenu' => 'default',
@@ -63,9 +59,8 @@
6460 'disable_zoom' => true,
6561 'parser' => 'html',
6662 'disable_links' => true,
67 - ),
68 - 'webkit_old' =>
69 - array (
 63+ ),
 64+ 'webkit_old' => array (
7065 'view_format' => 'html',
7166 'search_bar' => 'default',
7267 'footmenu' => 'default',
@@ -75,9 +70,8 @@
7671 'disable_zoom' => true,
7772 'parser' => 'html',
7873 'disable_links' => true,
79 - ),
80 - 'android' =>
81 - array (
 74+ ),
 75+ 'android' => array (
8276 'view_format' => 'html',
8377 'search_bar' => 'default',
8478 'footmenu' => 'default',
@@ -87,9 +81,8 @@
8882 'disable_zoom' => false,
8983 'parser' => 'html',
9084 'disable_links' => true,
91 - ),
92 - 'iphone' =>
93 - array (
 85+ ),
 86+ 'iphone' => array (
9487 'view_format' => 'html',
9588 'search_bar' => 'webkit',
9689 'footmenu' => 'default',
@@ -99,9 +92,8 @@
10093 'disable_zoom' => true,
10194 'parser' => 'html',
10295 'disable_links' => true,
103 - ),
104 - 'iphone2' =>
105 - array (
 96+ ),
 97+ 'iphone2' => array (
10698 'view_format' => 'html',
10799 'search_bar' => 'default',
108100 'footmenu' => 'default',
@@ -111,9 +103,8 @@
112104 'disable_zoom' => true,
113105 'parser' => 'html',
114106 'disable_links' => true,
115 - ),
116 - 'native_iphone' =>
117 - array (
 107+ ),
 108+ 'native_iphone' => array (
118109 'view_format' => 'html',
119110 'search_bar' => false,
120111 'footmenu' => 'default',
@@ -123,9 +114,8 @@
124115 'disable_zoom' => true,
125116 'parser' => 'html',
126117 'disable_links' => false,
127 - ),
128 - 'palm_pre' =>
129 - array (
 118+ ),
 119+ 'palm_pre' => array (
130120 'view_format' => 'html',
131121 'search_bar' => 'default',
132122 'footmenu' => 'default',
@@ -135,9 +125,8 @@
136126 'disable_zoom' => true,
137127 'parser' => 'html',
138128 'disable_links' => true,
139 - ),
140 - 'kindle' =>
141 - array (
 129+ ),
 130+ 'kindle' => array (
142131 'view_format' => 'html',
143132 'search_bar' => 'kindle',
144133 'footmenu' => 'default',
@@ -147,9 +136,8 @@
148137 'disable_zoom' => true,
149138 'parser' => 'html',
150139 'disable_links' => true,
151 - ),
152 - 'kindle2' =>
153 - array (
 140+ ),
 141+ 'kindle2' => array (
154142 'view_format' => 'html',
155143 'search_bar' => 'kindle',
156144 'footmenu' => 'default',
@@ -159,9 +147,8 @@
160148 'disable_zoom' => true,
161149 'parser' => 'html',
162150 'disable_links' => true,
163 - ),
164 - 'blackberry' =>
165 - array (
 151+ ),
 152+ 'blackberry' => array (
166153 'view_format' => 'html',
167154 'search_bar' => 'default',
168155 'footmenu' => 'default',
@@ -171,9 +158,8 @@
172159 'disable_zoom' => true,
173160 'parser' => 'html',
174161 'disable_links' => true,
175 - ),
176 - 'netfront' =>
177 - array (
 162+ ),
 163+ 'netfront' => array (
178164 'view_format' => 'html',
179165 'search_bar' => 'simple',
180166 'footmenu' => 'simple',
@@ -183,9 +169,8 @@
184170 'disable_zoom' => true,
185171 'parser' => 'html',
186172 'disable_links' => true,
187 - ),
188 - 'wap2' =>
189 - array (
 173+ ),
 174+ 'wap2' => array (
190175 'view_format' => 'html',
191176 'search_bar' => 'simple',
192177 'footmenu' => 'simple',
@@ -195,9 +180,8 @@
196181 'disable_zoom' => true,
197182 'parser' => 'html',
198183 'disable_links' => true,
199 - ),
200 - 'psp' =>
201 - array (
 184+ ),
 185+ 'psp' => array (
202186 'view_format' => 'html',
203187 'search_bar' => 'simple',
204188 'footmenu' => 'simple',
@@ -207,9 +191,8 @@
208192 'disable_zoom' => true,
209193 'parser' => 'html',
210194 'disable_links' => true,
211 - ),
212 - 'ps3' =>
213 - array (
 195+ ),
 196+ 'ps3' => array (
214197 'view_format' => 'html',
215198 'search_bar' => 'simple',
216199 'footmenu' => 'simple',
@@ -219,9 +202,8 @@
220203 'disable_zoom' => true,
221204 'parser' => 'html',
222205 'disable_links' => true,
223 - ),
224 - 'wii' =>
225 - array (
 206+ ),
 207+ 'wii' => array (
226208 'view_format' => 'html',
227209 'search_bar' => 'wii',
228210 'footmenu' => 'default',
@@ -231,9 +213,8 @@
232214 'disable_zoom' => true,
233215 'parser' => 'html',
234216 'disable_links' => true,
235 - ),
236 - 'operamini' =>
237 - array (
 217+ ),
 218+ 'operamini' => array (
238219 'view_format' => 'html',
239220 'search_bar' => 'simple',
240221 'footmenu' => 'simple',
@@ -243,9 +224,8 @@
244225 'disable_zoom' => true,
245226 'parser' => 'html',
246227 'disable_links' => true,
247 - ),
248 - 'nokia' =>
249 - array (
 228+ ),
 229+ 'nokia' => array (
250230 'view_format' => 'html',
251231 'search_bar' => 'webkit',
252232 'footmenu' => 'default',
@@ -255,15 +235,14 @@
256236 'disable_zoom' => true,
257237 'parser' => 'html',
258238 'disable_links' => true,
259 - ),
260 - 'wml' =>
261 - array (
 239+ ),
 240+ 'wml' => array (
262241 'view_format' => 'wml',
263242 'search_bar' => 'wml',
264243 'supports_javascript' => false,
265244 'parser' => 'wml',
266 - ),
267 - );
 245+ ),
 246+ );
268247 return $formats;
269248 }
270249
@@ -315,6 +294,9 @@
316295
317296 if ( preg_match( '/Android/', $userAgent ) ) {
318297 $formatName = 'android';
 298+ if ( strpos( $userAgent, 'Opera Mini' ) !== false ) {
 299+ $formatName = 'operamini';
 300+ }
319301 } elseif ( preg_match( '/iPhone.* Safari/', $userAgent ) ) {
320302 if ( strpos( $userAgent, 'iPhone OS 2' ) !== false ) {
321303 $formatName = 'iphone2';
@@ -362,7 +344,7 @@
363345 } elseif ( preg_match( '/PLAYSTATION 3/', $userAgent ) ) {
364346 $formatName = 'ps3';
365347 } elseif ( preg_match( '/SAMSUNG/', $userAgent ) ) {
366 - $formatName = 'capable';
 348+ $formatName = 'capable';
367349 } elseif ( preg_match( '/BlackBerry/', $userAgent ) ) {
368350 $formatName = 'blackberry';
369351 }
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php
@@ -65,7 +65,7 @@
6666 );
6767
6868 class ExtMobileFrontend {
69 - const VERSION = '0.5.46';
 69+ const VERSION = '0.5.50';
7070
7171 /**
7272 * @var DOMDocument
@@ -103,6 +103,36 @@
104104 public static $disableMobileSiteURL;
105105 public static $viewNormalSiteURL;
106106 public static $currentURL;
 107+
 108+ public static $messageKeys = array(
 109+ 'mobile-frontend-show-button',
 110+ 'mobile-frontend-hide-button',
 111+ 'mobile-frontend-back-to-top-of-section',
 112+ 'mobile-frontend-regular-site',
 113+ 'mobile-frontend-perm-stop-redirect',
 114+ 'mobile-frontend-home-button',
 115+ 'mobile-frontend-random-button',
 116+ 'mobile-frontend-are-you-sure',
 117+ 'mobile-frontend-explain-disable',
 118+ 'mobile-frontend-disable-button',
 119+ 'mobile-frontend-back-button',
 120+ 'mobile-frontend-opt-in-message',
 121+ 'mobile-frontend-opt-in-yes-button',
 122+ 'mobile-frontend-opt-in-no-button',
 123+ 'mobile-frontend-opt-in-title',
 124+ 'mobile-frontend-opt-out-message',
 125+ 'mobile-frontend-opt-out-yes-button',
 126+ 'mobile-frontend-opt-out-no-button',
 127+ 'mobile-frontend-opt-out-title',
 128+ 'mobile-frontend-opt-in-explain',
 129+ 'mobile-frontend-opt-out-explain',
 130+ 'mobile-frontend-disable-images',
 131+ 'mobile-frontend-wml-continue',
 132+ 'mobile-frontend-wml-back',
 133+ 'mobile-frontend-enable-images',
 134+ 'mobile-frontend-featured-article',
 135+ 'mobile-frontend-news-items',
 136+ );
107137
108138 public $itemsToRemove = array(
109139 '#contentSub', # redirection notice
@@ -118,7 +148,7 @@
119149 'form',
120150 'div.sister-project',
121151 'script',
122 - 'div.magnify', # stupid magnify thing
 152+ 'div.magnify', # magnify object
123153 '.editsection',
124154 'span.t',
125155 'sup[style*="help"]',
@@ -139,18 +169,20 @@
140170
141171 public function addMobileFooter( &$obj, &$tpl ) {
142172 global $wgRequest;
 173+ wfProfileIn( __METHOD__ );
143174 $footerlinks = $tpl->data['footerlinks'];
144175 $mobileViewUrl = $wgRequest->escapeAppendQuery( 'useformat=mobile' );
145176
146177 $tpl->set('mobileview', "<a href='{$mobileViewUrl}'>".wfMsg( 'mobile-frontend-view')."</a>");
147178 $footerlinks['places'][] = 'mobileview';
148179 $tpl->set('footerlinks', $footerlinks);
149 -
 180+ wfProfileOut( __METHOD__ );
150181 return true;
151182 }
152183
153184 public function getMsg() {
154185 global $wgUser, $wgContLang, $wgRequest;
 186+ wfProfileIn( __METHOD__ );
155187
156188 self::$disableImagesURL = $wgRequest->escapeAppendQuery( 'disableImages=1' );
157189 self::$enableImagesURL = $wgRequest->escapeAppendQuery( 'enableImages=1' );
@@ -162,40 +194,19 @@
163195 $copyright = $skin->getCopyright();
164196 // Need to stash the results of the "wfMsg" call before the Output Buffering handler
165197 // because at this point the database connection is shut down, etc.
166 - self::$messages['mobile-frontend-show'] = wfMsg( 'mobile-frontend-show-button' );
167 - self::$messages['mobile-frontend-hide'] = wfMsg( 'mobile-frontend-hide-button' );
168 - self::$messages['mobile-frontend-back-to-top'] = wfMsg( 'mobile-frontend-back-to-top-of-section' );
169 - self::$messages['mobile-frontend-regular-site'] = wfMsg( 'mobile-frontend-regular-site' );
170 - self::$messages['mobile-frontend-perm-stop-redirect'] = wfMsg( 'mobile-frontend-perm-stop-redirect' );
 198+
171199 self::$messages['mobile-frontend-copyright'] = $copyright;
172 - self::$messages['mobile-frontend-home-button'] = wfMsg( 'mobile-frontend-home-button' );
173 - self::$messages['mobile-frontend-random-button'] = wfMsg( 'mobile-frontend-random-button' );
174 - self::$messages['mobile-frontend-are-you-sure'] = wfMsg( 'mobile-frontend-are-you-sure' );
175 - self::$messages['mobile-frontend-explain-disable'] = wfMsg( 'mobile-frontend-explain-disable' );
176 - self::$messages['mobile-frontend-disable-button'] = wfMsg( 'mobile-frontend-disable-button' );
177 - self::$messages['mobile-frontend-back-button'] = wfMsg( 'mobile-frontend-back-button' );
178 - self::$messages['mobile-frontend-opt-in-message'] = wfMsg( 'mobile-frontend-opt-in-message' );
179 - self::$messages['mobile-frontend-opt-in-yes-button'] = wfMsg( 'mobile-frontend-opt-in-yes-button' );
180 - self::$messages['mobile-frontend-opt-in-no-button'] = wfMsg( 'mobile-frontend-opt-in-no-button' );
181 - self::$messages['mobile-frontend-opt-in-title'] = wfMsg( 'mobile-frontend-opt-in-title' );
182 - self::$messages['mobile-frontend-opt-out-message'] = wfMsg( 'mobile-frontend-opt-out-message' );
183 - self::$messages['mobile-frontend-opt-out-yes-button'] = wfMsg( 'mobile-frontend-opt-out-yes-button' );
184 - self::$messages['mobile-frontend-opt-out-no-button'] = wfMsg( 'mobile-frontend-opt-out-no-button' );
185 - self::$messages['mobile-frontend-opt-out-title'] = wfMsg( 'mobile-frontend-opt-out-title' );
186 - self::$messages['mobile-frontend-opt-in-explain'] = wfMsg( 'mobile-frontend-opt-in-explain' );
187 - self::$messages['mobile-frontend-opt-out-explain'] = wfMsg( 'mobile-frontend-opt-out-explain' );
188 - self::$messages['mobile-frontend-disable-images'] = wfMsg( 'mobile-frontend-disable-images' );
189 - self::$messages['mobile-frontend-wml-continue'] = wfMsg( 'mobile-frontend-wml-continue' );
190 - self::$messages['mobile-frontend-wml-back'] = wfMsg( 'mobile-frontend-wml-back' );
191 - self::$messages['mobile-frontend-enable-images'] = wfMsg( 'mobile-frontend-enable-images' );
192 - self::$messages['mobile-frontend-featured-article'] = wfMsg( 'mobile-frontend-featured-article' );
193 - self::$messages['mobile-frontend-news-items'] = wfMsg( 'mobile-frontend-news-items' );
 200+
 201+ foreach ( self::$messageKeys as $messageKey ) {
 202+ self::$messages[$messageKey] = wfMsg( $messageKey );
 203+ }
194204
195205 self::$dir = $wgContLang->getDir();
196206 self::$code = $wgContLang->getCode();
197207
198208 self::$mainPageUrl = Title::newMainPage()->getLocalUrl();
199209 self::$randomPageUrl = SpecialPage::getTitleFor( 'Randompage' )->getLocalUrl();
 210+ wfProfileOut( __METHOD__ );
200211 }
201212
202213 /**
@@ -205,7 +216,7 @@
206217 */
207218 public function beforePageDisplayHTML( &$out, &$text ) {
208219 global $wgContLang, $wgRequest, $wgMemc, $wgUser;
209 -
 220+ wfProfileIn( __METHOD__ );
210221 // The title
211222 self::$title = $out->getTitle();
212223
@@ -281,10 +292,18 @@
282293 self::$search = $wgRequest->getText( 'search' );
283294 self::$callback = $wgRequest->getText( 'callback' );
284295 self::$searchField = $wgRequest->getText( 'search', '' );
 296+
 297+ $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : '';
285298
286299 $acceptHeader = $_SERVER["HTTP_ACCEPT"];
287300 $device = new DeviceDetection();
288 - $formatName = $device->formatName( $userAgent, $acceptHeader );
 301+
 302+ if ( !empty( $xDevice ) ) {
 303+ $formatName = $xDevice;
 304+ } else {
 305+ $formatName = $device->formatName( $userAgent, $acceptHeader );
 306+ }
 307+
289308 self::$device = $device->format( $formatName );
290309
291310 if ( self::$device['view_format'] === 'wml' ) {
@@ -300,6 +319,7 @@
301320 if ( $mobileAction == 'disable_mobile_site' ) {
302321 if ( $this->contentFormat == 'XHTML' ) {
303322 echo $this->renderDisableMobileSiteXHTML();
 323+ wfProfileOut( __METHOD__ );
304324 exit();
305325 }
306326 }
@@ -307,6 +327,7 @@
308328 if ( $mobileAction == 'opt_in_mobile_site' ) {
309329 if ( $this->contentFormat == 'XHTML' ) {
310330 echo $this->renderOptInMobileSiteXHTML();
 331+ wfProfileOut( __METHOD__ );
311332 exit();
312333 }
313334 }
@@ -314,6 +335,7 @@
315336 if ( $mobileAction == 'opt_out_mobile_site' ) {
316337 if ( $this->contentFormat == 'XHTML' ) {
317338 echo $this->renderOptOutMobileSiteXHTML();
 339+ wfProfileOut( __METHOD__ );
318340 exit();
319341 }
320342 }
@@ -321,7 +343,7 @@
322344 if ( $mobileAction == 'opt_in_cookie' ) {
323345 $this->setOptInOutCookie( '1' );
324346 $this->disableCaching();
325 - $location = Title::newMainPage()->getFullURL();
 347+ $location = wfExpandUrl( Title::newMainPage()->getFullURL(), PROTO_CURRENT );
326348 $wgRequest->response()->header( 'Location: ' . $location );
327349 }
328350
@@ -352,8 +374,6 @@
353375
354376 // Determine
355377
356 - $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : '';
357 -
358378 if (self::$useFormat === 'mobile' ||
359379 self::$useFormat === 'mobile-wap' ||
360380 !empty( $xDevice ) ) {
@@ -366,49 +386,59 @@
367387 }
368388 }
369389
 390+ wfProfileOut( __METHOD__ );
370391 return true;
371392 }
372393
373394 private function setOptInOutCookie( $value ) {
374395 global $wgCookieDomain, $wgRequest;
 396+ wfProfileIn( __METHOD__ );
375397 $tempWgCookieDomain = $wgCookieDomain;
376398 $wgCookieDomain = $this->getBaseDomain();
377399 $wgRequest->response()->setcookie( 'optin', $value );
378400 $wgCookieDomain = $tempWgCookieDomain;
 401+ wfProfileOut( __METHOD__ );
379402 }
380403
381404 private function getBaseDomain() {
 405+ wfProfileIn( __METHOD__ );
382406 //Validates value as IP address
383407 if( !IP::isValid( $_SERVER['HTTP_HOST'] ) ) {
384408 $domainParts = explode( '.', $_SERVER['HTTP_HOST'] );
385409 $domainParts = array_reverse( $domainParts );
386410 //Although some browsers will accept cookies without the initial ., » RFC 2109 requires it to be included.
 411+ wfProfileOut( __METHOD__ );
387412 return '.' . $domainParts[1] . '.' . $domainParts[0];
388413 } else {
 414+ wfProfileOut( __METHOD__ );
389415 return $_SERVER['HTTP_HOST'];
390416 }
391417 }
392418
393419 private function disableCaching() {
394420 global $wgRequest;
 421+ wfProfileIn( __METHOD__ );
395422 if ( isset( $_SERVER['HTTP_VIA'] ) &&
396423 stripos( $_SERVER['HTTP_VIA'], '.wikimedia.org:3128' ) !== false ) {
397424 $wgRequest->response()->header( 'Cache-Control: no-cache, must-revalidate' );
398425 $wgRequest->response()->header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
399426 $wgRequest->response()->header( 'Pragma: no-cache' );
400427 }
 428+ wfProfileOut( __METHOD__ );
401429 }
402430
403431 private function sendXDeviceVaryHeader() {
404432 global $wgOut, $wgRequest;
405 -
 433+ wfProfileIn( __METHOD__ );
406434 if ( !empty( $_SERVER['HTTP_X_DEVICE'] ) ) {
407435 $wgRequest->response()->header( 'X-Device: ' . $_SERVER['HTTP_X_DEVICE'] );
408436 $wgOut->addVaryHeader( 'X-Device' );
409437 }
 438+ wfProfileOut( __METHOD__ );
410439 }
411440
412441 private function renderOptInMobileSiteXHTML() {
 442+ wfProfileIn( __METHOD__ );
413443 if ( $this->contentFormat == 'XHTML' ) {
414444 $this->getMsg();
415445 $yesButton = self::$messages['mobile-frontend-opt-in-yes-button'];
@@ -421,12 +451,15 @@
422452 require( 'views/information/optin.html.php' );
423453 $contentHtml = $optInHtml;
424454 require( 'views/layout/application.html.php' );
 455+ wfProfileOut( __METHOD__ );
425456 return $applicationHtml;
426457 }
 458+ wfProfileOut( __METHOD__ );
427459 return '';
428460 }
429461
430462 private function renderOptOutMobileSiteXHTML() {
 463+ wfProfileIn( __METHOD__ );
431464 if ( $this->contentFormat == 'XHTML' ) {
432465 $this->getMsg();
433466 $yesButton = self::$messages['mobile-frontend-opt-out-yes-button'];
@@ -439,12 +472,15 @@
440473 require( 'views/information/optout.html.php' );
441474 $contentHtml = $optOutHtml;
442475 require( 'views/layout/application.html.php' );
 476+ wfProfileOut( __METHOD__ );
443477 return $applicationHtml;
444478 }
 479+ wfProfileOut( __METHOD__ );
445480 return '';
446481 }
447482
448483 private function renderDisableMobileSiteXHTML() {
 484+ wfProfileIn( __METHOD__ );
449485 if ( $this->contentFormat == 'XHTML' ) {
450486 $this->getMsg();
451487 $areYouSure = self::$messages['mobile-frontend-are-you-sure'];
@@ -458,12 +494,15 @@
459495 require( 'views/information/disable.html.php' );
460496 $contentHtml = $disableHtml;
461497 require( 'views/layout/application.html.php' );
 498+ wfProfileOut( __METHOD__ );
462499 return $applicationHtml;
463500 }
 501+ wfProfileOut( __METHOD__ );
464502 return '';
465503 }
466504
467505 private function headingTransformCallbackWML( $matches ) {
 506+ wfProfileIn( __METHOD__ );
468507 static $headings = 0;
469508 ++$headings;
470509
@@ -471,12 +510,12 @@
472511 "<h2 class='section_heading' id='section_{$headings}'>{$matches[2]}</h2>";
473512
474513 self::$headings = $headings;
475 -
 514+ wfProfileOut( __METHOD__ );
476515 return $base;
477516 }
478517
479518 private function headingTransformCallbackXHTML( $matches ) {
480 -
 519+ wfProfileIn( __METHOD__ );
481520 if ( isset( $matches[0] ) ) {
482521 preg_match('/id="([^"]*)"/', $matches[0], $headlineMatches);
483522 }
@@ -484,27 +523,48 @@
485524 $headlineId = ( isset( $headlineMatches[1] ) ) ? $headlineMatches[1] : '';
486525
487526 static $headings = 0;
488 - $show = self::$messages['mobile-frontend-show'];
489 - $hide = self::$messages['mobile-frontend-hide'];
490 - $backToTop = self::$messages['mobile-frontend-back-to-top'];
 527+ $show = self::$messages['mobile-frontend-show-button'];
 528+ $hide = self::$messages['mobile-frontend-hide-button'];
 529+ $backToTop = self::$messages['mobile-frontend-back-to-top-of-section'];
491530 ++$headings;
492531 // Back to top link
493 - $base = "<div class='section_anchors' id='anchor_" . intval( $headings - 1 ) .
494 - "'><a href='#section_" . intval( $headings - 1 ) .
495 - "' class='back_to_top'>&#8593; {$backToTop}</a></div>";
 532+ $base = Html::openElement( 'div',
 533+ array( 'id' => 'anchor_' . intval( $headings - 1 ),
 534+ 'class' => 'section_anchors', )
 535+ ) .
 536+ Html::rawElement( 'a',
 537+ array( 'href' => '#section_' . intval( $headings - 1 ),
 538+ 'class' => 'back_to_top' ),
 539+ '&#8593;' . $backToTop ) .
 540+ Html::closeElement( 'div' );
496541 // generate the HTML we are going to inject
497 - $buttons = "<button class='section_heading show' section_id='{$headings}'>{$show}</button>" .
498 - "<button class='section_heading hide' section_id='{$headings}'>{$hide}</button>";
499 - $base .= "<h2 class='section_heading' id='section_{$headings}'{$matches[1]}{$buttons} <span id='{$headlineId}'>" .
500 - "{$matches[2]}</span></h2><div class='content_block' id='content_{$headings}'>";
 542+ $buttons = Html::element( 'button',
 543+ array('class' => 'section_heading show',
 544+ 'section_id' => $headings ),
 545+ $show ) .
 546+ Html::element( 'button',
 547+ array('class' => 'section_heading hide',
 548+ 'section_id' => $headings ),
 549+ $hide );
 550+ $base .= Html::openElement( 'h2',
 551+ array('class' => 'section_heading',
 552+ 'id' => 'section_' . $headings) ) .
 553+ $buttons .
 554+ Html::element( 'span',
 555+ array( 'id' => $headlineId),
 556+ $matches[2] ) .
 557+ Html::closeElement( 'h2' ) .
 558+ Html::openElement( 'div',
 559+ array('class' => 'content_block',
 560+ 'id' => 'content_' . $headings) );
501561
502562 if ( $headings > 1 ) {
503563 // Close it up here
504 - $base = '</div>' . $base;
 564+ $base = Html::closeElement( 'div' ) . $base;
505565 }
506566
507567 self::$headings = $headings;
508 -
 568+ wfProfileOut( __METHOD__ );
509569 return $base;
510570 }
511571
@@ -513,6 +573,7 @@
514574 * @return string
515575 */
516576 public function headingTransform( $s ) {
 577+ wfProfileIn( __METHOD__ );
517578 $callback = 'headingTransformCallback';
518579 $callback .= $this->contentFormat;
519580
@@ -533,15 +594,16 @@
534595 $s
535596 );
536597 }
537 -
 598+ wfProfileOut( __METHOD__ );
538599 return $s;
539600 }
540601
541602 private function createWMLCard( $s ) {
 603+ wfProfileIn( __METHOD__ );
542604 $segments = explode( $this->WMLSectionSeperator, $s );
543605 $card = '';
544606 $idx = 0;
545 - $requestedSegment = self::$requestedSegment;
 607+ $requestedSegment = htmlspecialchars( self::$requestedSegment );
546608 $title = htmlspecialchars( self::$title->getText() );
547609
548610 $card .= "<card id='{$idx}' title='{$title}'><p>{$segments[$requestedSegment]}</p>";
@@ -563,11 +625,13 @@
564626 }
565627
566628 $card .= '</card>';
 629+ wfProfileOut( __METHOD__ );
567630 return $card;
568631 }
569632
570633 private function parseItemsToRemove() {
571634 global $wgMFRemovableClasses;
 635+ wfProfileIn( __METHOD__ );
572636 $itemToRemoveRecords = array();
573637
574638 foreach ( array_merge( $this->itemsToRemove, $wgMFRemovableClasses )
@@ -578,11 +642,13 @@
579643 CssDetection::detectIdCssOrTag( $itemToRemove, $type, $rawName );
580644 $itemToRemoveRecords[$type][] = $rawName;
581645 }
582 -
 646+
 647+ wfProfileOut( __METHOD__ );
583648 return $itemToRemoveRecords;
584649 }
585650
586651 public function DOMParseMainPage( $html ) {
 652+ wfProfileIn( __METHOD__ );
587653 $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
588654 libxml_use_internal_errors( true );
589655 $this->mainPage = new DOMDocument();
@@ -613,13 +679,13 @@
614680 }
615681
616682 $contentHtml = $this->mainPage->saveXML( $content, LIBXML_NOEMPTYTAG );
617 -
 683+ wfProfileOut( __METHOD__ );
618684 return $contentHtml;
619685 }
620686
621687 public function DOMParse( $html ) {
622688 global $wgSitename;
623 -
 689+ wfProfileIn( __METHOD__ );
624690 $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
625691 libxml_use_internal_errors( true );
626692 $this->doc = new DOMDocument();
@@ -756,18 +822,20 @@
757823 header( 'Content-Type: application/json' );
758824 header( 'Content-Disposition: attachment; filename="data.js";' );
759825 $json_data = array();
760 - $json_data['title'] = self::$title->getText();
 826+ $json_data['title'] = htmlspecialchars ( self::$title->getText() );
761827 $json_data['html'] = $contentHtml;
762828
763 - $json = json_encode( $json_data );
 829+ $json = FormatJson::encode( $json_data );
764830
765831 if ( !empty( self::$callback ) ) {
766 - $json = urlencode( self::$callback ) . '(' . $json . ')';
 832+ $json = urlencode( htmlspecialchars( self::$callback ) ) . '(' . $json . ')';
767833 }
768834
 835+ wfProfileOut( __METHOD__ );
769836 return $json;
770837 }
771 -
 838+
 839+ wfProfileOut( __METHOD__ );
772840 return $applicationHtml;
773841 }
774842
@@ -776,8 +844,10 @@
777845 */
778846 public function setDefaultLogo() {
779847 global $wgMobileFrontendLogo, $wgExtensionAssetsPath;
 848+ wfProfileIn( __METHOD__ );
780849 if ( $wgMobileFrontendLogo === false ) {
781850 $wgMobileFrontendLogo = $wgExtensionAssetsPath . '/MobileFrontend/stylesheets/images/mw.png';
782851 }
 852+ wfProfileOut( __METHOD__ );
783853 }
784854 }
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_search_webkit.html.php
@@ -1,7 +1,7 @@
22 <?php
33 global $wgExtensionAssetsPath, $wgMobileFrontendLogo;
44
5 -$searchField = self::$searchField;
 5+$searchField = htmlspecialchars( self::$searchField );
66 $mainPageUrl = self::$mainPageUrl;
77 $randomPageUrl = self::$randomPageUrl;
88 $homeButton = self::$messages['mobile-frontend-home-button'];
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/_footmenu_default.html.php
@@ -6,15 +6,15 @@
77 $disableImages = self::$messages['mobile-frontend-disable-images'];
88 $enableImages = self::$messages['mobile-frontend-enable-images'];
99
10 -$disableMobileSiteURL = self::$disableMobileSiteURL;
11 -$viewNormalSiteURL = self::$viewNormalSiteURL;
 10+$disableMobileSiteURL = htmlspecialchars( self::$disableMobileSiteURL );
 11+$viewNormalSiteURL = htmlspecialchars( self::$viewNormalSiteURL );
1212
1313 if ( self::$disableImages == 0 ) {
1414 $imagesToggle = $disableImages;
15 - $imagesURL = self::$disableImagesURL;
 15+ $imagesURL = htmlspecialchars( self::$disableImagesURL );
1616 } else {
1717 $imagesToggle = $enableImages;
18 - $imagesURL = self::$enableImagesURL;
 18+ $imagesURL = htmlspecialchars( self::$enableImagesURL );
1919 }
2020
2121 $footerHtml = <<<EOD

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95549mft r95548preilly00:41, 26 August 2011
r95794use x-device headerpreilly17:20, 30 August 2011

Status & tagging log