From a4730b3511fab2e2e6b58b9b630c73d5f9b5bfca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=B6ckel?= Date: Thu, 2 Jun 2011 22:52:12 +0000 Subject: [PATCH] Added mobile browser detection function --- phpgwapi/inc/class.html.inc.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index 2652da21c4..9f9459cfcf 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -1523,5 +1523,29 @@ class html } return $html2ret; } + + + static private $mobileBrowser = null; + + /** + * Returns whether this is a mobile browser + */ + static public function is_mobile() + { + $agent = $_SERVER['HTTP_USER_AGENT']; + + if (self::$mobileBrowser == null) { + + self::$mobileBrowser = false; + + foreach(array('iPhone','iPad','Android','SymbianOS') as $pattern) + { + self::$mobileBrowser |= (stripos($agent,$pattern) !== false); + } + } + + return true; + //return self::$mobileBrowser; + } } html::_init_static();