/** * Get current mobile mode * * @return bool */ 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"]) { return $this->ismobile = false; } $xe_web_path = Context::pathToUrl(_XE_PATH_); // default setting. if there is cookie for a device, XE do not have to check if it is mobile or not and it will enhance performace of the server. $this->ismobile = FALSE; $m = Context::get('m'); if (strlen($m) == 1) { if ($m == "1") { $this->ismobile = true; } elseif ($m == "0") { $this->ismobile = false; } } elseif (isset($_COOKIE['mobile'])) { if ($_COOKIE['user-agent'] == md5($_SERVER['HTTP_USER_AGENT'])) { if ($_COOKIE['mobile'] == 'true') { $this->ismobile = true; } else { $this->ismobile = false; } } else { $this->ismobile = FALSE; setcookie("mobile", FALSE, 0, $xe_web_path); setcookie("user-agent", FALSE, 0, $xe_web_path); if (!$this->isMobilePadCheckByAgent() && $this->isMobileCheckByAgent()) { $this->ismobile = TRUE; } } } else { if ($this->isMobilePadCheckByAgent()) { $this->ismobile = FALSE; } else { if ($this->isMobileCheckByAgent()) { $this->ismobile = TRUE; } } } if ($this->ismobile !== NULL) { if ($this->ismobile == TRUE) { if ($_COOKIE['mobile'] != 'true') { $_COOKIE['mobile'] = 'true'; setcookie("mobile", 'true', 0, $xe_web_path); } } elseif ($_COOKIE['mobile'] != 'false') { $_COOKIE['mobile'] = 'false'; setcookie("mobile", 'false', 0, $xe_web_path); } if ($_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT'])) { setcookie("user-agent", md5($_SERVER['HTTP_USER_AGENT']), 0, $xe_web_path); } } return $this->ismobile; }
public static function getUrl($pattern = null, $relative = true) { return ($relative ? '' : getFullSiteUrl()) . Context::pathToUrl(_XE_PATH_) . BaseRepository::vid() . '/' . $pattern; }
function _replacePath($matches) { $val = trim($matches[3]); // Pass if the path is external or starts with /, #, { characters // /=absolute path, #=hash in a page, {=Template syntax if (strpos($val, '.') === FALSE || preg_match('@^((?:http|https|ftp|telnet|mms)://|(?:mailto|javascript):|[/#{])@i', $val)) { return $matches[0]; // In case of .. , get a path } else { if (strncasecmp('..', $val, 2) === 0) { $p = Context::pathToUrl($this->path); return sprintf("%s%s%s%s", $matches[1], $matches[2], $p . $val, $matches[4]); } } if (strncasecmp('..', $val, 2) === 0) { $val = substr($val, 2); } $p = Context::pathToUrl($this->path); $path = sprintf("%s%s%s%s", $matches[1], $matches[2], $p . $val, $matches[4]); return $path; }