Source for file Filter.php

Documentation is available at Filter.php

  1. <?php
  2.  
  3. /**
  4.  * Microsoft's proprietary filter: CSS property
  5.  * @note Currently supports the alpha filter. In the future, this will
  6.  *        probably need an extensible framework
  7.  */
  8. {
  9.     
  10.     protected $intValidator;
  11.     
  12.     public function __construct({
  13.         $this->intValidator = new HTMLPurifier_AttrDef_Integer();
  14.     }
  15.     
  16.     public function validate($value$config$context{
  17.         $value $this->parseCDATA($value);
  18.         if ($value === 'none'return $value;
  19.         // if we looped this we could support multiple filters
  20.         $function_length strcspn($value'(');
  21.         $function trim(substr($value0$function_length));
  22.         if ($function !== 'alpha' &&
  23.             $function !== 'Alpha' &&
  24.             $function !== 'progid:DXImageTransform.Microsoft.Alpha'
  25.             return false;
  26.         $cursor $function_length 1;
  27.         $parameters_length strcspn($value')'$cursor);
  28.         $parameters substr($value$cursor$parameters_length);
  29.         $params explode(','$parameters);
  30.         $ret_params array();
  31.         $lookup array();
  32.         foreach ($params as $param{
  33.             list($key$valueexplode('='$param);
  34.             $key   trim($key);
  35.             $value trim($value);
  36.             if (isset($lookup[$key])) continue;
  37.             if ($key !== 'opacity'continue;
  38.             $value $this->intValidator->validate($value$config$context);
  39.             if ($value === falsecontinue;
  40.             $int = (int) $value;
  41.             if ($int 100$value '100';
  42.             if ($int 0$value '0';
  43.             $ret_params["$key=$value";
  44.             $lookup[$keytrue;
  45.         }
  46.         $ret_parameters implode(','$ret_params);
  47.         $ret_function "$function($ret_parameters)";
  48.         return $ret_function;
  49.     }
  50.     
  51. }

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