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

Class: tera_wurfl

Source Location: /tera_wurfl.php

Class Overview


Tera-WURFL was written by Steve Kamerman, Tera Technologies and is based on the WURFL PHP Tools from http://wurfl.sourceforge.net/. This version uses a MySQL database to store the entire WURFL file to provide extreme performance increases.


Variables

Methods



Class Details

[line 58]
Tera-WURFL was written by Steve Kamerman, Tera Technologies and is based on the WURFL PHP Tools from http://wurfl.sourceforge.net/. This version uses a MySQL database to store the entire WURFL file to provide extreme performance increases.

See the documentation for specific usage information. Quick Example:

  1.  $myDevice new tera_wurfl();
  2.  $myDevice->getDeviceCapabilitiesFromAgent($_SERVER['HTTP_USER_AGENT');
  3.  // see if this device is really a mobile browser
  4.   if($myDevice->browser_is_wap){
  5.      // check capabilities
  6.         if($myDevice->capabilities['downloadfun']['downloadfun_support']){
  7.         echo "downloadfun supported<br />";
  8.     }else{
  9.         echo "WAP is supported, downloadfun is not<br />";
  10.      }
  11.     if($myDevice->device_image != ''){
  12.          // display device image
  13.                   echo '<img src="'.$myDevice->device_image.'" /><br />';
  14.      }
  15.  }




[ Top ]


Class Variables

$brand = ''

[line 78]

Device brand (manufacturer)



Tags:

access:  public

Type:   string


[ Top ]

$browser_is_wap = false

[line 92]

If this is a WAP device, this is set to true



Tags:

access:  public

Type:   boolean


[ Top ]

$capabilities = array()

[line 103]

associative array with all the device's capabilities.

Example: $this->capabilities['downloadfun']['downloadfun_support'] true if downloadfun is supported, otherwise false




Tags:

var:  array
access:  public

Type:   associative


[ Top ]

$device_image =  ''

[line 165]

Device image path and filename, relative to the class file



Tags:

access:  public

Type:   string


[ Top ]

$device_root =  ''

[line 157]

WURFL ID of the ancestoral device root This is the ID of the actual device, not a firmware revision



Tags:

access:  public

Type:   string


[ Top ]

$errors = array()

[line 133]

Track errors Anytime a LOG_ERR level event occurs, a description is added to the end of the array.

Example: echo count($this->$errors); // echos number of errors




Tags:

access:  public

Type:   array


[ Top ]

$found_in_cache =  false

[line 181]

True if the UA was found in the cache



Tags:

access:  public

Type:   boolean


[ Top ]

$GUI = false

[line 71]

If true, Openwave's GUI (mostly wml 1.3) is supported



Tags:

access:  public

Type:   bool


[ Top ]

$http_accept = ""

[line 113]

HTTP_ACCEPT request headers Use this to manually set the http-accept string:

Example: $this->http_accept = "text/vnd.wap.wml";




Tags:

access:  public

Type:   string


[ Top ]

$ignoreBrowser = false

[line 123]

Ignore desktop browser Set this to false if you want to search the WURFL/patch for desktop web browsers as well.



Tags:

access:  public

Type:   string


[ Top ]

$model = ''

[line 85]

Device model name



Tags:

access:  public

Type:   string


[ Top ]

$num_queries =  0

[line 173]

Total number of queries performed



Tags:

access:  public

Type:   number


[ Top ]



Class Methods


constructor tera_wurfl [line 191]

boolean tera_wurfl( )

Constructor, sets the http_accept property and connects to the WURFL database.

You don't need to call the constructor - it is called when you instantiate the class




Tags:

return:  success
access:  public


[ Top ]

method clearErrors [line 628]

boolean clearErrors( )

Clears any LOG_ERR level errors that were detected. This will allow you to continue testing other user agents after an error is detected.

Example:

  1.  $myDevice new tera_wurfl();
  2.  // this will throw an error and prevent the methods from working
  3.   $myDevice->getDeviceCapabilitiesFromAgent("");
  4.  // clear any errors
  5.   $myDevice->clearErrors();
  6.  // now we can check another user agent
  7.   $myDevice->getDeviceCapabilitiesFromAgent("MOT-V3");




Tags:

return:  true
access:  public


[ Top ]

method getDeviceCapabilitiesFromAgent [line 335]

boolean getDeviceCapabilitiesFromAgent( string $_user_agent, [boolean $_check_accept = false])

Given the user_agent reads the device's capabilities.

This method will return true or false based on its success. After calling this function, the following properties will be accessible (on success):

  • $this->brand
  • $this->model
  • $this->browser_is_wap
  • $this->capabilities
  • $this->device_root
  • $this->device_image (if enabled)
  • $this->errors
  • $this->GUI

Example:

  1.  $myDevice new tera_wurfl();
  2.  // get the capabilities of your device
  3.   $myDevice->getDeviceCapabilitiesFromAgent($_SERVER['HTTP_USER_AGENT');
  4.  echo "Device: ".$myDevice->brand." ".$myDevice->model."<br />";




Tags:

return:  success
access:  public


Parameters:

string   $_user_agent   device's user_agent
boolean   $_check_accept   check the HTTP-ACCEPT headers if needed

[ Top ]

method getDeviceCapability [line 592]

mixed getDeviceCapability( string $capability)

Given a capability name returns the value (true|false|<anythingelse>). This is helpful if you don't know the group that the capability is in.

Example:

  1.  $myDevice new tera_wurfl();
  2.  // get the capabilities of your device
  3.   $callstring $myDevice->getDeviceCapability('wml_make_phone_call_string');
  4.  echo "<a href=\"$callstring6161234567\">Call me</a>";




Tags:

return:  boolean success or other string if specified in the WURFL
access:  public


Parameters:

string   $capability   capability name as a string

[ Top ]


Documentation generated on Fri, 27 Apr 2007 12:10:18 -0400 by phpDocumentor 1.3.1