From dac1b468d5432ff9166fe221ac520b5050a65f0e Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 6 Jan 2011 17:40:10 +0000 Subject: Altered User agent library so that is_browser(), is_mobile() and is_robot() can optionally check for a specific browser or mobile device. --- user_guide/changelog.html | 1 + user_guide/libraries/user_agent.html | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'user_guide') diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 09efc5434..a6332d64d 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -113,6 +113,7 @@ Hg Tag:

  • Altered Form_Validation library to allow for method chaining on set_rules(), set_message() and set_error_delimiters() functions.
  • Altered Email Library to allow for method chaining.
  • Added request_headers(), get_request_header() and is_ajax_request() to the input class.
  • +
  • Altered User agent library so that is_browser(), is_mobile() and is_robot() can optionally check for a specific browser or mobile device.
  • Database diff --git a/user_guide/libraries/user_agent.html b/user_guide/libraries/user_agent.html index 944f1ed86..d2f79d2ec 100644 --- a/user_guide/libraries/user_agent.html +++ b/user_guide/libraries/user_agent.html @@ -111,9 +111,34 @@ echo $this->agent->platform(); // Platform info (Windows, Linux, Mac, etc.)

    $this->agent->is_browser()

    Returns TRUE/FALSE (boolean) if the user agent is a known web browser.

    + if ($this->agent->is_browser('Safari'))
    +{
    +    echo 'You are using Safari.';
    +}
    +else if ($this->agent->is_browser())
    +{
    +    echo 'You are using a browser.';
    +}
    + +

    Note:  The string "Safari" in this example is an array key in the list of browser definitions. +You can find this list in application/config/user_agents.php if you want to add new browsers or change the stings.

    +

    $this->agent->is_mobile()

    Returns TRUE/FALSE (boolean) if the user agent is a known mobile device.

    + if ($this->agent->is_mobile('iphone'))
    +{
    +    $this->load->view('iphone/home');
    +}
    +else if ($this->agent->is_mobile())
    +{
    +    $this->load->view('mobile/home');
    +}
    +else
    +{
    +    $this->load->view('web/home');
    +}
    +

    $this->agent->is_robot()

    Returns TRUE/FALSE (boolean) if the user agent is a known robot.

    -- cgit v1.2.3-24-g4f1b