Source for file ListStyle.php

Documentation is available at ListStyle.php

  1. <?php
  2.  
  3. /**
  4.  * Validates shorthand CSS property list-style.
  5.  * @warning Does not support url tokens that have internal spaces.
  6.  */
  7. {
  8.     
  9.     /**
  10.      * Local copy of component validators.
  11.      * @note See HTMLPurifier_AttrDef_CSS_Font::$info for a similar impl.
  12.      */
  13.     protected $info;
  14.     
  15.     public function __construct($config{
  16.         $def $config->getCSSDefinition();
  17.         $this->info['list-style-type']     $def->info['list-style-type'];
  18.         $this->info['list-style-position'$def->info['list-style-position'];
  19.         $this->info['list-style-image'$def->info['list-style-image'];
  20.     }
  21.     
  22.     public function validate($string$config$context{
  23.         
  24.         // regular pre-processing
  25.         $string $this->parseCDATA($string);
  26.         if ($string === ''return false;
  27.         
  28.         // assumes URI doesn't have spaces in it
  29.         $bits explode(' 'strtolower($string))// bits to process
  30.         
  31.         $caught array();
  32.         $caught['type']     false;
  33.         $caught['position'false;
  34.         $caught['image']    false;
  35.         
  36.         $i 0// number of catches
  37.         $none false;
  38.         
  39.         foreach ($bits as $bit{
  40.             if ($i >= 3return// optimization bit
  41.             if ($bit === ''continue;
  42.             foreach ($caught as $key => $status{
  43.                 if ($status !== falsecontinue;
  44.                 $r $this->info['list-style-' $key]->validate($bit$config$context);
  45.                 if ($r === falsecontinue;
  46.                 if ($r === 'none'{
  47.                     if ($nonecontinue;
  48.                     else $none true;
  49.                     if ($key == 'image'continue;
  50.                 }
  51.                 $caught[$key$r;
  52.                 $i++;
  53.                 break;
  54.             }
  55.         }
  56.         
  57.         if (!$ireturn false;
  58.         
  59.         $ret array();
  60.         
  61.         // construct type
  62.         if ($caught['type']$ret[$caught['type'];
  63.         
  64.         // construct image
  65.         if ($caught['image']$ret[$caught['image'];
  66.         
  67.         // construct position
  68.         if ($caught['position']$ret[$caught['position'];
  69.         
  70.         if (empty($ret)) return false;
  71.         return implode(' '$ret);
  72.         
  73.     }
  74.     
  75. }

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