Index: trunk/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | $wgExtMobileFrontend = new ExtMobileFrontend(); |
47 | 47 | |
48 | 48 | $wgHooks['OutputPageBeforeHTML'][] = array( &$wgExtMobileFrontend, 'onOutputPageBeforeHTML' ); |
49 | | - |
| 49 | + |
50 | 50 | $wgHooks['SkinTemplateOutputPageBeforeExec'][] = array( &$wgExtMobileFrontend, 'addMobileFooter' ); |
51 | 51 | |
52 | 52 | class ExtMobileFrontend { |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | public static $callback; |
71 | 71 | public static $useFormat; |
72 | 72 | public static $disableImages; |
73 | | - |
| 73 | + |
74 | 74 | public $itemsToRemove = array( |
75 | 75 | '#contentSub', # redirection notice |
76 | 76 | 'div.messagebox', # cleanup data |
— | — | @@ -103,18 +103,18 @@ |
104 | 104 | '#ogg_player_1', |
105 | 105 | '.nomobile', |
106 | 106 | ); |
107 | | - |
| 107 | + |
108 | 108 | public function addMobileFooter( &$obj, &$tpl ) { |
109 | | - global $wgRequest; |
| 109 | + global $wgRequest; |
110 | 110 | $footerlinks = $tpl->data['footerlinks']; |
111 | 111 | $mobileViewUrl = $wgRequest->getRequestURL(); |
112 | 112 | $delimiter = ( strpos( $mobileViewUrl, "?" ) !== false ) ? "&" : "?"; |
113 | 113 | $mobileViewUrl .= $delimiter . 'useFormat=mobile'; |
114 | | - |
| 114 | + |
115 | 115 | $tpl->set('mobileview', "<a href='{$mobileViewUrl}'>Mobile View</a>"); |
116 | 116 | $footerlinks['places'][] = 'mobileview'; |
117 | 117 | $tpl->set('footerlinks', $footerlinks); |
118 | | - |
| 118 | + |
119 | 119 | wfProfileOut(__METHOD__); |
120 | 120 | return true; |
121 | 121 | } |
— | — | @@ -143,8 +143,8 @@ |
144 | 144 | self::$disableImages = $wgRequest->getText( 'disableImages', 0 ); |
145 | 145 | |
146 | 146 | self::$mainPageUrl = Title::newMainPage()->getFullUrl(); |
147 | | - self::$randomPageUrl = SpecialPage::getTitleFor( 'Random' )->getFullUrl(); |
148 | | - |
| 147 | + self::$randomPageUrl = SpecialPage::getTitleFor( 'Randompage' )->getFullUrl(); |
| 148 | + |
149 | 149 | $userAgent = $_SERVER['HTTP_USER_AGENT']; |
150 | 150 | $uAmd5 = md5($userAgent); |
151 | 151 | |
— | — | @@ -158,7 +158,7 @@ |
159 | 159 | $wurflManager = $wurflManagerFactory->create(); |
160 | 160 | $device = $wurflManager->getDeviceForHttpRequest( $_SERVER ); |
161 | 161 | $props = $device->getAllCapabilities(); |
162 | | - |
| 162 | + |
163 | 163 | if ( $device->isSpecific() === true ) { |
164 | 164 | $wgMemc->set( $key, $props, 86400 ); |
165 | 165 | } else { |
— | — | @@ -169,13 +169,13 @@ |
170 | 170 | } catch (Exception $e) { |
171 | 171 | //echo $e->getMessage(); |
172 | 172 | } |
173 | | - |
| 173 | + |
174 | 174 | // 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. |
177 | 177 | // Thus, globalized objects will not be available as expected in the function. |
178 | 178 | // This is stated to be intended behavior, as per the following: [http://bugs.php.net/bug.php?id=40104] |
179 | | - |
| 179 | + |
180 | 180 | $mAction = $wgRequest->getText( 'mAction' ); |
181 | 181 | self::$useFormat = $wgRequest->getText( 'useFormat' ); |
182 | 182 | self::$format = $wgRequest->getText( 'format' ); |
— | — | @@ -193,7 +193,7 @@ |
194 | 194 | } elseif ( self::$device['view_format'] === 'html' ) { |
195 | 195 | $this->contentFormat = 'XHTML'; |
196 | 196 | } |
197 | | - |
| 197 | + |
198 | 198 | if ( self::$useFormat === 'mobile-wap' ) { |
199 | 199 | $this->contentFormat = 'WML'; |
200 | 200 | } |
— | — | @@ -204,7 +204,7 @@ |
205 | 205 | exit(); |
206 | 206 | } |
207 | 207 | } |
208 | | - |
| 208 | + |
209 | 209 | // Note: Temporarily disabling this section for trial deployment |
210 | 210 | // if ( is_array($props) && |
211 | 211 | // $mAction != 'view_normal_site' && |
— | — | @@ -212,13 +212,13 @@ |
213 | 213 | // $props['is_tablet'] === 'false' ) { |
214 | 214 | // $this->disableCaching(); |
215 | 215 | // ob_start( array( $this, 'DOMParse' ) ); |
216 | | - // } elseif (self::$useFormat === 'mobile' || |
| 216 | + // } elseif (self::$useFormat === 'mobile' || |
217 | 217 | // self::$useFormat === 'mobile-wap' ) { |
218 | 218 | // $this->disableCaching(); |
219 | 219 | // ob_start( array( $this, 'DOMParse' ) ); |
220 | 220 | // } |
221 | 221 | |
222 | | - if (self::$useFormat === 'mobile' || |
| 222 | + if (self::$useFormat === 'mobile' || |
223 | 223 | self::$useFormat === 'mobile-wap' ) { |
224 | 224 | $this->disableCaching(); |
225 | 225 | ob_start( array( $this, 'DOMParse' ) ); |
— | — | @@ -228,7 +228,7 @@ |
229 | 229 | } |
230 | 230 | |
231 | 231 | private function disableCaching() { |
232 | | - if ( isset( $_SERVER['HTTP_VIA'] ) && |
| 232 | + if ( isset( $_SERVER['HTTP_VIA'] ) && |
233 | 233 | stripos( $_SERVER['HTTP_VIA'], '.wikimedia.org:3128' ) !== false ) { |
234 | 234 | header( 'Cache-Control: no-cache, must-revalidate' ); |
235 | 235 | header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); |
— | — | @@ -274,13 +274,13 @@ |
275 | 275 | } |
276 | 276 | |
277 | 277 | private function showHideCallbackXHTML( $matches ) { |
278 | | - |
| 278 | + |
279 | 279 | if ( isset( $matches[0] ) ) { |
280 | 280 | preg_match('/id="([^"]*)"/', $matches[0], $headlineMatches); |
281 | 281 | } |
282 | | - |
| 282 | + |
283 | 283 | $headlineId = ( isset( $headlineMatches[1] ) ) ? $headlineMatches[1] : ''; |
284 | | - |
| 284 | + |
285 | 285 | static $headings = 0; |
286 | 286 | $show = self::$messages['mobile-frontend-show']; |
287 | 287 | $hide = self::$messages['mobile-frontend-hide']; |
— | — | @@ -336,12 +336,12 @@ |
337 | 337 | $card = ''; |
338 | 338 | $idx = 0; |
339 | 339 | $requestedSegment = self::$requestedSegment; |
340 | | - |
| 340 | + |
341 | 341 | $card .= "<card id='{$idx}' title='{$title}'><p>{$segments[$requestedSegment]}</p>"; |
342 | 342 | $idx = $requestedSegment + 1; |
343 | 343 | $segmentsCount = count($segments); |
344 | 344 | $card .= $idx . "/" . $segmentsCount; |
345 | | - |
| 345 | + |
346 | 346 | $useFormatParam = ( isset( self::$useFormat ) ) ? '&' . 'useFormat=' . self::$useFormat : ''; |
347 | 347 | |
348 | 348 | $basePage = htmlspecialchars( $_SERVER['PHP_SELF'] ); |
— | — | @@ -396,7 +396,7 @@ |
397 | 397 | // iterator on the foreach out of wack and results will be quite |
398 | 398 | // strange. Though, making a queue of items to remove seems to work. |
399 | 399 | // For example: |
400 | | - |
| 400 | + |
401 | 401 | if ( self::$disableImages == 1 ) { |
402 | 402 | $itemToRemoveRecords['TAG'][] = "img"; |
403 | 403 | $itemToRemoveRecords['CLASS'][] = "thumb tright"; |