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

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
50.00 %50.00%
50.00% 1 / 2
28.57 %28.57%
28.57% 4 / 14
 
HTMLPurifier_AttrTransform_ImgSpace
100.00 %100.00%
100.00% 1 / 1
50.00 %50.00%
50.00% 1 / 2
28.57 %28.57%
28.57% 4 / 14
 public function __construct($attr)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 3 / 3
 public function transform($attr, $config, $context)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 10


       1                 : <?php                                                                                
       2                 :                                                                                      
       3                 : /**                                                                                  
       4                 :  * Pre-transform that changes deprecated hspace and vspace attributes to CSS         
       5                 :  */                                                                                  
       6               1 : class HTMLPurifier_AttrTransform_ImgSpace extends HTMLPurifier_AttrTransform {       
       7                 :                                                                                      
       8                 :     protected $attr;                                                                 
       9                 :     protected $css = array(                                                          
      10                 :         'hspace' => array('left', 'right'),                                          
      11                 :         'vspace' => array('top', 'bottom')                                           
      12                 :     );                                                                               
      13                 :                                                                                      
      14                 :     public function __construct($attr) {                                             
      15               1 :         $this->attr = $attr;                                                         
      16               1 :         if (!isset($this->css[$attr])) {                                             
      17                 :             trigger_error(htmlspecialchars($attr) . ' is not valid space attribute');
      18                 :         }                                                                            
      19               1 :     }                                                                                
      20                 :                                                                                      
      21                 :     public function transform($attr, $config, $context) {                            
      22                 :                                                                                      
      23               0 :         if (!isset($attr[$this->attr])) return $attr;                                
      24                 :                                                                                      
      25               0 :         $width = $this->confiscateAttr($attr, $this->attr);                          
      26                 :         // some validation could happen here                                         
      27                 :                                                                                      
      28               0 :         if (!isset($this->css[$this->attr])) return $attr;                           
      29                 :                                                                                      
      30               0 :         $style = '';                                                                 
      31               0 :         foreach ($this->css[$this->attr] as $suffix) {                               
      32               0 :             $property = "margin-$suffix";                                            
      33               0 :             $style .= "$property:{$width}px;";                                       
      34               0 :         }                                                                            
      35                 :                                                                                      
      36               0 :         $this->prependCSS($attr, $style);                                            
      37                 :                                                                                      
      38               0 :         return $attr;                                                                
      39                 :                                                                                      
      40                 :     }                                                                                
      41                 :                                                                                      
      42                 : }                                                                                    
      43                 :                                                                                      

Generated by PHPUnit 3.2.20 and Xdebug 2.0.3 at Sat Jun 7 16:15:42 CEST 2008.