CI_User_agent Class Reference

List of all members.


Public Member Functions

 CI_User_agent ()
 Constructor.
 _load_agent_file ()
 Compile the User Agent Data.
 _compile_data ()
 Compile the User Agent Data.
 _set_platform ()
 Set the Platform.
 _set_browser ()
 Set the Browser.
 _set_robot ()
 Set the Robot.
 _set_mobile ()
 Set the Mobile Device.
 _set_languages ()
 Set the accepted languages.
 _set_charsets ()
 Set the accepted character sets.
 is_browser ()
 Is Browser.
 is_robot ()
 Is Robot.
 is_mobile ()
 Is Mobile.
 is_referral ()
 Is this a referral from another site?
 agent_string ()
 Agent String.
 platform ()
 Get Platform.
 browser ()
 Get Browser Name.
 version ()
 Get the Browser Version.
 robot ()
 Get The Robot Name.
 mobile ()
 Get the Mobile Device.
 referrer ()
 Get the referrer.
 languages ()
 Get the accepted languages.
 charsets ()
 Get the accepted Character Sets.
 accept_lang ($lang= 'en')
 Test for a particular language.
 accept_charset ($charset= 'utf-8')
 Test for a particular character set.

Public Attributes

 $agent = NULL
 $is_browser = FALSE
 $is_robot = FALSE
 $is_mobile = FALSE
 $languages = array()
 $charsets = array()
 $platforms = array()
 $browsers = array()
 $mobiles = array()
 $robots = array()
 $platform = ''
 $browser = ''
 $version = ''
 $mobile = ''
 $robot = ''

Detailed Description

Definition at line 29 of file User_agent.php.


Member Function Documentation

CI_User_agent::_compile_data (  ) 

Compile the User Agent Data.

private

Returns:
bool

Definition at line 133 of file User_agent.php.

References _set_platform().

Referenced by CI_User_agent().

00134         {
00135                 $this->_set_platform();
00136         
00137                 foreach (array('_set_browser', '_set_robot', '_set_mobile') as $function)
00138                 {
00139                         if ($this->$function() === TRUE)
00140                         {
00141                                 break;
00142                         }
00143                 }       
00144         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_User_agent::_load_agent_file (  ) 

Compile the User Agent Data.

private

Returns:
bool

Definition at line 85 of file User_agent.php.

References $browsers, $mobiles, $platforms, and $robots.

Referenced by CI_User_agent().

00086         {
00087                 if ( ! @include(APPPATH.'config/user_agents'.EXT))
00088                 {
00089                         return FALSE;
00090                 }
00091                 
00092                 $return = FALSE;
00093                 
00094                 if (isset($platforms))
00095                 {
00096                         $this->platforms = $platforms;
00097                         unset($platforms);
00098                         $return = TRUE;
00099                 }
00100 
00101                 if (isset($browsers))
00102                 {
00103                         $this->browsers = $browsers;
00104                         unset($browsers);
00105                         $return = TRUE;
00106                 }
00107 
00108                 if (isset($mobiles))
00109                 {
00110                         $this->mobiles = $mobiles;
00111                         unset($mobiles);
00112                         $return = TRUE;
00113                 }
00114                 
00115                 if (isset($robots))
00116                 {
00117                         $this->robots = $robots;
00118                         unset($robots);
00119                         $return = TRUE;
00120                 }
00121 
00122                 return $return;
00123         }

Here is the caller graph for this function:

CI_User_agent::_set_browser (  ) 

Set the Browser.

private

Returns:
bool

Definition at line 178 of file User_agent.php.

References _set_mobile(), browser(), is_browser(), and version().

00179         {
00180                 if (is_array($this->browsers) AND count($this->browsers) > 0)
00181                 {
00182                         foreach ($this->browsers as $key => $val)
00183                         {               
00184                                 if (preg_match("|".preg_quote($key).".*?([0-9\.]+)|i", $this->agent, $match))
00185                                 {
00186                                         $this->is_browser = TRUE;
00187                                         $this->version = $match[1];
00188                                         $this->browser = $val;
00189                                         $this->_set_mobile();
00190                                         return TRUE;
00191                                 }
00192                         }
00193                 }
00194                 return FALSE;
00195         }

Here is the call graph for this function:

CI_User_agent::_set_charsets (  ) 

Set the accepted character sets.

private

Returns:
void

Definition at line 278 of file User_agent.php.

References $charsets, and charsets().

Referenced by charsets().

00279         {       
00280                 if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '')
00281                 {
00282                         $charsets = preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET'])));
00283                         
00284                         $this->charsets = explode(',', $charsets);
00285                 }
00286                 
00287                 if (count($this->charsets) == 0)
00288                 {
00289                         $this->charsets = array('Undefined');
00290                 }       
00291         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_User_agent::_set_languages (  ) 

Set the accepted languages.

private

Returns:
void

Definition at line 255 of file User_agent.php.

References $languages, and languages().

Referenced by languages().

00256         {
00257                 if ((count($this->languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '')
00258                 {
00259                         $languages = preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])));
00260                         
00261                         $this->languages = explode(',', $languages);
00262                 }
00263                 
00264                 if (count($this->languages) == 0)
00265                 {
00266                         $this->languages = array('Undefined');
00267                 }       
00268         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_User_agent::_set_mobile (  ) 

Set the Mobile Device.

private

Returns:
bool

Definition at line 230 of file User_agent.php.

References is_mobile(), and mobile().

Referenced by _set_browser().

00231         {
00232                 if (is_array($this->mobiles) AND count($this->mobiles) > 0)
00233                 {               
00234                         foreach ($this->mobiles as $key => $val)
00235                         {
00236                                 if (FALSE !== (strpos(strtolower($this->agent), $key)))
00237                                 {
00238                                         $this->is_mobile = TRUE;
00239                                         $this->mobile = $val;
00240                                         return TRUE;
00241                                 }
00242                         }
00243                 }       
00244                 return FALSE;
00245         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_User_agent::_set_platform (  ) 

Set the Platform.

private

Returns:
mixed

Definition at line 154 of file User_agent.php.

References platform().

Referenced by _compile_data().

00155         {
00156                 if (is_array($this->platforms) AND count($this->platforms) > 0)
00157                 {
00158                         foreach ($this->platforms as $key => $val)
00159                         {
00160                                 if (preg_match("|".preg_quote($key)."|i", $this->agent))
00161                                 {
00162                                         $this->platform = $val;
00163                                         return TRUE;
00164                                 }
00165                         }
00166                 }
00167                 $this->platform = 'Unknown Platform';
00168         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_User_agent::_set_robot (  ) 

Set the Robot.

private

Returns:
bool

Definition at line 205 of file User_agent.php.

References is_robot(), and robot().

00206         {
00207                 if (is_array($this->robots) AND count($this->robots) > 0)
00208                 {               
00209                         foreach ($this->robots as $key => $val)
00210                         {
00211                                 if (preg_match("|".preg_quote($key)."|i", $this->agent))
00212                                 {
00213                                         $this->is_robot = TRUE;
00214                                         $this->robot = $val;
00215                                         return TRUE;
00216                                 }
00217                         }
00218                 }
00219                 return FALSE;
00220         }

Here is the call graph for this function:

CI_User_agent::accept_charset ( charset = 'utf-8'  ) 

Test for a particular character set.

public

Returns:
bool

Definition at line 492 of file User_agent.php.

References charsets().

00493         {
00494                 return (in_array(strtolower($charset), $this->charsets(), TRUE)) ? TRUE : FALSE;
00495         }

Here is the call graph for this function:

CI_User_agent::accept_lang ( lang = 'en'  ) 

Test for a particular language.

public

Returns:
bool

Definition at line 479 of file User_agent.php.

References $lang, and languages().

00480         {
00481                 return (in_array(strtolower($lang), $this->languages(), TRUE)) ? TRUE : FALSE;
00482         }

Here is the call graph for this function:

CI_User_agent::agent_string (  ) 

Agent String.

public

Returns:
string

Definition at line 353 of file User_agent.php.

00354         {
00355                 return $this->agent;
00356         }

CI_User_agent::browser (  ) 

Get Browser Name.

public

Returns:
string

Definition at line 379 of file User_agent.php.

Referenced by _set_browser().

00380         {
00381                 return $this->browser;
00382         }

Here is the caller graph for this function:

CI_User_agent::charsets (  ) 

Get the accepted Character Sets.

public

Returns:
array

Definition at line 461 of file User_agent.php.

References _set_charsets().

Referenced by _set_charsets(), and accept_charset().

00462         {
00463                 if (count($this->charsets) == 0)
00464                 {
00465                         $this->_set_charsets();
00466                 }
00467         
00468                 return $this->charsets;
00469         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_User_agent::CI_User_agent (  ) 

Constructor.

Sets the User Agent and runs the compilation routine

public

Returns:
void

Definition at line 59 of file User_agent.php.

References _compile_data(), _load_agent_file(), and log_message().

00060         {
00061                 if (isset($_SERVER['HTTP_USER_AGENT']))
00062                 {
00063                         $this->agent = trim($_SERVER['HTTP_USER_AGENT']);
00064                 }
00065                 
00066                 if ( ! is_null($this->agent))
00067                 {
00068                         if ($this->_load_agent_file())
00069                         {
00070                                 $this->_compile_data();
00071                         }
00072                 }
00073                 
00074                 log_message('debug', "User Agent Class Initialized");
00075         }

Here is the call graph for this function:

CI_User_agent::is_browser (  ) 

Is Browser.

public

Returns:
bool

Definition at line 301 of file User_agent.php.

Referenced by _set_browser().

00302         {
00303                 return $this->is_browser;
00304         }

Here is the caller graph for this function:

CI_User_agent::is_mobile (  ) 

Is Mobile.

public

Returns:
bool

Definition at line 327 of file User_agent.php.

Referenced by _set_mobile().

00328         {
00329                 return $this->is_mobile;
00330         }       

Here is the caller graph for this function:

CI_User_agent::is_referral (  ) 

Is this a referral from another site?

public

Returns:
bool

Definition at line 340 of file User_agent.php.

00341         {
00342                 return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? FALSE : TRUE;
00343         }

CI_User_agent::is_robot (  ) 

Is Robot.

public

Returns:
bool

Definition at line 314 of file User_agent.php.

Referenced by _set_robot().

00315         {
00316                 return $this->is_robot;
00317         }

Here is the caller graph for this function:

CI_User_agent::languages (  ) 

Get the accepted languages.

public

Returns:
array

Definition at line 443 of file User_agent.php.

References _set_languages().

Referenced by _set_languages(), and accept_lang().

00444         {
00445                 if (count($this->languages) == 0)
00446                 {
00447                         $this->_set_languages();
00448                 }
00449         
00450                 return $this->languages;
00451         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_User_agent::mobile (  ) 

Get the Mobile Device.

public

Returns:
string

Definition at line 417 of file User_agent.php.

Referenced by _set_mobile().

00418         {
00419                 return $this->mobile;
00420         }

Here is the caller graph for this function:

CI_User_agent::platform (  ) 

Get Platform.

public

Returns:
string

Definition at line 366 of file User_agent.php.

Referenced by _set_platform().

00367         {
00368                 return $this->platform;
00369         }

Here is the caller graph for this function:

CI_User_agent::referrer (  ) 

Get the referrer.

public

Returns:
bool

Definition at line 430 of file User_agent.php.

00431         {
00432                 return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? '' : trim($_SERVER['HTTP_REFERER']);
00433         }

CI_User_agent::robot (  ) 

Get The Robot Name.

public

Returns:
string

Definition at line 405 of file User_agent.php.

Referenced by _set_robot().

00406         {
00407                 return $this->robot;
00408         }

Here is the caller graph for this function:

CI_User_agent::version (  ) 

Get the Browser Version.

public

Returns:
string

Definition at line 392 of file User_agent.php.

Referenced by _set_browser().

00393         {
00394                 return $this->version;
00395         }

Here is the caller graph for this function:


Member Data Documentation

CI_User_agent::$agent = NULL

Definition at line 31 of file User_agent.php.

CI_User_agent::$browser = ''

Definition at line 46 of file User_agent.php.

CI_User_agent::$browsers = array()

Definition at line 41 of file User_agent.php.

Referenced by _load_agent_file().

CI_User_agent::$charsets = array()

Definition at line 38 of file User_agent.php.

Referenced by _set_charsets().

CI_User_agent::$is_browser = FALSE

Definition at line 33 of file User_agent.php.

CI_User_agent::$is_mobile = FALSE

Definition at line 35 of file User_agent.php.

CI_User_agent::$is_robot = FALSE

Definition at line 34 of file User_agent.php.

CI_User_agent::$languages = array()

Definition at line 37 of file User_agent.php.

Referenced by _set_languages().

CI_User_agent::$mobile = ''

Definition at line 48 of file User_agent.php.

CI_User_agent::$mobiles = array()

Definition at line 42 of file User_agent.php.

Referenced by _load_agent_file().

CI_User_agent::$platform = ''

Definition at line 45 of file User_agent.php.

CI_User_agent::$platforms = array()

Definition at line 40 of file User_agent.php.

Referenced by _load_agent_file().

CI_User_agent::$robot = ''

Definition at line 49 of file User_agent.php.

CI_User_agent::$robots = array()

Definition at line 43 of file User_agent.php.

Referenced by _load_agent_file().

CI_User_agent::$version = ''

Definition at line 47 of file User_agent.php.


The documentation for this class was generated from the following file: