issue 54 : Add a mobile agent string

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8529 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
taggon 2011-06-22 09:30:07 +00:00
parent 8064d65e67
commit d964631a14

View file

@ -16,44 +16,37 @@ class Mobile {
function _isFromMobilePhone() {
if($this->ismobile !== null) return $this->ismobile;
$db_info = Context::getDBInfo();
if($db_info->use_mobile_view != "Y" || Context::get('full_browse') || $_COOKIE["FullBrowse"])
{
$this->ismobile = false;
}
else
{
$xe_web_path = Context::pathToUrl(_XE_PATH_);
$m = Context::get('m');
if(strlen($m)==1) {
if($m == "1") {
$_COOKIE["mobile"] = 'true';
setcookie("mobile", 'true', 0, $xe_web_path);
$this->ismobile = true;
}
else if($m == "0") {
$_COOKIE["mobile"] = 'false';
setcookie("mobile", 'false', 0, $xe_web_path);
$this->ismobile = false;
}
$db_info = Context::getDBInfo();
if($db_info->use_mobile_view != "Y" || Context::get('full_browse') || $_COOKIE["FullBrowse"]) {
return ($this->ismobile = false);
}
$xe_web_path = Context::pathToUrl(_XE_PATH_);
$m = Context::get('m');
if(strlen($m)==1) {
if($m == "1") {
$_COOKIE['mobile'] = 'true';
setcookie('mobile', 'true', 0, $xe_web_path);
$this->ismobile = true;
} elseif($m == "0") {
$_COOKIE['mobile'] = 'false';
setcookie('mobile', 'false', 0, $xe_web_path);
$this->ismobile = false;
}
else if(isset($_COOKIE["mobile"])) {
if($_COOKIE['mobile'] == 'true') {
$this->ismobile = true;
}
else {
$_COOKIE["mobile"] = 'false';
setcookie("mobile", 'false', 0, $xe_web_path);
$this->ismobile = false;
}
}
else {
if(preg_match('/(iPod|iPhone|Android|BlackBerry|SymbianOS|SCH\-M[0-9]+)/',$_SERVER['HTTP_USER_AGENT']))
{
setcookie("mobile", 'true', 0, $xe_web_path);
$this->ismobile = true;
}
} elseif(isset($_COOKIE['mobile'])) {
if($_COOKIE['mobile'] == 'true') {
$this->ismobile = true;
} else {
$_COOKIE['mobile'] = 'false';
setcookie('mobile', 'false', 0, $xe_web_path);
$this->ismobile = false;
}
} else {
if($this->isMobileCheckByAgent()) {
setcookie("mobile", 'true', 0, $xe_web_path);
$this->ismobile = true;
}
}
@ -62,10 +55,7 @@ class Mobile {
function isMobileCheckByAgent()
{
if(preg_match('/(iPod|iPhone|Android|BlackBerry|SymbianOS|SCH\-M[0-9]+)/',$_SERVER['HTTP_USER_AGENT']))
return true;
else
return false;
return !!preg_match('/(iPod|iPhone|Android|BlackBerry|SymbianOS|SCH-M\d+|Googlebot-Mobile)/',$_SERVER['HTTP_USER_AGENT']);
}
function setMobile($ismobile)