So they wont want silly little mobile themes forced on them, will they? :D
// blackberry, playbook, iphone, nokia, android and ipods set a mobile flag
if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia'])
$this->_is_mobile = true;
Android sets a mobile tag in the user agent for phones, and doesn't set it for tablets. Examples here: http://www.gtrifonov.com/2011/04/15/google-android-user-agent-strings-2/
So, it would be better to split Android detection so that we have a $context thingy for teh phonez and another for teh tablets. Second one could be rolled into the iPad biz to make a is_tablet dooverlacky. This would be a better solution than the current code.
In case anyone gives a rat's this is what I'm using.
'is_iphone' => (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') !== false) && strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') === false,
'is_ipad' => strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') !== false,
'is_android_phone' => strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false,
'is_android_tablet' => strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') === false,
And this for tablets:
$context['browser']['is_tablet'] = $context['browser']['is_ipad'] || $context['browser']['is_android_tablet'];
Can add others of course, if anyone ever actually buys a W8 tablet. :D
Logged the issue for tracking ... thanks for the heads up :)
'is_android' => strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false,
'is_nokia' => strpos($_SERVER['HTTP_USER_AGENT'], 'SymbianOS') !== false,
'is_ipad' => strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') !== false,
);
// blackberry, playbook, iphone, nokia, android and ipods set a mobile flag
if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia'])
$this->_is_mobile = true;
// iPad and droid tablets get a tablet flag
if ($this->_browsers['is_ipad'] || ($this->_browsers['is_android'] && strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') === false))
$this->_is_tablet = true;
Just had to post the above without comment, coz I haz found another bug! :D
(Namely: put stuff in code tag, stretch out post box, oops cannot get cursor outside code tag to post extra comment).
Anyway: the detection code above is going to start by flagging droid tablets as droid phones, then set another flag as tablet. What's the advantage in doing it that way? If someone writes code that depends on the right choice between the two, you might get a conflict, yes?
'is_android' => strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false, <<Oh looky, it's a phone!
if ($this->_browsers['is_ipad'] || ($this->_browsers['is_android'] && strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') === false))
$this->_is_tablet = true; <<Oh bugger, which is it then?
That's why I wrote my code to split the two before it got that far. I think it's safer that way.
$this->_is_tablet as well as $this->_is_mobile are private variables to the class (meaning you don't access them, they are internal flags).
For final output it simply gives precedence to $this->_is_tablet over $this->_is_mobile ... meaning if tablet was detected that's output and that's all, otherwise mobile otherwise browser x
I did it that way to avoid repetitively doing (essentially) the same strpos checks again
Wotcha mean can't access them? Surely they can be used in templates n stuff?
Meaning those particular items you listed don't get used outside that function
Now it just sets $context['browser_body_id'] as tablet or mobile or ie or chrome or firefox etc
Guess we could add in isBrowser('tablet') and isBrowser('mobile') for completeness
Aha. Yeah I'd be inclined to go for something more comprehensive. Mobile/tablet stuff is still a tad wonky as far as standards support goes. Around a third of Android usrs are still on 2.x.x for instance, which is not as solid as the later versions. iShiz has significant problems with some areas of basic standards too (fixed positioning springs to mind). I think it'd be worthwhile giving maximum targeting ability for anything related to 'droid and iShiz, at least for the next couple of years.
/me lost track of what is needed here