/**
  * 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);
         }
     }
 }
     * @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();
 /**
  * Sorts the validated data from $this->devices into their respective UserAgentMatcher tables ($this->tables)
  * based on the UserAgentMatcher that matches the device's user agent
  * @return bool Success
  */
 public function sort()
 {
     $this->timesort = microtime(true);
     foreach ($this->devices as $id => &$device) {
         $this->wurfl->httpRequest = new TeraWurflHttpRequest(array('HTTP_USER_AGENT' => $device['user_agent']));
         // This will return something like "Nokia", "Motorola", or "CatchAll"
         $matcher = UserAgentMatcherFactory::userAgentType($this->wurfl, $this->wurfl->httpRequest);
         // TeraWurfl_Nokia
         $device['user_agent'] = $this->wurfl->httpRequest->user_agent->normalized;
         $uatable = TeraWurflConfig::$TABLE_PREFIX . '_' . $matcher;
         if (!isset($this->tables[$uatable])) {
             $this->tables[$uatable] = array();
         }
         $this->tables[$uatable][$device['id']] = $device;
     }
     // Destroy the devices array
     $this->devices = array();
     return true;
 }