Skip to content

Commit

Permalink
bug:2687
Browse files Browse the repository at this point in the history
bug:2778
Unable to switch from mobile theme to classic theme with incompatible plugins.
Detect blackberry and symbian for mobile theme.
Update mdetect class.

git-svn-id: http://piwigo.org/svn/trunk@18967 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
patdenice committed Nov 7, 2012
1 parent 18f7349 commit 294b6e9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 20 deletions.
3 changes: 1 addition & 2 deletions include/functions.inc.php
Expand Up @@ -1620,7 +1620,7 @@ function get_device()
{
include_once(PHPWG_ROOT_PATH.'include/mdetect.php');
$uagent_obj = new uagent_info();
if ($uagent_obj->DetectTierIphone())
if ($uagent_obj->DetectSmartphone())
{
$device = 'mobile';
}
Expand Down Expand Up @@ -1654,7 +1654,6 @@ function mobile_theme()
{
$is_mobile_theme = get_boolean($_GET['mobile']);
pwg_set_session_var('mobile_theme', $is_mobile_theme);
unset($_GET['mobile']);
}
else
{
Expand Down
69 changes: 51 additions & 18 deletions include/mdetect.php
Expand Up @@ -3,6 +3,22 @@
/* *******************************************
// Copyright 2010-2012, Anthony Hand
//
// File version date: April 23, 2012
// Update:
// - Updated DetectAmazonSilk(): Fixed an issue in the detection logic.
//
// File version date: April 22, 2012 - Second update
// Update: To address additional Kindle issues...
// - Updated DetectRichCSS(): Excluded e-Ink Kindle devices.
// - Created DetectAmazonSilk(): Created to detect Kindle Fire devices in Silk mode.
// - Updated DetectMobileQuick(): Updated to include e-Ink Kindle devices and the Kindle Fire in Silk mode.
//
// File version date: April 11, 2012
// Update:
// - Added a new variable for the new BlackBerry Curve Touch (9380): deviceBBCurveTouch.
// - Updated DetectBlackBerryTouch() to support the new BlackBerry Curve Touch (9380).
// - Updated DetectKindle(): Added the missing 'this' class identifier for the DetectAndroid() call.
//
// File version date: January 21, 2012
// Update:
// - Added the constructor method per new features in PHP 5.0: __construct().
Expand All @@ -19,13 +35,6 @@
// Update:
// - Updated DetectAndroidTablet() to exclude Opera Mini, which was falsely reporting as running on a tablet device when on a phone.
//
// File version date: August 7, 2011
// Update:
// - The Opera for Android browser doesn't follow Google's recommended useragent string guidelines, so some fixes were needed.
// - Updated DetectAndroidPhone() and DetectAndroidTablet() to properly detect devices running Opera Mobile.
// - Created 2 new methods: DetectOperaAndroidPhone() and DetectOperaAndroidTablet().
// - Updated DetectTierIphone(). Removed the call to DetectMaemoTablet(), an obsolete mobile OS.
//
//
// LICENSE INFORMATION
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -113,6 +122,7 @@ class uagent_info
var $deviceBBBoldTouch = 'blackberry 99'; //Bold 99x0 (touchscreen)
var $deviceBBTour = 'blackberry96'; //Tour
var $deviceBBCurve = 'blackberry89'; //Curve2
var $deviceBBCurveTouch = 'blackberry 938'; //Curve Touch
var $deviceBBTorch = 'blackberry 98'; //Torch
var $deviceBBPlaybook = 'playbook'; //PlayBook tablet

Expand All @@ -123,7 +133,8 @@ class uagent_info
var $engineBlazer = 'blazer'; //Old Palm browser
var $engineXiino = 'xiino'; //Another old Palm

var $deviceKindle = 'kindle'; //Amazon Kindle, eInk one.
var $deviceKindle = 'kindle'; //Amazon Kindle, eInk one
var $engineSilk = 'silk'; //Amazon's accelerated Silk browser for Kindle Fire

//Initialize variables for mobile-specific content.
var $vndwap = 'vnd.wap';
Expand Down Expand Up @@ -494,13 +505,14 @@ function DetectBlackBerryWebKit()
}

//**************************
// Detects if the current browser is a BlackBerry Touch phone
// device, such as the Storm, Torch, and Bold Touch. Excludes the Playbook.
// Detects if the current browser is a BlackBerry Touch phone device with
// a large screen, such as the Storm, Torch, and Bold Touch. Excludes the Playbook.
function DetectBlackBerryTouch()
{
{
if ((stripos($this->useragent, $this->deviceBBStorm) > -1) ||
(stripos($this->useragent, $this->deviceBBTorch) > -1) ||
(stripos($this->useragent, $this->deviceBBBoldTouch) > -1))
(stripos($this->useragent, $this->deviceBBBoldTouch) > -1) ||
(stripos($this->useragent, $this->deviceBBCurveTouch) > -1))
return $this->true;
else
return $this->false;
Expand Down Expand Up @@ -709,7 +721,18 @@ function DetectWapWml()
function DetectKindle()
{
if (stripos($this->useragent, $this->deviceKindle) > -1 &&
DetectAndroid() == $this->false)
$this->DetectAndroid() == $this->false)
return $this->true;
else
return $this->false;
}

//**************************
// Detects if the current Amazon device is using the Silk Browser.
// Note: Typically used by the the Kindle Fire.
function DetectAmazonSilk()
{
if (stripos($this->useragent, $this->engineSilk) > -1)
return $this->true;
else
return $this->false;
Expand All @@ -725,7 +748,7 @@ function DetectMobileQuick()
//Let's exclude tablets
if ($this->isTierTablet == $this->true)
return $this->false;

//Most mobile browsing is done on smartphones
if ($this->DetectSmartphone() == $this->true)
return $this->true;
Expand All @@ -752,6 +775,11 @@ function DetectMobileQuick()
if (stripos($this->useragent, $this->mobile) > -1)
return $this->true;

//We also look for Kindle devices
if ($this->DetectKindle() == $this->true ||
$this->DetectAmazonSilk() == $this->true)
return $this->true;

else
return $this->false;
}
Expand Down Expand Up @@ -952,7 +980,9 @@ function DetectTierRichCss()
{
if ($this->DetectMobileQuick() == $this->true)
{
if (($this->DetectTierIphone() == $this->true))
//Exclude iPhone Tier and e-Ink Kindle devices
if (($this->DetectTierIphone() == $this->true) ||
($this->DetectKindle() == $this->true))
return $this->false;

//The following devices are explicitly ok.
Expand All @@ -969,8 +999,8 @@ function DetectTierRichCss()
if ($this->DetectWindowsMobile() == $this->true)
return $this->true;
if (stripos($this->useragent, $this->engineTelecaQ) > -1)
return $this->true;
return $this->true;

//default
else
return $this->false;
Expand All @@ -997,4 +1027,7 @@ function DetectTierOtherPhones()

}

?>

//Was informed by a MobileESP user that it's a best practice
// to omit the closing ?> marks here. They can sometimes
// cause errors with HTML headers.

0 comments on commit 294b6e9

Please sign in to comment.