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

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 1 / 1
71.43 %71.43%
71.43% 10 / 14
 
HTMLPurifier_AttrTransform_ImgRequired
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 1 / 1
71.43 %71.43%
71.43% 10 / 14
 public function transform($attr, $config, $context)
100.00 %100.00%
100.00% 1 / 1
69.23 %69.23%
69.23% 9 / 13


       1                 : <?php                                                                          
       2                 :                                                                                
       3                 : // must be called POST validation                                              
       4                 :                                                                                
       5                 : /**                                                                            
       6                 :  * Transform that supplies default values for the src and alt attributes       
       7                 :  * in img tags, as well as prevents the img tag from being removed             
       8                 :  * because of a missing alt tag. This needs to be registered as both           
       9                 :  * a pre and post attribute transform.                                         
      10                 :  */                                                                            
      11               1 : class HTMLPurifier_AttrTransform_ImgRequired extends HTMLPurifier_AttrTransform
      12                 : {                                                                              
      13                 :                                                                                
      14                 :     public function transform($attr, $config, $context) {                      
      15                 :                                                                                
      16               2 :         $src = true;                                                           
      17               2 :         if (!isset($attr['src'])) {                                            
      18               1 :             if ($config->get('Core', 'RemoveInvalidImg')) return $attr;        
      19               0 :             $attr['src'] = $config->get('Attr', 'DefaultInvalidImage');        
      20               0 :             $src = false;                                                      
      21               0 :         }                                                                      
      22                 :                                                                                
      23               2 :         if (!isset($attr['alt'])) {                                            
      24               2 :             if ($src) {                                                        
      25               2 :                 $attr['alt'] = basename($attr['src']);                         
      26               2 :             } else {                                                           
      27               0 :                 $attr['alt'] = $config->get('Attr', 'DefaultInvalidImageAlt'); 
      28                 :             }                                                                  
      29               2 :         }                                                                      
      30                 :                                                                                
      31               2 :         return $attr;                                                          
      32                 :                                                                                
      33                 :     }                                                                          
      34                 :                                                                                
      35                 : }                                                                              
      36                 :                                                                                

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