* @param TeraWurflHttpRequest $httpRequest
     * @return string UserAgentMatcher UserAgentMatcher name
     */
    public static function userAgentType(TeraWurfl $wurfl, TeraWurflHttpRequest $httpRequest)
    {
        $matcher = self::createUserAgentMatcher($wurfl, $httpRequest);
        if ($matcher->runtime_normalization) {
            $matcher->simulation = true;
            $matcher->applyConclusiveMatch();
            $matcher->applyRecoveryMatch();
        }
        $type = get_class($matcher);
        return str_replace('UserAgentMatcher', '', $type);
    }
    public static function loadMatchers()
    {
        $dir = dirname(__FILE__) . '/UserAgentMatchers/';
        require_once $dir . 'UserAgentMatcher.php';
        foreach (WurflConstants::$matchers as $matcher_name) {
            $matcher_class_name = $matcher_name . 'UserAgentMatcher';
            if (!class_exists($matcher_class_name, false)) {
                include $dir . $matcher_class_name . '.php';
            }
        }
    }
}
/**
 * Load User Agent Matchers
 */
UserAgentMatcherFactory::loadMatchers();
Ejemplo n.º 2
0
 /**
  * Prints the contents of the API's UserAgentMatcher buckets
  */
 public function dumpBuckets()
 {
     if (!$this->httpRequest instanceof TeraWurflHttpRequest) {
         $this->httpRequest = new TeraWurflHttpRequest(array('HTTP_USER_AGENT' => 'debug'));
     }
     UserAgentMatcherFactory::loadMatchers();
     $matchers = WurflConstants::$matchers;
     sort($matchers);
     foreach ($matchers as $matcher_name) {
         $matcher_class_name = $matcher_name . 'UserAgentMatcher';
         /* @var $matcher UserAgentMatcher */
         $matcher = new $matcher_class_name($this);
         $bucket = $matcher->tableSuffix();
         $bucket_data = $this->db->getFullDeviceList(TeraWurflConfig::$TABLE_PREFIX . '_' . $bucket);
         ksort($bucket_data);
         foreach ($bucket_data as $device_id => $user_agent) {
             printf("%s\t%s\t%s\n", $bucket, $device_id, $user_agent);
         }
     }
 }