Index: trunk/extensions/MobileFrontend/tests/MobileFrontendTest.php |
— | — | @@ -1,9 +1,9 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class ExtMobileFrontendTest extends MediaWikiTestCase { |
5 | | - |
| 5 | + |
6 | 6 | /** |
7 | | - * PHP 5.3.2 introduces the ReflectionMethod::setAccessible() method to allow the invocation of |
| 7 | + * PHP 5.3.2 introduces the ReflectionMethod::setAccessible() method to allow the invocation of |
8 | 8 | * protected and private methods directly through the Reflection API |
9 | 9 | */ |
10 | 10 | protected static function getMethod( $name ) { |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | $method->setAccessible( true ); |
14 | 14 | return $method; |
15 | 15 | } |
16 | | - |
| 16 | + |
17 | 17 | protected function setUp() { |
18 | 18 | parent::setUp(); |
19 | 19 | $this->wgExtMobileFrontend = new ExtMobileFrontend(); |
— | — | @@ -22,21 +22,21 @@ |
23 | 23 | unset( $this->wgExtMobileFrontend ); |
24 | 24 | parent::tearDown(); |
25 | 25 | } |
26 | | - |
| 26 | + |
27 | 27 | public function testGetBaseDomain() { |
28 | 28 | $getBaseDomain = self::getMethod( 'getBaseDomain' ); |
29 | 29 | $wgExtMobileFrontend = new ExtMobileFrontend(); |
30 | 30 | $_SERVER['HTTP_HOST'] = 'en.wikipedia.org'; |
31 | 31 | $this->assertEquals( '.wikipedia.org', $getBaseDomain->invokeArgs( $wgExtMobileFrontend, array() ) ); |
32 | 32 | } |
33 | | - |
| 33 | + |
34 | 34 | public function testGetRelativeURL() { |
35 | 35 | $getRelativeURL = self::getMethod( 'getRelativeURL' ); |
36 | 36 | $wgExtMobileFrontend = new ExtMobileFrontend(); |
37 | 37 | $url = 'http://en.wikipedia.org/wiki/Positional_astronomy'; |
38 | 38 | $this->assertEquals( '/wiki/Positional_astronomy', $getRelativeURL->invokeArgs( $wgExtMobileFrontend, array( $url ) ) ); |
39 | 39 | } |
40 | | - |
| 40 | + |
41 | 41 | public function testDisableCaching() { |
42 | 42 | global $wgRequest; |
43 | 43 | $disableCaching = self::getMethod( 'disableCaching' ); |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | $this->assertEquals( 'Sat, 26 Jul 1997 05:00:00 GMT', $wgRequest->response()->getheader( 'Expires' ) ); |
49 | 49 | $this->assertEquals( 'no-cache', $wgRequest->response()->getheader( 'Pragma' ) ); |
50 | 50 | } |
51 | | - |
| 51 | + |
52 | 52 | public function testSendXDeviceVaryHeader() { |
53 | 53 | global $wgRequest; |
54 | 54 | $sendXDeviceVaryHeader = self::getMethod( 'sendXDeviceVaryHeader' ); |
Index: trunk/extensions/MobileFrontend/MobileFrontend.i18n.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | |
13 | 13 | $messages = array(); |
14 | 14 | |
15 | | -//en translation |
| 15 | +// en translation |
16 | 16 | $messages['en'] = array ( |
17 | 17 | 'mobile-frontend-desc' => 'Mobile Frontend', |
18 | 18 | 'mobile-frontend-search-submit' => 'Go', |
Index: trunk/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -18,11 +18,11 @@ |
19 | 19 | // Define the extension; allows us make sure the extension is used correctly |
20 | 20 | define( 'MOBILEFRONTEND', 'MobileFrontend' ); |
21 | 21 | // WURFL installation dir |
22 | | -define( 'WURFL_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'library' . |
| 22 | +define( 'WURFL_DIR', dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'library' . |
23 | 23 | DIRECTORY_SEPARATOR . 'WURFL' . DIRECTORY_SEPARATOR ); |
24 | 24 | // WURFL configuration files directory |
25 | | -define( 'RESOURCES_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'library' . |
26 | | - DIRECTORY_SEPARATOR. 'resources' . DIRECTORY_SEPARATOR ); |
| 25 | +define( 'RESOURCES_DIR', dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'library' . |
| 26 | + DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR ); |
27 | 27 | |
28 | 28 | require_once( WURFL_DIR . 'Application.php' ); |
29 | 29 | |
— | — | @@ -36,9 +36,9 @@ |
37 | 37 | 'url' => 'http://www.mediawiki.org/wiki/Extension:MobileFrontend', |
38 | 38 | ); |
39 | 39 | |
40 | | -$cwd = dirname(__FILE__) . DIRECTORY_SEPARATOR; |
| 40 | +$cwd = dirname( __FILE__ ) . DIRECTORY_SEPARATOR; |
41 | 41 | $wgExtensionMessagesFiles['MobileFrontend'] = $cwd . 'MobileFrontend.i18n.php'; |
42 | | -//autoload extension classes |
| 42 | +// autoload extension classes |
43 | 43 | $wgAutoloadClasses['DeviceDetection'] = $cwd . 'DeviceDetection.php'; |
44 | 44 | $wgAutoloadClasses['CssDetection'] = $cwd . 'CssDetection.php'; |
45 | 45 | |
— | — | @@ -125,8 +125,8 @@ |
126 | 126 | public static $displayNoticeId; |
127 | 127 | public static $leaveFeedbackURL; |
128 | 128 | public static $mobileRedirectFormAction; |
129 | | - |
130 | | - public static $messageKeys = array( |
| 129 | + |
| 130 | + public static $messageKeys = array( |
131 | 131 | 'mobile-frontend-show-button', |
132 | 132 | 'mobile-frontend-hide-button', |
133 | 133 | 'mobile-frontend-back-to-top-of-section', |
— | — | @@ -198,7 +198,7 @@ |
199 | 199 | '#ogg_player_1', |
200 | 200 | '.nomobile', |
201 | 201 | ); |
202 | | - |
| 202 | + |
203 | 203 | public function testCanonicalRedirect( $request, $title, $output ) { |
204 | 204 | $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : ''; |
205 | 205 | if ( empty( $xDevice ) ) { |
— | — | @@ -214,14 +214,14 @@ |
215 | 215 | |
216 | 216 | $title = $obj->getTitle(); |
217 | 217 | $isSpecial = $title->isSpecialPage(); |
218 | | - |
| 218 | + |
219 | 219 | if ( ! $isSpecial ) { |
220 | 220 | $footerlinks = $tpl->data['footerlinks']; |
221 | 221 | $mobileViewUrl = $wgRequest->escapeAppendQuery( 'useformat=mobile' ); |
222 | 222 | |
223 | | - $tpl->set('mobileview', "<a href='{$mobileViewUrl}'>" . wfMsg( 'mobile-frontend-view' ) . "</a>"); |
| 223 | + $tpl->set( 'mobileview', "<a href='{$mobileViewUrl}'>" . wfMsg( 'mobile-frontend-view' ) . "</a>" ); |
224 | 224 | $footerlinks['places'][] = 'mobileview'; |
225 | | - $tpl->set('footerlinks', $footerlinks); |
| 225 | + $tpl->set( 'footerlinks', $footerlinks ); |
226 | 226 | } |
227 | 227 | wfProfileOut( __METHOD__ ); |
228 | 228 | return true; |
— | — | @@ -230,23 +230,23 @@ |
231 | 231 | public function getMsg() { |
232 | 232 | global $wgUser, $wgContLang, $wgRequest, $wgServer, $wgMobileRedirectFormAction, $wgMobileDomain; |
233 | 233 | wfProfileIn( __METHOD__ ); |
234 | | - |
| 234 | + |
235 | 235 | self::$disableImagesURL = $wgRequest->escapeAppendQuery( 'disableImages=1' ); |
236 | 236 | self::$enableImagesURL = $wgRequest->escapeAppendQuery( 'enableImages=1' ); |
237 | 237 | self::$disableMobileSiteURL = $wgRequest->escapeAppendQuery( 'mobileaction=disable_mobile_site' ); |
238 | 238 | self::$viewNormalSiteURL = $wgRequest->escapeAppendQuery( 'mobileaction=view_normal_site' ); |
239 | 239 | self::$currentURL = $wgRequest->getFullRequestURL(); |
240 | 240 | self::$leaveFeedbackURL = $wgRequest->escapeAppendQuery( 'mobileaction=leave_feedback' ); |
241 | | - |
| 241 | + |
242 | 242 | $skin = $wgUser->getSkin(); |
243 | 243 | $copyright = $skin->getCopyright(); |
244 | 244 | // Need to stash the results of the "wfMsg" call before the Output Buffering handler |
245 | 245 | // because at this point the database connection is shut down, etc. |
246 | | - |
| 246 | + |
247 | 247 | self::$messages['mobile-frontend-copyright'] = $copyright; |
248 | | - |
| 248 | + |
249 | 249 | foreach ( self::$messageKeys as $messageKey ) { |
250 | | - |
| 250 | + |
251 | 251 | if ( $messageKey == 'mobile-frontend-leave-feedback-notice' ) { |
252 | 252 | $linkText = wfMsg( 'mobile-frontend-leave-feedback-link-text' ); |
253 | 253 | $linkTarget = wfMsgNoTrans( 'mobile-frontend-feedback-page' ); |
— | — | @@ -260,7 +260,7 @@ |
261 | 261 | |
262 | 262 | self::$dir = $wgContLang->getDir(); |
263 | 263 | self::$code = $wgContLang->getCode(); |
264 | | - |
| 264 | + |
265 | 265 | $nonMobileServerBaseURL = str_replace( $wgMobileDomain, '.', $wgServer ); |
266 | 266 | self::$mobileRedirectFormAction = ( $wgMobileRedirectFormAction !== false ) ? $wgMobileRedirectFormAction : "{$nonMobileServerBaseURL}/w/mobileRedirect.php"; |
267 | 267 | |
— | — | @@ -279,15 +279,15 @@ |
280 | 280 | wfProfileIn( __METHOD__ ); |
281 | 281 | // The title |
282 | 282 | self::$title = $out->getTitle(); |
283 | | - |
| 283 | + |
284 | 284 | if ( Title::newMainPage()->equals( self::$title ) ) { |
285 | 285 | self::$isMainPage = true; |
286 | 286 | } |
287 | | - |
| 287 | + |
288 | 288 | self::$htmlTitle = $out->getHTMLTitle(); |
289 | 289 | |
290 | 290 | $userAgent = $_SERVER['HTTP_USER_AGENT']; |
291 | | - $uAmd5 = md5($userAgent); |
| 291 | + $uAmd5 = md5( $userAgent ); |
292 | 292 | |
293 | 293 | $key = wfMemcKey( 'mobile', 'ua', $uAmd5 ); |
294 | 294 | |
— | — | @@ -308,8 +308,8 @@ |
309 | 309 | $props = "generic"; |
310 | 310 | } |
311 | 311 | } |
312 | | - } catch (Exception $e) { |
313 | | - //echo $e->getMessage(); |
| 312 | + } catch ( Exception $e ) { |
| 313 | + // echo $e->getMessage(); |
314 | 314 | } |
315 | 315 | |
316 | 316 | // Note: The WebRequest Class calls are made in this block because |
— | — | @@ -331,7 +331,7 @@ |
332 | 332 | $location = $this->getRelativeURL( $location ); |
333 | 333 | $wgRequest->response()->header( 'Location: ' . $location . '&mfi=0' ); |
334 | 334 | } |
335 | | - |
| 335 | + |
336 | 336 | if ( self::$disableImages == 0 ) { |
337 | 337 | $disableImages = $wgRequest->getCookie( 'disableImages' ); |
338 | 338 | if ( $disableImages ) { |
— | — | @@ -356,18 +356,18 @@ |
357 | 357 | self::$search = $wgRequest->getText( 'search' ); |
358 | 358 | self::$callback = $wgRequest->getText( 'callback' ); |
359 | 359 | self::$searchField = $wgRequest->getText( 'search', '' ); |
360 | | - |
| 360 | + |
361 | 361 | $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : ''; |
362 | 362 | |
363 | 363 | $acceptHeader = $_SERVER["HTTP_ACCEPT"]; |
364 | 364 | $device = new DeviceDetection(); |
365 | | - |
| 365 | + |
366 | 366 | if ( !empty( $xDevice ) ) { |
367 | 367 | $formatName = $xDevice; |
368 | 368 | } else { |
369 | 369 | $formatName = $device->formatName( $userAgent, $acceptHeader ); |
370 | 370 | } |
371 | | - |
| 371 | + |
372 | 372 | self::$device = $device->format( $formatName ); |
373 | 373 | |
374 | 374 | if ( self::$device['view_format'] === 'wml' ) { |
— | — | @@ -379,7 +379,7 @@ |
380 | 380 | if ( self::$useFormat === 'mobile-wap' ) { |
381 | 381 | $this->contentFormat = 'WML'; |
382 | 382 | } |
383 | | - |
| 383 | + |
384 | 384 | if ( $mobileAction == 'leave_feedback' ) { |
385 | 385 | echo $this->renderLeaveFeedbackXHTML(); |
386 | 386 | wfProfileOut( __METHOD__ ); |
— | — | @@ -387,15 +387,15 @@ |
388 | 388 | } |
389 | 389 | |
390 | 390 | if ( $mobileAction == 'leave_feedback_post' ) { |
391 | | - |
| 391 | + |
392 | 392 | $this->getMsg(); |
393 | | - |
| 393 | + |
394 | 394 | $subject = $wgRequest->getText( 'subject', '' ); |
395 | 395 | $message = $wgRequest->getText( 'message', '' ); |
396 | 396 | $token = $wgRequest->getText( 'edittoken', '' ); |
397 | | - |
| 397 | + |
398 | 398 | $title = Title::newFromText( self::$messages['mobile-frontend-feedback-page'] ); |
399 | | - |
| 399 | + |
400 | 400 | if ( $title->userCan( 'edit' ) && |
401 | 401 | !$wgUser->isBlockedFrom( $title ) && |
402 | 402 | $wgUser->matchEditToken( $token ) ) { |
— | — | @@ -404,7 +404,7 @@ |
405 | 405 | $rawtext .= "\n== {$subject} == \n {$message} ~~~~ \n <small>User agent: {$userAgent}</small> "; |
406 | 406 | $article->doEdit( $rawtext, '' ); |
407 | 407 | } |
408 | | - |
| 408 | + |
409 | 409 | $location = str_replace( '&mobileaction=leave_feedback_post', '', $wgRequest->getFullRequestURL() . '¬iceid=1' ); |
410 | 410 | $location = $this->getRelativeURL( $location ); |
411 | 411 | $wgRequest->response()->header( 'Location: ' . $location ); |
— | — | @@ -449,8 +449,8 @@ |
450 | 450 | |
451 | 451 | // WURFL documentation: http://wurfl.sourceforge.net/help_doc.php |
452 | 452 | // Determine the kind of markup |
453 | | - if( is_array( $props ) && $props['preferred_markup'] ) { |
454 | | - //wfDebug( __METHOD__ . ": preferred markup for this device: " . $props['preferred_markup'] ); |
| 453 | + if ( is_array( $props ) && $props['preferred_markup'] ) { |
| 454 | + // wfDebug( __METHOD__ . ": preferred markup for this device: " . $props['preferred_markup'] ); |
455 | 455 | // xhtml/html: html_web_3_2, html_web_4_0 |
456 | 456 | // xthml basic/xhtmlmp (wap 2.0): html_wi_w3_xhtmlbasic html_wi_oma_xhtmlmp_1_0 |
457 | 457 | // chtml (imode): html_wi_imode_* |
— | — | @@ -470,10 +470,10 @@ |
471 | 471 | |
472 | 472 | // Determine |
473 | 473 | |
474 | | - if (self::$useFormat === 'mobile' || |
| 474 | + if ( self::$useFormat === 'mobile' || |
475 | 475 | self::$useFormat === 'mobile-wap' || |
476 | 476 | !empty( $xDevice ) ) { |
477 | | - if ( $action !== 'edit' && |
| 477 | + if ( $action !== 'edit' && |
478 | 478 | $mobileAction !== 'view_normal_site' ) { |
479 | 479 | $this->getMsg(); |
480 | 480 | $this->disableCaching(); |
— | — | @@ -498,11 +498,11 @@ |
499 | 499 | |
500 | 500 | private function getBaseDomain() { |
501 | 501 | wfProfileIn( __METHOD__ ); |
502 | | - //Validates value as IP address |
503 | | - if( !IP::isValid( $_SERVER['HTTP_HOST'] ) ) { |
| 502 | + // Validates value as IP address |
| 503 | + if ( !IP::isValid( $_SERVER['HTTP_HOST'] ) ) { |
504 | 504 | $domainParts = explode( '.', $_SERVER['HTTP_HOST'] ); |
505 | 505 | $domainParts = array_reverse( $domainParts ); |
506 | | - //Although some browsers will accept cookies without the initial ., » RFC 2109 requires it to be included. |
| 506 | + // Although some browsers will accept cookies without the initial ., » RFC 2109 requires it to be included. |
507 | 507 | wfProfileOut( __METHOD__ ); |
508 | 508 | return '.' . $domainParts[1] . '.' . $domainParts[0]; |
509 | 509 | } else { |
— | — | @@ -514,8 +514,8 @@ |
515 | 515 | private function getRelativeURL( $url ) { |
516 | 516 | wfProfileIn( __METHOD__ ); |
517 | 517 | $parsedUrl = parse_url( $url ); |
518 | | - //Validates value as IP address |
519 | | - if( !IP::isValid( $parsedUrl['host'] ) ) { |
| 518 | + // Validates value as IP address |
| 519 | + if ( !IP::isValid( $parsedUrl['host'] ) ) { |
520 | 520 | wfProfileOut( __METHOD__ ); |
521 | 521 | $baseUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host']; |
522 | 522 | $baseUrl = str_replace( $baseUrl, '', $url ); |
— | — | @@ -537,7 +537,7 @@ |
538 | 538 | } |
539 | 539 | wfProfileOut( __METHOD__ ); |
540 | 540 | } |
541 | | - |
| 541 | + |
542 | 542 | private function sendXDeviceVaryHeader() { |
543 | 543 | global $wgOut, $wgRequest; |
544 | 544 | wfProfileIn( __METHOD__ ); |
— | — | @@ -547,14 +547,14 @@ |
548 | 548 | } |
549 | 549 | wfProfileOut( __METHOD__ ); |
550 | 550 | } |
551 | | - |
| 551 | + |
552 | 552 | private function renderLeaveFeedbackXHTML() { |
553 | 553 | global $wgRequest, $wgUser; |
554 | 554 | wfProfileIn( __METHOD__ ); |
555 | 555 | if ( $this->contentFormat == 'XHTML' ) { |
556 | 556 | $this->getMsg(); |
557 | 557 | $editToken = $wgUser->editToken(); |
558 | | - |
| 558 | + |
559 | 559 | $htmlTitle = self::$messages['mobile-frontend-leave-feedback']; |
560 | 560 | $title = self::$messages['mobile-frontend-leave-feedback-title']; |
561 | 561 | $notice = self::$messages['mobile-frontend-leave-feedback-notice']; |
— | — | @@ -562,7 +562,7 @@ |
563 | 563 | $message = self::$messages['mobile-frontend-leave-feedback-message']; |
564 | 564 | $cancel = self::$messages['mobile-frontend-leave-feedback-cancel']; |
565 | 565 | $submit = self::$messages['mobile-frontend-leave-feedback-submit']; |
566 | | - |
| 566 | + |
567 | 567 | $feedbackPostURL = str_replace( '&mobileaction=leave_feedback', '', $wgRequest->getFullRequestURL() ) . '&mobileaction=leave_feedback_post'; |
568 | 568 | require( 'views/layout/_search_webkit.html.php' ); |
569 | 569 | require( 'views/layout/_footmenu_default.html.php' ); |
— | — | @@ -656,7 +656,7 @@ |
657 | 657 | private function headingTransformCallbackXHTML( $matches ) { |
658 | 658 | wfProfileIn( __METHOD__ ); |
659 | 659 | if ( isset( $matches[0] ) ) { |
660 | | - preg_match('/id="([^"]*)"/', $matches[0], $headlineMatches); |
| 660 | + preg_match( '/id="([^"]*)"/', $matches[0], $headlineMatches ); |
661 | 661 | } |
662 | 662 | |
663 | 663 | $headlineId = ( isset( $headlineMatches[1] ) ) ? $headlineMatches[1] : ''; |
— | — | @@ -667,35 +667,35 @@ |
668 | 668 | $backToTop = self::$messages['mobile-frontend-back-to-top-of-section']; |
669 | 669 | ++$headings; |
670 | 670 | // Back to top link |
671 | | - $base = Html::openElement( 'div', |
672 | | - array( 'id' => 'anchor_' . intval( $headings - 1 ), |
673 | | - 'class' => 'section_anchors', ) |
| 671 | + $base = Html::openElement( 'div', |
| 672 | + array( 'id' => 'anchor_' . intval( $headings - 1 ), |
| 673 | + 'class' => 'section_anchors', ) |
674 | 674 | ) . |
675 | 675 | Html::rawElement( 'a', |
676 | | - array( 'href' => '#section_' . intval( $headings - 1 ), |
677 | | - 'class' => 'back_to_top' ), |
678 | | - '↑' . $backToTop ) . |
| 676 | + array( 'href' => '#section_' . intval( $headings - 1 ), |
| 677 | + 'class' => 'back_to_top' ), |
| 678 | + '↑' . $backToTop ) . |
679 | 679 | Html::closeElement( 'div' ); |
680 | 680 | // generate the HTML we are going to inject |
681 | 681 | $buttons = Html::element( 'button', |
682 | | - array('class' => 'section_heading show', |
683 | | - 'section_id' => $headings ), |
| 682 | + array( 'class' => 'section_heading show', |
| 683 | + 'section_id' => $headings ), |
684 | 684 | $show ) . |
685 | | - Html::element( 'button', |
686 | | - array('class' => 'section_heading hide', |
| 685 | + Html::element( 'button', |
| 686 | + array( 'class' => 'section_heading hide', |
687 | 687 | 'section_id' => $headings ), |
688 | | - $hide ); |
| 688 | + $hide ); |
689 | 689 | $base .= Html::openElement( 'h2', |
690 | | - array('class' => 'section_heading', |
691 | | - 'id' => 'section_' . $headings) ) . |
| 690 | + array( 'class' => 'section_heading', |
| 691 | + 'id' => 'section_' . $headings ) ) . |
692 | 692 | $buttons . |
693 | 693 | Html::rawElement( 'span', |
694 | | - array( 'id' => $headlineId), |
| 694 | + array( 'id' => $headlineId ), |
695 | 695 | $matches[2] ) . |
696 | | - Html::closeElement( 'h2' ) . |
697 | | - Html::openElement( 'div', |
698 | | - array('class' => 'content_block', |
699 | | - 'id' => 'content_' . $headings) ); |
| 696 | + Html::closeElement( 'h2' ) . |
| 697 | + Html::openElement( 'div', |
| 698 | + array( 'class' => 'content_block', |
| 699 | + 'id' => 'content_' . $headings ) ); |
700 | 700 | |
701 | 701 | if ( $headings > 1 ) { |
702 | 702 | // Close it up here |
— | — | @@ -748,11 +748,11 @@ |
749 | 749 | |
750 | 750 | $card .= "<card id='s{$idx}' title='{$title}'><p>{$segments[$requestedSegment]}</p>"; |
751 | 751 | $idx = $requestedSegment + 1; |
752 | | - $segmentsCount = count($segments); |
| 752 | + $segmentsCount = count( $segments ); |
753 | 753 | $card .= "<p>" . $idx . "/" . $segmentsCount . "</p>"; |
754 | 754 | |
755 | 755 | $useFormatParam = ( isset( self::$useFormat ) ) ? '&' . 'useformat=' . self::$useFormat : ''; |
756 | | - |
| 756 | + |
757 | 757 | // Title::getLocalUrl doesn't work at this point since PHP 5.1.x, all objects have their destructors called |
758 | 758 | // before the output buffer callback function executes. |
759 | 759 | // Thus, globalized objects will not be available as expected in the function. |
— | — | @@ -760,13 +760,13 @@ |
761 | 761 | $mDefaultQuery = $_GET; |
762 | 762 | unset( $mDefaultQuery['seg'] ); |
763 | 763 | unset( $mDefaultQuery['useformat'] ); |
764 | | - |
| 764 | + |
765 | 765 | $qs = wfArrayToCGI( $mDefaultQuery ); |
766 | 766 | $delimiter = ( !empty( $qs ) ) ? '?' : ''; |
767 | 767 | $basePageParts = wfParseUrl( self::$currentURL ); |
768 | 768 | $basePage = $basePageParts['scheme'] . $basePageParts['delimiter'] . $basePageParts['host'] . $basePageParts['path'] . $delimiter . $qs; |
769 | 769 | $appendDelimiter = ( $delimiter === '?' ) ? '&' : '?'; |
770 | | - |
| 770 | + |
771 | 771 | if ( $idx < $segmentsCount ) { |
772 | 772 | $card .= "<p><a href=\"{$basePage}{$appendDelimiter}seg={$idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-continue'] . "</a></p>"; |
773 | 773 | } |
— | — | @@ -794,47 +794,47 @@ |
795 | 795 | CssDetection::detectIdCssOrTag( $itemToRemove, $type, $rawName ); |
796 | 796 | $itemToRemoveRecords[$type][] = $rawName; |
797 | 797 | } |
798 | | - |
| 798 | + |
799 | 799 | wfProfileOut( __METHOD__ ); |
800 | 800 | return $itemToRemoveRecords; |
801 | 801 | } |
802 | | - |
| 802 | + |
803 | 803 | public function DOMParseMainPage( $html ) { |
804 | 804 | wfProfileIn( __METHOD__ ); |
805 | | - $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8"); |
| 805 | + $html = mb_convert_encoding( $html, 'HTML-ENTITIES', "UTF-8" ); |
806 | 806 | libxml_use_internal_errors( true ); |
807 | 807 | $this->mainPage = new DOMDocument(); |
808 | | - //It seems that loadhtml() does not "attach" the html dtd that defines id as an id-attribute to the DOM. |
| 808 | + // It seems that loadhtml() does not "attach" the html dtd that defines id as an id-attribute to the DOM. |
809 | 809 | $this->mainPage->loadHTML( '<?xml encoding="UTF-8"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
810 | 810 | <html><head><title></title></head><body>' . $html . '</body></html>' ); |
811 | 811 | libxml_use_internal_errors( false ); |
812 | 812 | $this->mainPage->preserveWhiteSpace = false; |
813 | 813 | $this->mainPage->strictErrorChecking = false; |
814 | 814 | $this->mainPage->encoding = 'UTF-8'; |
815 | | - |
| 815 | + |
816 | 816 | $featuredArticle = $this->mainPage->getElementById( 'mp-tfa' ); |
817 | 817 | $newsItems = $this->mainPage->getElementById( 'mp-itn' ); |
818 | | - |
| 818 | + |
819 | 819 | $xpath = new DOMXpath( $this->mainPage ); |
820 | 820 | $elements = $xpath->query( '//*[starts-with(@id, "mf-")]' ); |
821 | | - |
822 | | - $commonAttributes = array('mp-tfa', 'mp-itn'); |
823 | 821 | |
| 822 | + $commonAttributes = array( 'mp-tfa', 'mp-itn' ); |
| 823 | + |
824 | 824 | $content = $this->mainPage->createElement( 'div' ); |
825 | 825 | $content->setAttribute( 'id', 'main_box' ); |
826 | | - |
| 826 | + |
827 | 827 | if ( $featuredArticle ) { |
828 | 828 | $h2FeaturedArticle = $this->mainPage->createElement( 'h2', self::$messages['mobile-frontend-featured-article'] ); |
829 | 829 | $content->appendChild( $h2FeaturedArticle ); |
830 | 830 | $content->appendChild( $featuredArticle ); |
831 | 831 | } |
832 | | - |
| 832 | + |
833 | 833 | if ( $newsItems ) { |
834 | 834 | $h2NewsItems = $this->mainPage->createElement( 'h2', self::$messages['mobile-frontend-news-items'] ); |
835 | 835 | $content->appendChild( $h2NewsItems ); |
836 | 836 | $content->appendChild( $newsItems ); |
837 | 837 | } |
838 | | - |
| 838 | + |
839 | 839 | foreach ( $elements as $element ) { |
840 | 840 | if ( $element->hasAttribute( 'id' ) ) { |
841 | 841 | $id = $element->getAttribute( 'id' ); |
— | — | @@ -849,16 +849,16 @@ |
850 | 850 | } |
851 | 851 | } |
852 | 852 | } |
853 | | - |
| 853 | + |
854 | 854 | $contentHtml = $this->mainPage->saveXML( $content, LIBXML_NOEMPTYTAG ); |
855 | 855 | wfProfileOut( __METHOD__ ); |
856 | 856 | return $contentHtml; |
857 | 857 | } |
858 | 858 | |
859 | | - public function DOMParse( $html ) { |
| 859 | + public function DOMParse( $html ) { |
860 | 860 | global $wgSitename; |
861 | 861 | wfProfileIn( __METHOD__ ); |
862 | | - $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8"); |
| 862 | + $html = mb_convert_encoding( $html, 'HTML-ENTITIES', "UTF-8" ); |
863 | 863 | libxml_use_internal_errors( true ); |
864 | 864 | $this->doc = new DOMDocument(); |
865 | 865 | $this->doc->loadHTML( '<?xml encoding="UTF-8">' . $html ); |
— | — | @@ -891,14 +891,14 @@ |
892 | 892 | foreach ( $itemToRemoveRecords['TAG'] as $tagToRemove ) { |
893 | 893 | $tagToRemoveNodes = $this->doc->getElementsByTagName( $tagToRemove ); |
894 | 894 | |
895 | | - foreach( $tagToRemoveNodes as $tagToRemoveNode ) { |
| 895 | + foreach ( $tagToRemoveNodes as $tagToRemoveNode ) { |
896 | 896 | if ( $tagToRemoveNode ) { |
897 | 897 | $domElemsToRemove[] = $tagToRemoveNode; |
898 | 898 | } |
899 | 899 | } |
900 | 900 | } |
901 | 901 | |
902 | | - foreach( $domElemsToRemove as $domElement ) { |
| 902 | + foreach ( $domElemsToRemove as $domElement ) { |
903 | 903 | $domElement->parentNode->removeChild( $domElement ); |
904 | 904 | } |
905 | 905 | |
— | — | @@ -915,7 +915,7 @@ |
916 | 916 | foreach ( $itemToRemoveRecords['CLASS'] as $classToRemove ) { |
917 | 917 | $elements = $xpath->query( '//*[@class="' . $classToRemove . '"]' ); |
918 | 918 | |
919 | | - foreach( $elements as $element ) { |
| 919 | + foreach ( $elements as $element ) { |
920 | 920 | $removedElement = $element->parentNode->removeChild( $element ); |
921 | 921 | } |
922 | 922 | } |
— | — | @@ -928,15 +928,15 @@ |
929 | 929 | '//' . $parts[0] . '[@class="' . $parts[1] . '"]' |
930 | 930 | ); |
931 | 931 | |
932 | | - foreach( $elements as $element ) { |
| 932 | + foreach ( $elements as $element ) { |
933 | 933 | $removedElement = $element->parentNode->removeChild( $element ); |
934 | 934 | } |
935 | 935 | } |
936 | 936 | |
937 | 937 | // Handle red links with action equal to edit |
938 | 938 | $redLinks = $xpath->query( '//a[@class="new"]' ); |
939 | | - foreach( $redLinks as $redLink ) { |
940 | | - //PHP Bug #36795 — Inappropriate "unterminated entity reference" |
| 939 | + foreach ( $redLinks as $redLink ) { |
| 940 | + // PHP Bug #36795 — Inappropriate "unterminated entity reference" |
941 | 941 | $spanNode = $this->doc->createElement( "span", str_replace( "&", "&", $redLink->nodeValue ) ); |
942 | 942 | |
943 | 943 | if ( $redLink->hasAttributes() ) { |
— | — | @@ -951,7 +951,7 @@ |
952 | 952 | $content = $this->doc->getElementById( 'content' ); |
953 | 953 | |
954 | 954 | $contentHtml = $this->doc->saveXML( $content, LIBXML_NOEMPTYTAG ); |
955 | | - |
| 955 | + |
956 | 956 | if ( self::$isMainPage ) { |
957 | 957 | $contentHtml = $this->DOMParseMainPage( $contentHtml ); |
958 | 958 | } |
— | — | @@ -966,7 +966,7 @@ |
967 | 967 | } elseif ( $this->contentFormat == 'WML' ) { |
968 | 968 | $homeButton = self::$messages['mobile-frontend-home-button']; |
969 | 969 | $randomButton = self::$messages['mobile-frontend-random-button']; |
970 | | - //header( 'Content-Type: text/vnd.wap.wml' ); |
| 970 | + // header( 'Content-Type: text/vnd.wap.wml' ); |
971 | 971 | |
972 | 972 | // TODO: Content transformations required |
973 | 973 | // WML Validator: |
— | — | @@ -988,12 +988,12 @@ |
989 | 989 | if ( $this->contentFormat == 'XHTML' && self::$format != 'json' ) { |
990 | 990 | if ( !empty( self::$displayNoticeId ) ) { |
991 | 991 | $noticePagePath = 'views/notices/notice_' . intval( self::$displayNoticeId ) . '.html.php'; |
992 | | - if ( file_exists( dirname(__FILE__) . '/' . $noticePagePath ) ) { |
| 992 | + if ( file_exists( dirname( __FILE__ ) . '/' . $noticePagePath ) ) { |
993 | 993 | require( $noticePagePath ); |
994 | 994 | } |
995 | 995 | } |
996 | | - |
997 | | - //header( 'Content-Type: application/xhtml+xml; charset=utf-8' ); |
| 996 | + |
| 997 | + // header( 'Content-Type: application/xhtml+xml; charset=utf-8' ); |
998 | 998 | require( 'views/layout/_search_webkit.html.php' ); |
999 | 999 | require( 'views/layout/_footmenu_default.html.php' ); |
1000 | 1000 | require( 'views/layout/application.html.php' ); |
— | — | @@ -1015,7 +1015,7 @@ |
1016 | 1016 | wfProfileOut( __METHOD__ ); |
1017 | 1017 | return $json; |
1018 | 1018 | } |
1019 | | - |
| 1019 | + |
1020 | 1020 | wfProfileOut( __METHOD__ ); |
1021 | 1021 | return $applicationHtml; |
1022 | 1022 | } |
Index: trunk/extensions/MobileFrontend/views/information/disable.html.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | $currentURL = self::$currentURL; |
5 | | -$currentURL = str_replace('&mobileaction=disable_mobile_site', '', $currentURL); |
| 5 | +$currentURL = str_replace( '&mobileaction=disable_mobile_site', '', $currentURL ); |
6 | 6 | $mobileRedirectFormAction = self::$mobileRedirectFormAction; |
7 | 7 | |
8 | 8 | $disableHtml = <<<EOT |
Index: trunk/extensions/MobileFrontend/views/layout/application.html.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | $dir = self::$dir; |
6 | 6 | $code = self::$code; |
7 | 7 | |
8 | | -if( $wgAppleTouchIcon !== false ) { |
| 8 | +if ( $wgAppleTouchIcon !== false ) { |
9 | 9 | $appleTouchIconTag = Html::element( 'link', array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) ); |
10 | 10 | } else { |
11 | 11 | $appleTouchIconTag = ""; |