Changeset 187

Show
Ignore:
Timestamp:
06/20/08 13:34:45 (4 months ago)
Author:
llaumgui
Message:

Nettoyage et mise en option de la fonction TIDY

Location:
ez_publish/myutils/trunk
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • ez_publish/myutils/trunk/classes/myutilsfunction.php

    r185 r187  
    2222 * ###################### END LICENSE BLOCK #################### 
    2323 * 
    24  * myUtilsFunctions 
     24 * myUtilsFunctions : Enssemble de fonctions utilisée pour l'extension myUtils 
    2525 *  
    2626 * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com> 
    27  * @version 1.0 
     27 * @version 1.0.1 
    2828 */ 
    2929 
     
    3232 
    3333        /** 
    34          * Converti un "path" en "path_array". 
    35          * Permet de retrouver un équivalent de $node.path_array là où il n'y a que 
    36          * les informations path, par exemple dans le pagelayout ($module_result.path). 
    37          *        
     34         * Permet de nettoyer une string avec tidy 
     35         * 
    3836         * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com> 
    3937         * @since 1.0 
    40          * 
    41          * @param array $path 
    42          * @return array 
    43          */ 
    44         static function path2PathArray( $path ) 
    45         { 
    46                 $path_array     = array(); 
    47                 if ( !is_array( $path ) ) 
    48                         return array(); 
    49  
    50                 foreach ( $path as $p ) 
    51                 { 
    52                         $path_array[]=$p['node_id']; 
    53                 } 
    54                 return $path_array; 
    55         } 
    56          
    57          
    58          
    59         /** 
    60          * Fonction header() de php mise en forme pour faire des redirections. 
    61          * 
    62          * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com> 
    63          * @since 1.0 
    64          *        
    65          * @param string $url URL de redirection 
    66          * @param integer $type Type de redirection 
    67          */ 
    68         static function redirect( $url, $type ) 
    69         { 
    70                 switch( $type ) 
    71                 { 
    72                         case 301: 
    73                                 header("HTTP/1.1 301 Moved Permanently"); 
    74                                 break; 
    75                         case 307: 
    76                                 header("HTTP/1.1 307 Temporary Redirect"); 
    77                                 break; 
    78                 } 
    79                 header ('location: '.$url); 
    80                 eZExecution::cleanExit(); 
    81         } 
    82  
    83  
    84          
    85         /** 
    86          * Permet de nettoyer une string avec tidy 
    87          * 
    8838         * @param string $str 
    8939         */ 
     
    9343                { 
    9444                        $tidy           = new tidy; 
    95                         /* Mettre dans un ini pour faire plus propre */ 
    96                         $config   = array(      'show-body-only'     => true, 
    97                                                                 'output-xhtml'       => true, 
    98                                                                 'wrap'               => 0, 
    99                                                                 'alt-text'           => "" 
    100                                        ); 
    101                         $tidy->parseString( $str, $config, 'utf8' ); 
     45                        $iniTidy                = eZINI::instance( "tidy.ini" ); 
     46                        $config                 = $iniTidy->variable( 'Part', 'Options' ); 
     47                        $tidy->parseString( $str, $config, $iniTidy->variable( 'Global', 'Charset' ) ); 
    10248                        $tidy->cleanRepair(); 
    10349                } 
     
    10551        } 
    10652 
    107          
    108          
     53 
     54 
    10955        /** 
    11056         * Permet de nettoyer le champ "description" d'un flux RSS 
    11157         * 
     58         * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com> 
     59         * @since 1.0 
     60         * 
    11261         * @param string $str 
    11362         */ 
     
    206155                return $data; 
    207156        } 
    208 } 
     157 
     158 
     159         
     160        /** 
     161         * Converti un "path" en "path_array". 
     162         * Permet de retrouver un équivalent de $node.path_array là où il n'y a que 
     163         * les informations path, par exemple dans le pagelayout ($module_result.path). 
     164         *        
     165         * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com> 
     166         * @since 1.0.1 
     167         * 
     168         * @param array $path 
     169         * @return array 
     170         */ 
     171        static function path2PathArray( $path ) 
     172        { 
     173                $path_array     = array(); 
     174                if ( !is_array( $path ) ) 
     175                { 
     176                        return array(); 
     177                } 
     178 
     179                foreach ( $path as $p ) 
     180                { 
     181                        $path_array[]=$p['node_id']; 
     182                } 
     183                return $path_array; 
     184        } 
     185         
     186         
     187         
     188        /** 
     189         * Fonction header() de php mise en forme pour faire des redirections. 
     190         * 
     191         * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com> 
     192         * @since 1.0.1 
     193         *        
     194         * @param string $url URL de redirection 
     195         * @param integer $type Type de redirection 
     196         */ 
     197        static function redirect( $url, $type ) 
     198        { 
     199                switch( $type ) 
     200                { 
     201                        case 301: 
     202                                header("HTTP/1.1 301 Moved Permanently"); 
     203                                break; 
     204                        case 307: 
     205                                header("HTTP/1.1 307 Temporary Redirect"); 
     206                                break; 
     207                } 
     208                header ('location: '.$url); 
     209                eZExecution::cleanExit(); 
     210        } 
     211         
     212} // EOC 
    209213 
    210214?>