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

Source for file TeraWurflXMLParser.php

Documentation is available at TeraWurflXMLParser.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 TeraWurflXMLParser
  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.  * Abstract class to provide a skeleton for the wurfl.xml parsers.
  17.  * @abstract
  18.  * @package TeraWurflXMLParser
  19.  */
  20. abstract class TeraWurflXMLParser {
  21.  
  22.     public static $TYPE_WURFL 'wurfl';
  23.     public static $TYPE_PATCH 'patch';
  24.     
  25.     public $wurflVersion;
  26.     public $wurflLastUpdated;
  27.     public $devices = array();
  28.     public $errors = array();
  29.     
  30.     protected static $PARSER_SIMPLEXML 'simplexml';
  31.     protected static $PARSER_XMLREADER 'xmlreader';
  32.     
  33.     protected $parser_type;
  34.     protected $file_type;
  35.     protected $xml;
  36.         
  37.     abstract public function open($filename,$file_type);
  38.     abstract public function process(Array &$destination);
  39.     protected function cleanValue($value){
  40.         if($value === 'true'return true;
  41.         if($value === 'false')return false;
  42.         // Clean Numeric values by loosely comparing the (float) to the (string)
  43.         $numval = (float)$value;
  44.         if(strcmp($value,$numval)==0)$value=$numval;
  45.         return $value;
  46.     }
  47.     protected function enabled($cap_or_group){
  48.         return in_array($cap_or_group,TeraWurflConfig::$CAPABILITY_FILTER);
  49.     }
  50.     
  51.     final public static function getInstance(){
  52.         if(function_exists('simplexml_load_file')){
  53.             require_once realpath(dirname(__FILE__).'/TeraWurflXMLParser_SimpleXML.php');
  54.             return new TeraWurflXMLParser_SimpleXML();
  55.         }elseif(class_exists('XMLReader')){
  56.             require_once realpath(dirname(__FILE__).'/TeraWurflXMLParser_XMLReader.php');
  57.             return new TeraWurflXMLParser_XMLReader();
  58.         }else{
  59.             throw new Exception("No suitable XML Parser was found.  Please enable XMLReader or SimpleXML");
  60.         }
  61.     }
  62. }

Documentation generated on Sun, 19 Sep 2010 00:16:05 +0000 by phpDocumentor 1.4.3