PHPIDS
Current file: /home/mario/workspace/php-ids.org/trunk/lib/IDS/vendors/htmlpurifier/HTMLPurifier/AttrDef/CSS/ListStyle.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 2
2.94 %2.94%
2.94% 1 / 34
 
HTMLPurifier_AttrDef_CSS_ListStyle
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 2
2.94 %2.94%
2.94% 1 / 34
 public function __construct($config)
0.00 %0.00%
0.00% 0 / 1
100.00 %100.00%
100.00% 0 / 0
 public function validate($string, $config, $context)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 33


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

Generated by PHPUnit 3.3.1 and Xdebug 2.0.2 at Thu Sep 25 18:42:10 CEST 2008.