r114938 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114937‎ | r114938 | r114939 >
Date:17:58, 17 April 2012
Author:awjrichards
Status:deferred
Tags:
Comment:
MFG Change-Id: I242facaa01b0aa9970c2ece01fbd775ed39a88b4
Modified paths:
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/skins/SkinMobile.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/skins/SkinMobile.php
@@ -7,6 +7,7 @@
88 public $extMobileFrontend;
99
1010 public function __construct( ExtMobileFrontend &$extMobileFrontend ) {
 11+ $this->setContext( $extMobileFrontend );
1112 $this->extMobileFrontend = $extMobileFrontend;
1213 }
1314
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
@@ -1,14 +1,9 @@
22 <?php
33
4 -class ExtMobileFrontend {
 4+class ExtMobileFrontend extends ContextSource {
55
66 public $contentFormat = '';
77
8 - /**
9 - * @var Title
10 - */
11 - public static $title;
12 - public static $htmlTitle;
138 public static $randomPageUrl;
149 public static $format;
1510 public static $search;
@@ -53,12 +48,24 @@
5449 private $contentTransformations = true;
5550 private $device;
5651
57 - public function __construct() {
 52+ public function __construct( IContextSource $context ) {
5853 global $wgMFConfigProperties;
 54+ $this->setContext( $context );
5955 $this->wmlContext = new WmlContext();
6056 $this->setPropertiesFromArray( $wgMFConfigProperties );
6157 }
6258
 59+ public function attachHooks() {
 60+ global $wgHooks;
 61+ $wgHooks['RequestContextCreateSkin'][] = array( &$this, 'requestContextCreateSkin' );
 62+ $wgHooks['BeforePageRedirect'][] = array( &$this, 'beforePageRedirect' );
 63+ $wgHooks['SkinTemplateOutputPageBeforeExec'][] = array( &$this, 'addMobileFooter' );
 64+ $wgHooks['TestCanonicalRedirect'][] = array( &$this, 'testCanonicalRedirect' );
 65+ $wgHooks['ResourceLoaderTestModules'][] = array( &$this, 'addTestModules' );
 66+ $wgHooks['GetCacheVaryCookies'][] = array( &$this, 'getCacheVaryCookies' );
 67+ $wgHooks['ResourceLoaderRegisterModules'][] = array( &$this, 'resourceLoaderRegisterModules' );
 68+ }
 69+
6370 public function requestContextCreateSkin( $context, &$skin ) {
6471 // check whether or not the user has requested to toggle their view
6572 $mobileAction = $this->getMobileAction();
@@ -193,7 +200,7 @@
194201 * @return bool
195202 */
196203 public function addMobileFooter( &$obj, &$tpl ) {
197 - global $wgRequest, $wgServer;
 204+ global $wgServer;
198205 wfProfileIn( __METHOD__ );
199206
200207 $title = $obj->getTitle();
@@ -201,7 +208,7 @@
202209
203210 if ( ! $isSpecial ) {
204211 $footerlinks = $tpl->data['footerlinks'];
205 - $mobileViewUrl = $wgRequest->escapeAppendQuery( 'mobileaction=toggle_view_mobile' );
 212+ $mobileViewUrl = $this->getRequest()->escapeAppendQuery( 'mobileaction=toggle_view_mobile' );
206213
207214 $mobileViewUrl = $this->getMobileUrl( $wgServer . $mobileViewUrl );
208215 $tpl->set( 'mobileview', "<a href='{$mobileViewUrl}' class='noprint'>" . wfMsg( 'mobile-frontend-view' ) . "</a>" );
@@ -226,10 +233,12 @@
227234 }
228235
229236 public function getMsg() {
230 - global $wgRequest, $wgServer, $wgMobileRedirectFormAction;
 237+ global $wgServer, $wgMobileRedirectFormAction;
231238 wfProfileIn( __METHOD__ );
232239
233 - self::$viewNormalSiteURL = $this->getDesktopUrl( wfExpandUrl( $wgRequest->escapeAppendQuery( 'mobileaction=toggle_view_desktop' ) ) );
 240+ self::$viewNormalSiteURL = $this->getDesktopUrl( wfExpandUrl(
 241+ $this->getRequest()->escapeAppendQuery( 'mobileaction=toggle_view_desktop' ) )
 242+ );
234243
235244 self::$mobileRedirectFormAction = ( $wgMobileRedirectFormAction !== false )
236245 ? $wgMobileRedirectFormAction
@@ -272,19 +281,15 @@
273282
274283 /**
275284 * @param $out OutputPage
276 - * @param $text String
277285 * @return bool
278286 */
279 - public function beforePageDisplayHTML( &$out ) {
280 - global $wgRequest;
 287+ public function beforePageDisplayHTML( $out ) {
281288 wfProfileIn( __METHOD__ );
282289
283 - // Note: The WebRequest Class calls are made in this block because
284 - // since PHP 5.1.x, all objects have their destructors called
285 - // before the output buffer callback function executes.
286 - // Thus, globalized objects will not be available as expected in the function.
287 - // This is stated to be intended behavior, as per the following: [http://bugs.php.net/bug.php?id=40104]
 290+ if ( wfRunHooks( 'BeforePageDisplayMobile', array( &$out ) ) ) {
 291+ }
288292
 293+ $request = $this->getRequest();
289294 $xDevice = $this->getXDevice();
290295 $this->setWmlContextFormat();
291296 $mobileAction = $this->getMobileAction();
@@ -295,7 +300,7 @@
296301 );
297302 if ( isset( $bcRedirects[$mobileAction] ) ) {
298303 $location = SpecialMobileOptions::getUrl( $bcRedirects[$mobileAction], null, true );
299 - $wgRequest->response()->header( 'Location: ' . wfExpandUrl( $location ) );
 304+ $request->response()->header( 'Location: ' . wfExpandUrl( $location ) );
300305 exit;
301306 }
302307
@@ -305,16 +310,14 @@
306311
307312 $userAgent = $_SERVER['HTTP_USER_AGENT'];
308313 $acceptHeader = isset( $_SERVER["HTTP_ACCEPT"] ) ? $_SERVER["HTTP_ACCEPT"] : '';
309 - self::$title = $out->getTitle();
310314
311 - self::$htmlTitle = $out->getHTMLTitle();
312 - $this->disableImages = $wgRequest->getCookie( 'disableImages' );
313 - self::$displayNoticeId = $wgRequest->getText( 'noticeid', '' );
 315+ $this->disableImages = $request->getCookie( 'disableImages' );
 316+ self::$displayNoticeId = $request->getText( 'noticeid', '' );
314317
315 - self::$format = $wgRequest->getText( 'format' );
316 - $this->wmlContext->setRequestedSegment( $wgRequest->getInt( 'seg', 0 ) );
317 - self::$search = $wgRequest->getText( 'search' );
318 - self::$searchField = $wgRequest->getText( 'search', '' );
 318+ self::$format = $request->getText( 'format' );
 319+ $this->wmlContext->setRequestedSegment( $request->getInt( 'seg', 0 ) );
 320+ self::$search = $request->getText( 'search' );
 321+ self::$searchField = $request->getText( 'search', '' );
319322
320323 $detector = new DeviceDetection();
321324
@@ -338,16 +341,16 @@
339342 $this->sendApplicationVersionVaryHeader();
340343 $this->checkUserLoggedIn();
341344
342 - if ( self::$title->isSpecial( 'Userlogin' ) ) {
343 - self::$wsLoginToken = $wgRequest->getSessionData( 'wsLoginToken' );
 345+ if ( $this->getTitle()->isSpecial( 'Userlogin' ) ) {
 346+ self::$wsLoginToken = $request->getSessionData( 'wsLoginToken' );
344347 $q = array( 'action' => 'submitlogin', 'type' => 'login' );
345 - $returnToVal = $wgRequest->getVal( 'returnto' );
 348+ $returnToVal = $request->getVal( 'returnto' );
346349
347350 if ( $returnToVal ) {
348351 $q['returnto'] = $returnToVal;
349352 }
350353
351 - self::$wsLoginFormAction = self::$title->getLocalURL( $q );
 354+ self::$wsLoginFormAction = $this->getTitle()->getLocalURL( $q );
352355 }
353356
354357 wfProfileOut( __METHOD__ );
@@ -377,19 +380,20 @@
378381 * @return bool
379382 */
380383 private function checkUserLoggedIn() {
381 - global $wgUser, $wgCookieDomain, $wgRequest, $wgCookiePrefix;
 384+ global $wgCookieDomain, $wgCookiePrefix;
382385 wfProfileIn( __METHOD__ );
383386 $tempWgCookieDomain = $wgCookieDomain;
384387 $wgCookieDomain = $this->getBaseDomain();
385388 $tempWgCookiePrefix = $wgCookiePrefix;
386389 $wgCookiePrefix = '';
387390
388 - if ( $wgUser->isLoggedIn() ) {
389 - $wgRequest->response()->setcookie( 'mfsecure', '1', 0, '' );
 391+ $request = $this->getRequest();
 392+ if ( $this->getUser()->isLoggedIn() ) {
 393+ $request->response()->setcookie( 'mfsecure', '1', 0, '' );
390394 } else {
391 - $mfSecure = $wgRequest->getCookie( 'mfsecure', '' );
 395+ $mfSecure = $request->getCookie( 'mfsecure', '' );
392396 if ( $mfSecure && $mfSecure == '1' ) {
393 - $wgRequest->response()->setcookie( 'mfsecure', '', 0, '' );
 397+ $request->response()->setcookie( 'mfsecure', '', 0, '' );
394398 }
395399 }
396400
@@ -400,16 +404,15 @@
401405 }
402406
403407 private function checkUserStatus() {
404 - global $wgRequest;
405408 wfProfileIn( __METHOD__ );
406409
407 - $hideSearchBox = $wgRequest->getInt( 'hidesearchbox' );
 410+ $hideSearchBox = $this->getRequest()->getInt( 'hidesearchbox' );
408411
409412 if ( $hideSearchBox === 1 ) {
410413 self::$hideSearchBox = true;
411414 }
412415
413 - $hideLogo = $wgRequest->getInt( 'hidelogo' );
 416+ $hideLogo = $this->getRequest()->getInt( 'hidelogo' );
414417
415418 if ( $hideLogo === 1 ) {
416419 self::$hideLogo = true;
@@ -441,7 +444,7 @@
442445 * @return bool
443446 */
444447 public function setOptInOutCookie( $value ) {
445 - global $wgCookieDomain, $wgRequest, $wgCookiePrefix;
 448+ global $wgCookieDomain, $wgCookiePrefix;
446449 wfProfileIn( __METHOD__ );
447450 if ( $value ) {
448451 wfIncrStats( 'mobile.opt_in_cookie_set' );
@@ -450,7 +453,7 @@
451454 $wgCookieDomain = $this->getBaseDomain();
452455 $tempWgCookiePrefix = $wgCookiePrefix;
453456 $wgCookiePrefix = '';
454 - $wgRequest->response()->setcookie( 'optin', $value, 0, '' );
 457+ $this->getRequest()->response()->setcookie( 'optin', $value, 0, '' );
455458 $wgCookieDomain = $tempWgCookieDomain;
456459 $wgCookiePrefix = $tempWgCookiePrefix;
457460 wfProfileOut( __METHOD__ );
@@ -458,20 +461,21 @@
459462 }
460463
461464 private function getLanguageUrls() {
462 - global $wgRequest, $wgContLang, $wgLanguageCode, $wgOut;
 465+ global $wgContLang, $wgLanguageCode;
463466
464467 wfProfileIn( __METHOD__ );
465468 $languageUrls = array();
466469
 470+ $out = $this->getOutput();
467471 $languageUrls[] = array(
468 - 'href' => $wgRequest->getFullRequestURL(),
469 - 'text' => self::$htmlTitle,
 472+ 'href' => $this->getRequest()->getFullRequestURL(),
 473+ 'text' => $out->getHTMLTitle(),
470474 'language' => $wgContLang->getLanguageName( $wgLanguageCode ),
471475 'class' => 'interwiki-' . $wgLanguageCode,
472476 'lang' => $wgLanguageCode,
473477 );
474478
475 - foreach ( $wgOut->getLanguageLinks() as $l ) {
 479+ foreach ( $out->getLanguageLinks() as $l ) {
476480 $tmp = explode( ':', $l, 2 );
477481 $class = 'interwiki-' . $tmp[0];
478482 $lang = $tmp[0];
@@ -499,9 +503,8 @@
500504 * @return Mixed
501505 */
502506 private function getOptInOutCookie() {
503 - global $wgRequest;
504507 wfProfileIn( __METHOD__ );
505 - $optInCookie = $wgRequest->getCookie( 'optin', '' );
 508+ $optInCookie = $this->getRequest()->getCookie( 'optin', '' );
506509 wfProfileOut( __METHOD__ );
507510 return $optInCookie;
508511 }
@@ -528,7 +531,6 @@
529532 * @return bool
530533 */
531534 private function disableCaching() {
532 - global $wgRequest;
533535 wfProfileIn( __METHOD__ );
534536
535537 // Fetch the REMOTE_ADDR and check if it's a trusted proxy.
@@ -550,10 +552,11 @@
551553 * care about.
552554 */
553555 $trustedProxyCheckFunction = ( function_exists( 'wfIsConfiguredProxy' ) ) ? 'wfIsConfiguredProxy' : 'wfIsTrustedProxy';
 556+ $request = $this->getRequest();
554557 if ( $trustedProxyCheckFunction( $ip ) ) {
555 - $wgRequest->response()->header( 'Cache-Control: no-cache, must-revalidate' );
556 - $wgRequest->response()->header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
557 - $wgRequest->response()->header( 'Pragma: no-cache' );
 558+ $request->response()->header( 'Cache-Control: no-cache, must-revalidate' );
 559+ $request->response()->header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
 560+ $request->response()->header( 'Pragma: no-cache' );
558561 }
559562
560563 wfProfileOut( __METHOD__ );
@@ -561,30 +564,29 @@
562565 }
563566
564567 private function sendXDeviceVaryHeader() {
565 - global $wgOut, $wgRequest;
566568 wfProfileIn( __METHOD__ );
 569+ $out = $this->getOutput();
567570 if ( isset( $_SERVER['HTTP_X_DEVICE'] ) ) {
568 - $wgRequest->response()->header( 'X-Device: ' . $_SERVER['HTTP_X_DEVICE'] );
569 - $wgOut->addVaryHeader( 'X-Device' );
 571+ $this->getRequest()->response()->header( 'X-Device: ' . $_SERVER['HTTP_X_DEVICE'] );
 572+ $out->addVaryHeader( 'X-Device' );
570573 }
571 - $wgOut->addVaryHeader( 'Cookie' );
572 - $wgOut->addVaryHeader( 'X-Carrier' );
573 - $wgOut->addVaryHeader( 'X-Images' );
 574+ $out->addVaryHeader( 'Cookie' );
 575+ $out->addVaryHeader( 'X-Carrier' );
 576+ $out->addVaryHeader( 'X-Images' );
574577 wfProfileOut( __METHOD__ );
575578 return true;
576579 }
577580
578581 private function sendApplicationVersionVaryHeader() {
579 - global $wgOut, $wgRequest;
580582 wfProfileIn( __METHOD__ );
581 - $wgOut->addVaryHeader( 'Application_Version' );
 583+ $this->getOutput()->addVaryHeader( 'Application_Version' );
582584 if ( isset( $_SERVER['HTTP_APPLICATION_VERSION'] ) ) {
583 - $wgRequest->response()->header( 'Application_Version: ' . $_SERVER['HTTP_APPLICATION_VERSION'] );
 585+ $this->getRequest()->response()->header( 'Application_Version: ' . $_SERVER['HTTP_APPLICATION_VERSION'] );
584586 } else {
585587 if ( isset( $_SERVER['HTTP_X_DEVICE'] ) ) {
586588 if ( stripos( $_SERVER['HTTP_X_DEVICE'], 'iphone' ) !== false ||
587589 stripos( $_SERVER['HTTP_X_DEVICE'], 'android' ) !== false ) {
588 - $wgRequest->response()->header( 'Application_Version: ' . $_SERVER['HTTP_X_DEVICE'] );
 590+ $this->getRequest()->response()->header( 'Application_Version: ' . $_SERVER['HTTP_X_DEVICE'] );
589591 }
590592 }
591593 }
@@ -703,19 +705,17 @@
704706 }
705707
706708 private function getLoginLinks() {
707 - global $wgRequest, $wgUser;
708 -
709709 wfProfileIn( __METHOD__ );
710710 $login = $logout = '';
711 - $query = array( 'returnto' => self::$title->getPrefixedText() );
712 - if ( !$wgRequest->wasPosted() ) {
713 - $returntoquery = $wgRequest->getValues();
 711+ $query = array( 'returnto' => $this->getTitle()->getPrefixedText() );
 712+ if ( !$this->getRequest()->wasPosted() ) {
 713+ $returntoquery = $this->getRequest()->getValues();
714714 unset( $returntoquery['title'] );
715715 unset( $returntoquery['returnto'] );
716716 unset( $returntoquery['returntoquery'] );
717717 $query['returntoquery'] = wfArrayToCGI( $returntoquery );
718718 }
719 - if ( $wgUser->isLoggedIn() ) {
 719+ if ( $this->getUser()->isLoggedIn() ) {
720720 $login = Linker::link( SpecialPage::getTitleFor( 'UserLogin' ),
721721 wfMessage( 'mobile-frontend-login' )->escaped(),
722722 array(),
@@ -737,13 +737,13 @@
738738 * @return string
739739 */
740740 public function DOMParse( OutputPage $out ) {
741 - global $wgScript, $wgContLang, $wgRequest;
 741+ global $wgScript, $wgContLang;
742742 wfProfileIn( __METHOD__ );
743743
744744 $html = $out->getHTML();
745745
746746 wfProfileIn( __METHOD__ . '-formatter-init' );
747 - $formatter = new MobileFormatter( MobileFormatter::wrapHTML( $html ), self::$title, $this->contentFormat, $this->wmlContext );
 747+ $formatter = new MobileFormatter( MobileFormatter::wrapHTML( $html ), $this->getTitle(), $this->contentFormat, $this->wmlContext );
748748 $doc = $formatter->getDoc();
749749 wfProfileOut( __METHOD__ . '-formatter-init' );
750750
@@ -760,7 +760,7 @@
761761 wfProfileOut( __METHOD__ . '-zero' );
762762
763763 wfProfileIn( __METHOD__ . '-beta' );
764 - if ( self::$title->isSpecial( 'Userlogin' ) ) {
 764+ if ( $this->getTitle()->isSpecial( 'Userlogin' ) ) {
765765 $userlogin = $doc->getElementById( 'userloginForm' );
766766
767767 if ( $userlogin && get_class( $userlogin ) === 'DOMElement' ) {
@@ -781,7 +781,7 @@
782782 }
783783
784784 wfProfileIn( __METHOD__ . '-userlogin' );
785 - if ( self::$title->isSpecial( 'Userlogin' ) ) {
 785+ if ( $this->getTitle()->isSpecial( 'Userlogin' ) ) {
786786 if ( $userlogin && get_class( $userlogin ) === 'DOMElement' ) {
787787 $login = $this->renderLogin();
788788 $loginNode = $doc->importNode( $login, true );
@@ -791,7 +791,7 @@
792792 wfProfileOut( __METHOD__ . '-userlogin' );
793793
794794 wfProfileIn( __METHOD__ . '-getText' );
795 - $formatter->setIsMainPage( self::$title->isMainPage() );
 795+ $formatter->setIsMainPage( $this->getTitle()->isMainPage() );
796796 if ( $this->contentFormat == 'XHTML'
797797 && $this->device['supports_javascript'] === true
798798 && empty( self::$search ) )
@@ -802,7 +802,6 @@
803803 wfProfileOut( __METHOD__ . '-getText' );
804804
805805 wfProfileIn( __METHOD__ . '-templates' );
806 - $htmlTitle = htmlspecialchars( self::$htmlTitle );
807806 if ( $this->contentFormat == 'WML' ) {
808807 header( 'Content-Type: text/vnd.wap.wml' );
809808
@@ -843,7 +842,7 @@
844843 $applicationTemplate = $this->getApplicationTemplate();
845844 $options = array(
846845 'noticeHtml' => $noticeHtml,
847 - 'htmlTitle' => $htmlTitle,
 846+ 'htmlTitle' => $out->getHTMLTitle(),
848847 'searchWebkitHtml' => $searchWebkitHtml,
849848 'contentHtml' => $contentHtml,
850849 'footerHtml' => $footerHtml,
@@ -859,12 +858,12 @@
860859 header( 'Content-Type: application/javascript' );
861860 header( 'Content-Disposition: attachment; filename="data.js";' );
862861 $json_data = array();
863 - $json_data['title'] = htmlspecialchars ( self::$title->getText() );
 862+ $json_data['title'] = htmlspecialchars ( $this->getTitle()->getText() );
864863 $json_data['html'] = $contentHtml;
865864
866865 $json = FormatJson::encode( $json_data );
867866
868 - $callback = $wgRequest->getText( 'callback' );
 867+ $callback = $this->getRequest()->getText( 'callback' );
869868 if ( !empty( $callback ) ) {
870869 $json = urlencode( htmlspecialchars( $callback ) ) . '(' . $json . ')';
871870 }
@@ -889,11 +888,11 @@
890889 $footerTemplate = new FooterTemplate();
891890 $options = array(
892891 'leaveFeedbackURL' => SpecialPage::getTitleFor( 'MobileFeedback' )
893 - ->getLocalURL( array( 'returnto' => self::$title->getPrefixedText() ) ),
 892+ ->getLocalURL( array( 'returnto' => $this->getTitle()->getPrefixedText() ) ),
894893 'viewNormalSiteURL' => self::$viewNormalSiteURL,
895894 'disableImages' => $this->disableImages,
896 - 'disableImagesURL' => SpecialMobileOptions::getURL( 'DisableImages', self::$title ),
897 - 'enableImagesURL' => SpecialMobileOptions::getURL( 'EnableImages', self::$title ),
 895+ 'disableImagesURL' => SpecialMobileOptions::getURL( 'DisableImages', $this->getTitle() ),
 896+ 'enableImagesURL' => SpecialMobileOptions::getURL( 'EnableImages', $this->getTitle() ),
898897 'logoutHtml' => $logoutHtml,
899898 'loginHtml' => $loginHtml,
900899 'code' => $wgContLang->getCode(),
@@ -931,25 +930,26 @@
932931 }
933932
934933 public function getApplicationTemplate() {
935 - global $wgAppleTouchIcon, $wgExtensionAssetsPath, $wgScriptPath, $wgCookiePath, $wgOut, $wgContLang;
 934+ global $wgAppleTouchIcon, $wgExtensionAssetsPath, $wgScriptPath, $wgCookiePath, $wgContLang;
936935 wfProfileIn( __METHOD__ );
 936+ $out = $this->getOutput();
937937 if ( self::$isBetaGroupMember ) {
938 - $wgOut->addModuleStyles( 'ext.mobileFrontendBeta' );
 938+ $out->addModuleStyles( 'ext.mobileFrontendBeta' );
939939 } else {
940 - $wgOut->addModuleStyles( 'ext.mobileFrontend' );
 940+ $out->addModuleStyles( 'ext.mobileFrontend' );
941941 }
942 - $wgOut->addModuleStyles( "ext.mobileFrontend.{$this->device['css_file_name']}" );
943 - $isFilePage = self::$title->getNamespace() == NS_FILE;
 942+ $out->addModuleStyles( "ext.mobileFrontend.{$this->device['css_file_name']}" );
 943+ $isFilePage = $this->getTitle()->getNamespace() == NS_FILE;
944944 if ( $isFilePage ) {
945 - $wgOut->addModuleStyles( 'ext.mobileFrontend.filePage' );
 945+ $out->addModuleStyles( 'ext.mobileFrontend.filePage' );
946946 }
947 - $cssLinks = $wgOut->buildCssLinks();
 947+ $cssLinks = $out->buildCssLinks();
948948 $applicationTemplate = new ApplicationTemplate();
949949 $options = array(
950950 'dir' => $wgContLang->getDir(),
951951 'code' => $wgContLang->getCode(),
952 - 'title' => self::$title,
953 - 'pageTitle' => $wgOut->getPageTitle(),
 952+ 'title' => $this->getTitle(),
 953+ 'pageTitle' => $out->getPageTitle(),
954954 'placeholder' => wfMsg( 'mobile-frontend-placeholder' ),
955955 'dismissNotification' => wfMsg( 'mobile-frontend-dismiss-notification' ),
956956 'wgAppleTouchIcon' => $wgAppleTouchIcon,
@@ -1310,27 +1310,24 @@
13111311 }
13121312
13131313 public function getMobileAction() {
1314 - global $wgRequest;
13151314 if ( is_null( $this->mobileAction ) ) {
1316 - $this->mobileAction = $wgRequest->getText( 'mobileaction' );
 1315+ $this->mobileAction = $this->getRequest()->getText( 'mobileaction' );
13171316 }
13181317
13191318 return $this->mobileAction;
13201319 }
13211320
13221321 public function getAction() {
1323 - global $wgRequest;
13241322 if ( is_null( $this->action ) ) {
1325 - $this->action = $wgRequest->getText( 'action' );
 1323+ $this->action = $this->getRequest()->getText( 'action' );
13261324 }
13271325
13281326 return $this->action;
13291327 }
13301328
13311329 public function getUseFormat() {
1332 - global $wgRequest;
13331330 if ( !isset( $this->useFormat ) ) {
1334 - $useFormat = $wgRequest->getText( 'useformat' );
 1331+ $useFormat = $this->getRequest()->getText( 'useformat' );
13351332 $this->setUseFormat( $useFormat );
13361333 }
13371334 return $this->useFormat;
@@ -1358,10 +1355,8 @@
13591356 }
13601357
13611358 public function getStopMobileRedirectCookie() {
1362 - global $wgRequest;
 1359+ $stopMobileRedirectCookie = $this->getRequest()->getCookie( 'stopMobileRedirect', '' );
13631360
1364 - $stopMobileRedirectCookie = $wgRequest->getCookie( 'stopMobileRedirect', '' );
1365 -
13661361 return $stopMobileRedirectCookie;
13671362 }
13681363
@@ -1374,10 +1369,8 @@
13751370 * @return string|null
13761371 */
13771372 public function getUseFormatCookie() {
1378 - global $wgRequest;
 1373+ $useFormatFromCookie = $this->getRequest()->getCookie( $this->getUseFormatCookieName(), '' );
13791374
1380 - $useFormatFromCookie = $wgRequest->getCookie( $this->getUseFormatCookieName(), '' );
1381 -
13821375 return $useFormatFromCookie;
13831376 }
13841377
@@ -1441,9 +1434,9 @@
14421435 * @return bool
14431436 */
14441437 protected function shouldSetUseFormatCookie() {
1445 - global $wgRequest, $wgScriptPath;
 1438+ global $wgScriptPath;
14461439
1447 - $reqUrl = $wgRequest->getRequestUrl();
 1440+ $reqUrl = $this->getRequest()->getRequestUrl();
14481441 $urlsToIgnore = array( '/?useformat=mobile', $wgScriptPath . '/?useformat=mobile' );
14491442 if ( in_array( $reqUrl, $urlsToIgnore ) ) {
14501443 return false;
@@ -1501,7 +1494,7 @@
15021495 * and set a cookie to keep them on that view for subsequent requests.
15031496 */
15041497 public function toggleView( $view, $temporary = false ) {
1505 - global $wgMobileUrlTemplate, $wgOut, $wgRequest;
 1498+ global $wgMobileUrlTemplate;
15061499
15071500 if ( $view == 'mobile' ) {
15081501 // unset stopMobileRedirect cookie
@@ -1513,10 +1506,10 @@
15141507 $this->setUseFormat( $view );
15151508 } else {
15161509 // else redirect to mobile domain
1517 - $currentUrl = wfExpandUrl( $wgRequest->getRequestURL() );
 1510+ $currentUrl = wfExpandUrl( $this->getRequest()->getRequestURL() );
15181511 $currentUrl = $this->removeQueryStringParameter( $currentUrl, 'mobileaction' );
15191512 $mobileUrl = $this->getMobileUrl( $currentUrl );
1520 - $wgOut->redirect( $mobileUrl, 301 );
 1513+ $this->getOutput()->redirect( $mobileUrl, 301 );
15211514 }
15221515 } elseif ( $view == 'desktop' ) {
15231516 // set stopMobileRedirect cookie
@@ -1533,10 +1526,10 @@
15341527 $this->setUseFormat( $view );
15351528 } else {
15361529 // if mobileurl template, redirect to desktop domain
1537 - $currentUrl = wfExpandUrl( $wgRequest->getRequestURL() );
 1530+ $currentUrl = wfExpandUrl( $this->getRequest()->getRequestURL() );
15381531 $currentUrl = $this->removeQueryStringParameter( $currentUrl, 'mobileaction' );
15391532 $desktopUrl = $this->getDesktopUrl( $currentUrl );
1540 - $wgOut->redirect( $desktopUrl, 301 );
 1533+ $this->getOutput()->redirect( $desktopUrl, 301 );
15411534 }
15421535 }
15431536 }
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.php
@@ -155,14 +155,8 @@
156156
157157 function efMobileFrontend_Setup() {
158158 global $wgExtMobileFrontend, $wgHooks;
159 - $wgExtMobileFrontend = new ExtMobileFrontend();
160 - $wgHooks['RequestContextCreateSkin'][] = array( &$wgExtMobileFrontend, 'requestContextCreateSkin' );
161 - $wgHooks['BeforePageRedirect'][] = array( &$wgExtMobileFrontend, 'beforePageRedirect' );
162 - $wgHooks['SkinTemplateOutputPageBeforeExec'][] = array( &$wgExtMobileFrontend, 'addMobileFooter' );
163 - $wgHooks['TestCanonicalRedirect'][] = array( &$wgExtMobileFrontend, 'testCanonicalRedirect' );
164 - $wgHooks['ResourceLoaderTestModules'][] = array( &$wgExtMobileFrontend, 'addTestModules' );
165 - $wgHooks['GetCacheVaryCookies'][] = array( &$wgExtMobileFrontend, 'getCacheVaryCookies' );
166 - $wgHooks['ResourceLoaderRegisterModules'][] = array( &$wgExtMobileFrontend, 'resourceLoaderRegisterModules' );
 159+ $wgExtMobileFrontend = new ExtMobileFrontend( RequestContext::getMain() );
 160+ $wgExtMobileFrontend->attachHooks();
167161 }
168162
169163 /**
Index: branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
@@ -14,6 +14,7 @@
1515 $appleTouchIconTag = '';
1616 }
1717
 18+ $htmlTitle = htmlspecialchars( $this->data['htmlTitle'] );
1819 $zeroRatedBanner = ( isset( $this->data['zeroRatedBanner'] ) ) ? str_replace( 'style="display:none;"', '', $this->data['zeroRatedBanner'] ) : '';
1920
2021 if ( $zeroRatedBanner ) {
@@ -57,11 +58,11 @@
5859 );
5960 if ( $this->data['title']->isMainPage() ) {
6061 $jsconfig['messages']['empty-homepage'] = wfMsg( 'mobile-frontend-empty-homepage' );
 62+ $firstHeading = '';
 63+ } else {
6164 $firstHeading = Html::element( 'h1', array( 'id' => 'firstHeading' ),
6265 $this->data['pageTitle']
6366 );
64 - } else {
65 - $firstHeading = '';
6667 }
6768 $configuration = FormatJSON::encode( $jsconfig );
6869
@@ -76,7 +77,7 @@
7778 <!DOCTYPE html>
7879 <html lang='{$this->data['code']}' dir='{$this->data['dir']}' xml:lang='{$this->data['code']}' xmlns='http://www.w3.org/1999/xhtml'>
7980 <head>
80 - <title>{$this->data['htmlTitle']}</title>
 81+ <title>{$htmlTitle}</title>
8182 <meta http-equiv="content-type" content="text/html; charset=utf-8" />{$robots}
8283 {$this->data['cssLinks']}
8384 <meta name="viewport" content="initial-scale=1.0, user-scalable=yes">

Status & tagging log