summaryrefslogtreecommitdiffstats
path: root/system/libraries/User_agent.php
diff options
context:
space:
mode:
authorAnton Lindqvist <anton@qvister.se>2012-06-08 10:09:47 +0200
committerAnton Lindqvist <anton@qvister.se>2012-06-08 10:09:47 +0200
commit94c6b1f1c02466178c1f8e144542d753f27dd3d8 (patch)
tree8e8ca4b8383e2481b0a689fd07fc230013531822 /system/libraries/User_agent.php
parent6581cac4d2b5fef69478ce1a5c3464200bfcbba5 (diff)
parentc78e56a7df140ee777ffc67687877f3e70c77e28 (diff)
Merge branch 'develop' of https://github.com/EllisLab/CodeIgniter into develop
Conflicts: system/libraries/Cache/Cache.php
Diffstat (limited to 'system/libraries/User_agent.php')
-rw-r--r--system/libraries/User_agent.php122
1 files changed, 106 insertions, 16 deletions
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index b8e0d37fb..ff596f04b 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -38,25 +38,110 @@
*/
class CI_User_agent {
- public $agent = NULL;
+ /**
+ * Current user-agent
+ *
+ * @var string
+ */
+ public $agent = NULL;
+
+ /**
+ * Flag for if the user-agent belongs to a browser
+ *
+ * @var bool
+ */
+ public $is_browser = FALSE;
+
+ /**
+ * Flag for if the user-agent is a robot
+ *
+ * @var bool
+ */
+ public $is_robot = FALSE;
+
+ /**
+ * Flag for if the user-agent is a mobile browser
+ *
+ * @var bool
+ */
+ public $is_mobile = FALSE;
- public $is_browser = FALSE;
- public $is_robot = FALSE;
- public $is_mobile = FALSE;
+ /**
+ * Languages accepted by the current user agent
+ *
+ * @var array
+ */
+ public $languages = array();
+
+ /**
+ * Character sets accepted by the current user agent
+ *
+ * @var array
+ */
+ public $charsets = array();
- public $languages = array();
- public $charsets = array();
+ /**
+ * List of platforms to compare against current user agent
+ *
+ * @var array
+ */
+ public $platforms = array();
- public $platforms = array();
- public $browsers = array();
- public $mobiles = array();
- public $robots = array();
+ /**
+ * List of browsers to compare against current user agent
+ *
+ * @var array
+ */
+ public $browsers = array();
- public $platform = '';
- public $browser = '';
- public $version = '';
- public $mobile = '';
- public $robot = '';
+ /**
+ * List of mobile browsers to compare against current user agent
+ *
+ * @var array
+ */
+ public $mobiles = array();
+
+ /**
+ * List of robots to compare against current user agent
+ *
+ * @var array
+ */
+ public $robots = array();
+
+ /**
+ * Current user-agent platform
+ *
+ * @var string
+ */
+ public $platform = '';
+
+ /**
+ * Current user-agent browser
+ *
+ * @var string
+ */
+ public $browser = '';
+
+ /**
+ * Current user-agent version
+ *
+ * @var string
+ */
+ public $version = '';
+
+ /**
+ * Current user-agent mobile name
+ *
+ * @var string
+ */
+ public $mobile = '';
+
+ /**
+ * Current user-agent robot name
+ *
+ * @var string
+ */
+ public $robot = '';
/**
* Constructor
@@ -245,7 +330,7 @@ class CI_User_agent {
{
foreach ($this->mobiles as $key => $val)
{
- if (FALSE !== (strpos(strtolower($this->agent), $key)))
+ if (FALSE !== (stripos($this->agent, $key)))
{
$this->is_mobile = TRUE;
$this->mobile = $val;
@@ -302,6 +387,7 @@ class CI_User_agent {
/**
* Is Browser
*
+ * @param string $key
* @return bool
*/
public function is_browser($key = NULL)
@@ -326,6 +412,7 @@ class CI_User_agent {
/**
* Is Robot
*
+ * @param string $key
* @return bool
*/
public function is_robot($key = NULL)
@@ -350,6 +437,7 @@ class CI_User_agent {
/**
* Is Mobile
*
+ * @param string $key
* @return bool
*/
public function is_mobile($key = NULL)
@@ -503,6 +591,7 @@ class CI_User_agent {
/**
* Test for a particular language
*
+ * @param string $lang
* @return bool
*/
public function accept_lang($lang = 'en')
@@ -515,6 +604,7 @@ class CI_User_agent {
/**
* Test for a particular character set
*
+ * @param string $charset
* @return bool
*/
public function accept_charset($charset = 'utf-8')