Source for file AttrTypes.php

Documentation is available at AttrTypes.php

  1. <?php
  2.  
  3. /**
  4.  * Provides lookup array of attribute types to HTMLPurifier_AttrDef objects
  5.  */
  6. {
  7.     /**
  8.      * Lookup array of attribute string identifiers to concrete implementations
  9.      */
  10.     protected $info = array();
  11.     
  12.     /**
  13.      * Constructs the info array, supplying default implementations for attribute
  14.      * types.
  15.      */
  16.     public function __construct({
  17.         // pseudo-types, must be instantiated via shorthand
  18.         $this->info['Enum']    new HTMLPurifier_AttrDef_Enum();
  19.         $this->info['Bool']    new HTMLPurifier_AttrDef_HTML_Bool();
  20.         
  21.         $this->info['CDATA']    new HTMLPurifier_AttrDef_Text();
  22.         $this->info['ID']       new HTMLPurifier_AttrDef_HTML_ID();
  23.         $this->info['Length']   new HTMLPurifier_AttrDef_HTML_Length();
  24.         $this->info['MultiLength'new HTMLPurifier_AttrDef_HTML_MultiLength();
  25.         $this->info['NMTOKENS'new HTMLPurifier_AttrDef_HTML_Nmtokens();
  26.         $this->info['Pixels']   new HTMLPurifier_AttrDef_HTML_Pixels();
  27.         $this->info['Text']     new HTMLPurifier_AttrDef_Text();
  28.         $this->info['URI']      new HTMLPurifier_AttrDef_URI();
  29.         $this->info['LanguageCode'new HTMLPurifier_AttrDef_Lang();
  30.         $this->info['Color']    new HTMLPurifier_AttrDef_HTML_Color();
  31.         
  32.         // unimplemented aliases
  33.         $this->info['ContentType'new HTMLPurifier_AttrDef_Text();
  34.         
  35.         // number is really a positive integer (one or more digits)
  36.         // FIXME: ^^ not always, see start and value of list items
  37.         $this->info['Number']   new HTMLPurifier_AttrDef_Integer(falsefalsetrue);
  38.     }
  39.     
  40.     /**
  41.      * Retrieves a type
  42.      * @param $type String type name
  43.      * @return Object AttrDef for type
  44.      */
  45.     public function get($type{
  46.         
  47.         // determine if there is any extra info tacked on
  48.         if (strpos($type'#'!== falselist($type$stringexplode('#'$type2);
  49.         else $string '';
  50.         
  51.         if (!isset($this->info[$type])) {
  52.             trigger_error('Cannot retrieve undefined attribute type ' $typeE_USER_ERROR);
  53.             return;
  54.         }
  55.         
  56.         return $this->info[$type]->make($string);
  57.         
  58.     }
  59.     
  60.     /**
  61.      * Sets a new implementation for a type
  62.      * @param $type String type name
  63.      * @param $impl Object AttrDef for type
  64.      */
  65.     public function set($type$impl{
  66.         $this->info[$type$impl;
  67.     }
  68. }

Documentation generated on Thu, 19 Jun 2008 18:48:50 -0400 by phpDocumentor 1.4.2