https://bugzilla.wikimedia.org/show_bug.cgi?id=54115
Web browser: ---
Bug ID: 54115
Summary: Allow to detect mobile externally without using AMF
module
Product: MediaWiki extensions
Version: master
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: enhancement
Priority: Unprioritized
Component: MobileFrontend (Beta)
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected], [email protected],
[email protected]
Classification: Unclassified
Mobile Platform: ---
Created attachment 13276
--> https://bugzilla.wikimedia.org/attachment.cgi?id=13276&action=edit
Header and phpcode
Currently there are two options for mobile users:
* Install AMF plugin
* Enable wgMFAutodetectMobileView
But I'd like to do this myself, e.g. set my own header and say: Hey, mobile
view please.
So I looked into the code and tried:
AMF plugin sets a header AMF_DEVICE_IS_MOBILE. Idea: Set the header myself:
RequestHeader set AMF_DEVICE_IS_MOBILE true env=ismobile
But alas PHP, in it's infinite wisdom, adds HTTP_AMF_DEVICE_IS_MOBILE to
$_SERVER and it doesn't work. See attached code/example for reference.
So, I see three simple solutions:
a) Add a second function similar to getAMF to MobileContext (see c) for an
example)
b) Add a variable that overrides detection:
public function isMobileDevice() {
global $wgMFAutodetectMobileView;
global $wgMFOverridedetectMobileView;
return ( $wgMFAutodetectMobileView &&
$this->getDevice()->isMobileDevice() )
|| $this->getAMF() || $wgMFOverridedetectMobileView;
}
c) Make getAMF generic and allow a custom header
public function isMobileHeaderSet() {
global $wgMFMobileHeader;
global $wgMFTabletHeader;
if ( isset( $_SERVER[$wgMFMobileHeader] ) &&
$_SERVER[$wgMFMobileHeader] === "true" &&
$_SERVER[$wgMFTabletHeader] === "false" ) {
return true;
}
return false;
}
By default, $wgMFMobileHeader would be AMF_DEVICE_IS_MOBILE by default, but
people using a different kind of detection algorithm/module could use it.
Not sure what's better. If b) then I could test myself in LocalSettings.php and
set the variable. Btw.: I already tried to do stuff like this in
LocalSettings.php, but I got problems with manually switching to desktop view
and back:
if ( isset( $_SERVER['HTTP_AMF_DEVICE_IS_MOBILE'] ) &&
$_SERVER['HTTP_AMF_DEVICE_IS_MOBILE'] === "true" ) {
MobileContext::singleton()->setForceMobileView( true );
}
Thanks for consideration!
--
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l