PHPIDS
Current file: /home/mario/workspace/php-ids.org/trunk/lib/IDS/vendors/htmlpurifier/HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.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
100.00 %100.00%
100.00% 90 / 90
 
HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 90 / 90
 public function makeFixes()
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 89 / 89


       1                 : <?php                                                                                                
       2                 :                                                                                                      
       3               1 : class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends HTMLPurifier_HTMLModule_Tidy                
       4                 : {                                                                                                    
       5                 :                                                                                                      
       6                 :     public function makeFixes() {                                                                    
       7                 :                                                                                                      
       8               1 :         $r = array();                                                                                
       9                 :                                                                                                      
      10                 :         // == deprecated tag transforms ===================================                          
      11                 :                                                                                                      
      12               1 :         $r['font']   = new HTMLPurifier_TagTransform_Font();                                         
      13               1 :         $r['menu']   = new HTMLPurifier_TagTransform_Simple('ul');                                   
      14               1 :         $r['dir']    = new HTMLPurifier_TagTransform_Simple('ul');                                   
      15               1 :         $r['center'] = new HTMLPurifier_TagTransform_Simple('div',  'text-align:center;');           
      16               1 :         $r['u']      = new HTMLPurifier_TagTransform_Simple('span', 'text-decoration:underline;');   
      17               1 :         $r['s']      = new HTMLPurifier_TagTransform_Simple('span', 'text-decoration:line-through;');
      18               1 :         $r['strike'] = new HTMLPurifier_TagTransform_Simple('span', 'text-decoration:line-through;');
      19                 :                                                                                                      
      20                 :         // == deprecated attribute transforms =============================                          
      21                 :                                                                                                      
      22               1 :         $r['caption@align'] =                                                                        
      23               1 :             new HTMLPurifier_AttrTransform_EnumToCSS('align', array(                                 
      24                 :                 // we're following IE's behavior, not Firefox's, due                                 
      25                 :                 // to the fact that no one supports caption-side:right,                              
      26                 :                 // W3C included (with CSS 2.1). This is a slightly                                   
      27                 :                 // unreasonable attribute!                                                           
      28               1 :                 'left'   => 'text-align:left;',                                                      
      29               1 :                 'right'  => 'text-align:right;',                                                     
      30               1 :                 'top'    => 'caption-side:top;',                                                     
      31                 :                 'bottom' => 'caption-side:bottom;' // not supported by IE                            
      32               1 :             ));                                                                                      
      33                 :                                                                                                      
      34                 :         // @align for img -------------------------------------------------                          
      35               1 :         $r['img@align'] =                                                                            
      36               1 :             new HTMLPurifier_AttrTransform_EnumToCSS('align', array(                                 
      37               1 :                 'left'   => 'float:left;',                                                           
      38               1 :                 'right'  => 'float:right;',                                                          
      39               1 :                 'top'    => 'vertical-align:top;',                                                   
      40               1 :                 'middle' => 'vertical-align:middle;',                                                
      41               1 :                 'bottom' => 'vertical-align:baseline;',                                              
      42               1 :             ));                                                                                      
      43                 :                                                                                                      
      44                 :         // @align for table -----------------------------------------------                          
      45               1 :         $r['table@align'] =                                                                          
      46               1 :             new HTMLPurifier_AttrTransform_EnumToCSS('align', array(                                 
      47               1 :                 'left'   => 'float:left;',                                                           
      48               1 :                 'center' => 'margin-left:auto;margin-right:auto;',                                   
      49                 :                 'right'  => 'float:right;'                                                           
      50               1 :             ));                                                                                      
      51                 :                                                                                                      
      52                 :         // @align for hr -----------------------------------------------                             
      53               1 :         $r['hr@align'] =                                                                             
      54               1 :             new HTMLPurifier_AttrTransform_EnumToCSS('align', array(                                 
      55                 :                 // we use both text-align and margin because these work                              
      56                 :                 // for different browsers (IE and Firefox, respectively)                             
      57                 :                 // and the melange makes for a pretty cross-compatible                               
      58                 :                 // solution                                                                          
      59               1 :                 'left'   => 'margin-left:0;margin-right:auto;text-align:left;',                      
      60               1 :                 'center' => 'margin-left:auto;margin-right:auto;text-align:center;',                 
      61                 :                 'right'  => 'margin-left:auto;margin-right:0;text-align:right;'                      
      62               1 :             ));                                                                                      
      63                 :                                                                                                      
      64                 :         // @align for h1, h2, h3, h4, h5, h6, p, div ----------------------                          
      65                 :         // {{{                                                                                       
      66               1 :             $align_lookup = array();                                                                 
      67               1 :             $align_values = array('left', 'right', 'center', 'justify');                             
      68               1 :             foreach ($align_values as $v) $align_lookup[$v] = "text-align:$v;";                      
      69                 :         // }}}                                                                                       
      70               1 :         $r['h1@align'] =                                                                             
      71               1 :         $r['h2@align'] =                                                                             
      72               1 :         $r['h3@align'] =                                                                             
      73               1 :         $r['h4@align'] =                                                                             
      74               1 :         $r['h5@align'] =                                                                             
      75               1 :         $r['h6@align'] =                                                                             
      76               1 :         $r['p@align']  =                                                                             
      77               1 :         $r['div@align'] =                                                                            
      78               1 :             new HTMLPurifier_AttrTransform_EnumToCSS('align', $align_lookup);                        
      79                 :                                                                                                      
      80                 :         // @bgcolor for table, tr, td, th ---------------------------------                          
      81               1 :         $r['table@bgcolor'] =                                                                        
      82               1 :         $r['td@bgcolor'] =                                                                           
      83               1 :         $r['th@bgcolor'] =                                                                           
      84               1 :             new HTMLPurifier_AttrTransform_BgColor();                                                
      85                 :                                                                                                      
      86                 :         // @border for img ------------------------------------------------                          
      87               1 :         $r['img@border'] = new HTMLPurifier_AttrTransform_Border();                                  
      88                 :                                                                                                      
      89                 :         // @clear for br --------------------------------------------------                          
      90               1 :         $r['br@clear'] =                                                                             
      91               1 :             new HTMLPurifier_AttrTransform_EnumToCSS('clear', array(                                 
      92               1 :                 'left'  => 'clear:left;',                                                            
      93               1 :                 'right' => 'clear:right;',                                                           
      94               1 :                 'all'   => 'clear:both;',                                                            
      95               1 :                 'none'  => 'clear:none;',                                                            
      96               1 :             ));                                                                                      
      97                 :                                                                                                      
      98                 :         // @height for td, th ---------------------------------------------                          
      99               1 :         $r['td@height'] =                                                                            
     100               1 :         $r['th@height'] =                                                                            
     101               1 :             new HTMLPurifier_AttrTransform_Length('height');                                         
     102                 :                                                                                                      
     103                 :         // @hspace for img ------------------------------------------------                          
     104               1 :         $r['img@hspace'] = new HTMLPurifier_AttrTransform_ImgSpace('hspace');                        
     105                 :                                                                                                      
     106                 :         // @name for img, a -----------------------------------------------                          
     107               1 :         $r['img@name'] =                                                                             
     108               1 :         $r['a@name'] = new HTMLPurifier_AttrTransform_Name();                                        
     109                 :                                                                                                      
     110                 :         // @noshade for hr ------------------------------------------------                          
     111                 :         // this transformation is not precise but often good enough.                                 
     112                 :         // different browsers use different styles to designate noshade                              
     113               1 :         $r['hr@noshade'] =                                                                           
     114               1 :             new HTMLPurifier_AttrTransform_BoolToCSS(                                                
     115               1 :                 'noshade',                                                                           
     116                 :                 'color:#808080;background-color:#808080;border:0;'                                   
     117               1 :             );                                                                                       
     118                 :                                                                                                      
     119                 :         // @nowrap for td, th ---------------------------------------------                          
     120               1 :         $r['td@nowrap'] =                                                                            
     121               1 :         $r['th@nowrap'] =                                                                            
     122               1 :             new HTMLPurifier_AttrTransform_BoolToCSS(                                                
     123               1 :                 'nowrap',                                                                            
     124                 :                 'white-space:nowrap;'                                                                
     125               1 :             );                                                                                       
     126                 :                                                                                                      
     127                 :         // @size for hr  --------------------------------------------------                          
     128               1 :         $r['hr@size'] = new HTMLPurifier_AttrTransform_Length('size', 'height');                     
     129                 :                                                                                                      
     130                 :         // @type for li, ol, ul -------------------------------------------                          
     131                 :         // {{{                                                                                       
     132                 :             $ul_types = array(                                                                       
     133               1 :                 'disc'   => 'list-style-type:disc;',                                                 
     134               1 :                 'square' => 'list-style-type:square;',                                               
     135                 :                 'circle' => 'list-style-type:circle;'                                                
     136               1 :             );                                                                                       
     137                 :             $ol_types = array(                                                                       
     138               1 :                 '1'   => 'list-style-type:decimal;',                                                 
     139               1 :                 'i'   => 'list-style-type:lower-roman;',                                             
     140               1 :                 'I'   => 'list-style-type:upper-roman;',                                             
     141               1 :                 'a'   => 'list-style-type:lower-alpha;',                                             
     142                 :                 'A'   => 'list-style-type:upper-alpha;'                                              
     143               1 :             );                                                                                       
     144               1 :             $li_types = $ul_types + $ol_types;                                                       
     145                 :         // }}}                                                                                       
     146                 :                                                                                                      
     147               1 :         $r['ul@type'] = new HTMLPurifier_AttrTransform_EnumToCSS('type', $ul_types);                 
     148               1 :         $r['ol@type'] = new HTMLPurifier_AttrTransform_EnumToCSS('type', $ol_types, true);           
     149               1 :         $r['li@type'] = new HTMLPurifier_AttrTransform_EnumToCSS('type', $li_types, true);           
     150                 :                                                                                                      
     151                 :         // @vspace for img ------------------------------------------------                          
     152               1 :         $r['img@vspace'] = new HTMLPurifier_AttrTransform_ImgSpace('vspace');                        
     153                 :                                                                                                      
     154                 :         // @width for hr, td, th ------------------------------------------                          
     155               1 :         $r['td@width'] =                                                                             
     156               1 :         $r['th@width'] =                                                                             
     157               1 :         $r['hr@width'] = new HTMLPurifier_AttrTransform_Length('width');                             
     158                 :                                                                                                      
     159               1 :         return $r;                                                                                   
     160                 :                                                                                                      
     161                 :     }                                                                                                
     162                 :                                                                                                      
     163                 : }                                                                                                    
     164                 :                                                                                                      

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