r93472 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93471‎ | r93472 | r93473 >
Date:17:38, 29 July 2011
Author:aaron
Status:ok
Tags:
Comment:
Fixed call to getTitleFor for Randompage
Modified paths:
  • /trunk/extensions/MobileFrontend/MobileFrontend.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/MobileFrontend.php
@@ -45,7 +45,7 @@
4646 $wgExtMobileFrontend = new ExtMobileFrontend();
4747
4848 $wgHooks['OutputPageBeforeHTML'][] = array( &$wgExtMobileFrontend, 'onOutputPageBeforeHTML' );
49 -
 49+
5050 $wgHooks['SkinTemplateOutputPageBeforeExec'][] = array( &$wgExtMobileFrontend, 'addMobileFooter' );
5151
5252 class ExtMobileFrontend {
@@ -69,7 +69,7 @@
7070 public static $callback;
7171 public static $useFormat;
7272 public static $disableImages;
73 -
 73+
7474 public $itemsToRemove = array(
7575 '#contentSub', # redirection notice
7676 'div.messagebox', # cleanup data
@@ -103,18 +103,18 @@
104104 '#ogg_player_1',
105105 '.nomobile',
106106 );
107 -
 107+
108108 public function addMobileFooter( &$obj, &$tpl ) {
109 - global $wgRequest;
 109+ global $wgRequest;
110110 $footerlinks = $tpl->data['footerlinks'];
111111 $mobileViewUrl = $wgRequest->getRequestURL();
112112 $delimiter = ( strpos( $mobileViewUrl, "?" ) !== false ) ? "&" : "?";
113113 $mobileViewUrl .= $delimiter . 'useFormat=mobile';
114 -
 114+
115115 $tpl->set('mobileview', "<a href='{$mobileViewUrl}'>Mobile View</a>");
116116 $footerlinks['places'][] = 'mobileview';
117117 $tpl->set('footerlinks', $footerlinks);
118 -
 118+
119119 wfProfileOut(__METHOD__);
120120 return true;
121121 }
@@ -143,8 +143,8 @@
144144 self::$disableImages = $wgRequest->getText( 'disableImages', 0 );
145145
146146 self::$mainPageUrl = Title::newMainPage()->getFullUrl();
147 - self::$randomPageUrl = SpecialPage::getTitleFor( 'Random' )->getFullUrl();
148 -
 147+ self::$randomPageUrl = SpecialPage::getTitleFor( 'Randompage' )->getFullUrl();
 148+
149149 $userAgent = $_SERVER['HTTP_USER_AGENT'];
150150 $uAmd5 = md5($userAgent);
151151
@@ -158,7 +158,7 @@
159159 $wurflManager = $wurflManagerFactory->create();
160160 $device = $wurflManager->getDeviceForHttpRequest( $_SERVER );
161161 $props = $device->getAllCapabilities();
162 -
 162+
163163 if ( $device->isSpecific() === true ) {
164164 $wgMemc->set( $key, $props, 86400 );
165165 } else {
@@ -169,13 +169,13 @@
170170 } catch (Exception $e) {
171171 //echo $e->getMessage();
172172 }
173 -
 173+
174174 // Note: The WebRequest Class calls are made in this block because
175 - // since PHP 5.1.x, all objects have their destructors called
176 - // before the output buffer callback function executes.
 175+ // since PHP 5.1.x, all objects have their destructors called
 176+ // before the output buffer callback function executes.
177177 // Thus, globalized objects will not be available as expected in the function.
178178 // This is stated to be intended behavior, as per the following: [http://bugs.php.net/bug.php?id=40104]
179 -
 179+
180180 $mAction = $wgRequest->getText( 'mAction' );
181181 self::$useFormat = $wgRequest->getText( 'useFormat' );
182182 self::$format = $wgRequest->getText( 'format' );
@@ -193,7 +193,7 @@
194194 } elseif ( self::$device['view_format'] === 'html' ) {
195195 $this->contentFormat = 'XHTML';
196196 }
197 -
 197+
198198 if ( self::$useFormat === 'mobile-wap' ) {
199199 $this->contentFormat = 'WML';
200200 }
@@ -204,7 +204,7 @@
205205 exit();
206206 }
207207 }
208 -
 208+
209209 // Note: Temporarily disabling this section for trial deployment
210210 // if ( is_array($props) &&
211211 // $mAction != 'view_normal_site' &&
@@ -212,13 +212,13 @@
213213 // $props['is_tablet'] === 'false' ) {
214214 // $this->disableCaching();
215215 // ob_start( array( $this, 'DOMParse' ) );
216 - // } elseif (self::$useFormat === 'mobile' ||
 216+ // } elseif (self::$useFormat === 'mobile' ||
217217 // self::$useFormat === 'mobile-wap' ) {
218218 // $this->disableCaching();
219219 // ob_start( array( $this, 'DOMParse' ) );
220220 // }
221221
222 - if (self::$useFormat === 'mobile' ||
 222+ if (self::$useFormat === 'mobile' ||
223223 self::$useFormat === 'mobile-wap' ) {
224224 $this->disableCaching();
225225 ob_start( array( $this, 'DOMParse' ) );
@@ -228,7 +228,7 @@
229229 }
230230
231231 private function disableCaching() {
232 - if ( isset( $_SERVER['HTTP_VIA'] ) &&
 232+ if ( isset( $_SERVER['HTTP_VIA'] ) &&
233233 stripos( $_SERVER['HTTP_VIA'], '.wikimedia.org:3128' ) !== false ) {
234234 header( 'Cache-Control: no-cache, must-revalidate' );
235235 header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
@@ -274,13 +274,13 @@
275275 }
276276
277277 private function showHideCallbackXHTML( $matches ) {
278 -
 278+
279279 if ( isset( $matches[0] ) ) {
280280 preg_match('/id="([^"]*)"/', $matches[0], $headlineMatches);
281281 }
282 -
 282+
283283 $headlineId = ( isset( $headlineMatches[1] ) ) ? $headlineMatches[1] : '';
284 -
 284+
285285 static $headings = 0;
286286 $show = self::$messages['mobile-frontend-show'];
287287 $hide = self::$messages['mobile-frontend-hide'];
@@ -336,12 +336,12 @@
337337 $card = '';
338338 $idx = 0;
339339 $requestedSegment = self::$requestedSegment;
340 -
 340+
341341 $card .= "<card id='{$idx}' title='{$title}'><p>{$segments[$requestedSegment]}</p>";
342342 $idx = $requestedSegment + 1;
343343 $segmentsCount = count($segments);
344344 $card .= $idx . "/" . $segmentsCount;
345 -
 345+
346346 $useFormatParam = ( isset( self::$useFormat ) ) ? '&' . 'useFormat=' . self::$useFormat : '';
347347
348348 $basePage = htmlspecialchars( $_SERVER['PHP_SELF'] );
@@ -396,7 +396,7 @@
397397 // iterator on the foreach out of wack and results will be quite
398398 // strange. Though, making a queue of items to remove seems to work.
399399 // For example:
400 -
 400+
401401 if ( self::$disableImages == 1 ) {
402402 $itemToRemoveRecords['TAG'][] = "img";
403403 $itemToRemoveRecords['CLASS'][] = "thumb tright";

Status & tagging log