Last modified: 2014-02-12 23:45:31 UTC
Created attachment 13276 [details] 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!
Prioritization and scheduling of this bug is tracked on Mingle card https://mingle.corp.wikimedia.org/projects/mobile/cards/1197
On MF version for MW 1.21, there's X-Device header that is used for this, and in 1.22, there is X-WAP. Ask on IRC if you neeed help with configuring these.
That's not true. The WAP header is only processed when $wgMobileUrlTemplate is set: if ( $wgMobileUrlTemplate && $this->getRequest()->getHeader( 'X-WAP' ) ) { return true; } Why am I forced to setup a mobile subdomain? I don't need one. Btw.: If you stand with your logic, it would be consequent to remove getAMF(). It isn't needed either.
Interesting. The version for The same code in MobileContext 1.21 looks this way: public function isMobileDevice() { global $wgMFAutodetectMobileView; return $this->getXDevice() || $this->getAMF() || ( $wgMFAutodetectMobileView && $this->getDevice()->isMobileDevice() ); } You are right: In Mediawiki 1.21 I can set my own header. In Mediawiki 1.22 this option was basically removed.