From 6c9f736650bd9eafb2c44bb844f13de259d5efb6 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 9 Oct 2006 03:33:48 +0000 Subject: --- system/libraries/Calendar.php | 42 ++++----- system/libraries/User_agent.php | 178 ++++++++++++++++++++++++++++++++++-- user_guide/libraries/trackback.html | 4 +- user_guide/libraries/uri.html | 2 +- user_guide/nav/nav.js | 1 + 5 files changed, 193 insertions(+), 34 deletions(-) diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 23a6bf791..048934b82 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -398,27 +398,27 @@ class CI_Calendar { function default_template() { return array ( - 'table_open' => '', - 'heading_row_start' => '', - 'heading_previous_cell' => '', - 'heading_title_cell' => '', - 'heading_next_cell' => '', - 'heading_row_end' => '', - 'week_row_start' => '', - 'week_day_cell' => '', - 'week_row_end' => '', - 'cal_row_start' => '', - 'cal_cell_start' => '', - 'cal_cell_end_today' => '', - 'cal_row_end' => '', - 'table_close' => '
<<{heading}>>
{week_day}
', - 'cal_cell_start_today' => '', - 'cal_cell_content' => '{day}', - 'cal_cell_content_today' => '{day}', - 'cal_cell_no_content' => '{day}', - 'cal_cell_no_content_today' => '{day}', - 'cal_cell_blank' => ' ', - 'cal_cell_end' => '
' + 'table_open' => '', + 'heading_row_start' => '', + 'heading_previous_cell' => '', + 'heading_title_cell' => '', + 'heading_next_cell' => '', + 'heading_row_end' => '', + 'week_row_start' => '', + 'week_day_cell' => '', + 'week_row_end' => '', + 'cal_row_start' => '', + 'cal_cell_start' => '', + 'cal_cell_end_today' => '', + 'cal_row_end' => '', + 'table_close' => '
<<{heading}>>
{week_day}
', + 'cal_cell_start_today' => '', + 'cal_cell_content' => '{day}', + 'cal_cell_content_today' => '{day}', + 'cal_cell_no_content' => '{day}', + 'cal_cell_no_content_today' => '{day}', + 'cal_cell_blank' => ' ', + 'cal_cell_end' => '
' ); } diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index 33e8451c6..8c63924b9 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -33,6 +33,9 @@ class CI_User_agent { var $is_browser = FALSE; var $is_robot = FALSE; var $is_mobile = FALSE; + + var $languages = array(); + var $charsets = array(); var $platform = ''; var $browser = ''; @@ -40,7 +43,6 @@ class CI_User_agent { var $moble = ''; var $robot = ''; - var $platforms = array ( 'windows nt 6.0' => 'Windows Longhorn', 'windows nt 5.2' => 'Windows 2003', @@ -55,12 +57,13 @@ class CI_User_agent { 'windows 95' => 'Windows 95', 'win95' => 'Windows 95', 'windows' => 'Unknown Windows OS', - 'mac os x' => 'Mac OS X', + 'os x' => 'Mac OS X', + 'ppc mac' => 'Power PC Mac', 'freebsd' => 'FreeBSD', 'ppc' => 'Macintosh', - 'sunos' => 'Sun Solaris', 'linux' => 'Linux', 'debian' => 'Debian', + 'sunos' => 'Sun Solaris', 'beos' => 'BeOS', 'apachebench' => 'ApacheBench', 'aix' => 'AIX', @@ -80,12 +83,21 @@ class CI_User_agent { 'Internet Explorer' => 'Internet Explorer', 'Shiira' => 'Shiira', 'Firefox' => 'Firefox', + 'Chimera' => 'Chimera', + 'Phoenix' => 'Phoenix', + 'Firebird' => 'Firebird', 'Camino' => 'Camino', + 'Netscape' => 'Netscape', + 'OmniWeb' => 'OmniWeb', 'Mozilla' => 'Mozilla', 'Safari' => 'Safari', 'Konqueror' => 'Konqueror', + 'icab' => 'iCab', 'Lynx' => 'Lynx', - 'ANTFresco' => 'Fresco' + 'Links' => 'Links', + 'hotjava' => 'HotJava', + 'amaya' => 'Amaya', + 'IBrowse' => 'IBrowse' ); var $mobiles = array( @@ -488,7 +500,7 @@ class CI_User_agent { return FALSE; } - + // -------------------------------------------------------------------- /** @@ -535,6 +547,51 @@ class CI_User_agent { return FALSE; } + // -------------------------------------------------------------------- + + /** + * Set the accepted languages + * + * @access private + * @return void + */ + function _set_languages() + { + if ((count($this->languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '') + { + $languages = preg_replace('/(;q=.+)/i', '', $_SERVER['HTTP_ACCEPT_LANGUAGE']); + + $this->languages = explode(',', $languages); + } + + if (count($this->languages) == 0) + { + $this->languages = array('Undefined'); + } + } + + // -------------------------------------------------------------------- + + /** + * Set the accepted character sets + * + * @access private + * @return void + */ + function _set_charsets() + { + if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '') + { + $charsets = preg_replace('/(;q=.+)/i', '', $_SERVER['HTTP_ACCEPT_CHARSET']); + + $this->charsets = explode(',', $charsets); + } + + if (count($this->charsets) == 0) + { + $this->charsets = array('Undefined'); + } + } // -------------------------------------------------------------------- @@ -577,13 +634,39 @@ class CI_User_agent { // -------------------------------------------------------------------- + /** + * Is this a referral from another site? + * + * @access public + * @return bool + */ + function is_referral() + { + return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? FALSE : TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Agent String + * + * @access public + * @return string + */ + function agent() + { + return $this->agent; + } + + // -------------------------------------------------------------------- + /** * Get Platform * * @access public * @return string */ - function get_platform() + function platform() { return $this->platform; } @@ -596,7 +679,7 @@ class CI_User_agent { * @access public * @return string */ - function get_browser() + function browser() { return $this->browser; } @@ -609,7 +692,7 @@ class CI_User_agent { * @access public * @return string */ - function get_version() + function version() { return $this->version; } @@ -622,7 +705,7 @@ class CI_User_agent { * @access public * @return string */ - function get_robot() + function robot() { return $this->robot; } @@ -634,11 +717,86 @@ class CI_User_agent { * @access public * @return string */ - function get_mobile() + function mobile() { return $this->mobile; } + // -------------------------------------------------------------------- + + /** + * Get the referrer + * + * @access public + * @return bool + */ + function referrer() + { + return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? '' : $_SERVER['HTTP_REFERER']; + } + + // -------------------------------------------------------------------- + + /** + * Get the accepted languages + * + * @access public + * @return array + */ + function languages() + { + if (count($this->languages) == 0) + { + $this->_set_languages(); + } + + return $this->languages; + } + + // -------------------------------------------------------------------- + + /** + * Get the accepted Character Sets + * + * @access public + * @return array + */ + function charsets() + { + if (count($this->charsets) == 0) + { + $this->_set_charsets(); + } + + return $this->charsets; + } + + // -------------------------------------------------------------------- + + /** + * Test for a particular language + * + * @access public + * @return bool + */ + function accept_lang($lang = 'en') + { + return (in_array(strtolower($lang), $this->languages(), TRUE)) ? TRUE : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Test for a particular character set + * + * @access public + * @return bool + */ + function accept_charset($charset = 'utf-8') + { + return (in_array(strtolower($charset), $this->charsets(), TRUE)) ? TRUE : FALSE; + } + } diff --git a/user_guide/libraries/trackback.html b/user_guide/libraries/trackback.html index c2c9e815e..0621d4e75 100644 --- a/user_guide/libraries/trackback.html +++ b/user_guide/libraries/trackback.html @@ -238,11 +238,11 @@ It returns TRUE on success and FALSE on failure. If it fails you will issue an diff --git a/user_guide/libraries/uri.html b/user_guide/libraries/uri.html index 8d2f2ee31..e221f4c63 100644 --- a/user_guide/libraries/uri.html +++ b/user_guide/libraries/uri.html @@ -249,7 +249,7 @@ Previous Topic:  Template Parser Class    ·   Top of Page   ·   User Guide Home   ·   -Next Topic:  Validation Class +Next Topic:  User Agent Class

Code Igniter  ·  Copyright © 2006  ·  pMachine, Inc.

diff --git a/user_guide/nav/nav.js b/user_guide/nav/nav.js index 8d1955729..b280e8fc7 100644 --- a/user_guide/nav/nav.js +++ b/user_guide/nav/nav.js @@ -78,6 +78,7 @@ function create_menu(basepath) '
  • Output Class
  • ' + '
  • Pagination Class
  • ' + '
  • Session Class
  • ' + + '
  • Table Class
  • ' + '
  • Trackback Class
  • ' + '
  • Template Parser Class
  • ' + '
  • Unit Testing Class
  • ' + -- cgit v1.2.3-24-g4f1b