r95794 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95793‎ | r95794 | r95795 >
Date:17:20, 30 August 2011
Author:preilly
Status:ok
Tags:
Comment:
use x-device header
Modified paths:
  • /trunk/extensions/MobileFrontend/DeviceDetection.php (modified) (history)
  • /trunk/extensions/MobileFrontend/MobileFrontend.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/DeviceDetection.php
@@ -294,6 +294,9 @@
295295
296296 if ( preg_match( '/Android/', $userAgent ) ) {
297297 $formatName = 'android';
 298+ if ( strpos( $userAgent, 'Opera Mini' ) !== false ) {
 299+ $formatName = 'operamini';
 300+ }
298301 } elseif ( preg_match( '/iPhone.* Safari/', $userAgent ) ) {
299302 if ( strpos( $userAgent, 'iPhone OS 2' ) !== false ) {
300303 $formatName = 'iphone2';
Index: trunk/extensions/MobileFrontend/MobileFrontend.php
@@ -65,7 +65,7 @@
6666 );
6767
6868 class ExtMobileFrontend {
69 - const VERSION = '0.5.49';
 69+ const VERSION = '0.5.50';
7070
7171 /**
7272 * @var DOMDocument
@@ -292,10 +292,18 @@
293293 self::$search = $wgRequest->getText( 'search' );
294294 self::$callback = $wgRequest->getText( 'callback' );
295295 self::$searchField = $wgRequest->getText( 'search', '' );
 296+
 297+ $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : '';
296298
297299 $acceptHeader = $_SERVER["HTTP_ACCEPT"];
298300 $device = new DeviceDetection();
299 - $formatName = $device->formatName( $userAgent, $acceptHeader );
 301+
 302+ if ( !empty( $xDevice ) ) {
 303+ $formatName = $xDevice;
 304+ } else {
 305+ $formatName = $device->formatName( $userAgent, $acceptHeader );
 306+ }
 307+
300308 self::$device = $device->format( $formatName );
301309
302310 if ( self::$device['view_format'] === 'wml' ) {
@@ -366,8 +374,6 @@
367375
368376 // Determine
369377
370 - $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : '';
371 -
372378 if (self::$useFormat === 'mobile' ||
373379 self::$useFormat === 'mobile-wap' ||
374380 !empty( $xDevice ) ) {
@@ -529,7 +535,7 @@
530536 Html::rawElement( 'a',
531537 array( 'href' => '#section_' . intval( $headings - 1 ),
532538 'class' => 'back_to_top' ),
533 - '↑' . $backToTop ) .
 539+ '↑' . $backToTop ) .
534540 Html::closeElement( 'div' );
535541 // generate the HTML we are going to inject
536542 $buttons = Html::element( 'button',

Follow-up revisions

RevisionCommit summaryAuthorDate
r95795mft r95549 through r95794preilly17:22, 30 August 2011

Status & tagging log