Changeset 154

Show
Ignore:
Timestamp:
05/30/08 17:41:07 (5 months ago)
Author:
llaumgui
Message:
 
Location:
ez_publish/myutils/trunk/autoloads
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • ez_publish/myutils/trunk/autoloads/eztemplateautoload.php

    r108 r154  
    3434                                                                                'operator_names'        => array(       'is_debug_enabled', 
    3535                                                                                                                                                'path_to_path_array', 
     36                                                                                                                                                'php_tidy', 
    3637                                                                                                                                                'redirect', 
    3738                                                                                                                                                'str_ireplace', 
  • ez_publish/myutils/trunk/autoloads/myutils_operators.php

    r108 r154  
    2525 *  
    2626 * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com> 
    27  * @version 1.0 
     27 * @version 1.1 
    2828 */ 
    2929 
     
    4242                $this->Operators = array(       'is_debug_enabled', 
    4343                                                                        'path_to_path_array', 
     44                                                                        'php_tidy', 
    4445                                                                        'redirect', 
    4546                                                                        'str_ireplace', 
    46                                                                         'str_replace'                                                                    
     47                                                                        'str_replace' 
    4748                                                                 ); 
    4849        } 
     
    6263        function namedParameterList() 
    6364        { 
    64                  return array(  'is_debug_enabled'                      => array( 
     65                 return array(  'is_debug_enabled'                              => array( 
    6566                                                                                                        ), 
    6667 
    6768                                                'path_to_path_array'                    => array( 
    68                                                                 'path'                  => array( 'url'         => 'array', 'required' => true, 'default' => ''  ), 
    69                                                                                                         ), 
    70                  
     69                                                                'path'                  => array( 'type'        => 'array', 'required' => true, 'default' => ''  ), 
     70                                                                                                        ), 
     71 
     72                                                'php_tidy'                                              => array( 
     73                                                                'string'                => array( 'type'        => 'string', 'required' => true, 'default' => ''  ), 
     74                                                                                                        ), 
     75 
    7176                                                'redirect'                                              => array( 
    72                                                                 'url'                   => array( 'url'         => 'string', 'required' => true, 'default' => ''  ), 
     77                                                                'url'                   => array( 'type'        => 'string', 'required' => true, 'default' => ''  ), 
    7378                                                                'type'                  => array( 'type' => 'integer', 'required' => false, 'default' => '301' ) 
    7479                                                                                                        ), 
    75                                                                                                          
    76                  
     80                         
    7781                                                'str_ireplace'                                  => array(        
    7882                                                                'search'                => array( 'type' => 'string', 'required' => true, 'default' => '' ), 
     
    96100            switch ( $operatorName ) 
    97101            { 
    98                 case 'is_debug_enabled': 
     102                        case 'is_debug_enabled': 
    99103                        $operatorValue = $this->isDebugEnabled(); 
    100104                        break; 
     
    103107                        $operatorValue = $this->path2PathArray(         $namedParameters['path'] ); 
    104108                        break; 
     109                                 
     110                        case 'php_tidy': 
     111                        $operatorValue = $this->phpTidy(        $namedParameters['string'] ); 
     112                        break; 
     113 
    105114                        case 'redirect': 
    106115                        $operatorValue = $this->redirect(       $namedParameters['url'], 
     
    169178        } 
    170179 
    171  
     180         
     181         
     182        /** 
     183         * Métrosexualisation du code avec Tidy 
     184         *        
     185         * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com> 
     186         * @since 1.0 
     187         * 
     188         * @param array $path 
     189         * @return array 
     190         */ 
     191        function phpTidy( $path ) 
     192        { 
     193                if ( function_exists( 'tidy_get_output') ) 
     194                { 
     195                        $tidy   = new tidy(); 
     196                        /* Mettre dans un tidy.conf  */ 
     197                        $config         = array(        'indent'                                => true, 
     198                                                                        'output-xhtml'                  => true, 
     199                                                                        'wrap'                                  => 400, 
     200                                                                        'hide-comments'                 => false,   
     201                                                                        'doctype'                               => 'auto',   
     202                                                                ); 
     203                        $encoding       = 'UTF8'; 
     204                        $tidy->parseString( $originalMarkup, $config, $encoding ); 
     205                        $tidy->CleanRepair(); 
     206                        if ( $tidy->errorBuffer ) { 
     207                        //echo "Les erreurs suivantes ont été détectées :\n"; 
     208                        //echo $tidy->errorBuffer; 
     209                        } 
     210                        return (string) $tidy; 
     211                } 
    172212 
    173213        /**