Changeset 185
- Timestamp:
- 06/20/08 12:37:15 (4 months ago)
- Location:
- ez_publish/myutils/trunk
- Files:
-
- 2 modified
-
autoloads/myutils_operators.php (modified) (4 diffs)
-
classes/myutilsfunction.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ez_publish/myutils/trunk/autoloads/myutils_operators.php
r184 r185 39 39 function __construct() 40 40 { 41 /* Op érateurs */41 /* Opérateurs */ 42 42 $this->Operators = array( 'get_siteaccess', 43 43 'gmdate', … … 71 71 ), 72 72 73 'is_debug_enabled' => array( 74 ), 73 'is_debug_enabled' => array( ), 75 74 76 75 'path_to_path_array' => array( … … 109 108 110 109 case 'gmdate': 111 $operatorValue = $this->gmDate( $namedParameters['format'], 112 $namedParameters['timestamp'] ); 110 $operatorValue = gmdate( $namedParameters['format'], $namedParameters['timestamp'] ); 113 111 break; 114 112 … … 118 116 119 117 case 'path_to_path_array': 120 $operatorValue = $this->path2PathArray($namedParameters['path'] );118 $operatorValue = myUtilsFunctions::path2PathArray( $namedParameters['path'] ); 121 119 break; 122 120 123 121 case 'redirect': 124 $operatorValue = $this->redirect( $namedParameters['url'], 125 $namedParameters['type'] ); 122 $operatorValue = myUtilsFunctions::redirect( $namedParameters['url'], $namedParameters['type'] ); 126 123 break; 127 124 128 125 case 'str_ireplace': 129 $operatorValue = $this->strIReplace($namedParameters['search'],130 $namedParameters['replace'],131 $namedParameters['subject'] );126 $operatorValue = str_ireplace( $namedParameters['search'], 127 $namedParameters['replace'], 128 $namedParameters['subject'] ); 132 129 break; 133 130 134 131 case 'str_replace': 135 $operatorValue = $this->strReplace( $namedParameters['search'],136 $namedParameters['replace'],137 $namedParameters['subject'] );132 $operatorValue = str_replace( $namedParameters['search'], 133 $namedParameters['replace'], 134 $namedParameters['subject'] ); 138 135 break; 139 136 } 140 137 } 141 138 142 143 /** #####################################################################144 *145 *146 *147 * ###################################################################### */148 149 /**150 * Fonction gmdate dans eZ (pour les flux RSS par exemple).151 *152 * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com>153 * @since 1.1154 *155 * @param string format156 * @param integer timestamp157 * @return string158 */159 function gmDate( $format, $timestamp)160 {161 return gmdate( $format, $timestamp);162 }163 164 165 166 /**167 * Converti un "path" en "path_array".168 * Permet de retrouver un équivalent de $node.path_array là où il n'y a que169 * les informations path, par exemple dans le pagelayout ($module_result.path).170 *171 * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com>172 * @since 1.0173 *174 * @param array $path175 * @return array176 */177 function path2PathArray( $path )178 {179 $path_array = array();180 if ( !is_array( $path ) )181 return array();182 183 foreach ( $path as $p )184 {185 $path_array[]=$p['node_id'];186 }187 return $path_array;188 }189 190 191 192 /**193 * Fonction header() de php mise en forme pour faire des redirections.194 *195 * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com>196 * @since 1.0197 *198 * @param string $url URL de redirection199 * @param integer $type Type de redirection200 */201 private function redirect( $url, $type )202 {203 switch( $type )204 {205 case 301:206 header("HTTP/1.1 301 Moved Permanently");207 break;208 case 307:209 header("HTTP/1.1 307 Temporary Redirect");210 break;211 }212 header ('location: '.$url);213 eZExecution::cleanExit();214 }215 216 217 218 /**219 * Fonction str_replace de php.220 *221 * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com>222 * @since 1.0223 *224 * @param string $search225 * @param string $replace226 * @param string $subject227 * @return string228 */229 function strIReplace( $search, $replace, $subject )230 {231 return str_replace( $search, $replace, $subject );232 }233 234 235 236 /**237 * Fonction str_ireplace de php.238 *239 * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com>240 * @since 1.0241 *242 * @param string $search243 * @param string $replace244 * @param string $subject245 * @return string246 */247 function strReplace( $search, $replace, $subject )248 {249 return str_ireplace( $search, $replace, $subject );250 }251 252 253 139 } // EOC 254 140 -
ez_publish/myutils/trunk/classes/myutilsfunction.php
r182 r185 31 31 { 32 32 33 33 /** 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 * 38 * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com> 39 * @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 34 85 /** 35 86 * Permet de nettoyer une string avec tidy
