// Improvement when detect mobile
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17222 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
1 parent
68d9b26721
commit
79aa52f4a2
1 file changed
+13
-4
+13
-4
@@ -98,11 +98,21 @@ class ContextCore
|
|||||||
*/
|
*/
|
||||||
public $smarty;
|
public $smarty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ var Mobile Detect
|
||||||
|
*/
|
||||||
|
public $mobile_detect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var boolean|string mobile device of the customer
|
* @var boolean|string mobile device of the customer
|
||||||
*/
|
*/
|
||||||
protected $mobile_device;
|
protected $mobile_device;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->mobile_detect = new Mobile_Detect();
|
||||||
|
}
|
||||||
|
|
||||||
public function getMobileDevice()
|
public function getMobileDevice()
|
||||||
{
|
{
|
||||||
if (is_null($this->mobile_device))
|
if (is_null($this->mobile_device))
|
||||||
@@ -110,20 +120,19 @@ class ContextCore
|
|||||||
$this->mobile_device = false;
|
$this->mobile_device = false;
|
||||||
if ($this->checkMobileContext())
|
if ($this->checkMobileContext())
|
||||||
{
|
{
|
||||||
$detect = new Mobile_Detect();
|
|
||||||
|
|
||||||
switch ((int)Configuration::get('PS_ALLOW_MOBILE_DEVICE'))
|
switch ((int)Configuration::get('PS_ALLOW_MOBILE_DEVICE'))
|
||||||
{
|
{
|
||||||
case 1: // Only for mobile device
|
case 1: // Only for mobile device
|
||||||
if ($detect->isMobile() && !$detect->isTablet())
|
if ($this->mobile_detect->isMobile() && !$this->mobile_detect->isTablet())
|
||||||
$this->mobile_device = true;
|
$this->mobile_device = true;
|
||||||
break;
|
break;
|
||||||
case 2: // Only for touchpads
|
case 2: // Only for touchpads
|
||||||
if ($detect->isTablet() && !$detect->is_mobile())
|
if ($this->mobile_detect->isTablet() && !$this->mobile_detect->is_mobile())
|
||||||
$this->mobile_device = true;
|
$this->mobile_device = true;
|
||||||
break;
|
break;
|
||||||
case 3: // For touchpad or mobile devices
|
case 3: // For touchpad or mobile devices
|
||||||
if ($detect->isMobile() || $detect->isTablet())
|
if ($this->mobile_detect->isMobile() || $this->mobile_detect->isTablet())
|
||||||
$this->mobile_device = true;
|
$this->mobile_device = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user