From e9ccf74554266bf8122359d4221a228725c54218 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 17:30:10 +0200 Subject: Improve the User agent library --- system/libraries/User_agent.php | 63 ++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 36 deletions(-) (limited to 'system/libraries/User_agent.php') diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index a007acec8..060de695f 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -1,13 +1,13 @@ -languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '') + if ((count($this->languages) === 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '') { - $languages = preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE']))); - - $this->languages = explode(',', $languages); + $this->languages = explode(',', preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])))); } - if (count($this->languages) == 0) + if (count($this->languages) === 0) { $this->languages = array('Undefined'); } @@ -297,14 +295,12 @@ class CI_User_agent { */ private function _set_charsets() { - if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '') + if ((count($this->charsets) === 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '') { - $charsets = preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET']))); - - $this->charsets = explode(',', $charsets); + $this->charsets = explode(',', preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET'])))); } - if (count($this->charsets) == 0) + if (count($this->charsets) === 0) { $this->charsets = array('Undefined'); } @@ -395,11 +391,7 @@ class CI_User_agent { */ public function is_referral() { - if ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') - { - return FALSE; - } - return TRUE; + return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? FALSE : TRUE; } // -------------------------------------------------------------------- @@ -502,7 +494,7 @@ class CI_User_agent { */ public function languages() { - if (count($this->languages) == 0) + if (count($this->languages) === 0) { $this->_set_languages(); } @@ -520,7 +512,7 @@ class CI_User_agent { */ public function charsets() { - if (count($this->charsets) == 0) + if (count($this->charsets) === 0) { $this->_set_charsets(); } @@ -556,6 +548,5 @@ class CI_User_agent { } - /* End of file User_agent.php */ /* Location: ./system/libraries/User_agent.php */ -- cgit v1.2.3-24-g4f1b