[-] BO : theme mobile : #PSCFV-3880 : Now you have 4 options for enable the theme mobile

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17217 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
lLefevre
2012-09-06 15:57:20 +00:00
parent 161863abe9
commit 85f9330df2
7 changed files with 381 additions and 34 deletions
+24 -24
View File
@@ -25,6 +25,9 @@
* International Registered Trademark & Property of PrestaShop SA
*/
if ((bool)Configuration::get('PS_ALLOW_MOBILE_DEVICE'))
include_once(_PS_TOOL_DIR_.'/Mobile_Detect/Mobile_Detect.php');
/**
* @since 1.5.0
*/
@@ -111,8 +114,27 @@ class ContextCore
{
$this->mobile_device = false;
if ($this->checkMobileContext())
if (preg_match('/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine|htc|iemobile|iphone|ipaq|ipod|j2me|java|midp|mini|mmp|mobi\s|motorola|nec-|nokia|palm|panasonic|philips|phone|sagem|sharp|sie-|smartphone|sony|symbian|t-mobile|telus|up\.browser|up\.link|vodafone|wap|webos|wireless|xda|zte)/i', $_SERVER['HTTP_USER_AGENT'], $out))
$this->mobile_device = $out[0];
{
$detect = new Mobile_Detect();
switch (Configuration::get('PS_ALLOW_MOBILE_DEVICE'))
{
case '1': // Only for mobile device
if ($detect->isMobile() && !$detect->isTablet())
$this->mobile_device = true;
break;
case '2': // Only for touchpads
if ($detect->isTablet() && !$detect->is_mobile())
$this->mobile_device = true;
break;
case '3': // For touchpad and mobile devices
if ($detect->isMobile() && $detect->isTablet())
$this->mobile_device = true;
break;
}
if ($detect->isMobile() && !$detect->isTablet())
$this->mobile_device = true;
}
}
return $this->mobile_device;
@@ -126,28 +148,6 @@ class ContextCore
&& !Context::getContext()->cookie->no_mobile;
}
protected function getTouchPadDevice()
{
if (is_null($this->touchpad_device))
{
$this->touchpad_device = false;
if ($this->checkMobileContext())
{
if (preg_match('/(xoom|ipad)/i', $_SERVER['HTTP_USER_AGENT'], $out))
$this->touchpad_device = $out[0];
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'android') && !strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mobile'))
$this->touchpad_device = 'android';
// for Galaxy tab
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'android')
&& (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'sch-i800')
|| strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'gt-p1000')))
$this->touchpad_device = 'android';
}
}
return $this->touchpad_device;
}
/**
* Get a singleton context
*