r104524 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104523‎ | r104524 | r104525 >
Date:00:53, 29 November 2011
Author:preilly
Status:ok
Tags:
Comment:
small refactoring
Modified paths:
  • /trunk/extensions/MobileFrontend/MobileFrontend.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/MobileFrontend.php
@@ -87,7 +87,7 @@
8888 }
8989
9090 class ExtMobileFrontend {
91 - const VERSION = '0.5.80';
 91+ const VERSION = '0.5.81';
9292
9393 /**
9494 * @var DOMDocument
@@ -404,22 +404,7 @@
405405 public function beforePageDisplayHTML( &$out, &$text ) {
406406 global $wgContLang, $wgRequest, $wgMemc, $wgUser;
407407 wfProfileIn( __METHOD__ );
408 - // The title
409 - self::$title = $out->getTitle();
410408
411 - if ( Title::newMainPage()->equals( self::$title ) ) {
412 - self::$isMainPage = true;
413 - }
414 -
415 - if ( self::$title == 'Special:UserLogin' ) {
416 - self::$wsLoginToken = $wgRequest->getSessionData( 'wsLoginToken' );
417 - $returnToVal = $wgRequest->getVal( 'returnto' );
418 - $returnto = ( !empty ( $returnToVal ) ) ? '&returnto=' . wfUrlencode( $returnToVal ) : '';
419 - self::$wsLoginFormAction = self::$title->getLocalURL( 'action=submitlogin&type=login' . $returnto );
420 - }
421 -
422 - self::$htmlTitle = $out->getHTMLTitle();
423 -
424409 $userAgent = $_SERVER['HTTP_USER_AGENT'];
425410 $uAmd5 = md5( $userAgent );
426411
@@ -439,14 +424,30 @@
440425 $props = $device->getAllCapabilities();
441426 $wgMemc->set( $key, $props, 86400 );
442427 } else {
443 - $wgMemc->set( $key, "generic", 86400 );
444 - $props = "generic";
 428+ $wgMemc->set( $key, 'generic', 86400 );
 429+ $props = 'generic';
445430 }
446431 }
447432 } catch ( Exception $e ) {
448433 // echo $e->getMessage();
449434 }
 435+
 436+ // The title
 437+ self::$title = $out->getTitle();
450438
 439+ if ( Title::newMainPage()->equals( self::$title ) ) {
 440+ self::$isMainPage = true;
 441+ }
 442+
 443+ if ( self::$title == 'Special:UserLogin' ) {
 444+ self::$wsLoginToken = $wgRequest->getSessionData( 'wsLoginToken' );
 445+ $returnToVal = $wgRequest->getVal( 'returnto' );
 446+ $returnto = ( !empty ( $returnToVal ) ) ? '&returnto=' . wfUrlencode( $returnToVal ) : '';
 447+ self::$wsLoginFormAction = self::$title->getLocalURL( 'action=submitlogin&type=login' . $returnto );
 448+ }
 449+
 450+ self::$htmlTitle = $out->getHTMLTitle();
 451+
451452 // Note: The WebRequest Class calls are made in this block because
452453 // since PHP 5.1.x, all objects have their destructors called
453454 // before the output buffer callback function executes.
@@ -492,9 +493,9 @@
493494 self::$callback = $wgRequest->getText( 'callback' );
494495 self::$searchField = $wgRequest->getText( 'search', '' );
495496
496 - $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : '';
 497+ $xDevice = !empty( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : '';
497498
498 - $acceptHeader = isset( $_SERVER["HTTP_ACCEPT"] ) ? $_SERVER["HTTP_ACCEPT"] : '';
 499+ $acceptHeader = !empty( $_SERVER["HTTP_ACCEPT"] ) ? $_SERVER["HTTP_ACCEPT"] : '';
499500 $device = new DeviceDetection();
500501
501502 if ( !empty( $xDevice ) ) {
@@ -576,29 +577,6 @@
577578 $this->setOptInOutCookie( '' );
578579 }
579580
580 - // WURFL documentation: http://wurfl.sourceforge.net/help_doc.php
581 - // Determine the kind of markup
582 - //if ( is_array( $props ) && isset( $props['preferred_markup'] ) && $props['preferred_markup'] ) {
583 - // wfDebug( __METHOD__ . ": preferred markup for this device: " . $props['preferred_markup'] );
584 - // xhtml/html: html_web_3_2, html_web_4_0
585 - // xthml basic/xhtmlmp (wap 2.0): html_wi_w3_xhtmlbasic html_wi_oma_xhtmlmp_1_0
586 - // chtml (imode): html_wi_imode_*
587 - // wml (wap 1): wml_1_1, wml_1_2, wml_1_3
588 - //}
589 - // WML options that might influence our 'style' of output
590 - // $props['access_key_support'] (for creating easy keypad navigation)
591 - // $props['softkey_support'] ( for creating your own menu)
592 -
593 - // WAP2/XHTML MP
594 - // xhtmlmp_preferred_mime_type ( the mime type with which you should serve your xhtml to this device
595 -
596 - // HTML
597 - // $props['pointing_method'] == touchscreen
598 - // ajax_support_javascript
599 - // html_preferred_dtd
600 -
601 - // Determine
602 -
603581 if ( self::$useFormat === 'mobile' ||
604582 self::$useFormat === 'mobile-wap' ||
605583 !empty( $xDevice ) ) {

Status & tagging log