| 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.1 |
| 154 | | * |
| 155 | | * @param string format |
| 156 | | * @param integer timestamp |
| 157 | | * @return string |
| 158 | | */ |
| 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 que |
| 169 | | * les informations path, par exemple dans le pagelayout ($module_result.path). |
| 170 | | * |
| 171 | | * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com> |
| 172 | | * @since 1.0 |
| 173 | | * |
| 174 | | * @param array $path |
| 175 | | * @return array |
| 176 | | */ |
| 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.0 |
| 197 | | * |
| 198 | | * @param string $url URL de redirection |
| 199 | | * @param integer $type Type de redirection |
| 200 | | */ |
| 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.0 |
| 223 | | * |
| 224 | | * @param string $search |
| 225 | | * @param string $replace |
| 226 | | * @param string $subject |
| 227 | | * @return string |
| 228 | | */ |
| 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.0 |
| 241 | | * |
| 242 | | * @param string $search |
| 243 | | * @param string $replace |
| 244 | | * @param string $subject |
| 245 | | * @return string |
| 246 | | */ |
| 247 | | function strReplace( $search, $replace, $subject ) |
| 248 | | { |
| 249 | | return str_ireplace( $search, $replace, $subject ); |
| 250 | | } |
| 251 | | |
| 252 | | |