diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-01-03 10:01:50 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-01-03 10:01:50 +0100 |
commit | 166396ed9e03f78444970372983d50fd34a5ca96 (patch) | |
tree | f209bdbc89c0e4310ebf772299e0bd7e7ecef68d /system/libraries/User_agent.php | |
parent | b195637240bbbc7c3dc7ee0585f0e4cd39cb9d81 (diff) | |
parent | 29e1122c19c532b7299598fb7ddfb7f15264ad78 (diff) |
Merge remote-tracking branch 'upstream/develop' into develop-xmlrpc
Diffstat (limited to 'system/libraries/User_agent.php')
-rw-r--r-- | system/libraries/User_agent.php | 105 |
1 files changed, 36 insertions, 69 deletions
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index a007acec8..cd644c00d 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -1,13 +1,13 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * CodeIgniter * * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 @@ -40,32 +40,31 @@ */ class CI_User_agent { - var $agent = NULL; + public $agent = NULL; - var $is_browser = FALSE; - var $is_robot = FALSE; - var $is_mobile = FALSE; + public $is_browser = FALSE; + public $is_robot = FALSE; + public $is_mobile = FALSE; - var $languages = array(); - var $charsets = array(); + public $languages = array(); + public $charsets = array(); - var $platforms = array(); - var $browsers = array(); - var $mobiles = array(); - var $robots = array(); + public $platforms = array(); + public $browsers = array(); + public $mobiles = array(); + public $robots = array(); - var $platform = ''; - var $browser = ''; - var $version = ''; - var $mobile = ''; - var $robot = ''; + public $platform = ''; + public $browser = ''; + public $version = ''; + public $mobile = ''; + public $robot = ''; /** * Constructor * * Sets the User Agent and runs the compilation routine * - * @access public * @return void */ public function __construct() @@ -91,10 +90,9 @@ class CI_User_agent { /** * Compile the User Agent Data * - * @access private * @return bool */ - private function _load_agent_file() + protected function _load_agent_file() { if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php')) { @@ -147,10 +145,9 @@ class CI_User_agent { /** * Compile the User Agent Data * - * @access private * @return bool */ - private function _compile_data() + protected function _compile_data() { $this->_set_platform(); @@ -168,10 +165,9 @@ class CI_User_agent { /** * Set the Platform * - * @access private * @return mixed */ - private function _set_platform() + protected function _set_platform() { if (is_array($this->platforms) AND count($this->platforms) > 0) { @@ -192,10 +188,9 @@ class CI_User_agent { /** * Set the Browser * - * @access private * @return bool */ - private function _set_browser() + protected function _set_browser() { if (is_array($this->browsers) AND count($this->browsers) > 0) { @@ -219,10 +214,9 @@ class CI_User_agent { /** * Set the Robot * - * @access private * @return bool */ - private function _set_robot() + protected function _set_robot() { if (is_array($this->robots) AND count($this->robots) > 0) { @@ -244,10 +238,9 @@ class CI_User_agent { /** * Set the Mobile Device * - * @access private * @return bool */ - private function _set_mobile() + protected function _set_mobile() { if (is_array($this->mobiles) AND count($this->mobiles) > 0) { @@ -269,19 +262,16 @@ class CI_User_agent { /** * Set the accepted languages * - * @access private * @return void */ - private function _set_languages() + protected function _set_languages() { - if ((count($this->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'); } @@ -292,19 +282,16 @@ class CI_User_agent { /** * Set the accepted character sets * - * @access private * @return void */ - private function _set_charsets() + protected 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'); } @@ -315,7 +302,6 @@ class CI_User_agent { /** * Is Browser * - * @access public * @return bool */ public function is_browser($key = NULL) @@ -340,7 +326,6 @@ class CI_User_agent { /** * Is Robot * - * @access public * @return bool */ public function is_robot($key = NULL) @@ -365,7 +350,6 @@ class CI_User_agent { /** * Is Mobile * - * @access public * @return bool */ public function is_mobile($key = NULL) @@ -390,16 +374,11 @@ class CI_User_agent { /** * Is this a referral from another site? * - * @access public * @return bool */ 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; } // -------------------------------------------------------------------- @@ -407,7 +386,6 @@ class CI_User_agent { /** * Agent String * - * @access public * @return string */ public function agent_string() @@ -420,7 +398,6 @@ class CI_User_agent { /** * Get Platform * - * @access public * @return string */ public function platform() @@ -433,7 +410,6 @@ class CI_User_agent { /** * Get Browser Name * - * @access public * @return string */ public function browser() @@ -446,7 +422,6 @@ class CI_User_agent { /** * Get the Browser Version * - * @access public * @return string */ public function version() @@ -459,7 +434,6 @@ class CI_User_agent { /** * Get The Robot Name * - * @access public * @return string */ public function robot() @@ -471,7 +445,6 @@ class CI_User_agent { /** * Get the Mobile Device * - * @access public * @return string */ public function mobile() @@ -484,7 +457,6 @@ class CI_User_agent { /** * Get the referrer * - * @access public * @return bool */ public function referrer() @@ -497,12 +469,11 @@ class CI_User_agent { /** * Get the accepted languages * - * @access public * @return array */ public function languages() { - if (count($this->languages) == 0) + if (count($this->languages) === 0) { $this->_set_languages(); } @@ -515,12 +486,11 @@ class CI_User_agent { /** * Get the accepted Character Sets * - * @access public * @return array */ public function charsets() { - if (count($this->charsets) == 0) + if (count($this->charsets) === 0) { $this->_set_charsets(); } @@ -533,7 +503,6 @@ class CI_User_agent { /** * Test for a particular language * - * @access public * @return bool */ public function accept_lang($lang = 'en') @@ -546,7 +515,6 @@ class CI_User_agent { /** * Test for a particular character set * - * @access public * @return bool */ public function accept_charset($charset = 'utf-8') @@ -556,6 +524,5 @@ class CI_User_agent { } - /* End of file User_agent.php */ /* Location: ./system/libraries/User_agent.php */ |