Source for file AttrTransform.php

Documentation is available at AttrTransform.php

  1. <?php
  2.  
  3. /**
  4.  * Processes an entire attribute array for corrections needing multiple values.
  5.  * 
  6.  * Occasionally, a certain attribute will need to be removed and popped onto
  7.  * another value.  Instead of creating a complex return syntax for
  8.  * HTMLPurifier_AttrDef, we just pass the whole attribute array to a
  9.  * specialized object and have that do the special work.  That is the
  10.  * family of HTMLPurifier_AttrTransform.
  11.  * 
  12.  * An attribute transformation can be assigned to run before or after
  13.  * HTMLPurifier_AttrDef validation.  See HTMLPurifier_HTMLDefinition for
  14.  * more details.
  15.  */
  16.  
  17. {
  18.     
  19.     /**
  20.      * Abstract: makes changes to the attributes dependent on multiple values.
  21.      * 
  22.      * @param $attr Assoc array of attributes, usually from
  23.      *               HTMLPurifier_Token_Tag::$attr
  24.      * @param $config Mandatory HTMLPurifier_Config object.
  25.      * @param $context Mandatory HTMLPurifier_Context object
  26.      * @returns Processed attribute array.
  27.      */
  28.     abstract public function transform($attr$config$context);
  29.     
  30.     /**
  31.      * Prepends CSS properties to the style attribute, creating the
  32.      * attribute if it doesn't exist.
  33.      * @param $attr Attribute array to process (passed by reference)
  34.      * @param $css CSS to prepend
  35.      */
  36.     public function prependCSS(&$attr$css{
  37.         $attr['style'= isset($attr['style']$attr['style''';
  38.         $attr['style'$css $attr['style'];
  39.     }
  40.     
  41.     /**
  42.      * Retrieves and removes an attribute
  43.      * @param $attr Attribute array to process (passed by reference)
  44.      * @param $key Key of attribute to confiscate
  45.      */
  46.     public function confiscateAttr(&$attr$key{
  47.         if (!isset($attr[$key])) return null;
  48.         $value $attr[$key];
  49.         unset($attr[$key]);
  50.         return $value;
  51.     }
  52.     
  53. }

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