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

Source for file SimpleDesktopUserAgentMatcher.php

Documentation is available at SimpleDesktopUserAgentMatcher.php

  1. <?php
  2. /**
  3.  * Tera_WURFL - PHP MySQL driven WURFL
  4.  * 
  5.  * Tera-WURFL was written by Steve Kamerman, and is based on the
  6.  * Java WURFL Evolution package by Luca Passani and WURFL PHP Tools by Andrea Trassati.
  7.  * This version uses a MySQL database to store the entire WURFL file, multiple patch
  8.  * files, and a persistent caching mechanism to provide extreme performance increases.
  9.  * 
  10.  * @package TeraWurflUserAgentMatchers
  11.  * @author Steve Kamerman <stevekamerman AT gmail.com>
  12.  * @version Stable 2.1.3 $Date: 2010/09/18 15:43:21
  13.  * @license http://www.mozilla.org/MPL/ MPL Vesion 1.1
  14.  */
  15. /**
  16.  * Matches desktop browsers.  This UserAgentMatcher is unlike the rest in that it is does not use any database functions to find a matching device.  If a device is not matched with this UserAgentMatcher, another one is assigned to match it using the database.
  17.  * @package TeraWurflUserAgentMatchers
  18.  */
  19.     public function __construct(TeraWurfl $wurfl){
  20.         parent::__construct($wurfl);
  21.     }
  22.     public function applyConclusiveMatch($ua{
  23.         return WurflConstants::$GENERIC_WEB_BROWSER;
  24.     }
  25.     /**
  26.      * Is the given user agent very likely to be a desktop browser
  27.      * @param String User agent
  28.      * @return Bool 
  29.      */
  30.     public static function isDesktopBrowser($ua){
  31.         if(UserAgentUtils::isMobileBrowser($ua)) return false;
  32.         if(self::contains($ua,array(
  33.             'HTC'// HTC; horrible user agents, especially with Opera
  34.             'PPC'// PowerPC; not always mobile, but we'll kick it out of SimpleDesktop and match it in the WURFL DB
  35.             'Nintendo' // too hard to distinguish from Opera
  36.         ))) return false;
  37.         // Firefox
  38.         if(self::contains($ua,"Firefox"&& !self::contains($ua,'Tablet')) return true;
  39.         if(UserAgentUtils::isDesktopBrowser($ua)) return true;
  40.         if(self::startsWith($ua,'Opera/')) return true;
  41.         if(self::regexContains($ua,array(
  42. //            // Opera
  43. //            '/Opera\/\d/',
  44.             // Internet Explorer
  45.             '/^Mozilla\/4\.0 \(compatible; MSIE \d.\d; Windows NT \d.\d/'
  46.         ))) return true;
  47.         if(self::contains($ua,array(
  48.             "Chrome",
  49.             "yahoo.com",
  50.             "google.com",
  51.             "Comcast"
  52.         ))){
  53.             return true;
  54.         }
  55.         return false;
  56.     }
  57. }

Documentation generated on Sun, 19 Sep 2010 00:15:55 +0000 by phpDocumentor 1.4.3