| 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 | | * |
| 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' ) ); |
| 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 |