MaxSem has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/67549


Change subject: Move ExtMobileFrontend::parseContentFormat() to MobileContext
......................................................................

Move ExtMobileFrontend::parseContentFormat() to MobileContext

Change-Id: I2cbf1020ecf1190289daa686df01e558e974f742
---
M includes/MobileContext.php
M includes/MobileFrontend.body.php
M includes/api/ApiParseExtender.php
3 files changed, 22 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/49/67549/1

diff --git a/includes/MobileContext.php b/includes/MobileContext.php
index 1b67389..a2ce859 100644
--- a/includes/MobileContext.php
+++ b/includes/MobileContext.php
@@ -90,13 +90,31 @@
                if ( $this->contentFormat ) {
                        return $this->contentFormat;
                }
-               // honor useformat=mobile-wap if it's set, otherwise determine 
by device
+               // honor useformat if it's set, otherwise determine by device
                $device = $this->getDevice();
-               $viewFormat = ( $this->getUseFormat() == 'mobile-wap' ) ? 
'mobile-wap' : $device->format();
-               $this->contentFormat = ExtMobileFrontend::parseContentFormat( 
$viewFormat );
+               $viewFormat = ( $this->getUseFormat() != '' ) ? 
$this->getUseFormat() : $device->format();
+               $this->contentFormat = self::parseContentFormat( $viewFormat );
                return $this->contentFormat;
        }
 
+       /**
+        * Converts a multitude of format strings to 'HTML' or 'WML'
+        * @param string $format
+        *
+        * @return string
+        */
+       public static function parseContentFormat( $format ) {
+               if ( $format === 'wml' ) {
+                       return 'WML';
+               } elseif ( $format === 'html' ) {
+                       return 'HTML';
+               }
+               if ( $format === 'mobile-wap' ) {
+                       return 'WML';
+               }
+               return 'HTML';
+       }
+
        public function imagesDisabled() {
                if ( is_null( $this->disableImages ) ) {
                        $this->disableImages = 
(bool)$this->getRequest()->getCookie( 'disableImages' );
diff --git a/includes/MobileFrontend.body.php b/includes/MobileFrontend.body.php
index 4d97c54..07391ff 100644
--- a/includes/MobileFrontend.body.php
+++ b/includes/MobileFrontend.body.php
@@ -37,18 +37,6 @@
                wfProfileOut( __METHOD__ );
        }
 
-       public static function parseContentFormat( $format ) {
-               if ( $format === 'wml' ) {
-                       return 'WML';
-               } elseif ( $format === 'html' ) {
-                       return 'HTML';
-               }
-               if ( $format === 'mobile-wap' ) {
-                       return 'WML';
-               }
-               return 'HTML';
-       }
-
        /**
         * Disables caching if the request is coming from a trusted proxy
         */
diff --git a/includes/api/ApiParseExtender.php 
b/includes/api/ApiParseExtender.php
index 9d45a05..c3dbf81 100644
--- a/includes/api/ApiParseExtender.php
+++ b/includes/api/ApiParseExtender.php
@@ -80,7 +80,7 @@
                                $context->setOnlyThisSegment( isset( 
$params['section'] ) );
                                $mf = new MobileFormatter( 
MobileFormatter::wrapHTML( $data['parse']['text']['*'] ),
                                        $title,
-                                       ExtMobileFrontend::parseContentFormat( 
$params['mobileformat'] ),
+                                       MobileContext::parseContentFormat( 
$params['mobileformat'] ),
                                        $context
                                );
                                $mf->removeImages( $params['noimages'] );

-- 
To view, visit https://gerrit.wikimedia.org/r/67549
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2cbf1020ecf1190289daa686df01e558e974f742
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to