Net_UserAgent
[ class tree: Net_UserAgent ] [ index: Net_UserAgent ] [ all elements ]

Class: Net_UserAgent_Detect

Source Location: /Net_UserAgent_Detect-2.5.2/Detect.php

Class Overview


The Net_UserAgent_Detect object does a number of tests on an HTTP user


Author(s):

Methods


Child classes:

Net_UserAgent_Detect_APC
Net_UserAgent_Detect_APC

Inherited Variables

Inherited Methods


Class Details

[line 56]
The Net_UserAgent_Detect object does a number of tests on an HTTP user

agent string. The results of these tests are available via methods of the object. Note that all methods in this class can be called statically. The constructor and singleton methods are only retained for BC.

This module is based upon the JavaScript browser detection code available at http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html. This module had many influences from the lib/Browser.php code in version 1.3 of Horde.



[ Top ]


Method Detail

Net_UserAgent_Detect (Constructor)   [line 59]

Net_UserAgent_Detect Net_UserAgent_Detect( [ $in_userAgent = null], [ $in_detect = null])


Parameters:

   $in_userAgent   — 
   $in_detect   — 

[ Top ]

detect   [line 105]

void detect( [string $in_userAgent = null], [mixed $in_detect = null])

Detect the user agent and prepare flags, features and quirks based on what is found

This is the core of the Net_UserAgent_Detect class. It moves its way through the user agent string setting up the flags based on the vendors and versions of the browsers, determining the OS and setting up the features and quirks owned by each of the relevant clients. Note that if you are going to be calling methods of this class statically then set all the parameters using th setOption()

  • Access: public

Parameters:

string   $in_userAgent   —  (optional) User agent override.
mixed   $in_detect   —  (optional) The level of checking to do.

[ Top ]

getAcceptType   [line 891]

string getAcceptType( string $in_expectList, string $in_type)

Retrive the accept type for the current browser.

To keep track of the mime-types, languages, charsets and encodings that each browser accepts we use associative arrays for each type. This function works like getBrowser() as it takes an expect list and returns the first match. For instance, to find the language you would pass in your allowed languages and see if any of the languages set in the browser match.

  • Return: the first matched value
  • Access: public

Parameters:

string   $in_expectList   —  values to check
string   $in_type   —  type of accept

[ Top ]

getBrowser   [line 520]

string getBrowser( array $in_expectList)

Since simply returning the "browser" is somewhat ambiguous since there are different ways to classify the browser, this function works by taking an expect list and returning the string of the first match, so put the important ones first in the array.
  • Return: first flag that matches
  • Access: public

Parameters:

array   $in_expectList   —  the browser flags to search for

[ Top ]

getBrowserString   [line 548]

string getBrowserString( [array $in_vendorStrings = null])

This function returns the vendor string corresponding to the flag.

Either use the default matches or pass in an associative array of flags and corresponding vendor strings. This function will find the highest version flag and return the vendor string corresponding to the appropriate flag. Be sure to pass in the flags in ascending order if you want a basic matches first, followed by more detailed matches.

  • Return: vendor string matches appropriate flag
  • Access: public

Parameters:

array   $in_vendorStrings   —  (optional) array of flags matched with vendor strings

[ Top ]

getFeature   [line 865]

string getFeature( string $in_feature)

Get the capabilities for the current browser.

Since the capabilities of client browsers vary widly, this interface helps keep track of the core features of a client, such as if the client supports dhtml, dom, javascript, etc.

  • Return: value of the feature requested
  • Access: public

Parameters:

string   $in_feature   —  The feature to detect

[ Top ]

getOS   [line 679]

string getOS( $in_expectList)

Since simply returning the "os" is somewhat ambiguous since there are different ways to classify the browser, this function works by taking an expect list and returning the string of the first match, so put the important ones first in the array.
  • Return: first flag that matches
  • Access: public

Parameters:

   $in_expectList   — 

[ Top ]

getOSString   [line 707]

string getOSString( [array $in_osStrings = null])

This function returns the os string corresponding to the flag.

Either use the default matches or pass in an associative array of flags and corresponding os strings. This function will find the highest version flag and return the os string corresponding to the appropriate flag. Be sure to pass in the flags in ascending order if you want a basic matches first, followed by more detailed matches.

  • Return: os string matches appropriate flag
  • Access: public

Parameters:

array   $in_osStrings   —  (optional) array of flags matched with os strings

[ Top ]

getQuirk   [line 801]

string getQuirk( string $in_quirk)

Get the unique behavior for the current browser.

Many client browsers do some really funky things, and this mechanism allows the coder to determine if an excepetion must be made with the current client.

  • Return: value of the quirk, in this case usually a boolean
  • Access: public

Parameters:

string   $in_quirk   —  The quirk to detect

[ Top ]

getUserAgent   [line 968]

string getUserAgent( )

Return the user agent string that is being worked on
  • Return: user agent
  • Access: public

[ Top ]

hasAcceptType   [line 954]

bool hasAcceptType( string $in_value, string $in_type)

Check the accept types for the current browser.

To keep track of the mime-types, languages, charsets and encodings that each browser accepts we use associative arrays for each type. This function checks the array for the given type and determines if the browser accepts it.

  • Return: whether or not the value is accept for this type
  • Access: public

Parameters:

string   $in_value   —  values to check
string   $in_type   —  type of accept

[ Top ]

hasFeature   [line 845]

bool hasFeature( string $in_feature)

Check the capabilities for the current browser.

Since the capabilities of client browsers vary widly, this interface helps keep track of the core features of a client, such as if the client supports dhtml, dom, javascript, etc.

  • Return: whether or not the current client has this feature
  • Access: public

Parameters:

string   $in_feature   —  The feature to detect

[ Top ]

hasQuirk   [line 781]

bool hasQuirk( string $in_quirk)

Check a unique behavior for the current browser.

Many client browsers do some really funky things, and this mechanism allows the coder to determine if an excepetion must be made with the current client.

  • Return: whether or not browser has this quirk
  • Access: public

Parameters:

string   $in_quirk   —  The quirk to detect

[ Top ]

isBrowser   [line 499]

boolean isBrowser( string $in_match)

Look up the provide browser flag and return a boolean value

Given one of the flags listed in the properties, this function will return the value associated with that flag.

  • Return: whether or not the browser satisfies this flag
  • Access: public

Parameters:

string   $in_match   —  flag to lookup

[ Top ]

isIE   [line 603]

bool isIE( )

Determine if the browser is an Internet Explorer browser
  • Return: whether or not this browser is an ie browser
  • Access: public

[ Top ]

isNavigator   [line 619]

bool isNavigator( )

Determine if the browser is a Netscape Navigator browser
  • Return: whether or not this browser is a Netscape Navigator browser
  • Access: public

[ Top ]

isNetscape   [line 639]

bool isNetscape( )

Determine if the browser is a Netscape or Mozilla browser

Note that this function is not the same as isNavigator, since the new Mozilla browsers are still sponsered by Netscape, and hence are Netscape products, but not the original Navigators

  • Return: whether or not this browser is a Netscape product
  • Access: public

[ Top ]

isOS   [line 660]

boolean isOS( string $in_match)

Look up the provide OS flag and return a boolean value

Given one of the flags listed in the properties, this function will return the value associated with that flag for the operating system.

  • Return: whether or not the OS satisfies this flag
  • Access: public

Parameters:

string   $in_match   —  flag to lookup

[ Top ]

setAcceptType   [line 925]

void setAcceptType( array $in_values, string $in_type)

Set the accept types for the current browser.

To keep track of the mime-types, languages, charsets and encodings that each browser accepts we use associative arrays for each type. This function takes and array of accepted values for the type and records them for retrieval.

  • Access: public

Parameters:

array   $in_values   —  values of the accept type
string   $in_type   —  type of accept

[ Top ]

setFeature   [line 824]

void setFeature( string $in_feature, [string $in_hasFeature = true])

Set capabilities for the current browser.

Since the capabilities of client browsers vary widly, this interface helps keep track of the core features of a client, such as if the client supports dhtml, dom, javascript, etc.

  • Access: public

Parameters:

string   $in_feature   —  The feature to set
string   $in_hasFeature   —  (optional) Does the browser have the feature?

[ Top ]

setOption   [line 479]

void setOption( string $in_field, mixed $in_value)

Sets a class option. The available settings are:
  • 'userAgent' => The user agent string to detect (useful for
checking a string manually).

  • 'detectOptions' => The level of checking to do. A single level
  • r an array of options. Default is NET_USERAGENT_DETECT_ALL.


Parameters:

string   $in_field   —  The option field (userAgent or detectOptions)
mixed   $in_value   —  The value for the field

[ Top ]

setQuirk   [line 759]

void setQuirk( string $in_quirk, [string $in_hasQuirk = true])

Set a unique behavior for the current browser.

Many client browsers do some really funky things, and this mechanism allows the coder to determine if an excepetion must be made with the current client.

  • Access: public

Parameters:

string   $in_quirk   —  The quirk to set
string   $in_hasQuirk   —  (optional) Does the browser have the quirk?

[ Top ]

singleton   [line 73]

object Net_UserAgent_Detect &singleton( [ $in_userAgent = null], [ $in_detect = null])

To be used in place of the contructor to return only open instance.
  • Return: instance
  • Access: public

Overridden in child classes as:

Net_UserAgent_Detect_APC::singleton()
To be used in place of the contructor to return only open instance.

Parameters:

   $in_userAgent   — 
   $in_detect   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:37:06 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.