Subversion Repositories eFlore/Applications.cel

Rev

Rev 3281 | Rev 3289 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3164 idir 1
 <?php
3122 delphine 2
// declare(encoding='UTF-8');
3
/**
4
 * Service affichant les dernières photo publiques du CEL ouvrable sous forme de diaporama.
5
 * Encodage en entrée : utf8
6
 * Encodage en sortie : utf8
7
 *
8
 * Cas d'utilisation et documentation :
9
 * @link http://www.tela-botanica.org/wikini/eflore/wakka.php?wiki=AideCELWidgetPhoto
10
 *
11
 * Paramètres :
12
 * ===> extra = booléen (1 ou 0)  [par défaut : 1]
13
 * Affiche / Cache la vignette en taille plus importante au bas du widget.
14
 * ===> vignette = [0-9]+,[0-9]+  [par défaut : 4,3]
15
 * Indique le nombre de vignette par ligne et le nombre de ligne.
16
 *
3164 idir 17
 * @author              Jean-Pascal MILCENT <jpm@tela-botanica.org>
18
 * @license     GPL v3 <http://www.gnu.org/licenses/gpl.txt>
19
 * @license     CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
20
 * @version     $Id$
21
 * @copyright   Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
3122 delphine 22
 */
23
class Manager extends WidgetCommun {
24
 
3233 idir 25
	const DS = DIRECTORY_SEPARATOR;
26
	const SERVICE_DEFAUT = 'manager';
27
	private $cel_url_tpl = null;
28
	/** Si spécifié, on ajoute une barre de navigation inter-applications */
29
	private $bar;
30
	//private $parametres_autorises = array('projet', 'type', 'langue', 'order');
31
	private $parametres_autorises = array(
32
		'projet' => 'projet',
33
		'type' => 'type',
34
		'langue' => 'langue',
35
		'order' => 'order'
36
	);
37
	/**
38
	 * Méthode appelée par défaut pour charger ce widget.
39
	 */
40
	public function executer() {
41
		$retour = null;
3164 idir 42
 
3233 idir 43
		// Pour la création de l'id du cache nous ne tenons pas compte du paramètre de l'url callback
44
		unset( $this->parametres['callback'] );
45
		extract( $this->parametres );
46
		$this->bar = ( isset( $bar ) ) ? $bar : false;
3164 idir 47
 
3233 idir 48
		$framework = dirname( __FILE__ ) . '/framework.php';
3164 idir 49
 
3233 idir 50
		if ( !file_exists( $framework ) ) {
51
			$e = 'Veuillez paramêtrer l\'emplacement et la version du Framework dans le fichier $framework';
52
			trigger_error( $e, E_USER_ERROR );
53
		} else {
54
			// Inclusion du Framework
55
			require_once $framework;
56
			// Ajout d'information concernant cette application
57
			Framework::setCheminAppli( __FILE__ );// Obligatoire
58
			Framework::setInfoAppli( Config::get( 'info' ) );// Optionnel
59
		}
3164 idir 60
 
3233 idir 61
		if ( !isset( $mode ) ) {
62
			$mode = self::SERVICE_DEFAUT;
63
		}
3164 idir 64
 
3233 idir 65
		$this->cel_url_tpl = $this->config['manager']['celUrlTpl'];
3166 idir 66
 
3233 idir 67
		if ( $_POST !== array() ) { //print_r($_POST);
68
			$this->parametres['projet'] = $_POST['projet'];
69
			$this->parametres['langue'] = $_POST['langue'];
3164 idir 70
 
3233 idir 71
			if ( $mode === 'modification' ) {
72
				$parametres = $this->traiterParametresModif();
73
				$json       = $this->getDao()->modifier( $this->cel_url_tpl, $parametres );
74
			} else {
75
				$donnees = array_merge( $_POST, $this->traiterDonneesFiles() );
76
				// var_dump($donnees);
77
				$json  = $this->getDao()->ajouter( $this->cel_url_tpl, $donnees );
78
				$mode  = $this->parametres['mode'] = 'modification';
79
			}
80
		}
3226 idir 81
 
3233 idir 82
		$methode = $this->traiterNomMethodeExecuter( $mode );
83
		if ( method_exists( $this, $methode ) ) {
84
			$retour = $this->$methode();
85
		} else {
3226 idir 86
 
3233 idir 87
			$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
88
		}
3226 idir 89
 
3233 idir 90
		$contenu = '';
91
		if ( is_null( $retour ) ) {
92
			$this->messages[] = 'La ressource demandée a retourné une valeur nulle.';
3226 idir 93
 
3233 idir 94
		} else {
3226 idir 95
 
3233 idir 96
			if ( isset( $retour['donnees'] ) ) {
97
				$retour['donnees']['params']   = '&projet=' . $_POST['projet'] . '&langue=' . $_POST['langue'];
98
				$retour['donnees']['prod']     = ( $this->config['parametres']['modeServeur'] === 'prod' );
99
				$retour['donnees']['bar']      = $this->bar;
100
				$retour['donnees']['url_base'] = sprintf( $this->config['chemins']['baseURLAbsoluDyn'], '' );
3226 idir 101
 
3233 idir 102
				$retour['donnees']['mode']     = $mode; //print_r($retour);
103
				$squelette = dirname( __FILE__ ) . self::DS . 'squelettes' . self::DS . $retour['squelette'] . '.tpl.html';
104
				$contenu   = $this->traiterSquelettePhp( $squelette, $retour['donnees'] );
105
			} else {
3226 idir 106
 
3233 idir 107
				$this->messages[] = 'Les données à transmettre au squelette sont nulles.';
108
			}
109
		}
110
		$this->envoyer($contenu);
111
	}
3226 idir 112
 
3233 idir 113
	private function executerManager() {
114
		$params = array();
115
		$retour['squelette'] = 'manager';
3226 idir 116
 
3233 idir 117
		foreach ( $this->parametres_autorises as $id => $pa ) {
118
			if ( isset( $this->parametres[$pa] ) ) {
119
				$params[] = $pa . '=' . $this->parametres[$pa];
120
			}
121
		}
3226 idir 122
 
3233 idir 123
		$param = implode( $params, '&' );
124
		$url   = $this->cel_url_tpl;
3226 idir 125
 
3233 idir 126
		if ( $param !== '' ) {
127
			$url .= '?' . $param;
128
		}
3226 idir 129
 
3233 idir 130
		$json = $this->getDao()->consulter( $url );
3241 idir 131
		$retour['donnees']['widget']        = (array) json_decode( $json, true );
132
		$retour['donnees']['widgetUrlTpl']  = $this->config['manager']['widgetUrlTpl'];
133
		$retour['donnees']['chemin_images'] = sprintf( $this->config['chemins']['baseURLAbsoluDyn'], $this->config['manager']['dossierTmp'] );
3226 idir 134
 
3233 idir 135
		return $retour;
136
	}
3226 idir 137
 
3233 idir 138
	private function executerCreation() {
139
		//https://api.tela-botanica.org/service:cel:NomsChampsEtendus/cle
140
		$jsonlangue    = $this->getDao()->consulter( $this->config['manager']['languesUrl'] );
141
		$tableaulangue = (array) json_decode( $jsonlangue, true );
142
		$retour['squelette']          = 'creation';
143
		$retour['donnees']['langues'] = $tableaulangue['resultat'] ;
144
		$retour['donnees']['widget']  = array();
3226 idir 145
 
3233 idir 146
		if ( isset( $this->parametres['projet'] ) ) {
147
			$url     = $this->cel_url_tpl . '?projet=' . $this->parametres['projet'];
148
			$json    = $this->getDao()->consulter( $url );
149
			$tableau = (array) json_decode( $json, true );
150
			$retour['donnees']['widget'] = $tableau[0];
151
		}
3226 idir 152
 
3233 idir 153
		$urltype     = $this->cel_url_tpl . '?esttype=1';
154
		$jsontype    = $this->getDao()->consulter( $urltype );
155
		$tableautype = (array) json_decode( $jsontype, true );
156
		$retour['donnees']['type'] = $tableautype;
3226 idir 157
 
3233 idir 158
		return $retour;
159
	}
3226 idir 160
 
161
 
162
 
3233 idir 163
	private function executerModification() {
164
		$retour = array();
165
		if ( isset( $this->parametres['projet'] ) ) {
3226 idir 166
 
3233 idir 167
			$url     = $this->cel_url_tpl . '?projet=' . $this->parametres['projet'] . '&langue=' . $this->parametres['langue'];
168
			$json    = $this->getDao()->consulter( $url );
169
			$tableau = (array) json_decode( $json, true );
170
			$retour['squelette']         = 'creation';
171
			$retour['donnees']['widget'] = $tableau[0];
3226 idir 172
 
3233 idir 173
			$urltype     = $this->cel_url_tpl .'?esttype=1';
174
			$jsontype    = $this->getDao()->consulter( $urltype );
175
			$tableautype = (array) json_decode( $jsontype, true );
176
			$retour['donnees']['type'] = $tableautype;
177
		}//print_r($retour['donnees']);
3226 idir 178
 
3233 idir 179
		return $retour;
180
	}
181
	private function traiterParametres() {
182
		$parametres_flux = '?';
3281 delphine 183
		$criteres        = array( 'projet', 'langue', 'titre' );
3226 idir 184
 
3233 idir 185
		foreach( $this->parametres as $nom_critere => $valeur_critere ) {
186
			if ( in_array( $nom_critere, $criteres ) ) {
3226 idir 187
 
3233 idir 188
				$valeur_critere   = str_replace( ' ', '%20', $valeur_critere );
189
				$parametres_flux .= $nom_critere . '=' . $valeur_critere . '&';
190
			}
191
		}
3226 idir 192
 
3233 idir 193
		$parametres_flux = ( $parametres_flux === '?' ) ? '' : rtrim( $parametres_flux, '&' );
3226 idir 194
 
3233 idir 195
		return $parametres_flux;
196
	}
3226 idir 197
 
3233 idir 198
	private function traiterParametresModif() {
199
		$parametres_modif = array();
3226 idir 200
 
3233 idir 201
		foreach ( $_POST as $id => $parametres ) {
202
			if ($parametres !== '' ) {
203
				$parametres_modif[$id] = $parametres;
3282 delphine 204
			} else {
205
			    $parametres_modif[$id] = NULL;
3233 idir 206
			}
207
		}
208
		return $parametres_modif;
209
	}
3226 idir 210
 
3233 idir 211
	private function traiterDonneesFiles() {
212
		$return = array();
213
		$transmettre_donnees = false;
214
		$files_names = array();
215
		$help_files_names = array();
216
		$error =
217
			"<div class=\"message-echec container\">Echec du téléchargement : ".
218
	    	"L\'extention de l\'image pour " . $nom . " n\'est pas bonne".
219
	    	", formats acceptés : png, gif, jpg, jpeg, ou csv.".
220
			"</div>";
3241 idir 221
		$image_projet_langue = ( $this->parametres['langue'] !== 'fr' ) ? '_' . $this->parametres['langue'] : '';
222
		$dossier_url = __DIR__ . '/squelettes/img/images_projets/' . $_POST['projet'] . $image_projet_langue . '/';
3226 idir 223
 
3233 idir 224
		foreach ( array_keys( $_FILES ) as $file ) {
3226 idir 225
 
3233 idir 226
			if ( $_FILES[$file]['name'] !== '' ) {
227
				$extension = $this->obtenirExtension( $_FILES[$file] );
3226 idir 228
 
3233 idir 229
				if ( $extension ) {
3226 idir 230
 
3233 idir 231
					$transmettre_donnees = true;
3226 idir 232
 
3235 idir 233
			 		if ( strstr( $file, 'help-') ) {
234
			 			// Pas besoin de $return :
235
			 			// Type déjà transmis dans le json des champs supp
236
						$real_file_key = str_replace( 'help-', '', $file );
237
						$help_files_names[$real_file_key] = $real_file_key . '.' . $extension;
238
					} else {
239
						$return[$file] = $_FILES[$file]['type'];
240
					 	$files_names[$file] = $file .'.' . $extension;
3233 idir 241
					}
242
				} else {
3235 idir 243
 
3233 idir 244
					echo (
245
						"<div class=\"message-echec container\">Echec du téléchargement : ".
246
				    	"L\'extention de l\'image pour " . $nom . " n\'est pas bonne".
247
				    	", formats acceptés : png, gif, jpg, jpeg, ou csv.".
248
						"</div>"
249
					);
250
				}
251
			}
252
		}
3226 idir 253
 
3233 idir 254
		if ( $transmettre_donnees ) {
255
			if( !is_dir( $dossier_url ) ) {
3164 idir 256
 
3233 idir 257
				mkdir( $dossier_url, 0755 );
258
			}
3226 idir 259
 
3233 idir 260
			// Téléversements
261
			if ( count( $files_names ) > 0 ) {
262
				foreach ( array_keys( $files_names ) as $file ) {
263
					$this->televerser( $file, $files_names[ $file ], $dossier_url );
264
				}
265
			}
266
			if ( count( $help_files_names ) > 0 ) {
267
				foreach ( array_keys( $help_files_names ) as $file ) {
268
					$this->televerser( 'help-' . $file, $help_files_names[ $file ], $dossier_url );
269
				}
270
			}
271
		}
3226 idir 272
 
3233 idir 273
		return $return;
274
	}
3226 idir 275
 
3233 idir 276
	private function televerser( $file, $full_name, $dossier_url ) {
277
		$taille_maxi = 5242880;
278
		$taille      = filesize( $_FILES[$file]['tmp_name'] );
279
		$extension   = $this->obtenirExtension( $_FILES[$file] );
280
		$file_name   = str_replace( $extension, '', $full_name );
3226 idir 281
 
3233 idir 282
		//Début des vérifications de sécurité...
283
		if ( file_exists( $dossier_url . $full_name ) ) {
3226 idir 284
 
3233 idir 285
			if ( $_POST['mode'] === 'modification' ) {
3226 idir 286
 
3233 idir 287
				// Le fichier existe déjà, c'est normal si on est en mode modification
288
				unlink ( $dossier_url . $full_name );
289
			} else {
3226 idir 290
 
3233 idir 291
				$erreur =
292
					"<div class=\"message-echec container\">Echec du téléchargement : ".
293
						"Un fichier pour \"" . $file_name.
294
						"\", existe déjà dans un projet nommé \"" . $_POST['projet'] . "\".".
295
						"<br>Vérifiez que le nom du projet n'est pas déjà pris, ".
296
						"ou qu'un fichier \"" . $full_name . "\" n'ait pas déjà été téléchargé pour ce projet.".
297
					"</div>";
298
			}
299
		}
3226 idir 300
 
3233 idir 301
		if ( !$extension ) {
3226 idir 302
 
3233 idir 303
			//Si le format n'est pas bon
304
			$erreur =
305
				"<div class=\"message-echec container\">".
306
					"Echec du téléchargement pour ".
307
					"\"" . $file_name . "\" ".
308
					", formats acceptés : png, gif, jpg, jpeg, ou csv".
309
				"</div>";
310
		}
3226 idir 311
 
3233 idir 312
		if ( $taille > $taille_maxi ) {
3226 idir 313
 
3233 idir 314
			$erreur =
315
				"<div class=\"message-echec container\">".
316
					"Echec du téléchargement pour ".
317
					"\"" . $file_name . "\" ".
318
					": Max 5Mo".
319
				"</div>";
320
		}
3226 idir 321
 
3233 idir 322
		if ( isset( $erreur ) ) {
3226 idir 323
 
3233 idir 324
			echo $erreur;
325
		} else {
3226 idir 326
 
3233 idir 327
			if ( !move_uploaded_file( $_FILES[$file]['tmp_name'], $dossier_url . $this->remove_accents( $full_name ) ) ) {
328
			// move_uploaded_file() renvoie false si l'upload a échoué
329
				echo
330
					"<div class=\"message-echec container\">".
331
						"Erreur du téléchargement pour ".
332
						"\"" . $file_name . "\"".
333
					"</div>";
334
			}
335
		}
336
	}
3226 idir 337
 
3233 idir 338
	private function obtenirExtension( $files ) {
339
		$type = exif_imagetype( $files['tmp_name'] );
340
		//une vérif pas mal pour les types image
341
		if ( $type == ( IMAGETYPE_PNG || IMAGETYPE_JPEG || IMAGETYPE_GIF ) ) {
3226 idir 342
 
3233 idir 343
	    switch ( $type ) {
344
	      case '1' :
345
	        $format = 'gif';
346
	        break;
347
	      case '2' :
348
	        $format = 'jpg';
349
	        break;
350
	      case '3' :
351
	        $format = 'png';
352
	        break;
353
	      default :
354
	      	break;
355
	    }
356
	  } elseif ( str_replace( '.csv' , '', $files['name'] ) && substr( strrchr($files['type'], '/' ), 1 ) === 'csv' ) {
357
	  	// Pas trouvé mieux pour csv :
358
	  	// Les fonctions qui pourraient utiliser $_FILES[file]["tmp_path"] me répondent "text/plain"...
3226 idir 359
 
3233 idir 360
	  	$format = 'csv';
361
	  } else {
3226 idir 362
 
3233 idir 363
	  	return false;
364
	  }
365
		return $format;
366
	}
3226 idir 367
 
3233 idir 368
	private function remove_accents( $string ) {
369
		if ( !preg_match( '/[\x80-\xff]/' , $string ) ) {
3226 idir 370
 
3233 idir 371
			return $string;
372
		}
3226 idir 373
 
3233 idir 374
		$chars = array(
375
			// Decompositions for Latin-1 Supplement
376
			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
377
			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
378
			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
379
			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
380
			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
381
			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
382
			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
383
			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
384
			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
385
			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
386
			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
387
			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
388
			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
389
			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
390
			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
391
			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
392
			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
393
			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
394
			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
395
			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
396
			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
397
			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
398
			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
399
			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
400
			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
401
			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
402
			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
403
			chr(195).chr(191) => 'y',
404
			// Decompositions for Latin Extended-A
405
			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
406
			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
407
			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
408
			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
409
			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
410
			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
411
			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
412
			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
413
			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
414
			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
415
			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
416
			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
417
			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
418
			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
419
			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
420
			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
421
			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
422
			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
423
			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
424
			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
425
			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
426
			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
427
			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
428
			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
429
			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
430
			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
431
			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
432
			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
433
			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
434
			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
435
			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
436
			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
437
			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
438
			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
439
			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
440
			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
441
			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
442
			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
443
			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
444
			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
445
			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
446
			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
447
			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
448
			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
449
			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
450
			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
451
			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
452
			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
453
			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
454
			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
455
			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
456
			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
457
			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
458
			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
459
			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
460
			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
461
			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
462
			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
463
			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
464
			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
465
			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
466
			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
467
			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
468
			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
469
		);
3226 idir 470
 
3233 idir 471
		$string = strtr( $string, $chars );
3226 idir 472
 
3233 idir 473
		return preg_replace( '/([^.a-z0-9]+)/i', '-', $string );
474
	}
3122 delphine 475
}