Florianschmidtwelzow has uploaded a new change for review.

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

Change subject: PoC: Allow a user to change the skin with the api
......................................................................

PoC: Allow a user to change the skin with the api

With the mobileskin option, the user can specify, which skin he/she want to use.
The option if available through the api and can, e.g., changed using this query
in the brwosers console (while the tab with the target wiki is open):

new mw.Api().postWithToken(
        'options',
        {
                action: 'options',
                change: 'mobileskin=vector'
        })
        .fail( function( error ) {
                console.log( error );
        })
        .done( function( resp ) {
                console.log( resp, 'done' );
        });

After a short waiting time, the console should show a "done", if anything worked
correctly. After a reload, the mobile site should use vector as the skin class, 
instead of minerva.

Change-Id: I14bf3f80ad5d935a6ea4ed61f85dd9e9b02b433d
---
M includes/MobileFrontend.hooks.php
1 file changed, 8 insertions(+), 3 deletions(-)


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

diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index 2d5f9fb..3a81881 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -116,9 +116,8 @@
                $skin = new $skinName( $context );
 
                // Allow overriding of skin by useskin e.g. 
useskin=vector&useformat=mobile
-               if ( $context->getRequest()->getVal( 'useskin' ) ) {
-                       $userSkin = $mobileContext->getRequest()->getVal( 
'useskin' );
-
+               $userSkin = $context->getRequest()->getVal( 'useskin', 
$context->getUser()->getOption( 'mobileskin' ) );
+               if ( $userSkin ) {
                        // Normalize the key in case the user is passing 
gibberish or has old preferences
                        $normalizedSkin = Skin::normalizeKey( $userSkin );
                        // If the skin has been normalized and is different 
from user input use it
@@ -870,6 +869,12 @@
                        }
                }
 
+               // preference that allow a user to set the preffered mobile 
skin using the api
+               $preferences['mobileskin'] = array(
+                       'type' => 'api',
+                       'default' => '',
+               );
+
                return true;
        }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I14bf3f80ad5d935a6ea4ed61f85dd9e9b02b433d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to