Extension:MobileSkin


 * Also see Simple mobile skin auto change for a simple mobile skin detector that only requires adding a few lines to LocalSettings.php.

MobileSkin automatically detects the computer (device) requesting the page and determines if there is a skin that should be used instead. The user's preference is not changed, it simply becomes the user's default choice.

What can this extension do?
This extension automatically detects mobile devices using values in HTTP_USER_AGENT (browser identity) and changes the skin used to display the requested page. If HTTP_USER_AGENT does not contain any known mobile indicators (e.g. "iphone", "smartphone", "blackberry", "mobile", etc) the page will display with the user's default skin defined in his or her preferences.

If a mobile device is detected the extension uses the skin selected for that device type. For example, 'chick' is probably good for most mobile devices. You can, however, create new skins and direct MobileSkin to use those skins for different devices. The iPhone, for example, might use a different skin.

This extension allows users to have one username that automatically changes skin when the user is using a different type of device. This does assume a skin has been created and set up for each device type or a suitable skin already exists.

This extension does not use wurfl level detection.

Localization
This extension does not display any text to users or on the page; it simply changes the skin when displaying wiki pages based on the device. Thererefore, there is no 'MobileSkin.i18n.php' file to contain translations.

Usage
This extension operates without any additional tags or in-page instructions.

The class can be instantiated so other extensions can detect mobile devices or decide to include extensions if a mobile device - or not a mobile device - is requesting the page.

isMobile
This method simply indicates if this is a mobile device or not.

INPUT: no arguments

OUTPUT: boolean (true or false)
 * TRUE : mobile device of some kind requested the page
 * FALSE : page was not requested by a mobile device

EXAMPLE: Optionally include extensions for desktop-only use

isIphone
This method works like isMobile but checks to see if the device is an iPhone compatible device.

INPUT: no arguments

OUTPUT: boolean (true or false)
 * TRUE : iPhone requested the page
 * FALSE : page was not requested by an iPhone

EXAMPLE: Optionally include extensions for iPhone use

Change log

 * v0.4 2009-04-30 - fix bug in isSkinInstalled
 * v0.3 2009-04-30 - convert extension to a class
 * Remove $wgMobileSkinEnabled and $wgMobileSkinList settings
 * Move list of devices, skins, and HTTP_USER_AGENT patterns into class constructor
 * Split detection and change functions into separate "body" file
 * v0.2 2008-12-15 - initial beta release; basic functions
 * v0.1 2008-12-10 - initial test release (not posted to MediaWiki

Download instructions
Please cut and paste the code found below and place it in. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation

 * 1) Create and install any custom skins into the /skins folder. (optional)
 * 2) Install FCKeditor extension. (required for example usage)
 * 3) Create the /extensions/MobileSkin folder. (required)
 * 4) Create each file, as named below, in the /extensions/MobileSkin folder. (required)
 * 5) Edit MobileSkin.body.php to make any changes to the "mobileDevices" multi-dimensional array. (optional) Typically, this includes:
 * 6) Change skin names for each device to any new skins or existing skins you prefer on a device by device basis
 * 7) Add new devices with skin name and patterns to identify it
 * 8) Add new patterns as new phones become available
 * 9) Add the following code into LocalSettings.php: (required)

By default, all mobile devices uses the "chick" skin. If you create and install custom skin for the iPhone (for example), you should change the mapping to that skin.

User rights
This extension does not modify any user rights.

MobileSkin.php
This file registers the extension.

MobileSkin.body.php
This file contains the actual processing code that is called automatically by the extension event handler. In addition, there are some functions you can call for other reasons.

MobileSkin.LocalSettings.php
This file contains up to date configuration settings for the extension. Copy this code into your LocalSettings.php file.