Subversion Repositories eFlore/Applications.cel

Rev

Rev 3359 | Rev 3361 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3359 Rev 3360
1
 <?php
1
 <?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Service affichant les dernières photo publiques du CEL ouvrable sous forme de diaporama.
4
 * Service affichant les dernières photo publiques du CEL ouvrable sous forme de diaporama.
5
 * Encodage en entrée : utf8
5
 * Encodage en entrée : utf8
6
 * Encodage en sortie : utf8
6
 * Encodage en sortie : utf8
7
 *
7
 *
8
 * Cas d'utilisation et documentation :
8
 * Cas d'utilisation et documentation :
9
 * @link http://www.tela-botanica.org/wikini/eflore/wakka.php?wiki=AideCELWidgetPhoto
9
 * @link http://www.tela-botanica.org/wikini/eflore/wakka.php?wiki=AideCELWidgetPhoto
10
 *
10
 *
11
 * Paramètres :
11
 * Paramètres :
12
 * ===> extra = booléen (1 ou 0)  [par défaut : 1]
12
 * ===> extra = booléen (1 ou 0)  [par défaut : 1]
13
 * Affiche / Cache la vignette en taille plus importante au bas du widget.
13
 * Affiche / Cache la vignette en taille plus importante au bas du widget.
14
 * ===> vignette = [0-9]+,[0-9]+  [par défaut : 4,3]
14
 * ===> vignette = [0-9]+,[0-9]+  [par défaut : 4,3]
15
 * Indique le nombre de vignette par ligne et le nombre de ligne.
15
 * Indique le nombre de vignette par ligne et le nombre de ligne.
16
 *
16
 *
17
 * @author              Jean-Pascal MILCENT <jpm@tela-botanica.org>
17
 * @author              Jean-Pascal MILCENT <jpm@tela-botanica.org>
18
 * @license     GPL v3 <http://www.gnu.org/licenses/gpl.txt>
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>
19
 * @license     CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
20
 * @version     $Id$
20
 * @version     $Id$
21
 * @copyright   Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
21
 * @copyright   Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
22
 */
22
 */
23
class Manager extends WidgetCommun {
23
class Manager extends WidgetCommun {
24
 
24
 
25
	const DS = DIRECTORY_SEPARATOR;
25
	const DS = DIRECTORY_SEPARATOR;
26
	const SERVICE_DEFAUT = 'manager';
26
	const SERVICE_DEFAUT = 'manager';
27
	private $cel_url_tpl = null;
27
	private $cel_url_tpl = null;
28
	/** Si spécifié, on ajoute une barre de navigation inter-applications */
28
	/** Si spécifié, on ajoute une barre de navigation inter-applications */
29
	private $bar;
29
	private $bar;
30
	//private $parametres_autorises = array('projet', 'type', 'langue', 'order');
30
	//private $parametres_autorises = array('projet', 'type', 'langue', 'order');
31
	private $parametres_autorises = array(
31
	private $parametres_autorises = array(
32
		'projet' => 'projet',
32
		'projet' => 'projet',
33
		'type' => 'type',
33
		'type' => 'type',
34
		'langue' => 'langue',
34
		'langue' => 'langue',
35
		'order' => 'order'
35
		'order' => 'order'
36
	);
36
	);
37
	/**
37
	/**
38
	 * Méthode appelée par défaut pour charger ce widget.
38
	 * Méthode appelée par défaut pour charger ce widget.
39
	 */
39
	 */
40
	public function executer() {
40
	public function executer() {
41
		$retour = null;
41
		$retour = null;
42
 
42
 
43
		// Pour la création de l'id du cache nous ne tenons pas compte du paramètre de l'url callback
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'] );
44
		unset( $this->parametres['callback'] );
45
		extract( $this->parametres );
45
		extract( $this->parametres );
46
		$this->bar = ( isset( $bar ) ) ? $bar : false;
46
		$this->bar = ( isset( $bar ) ) ? $bar : false;
47
 
47
 
48
		$framework = dirname( __FILE__ ) . '/framework.php';
48
		$framework = dirname( __FILE__ ) . '/framework.php';
49
 
49
 
50
		if ( !file_exists( $framework ) ) {
50
		if ( !file_exists( $framework ) ) {
51
			$e = 'Veuillez paramêtrer l\'emplacement et la version du Framework dans le fichier $framework';
51
			$e = 'Veuillez paramêtrer l\'emplacement et la version du Framework dans le fichier $framework';
52
			trigger_error( $e, E_USER_ERROR );
52
			trigger_error( $e, E_USER_ERROR );
53
		} else {
53
		} else {
54
			// Inclusion du Framework
54
			// Inclusion du Framework
55
			require_once $framework;
55
			require_once $framework;
56
			// Ajout d'information concernant cette application
56
			// Ajout d'information concernant cette application
57
			Framework::setCheminAppli( __FILE__ );// Obligatoire
57
			Framework::setCheminAppli( __FILE__ );// Obligatoire
58
			Framework::setInfoAppli( Config::get( 'info' ) );// Optionnel
58
			Framework::setInfoAppli( Config::get( 'info' ) );// Optionnel
59
		}
59
		}
60
 
60
 
61
		if ( !isset( $mode ) ) {
61
		if ( !isset( $mode ) ) {
62
			$mode = self::SERVICE_DEFAUT;
62
			$mode = self::SERVICE_DEFAUT;
63
		}
63
		}
64
 
64
 
65
		$this->cel_url_tpl = $this->config['manager']['celUrlTpl'];
65
		$this->cel_url_tpl = $this->config['manager']['celUrlTpl'];
66
 
66
 
67
		if ( $_POST !== array() ) { //print_r($_POST);
67
		if ( $_POST !== array() ) { //print_r($_POST);
68
			$this->parametres['projet'] = $_POST['projet'];
68
			$this->parametres['projet'] = $_POST['projet'];
69
			$this->parametres['langue'] = $_POST['langue'];
69
			$this->parametres['langue'] = $_POST['langue'];
70
 
70
 
71
			if ( $mode === 'modification' ) {
71
			if ( $mode === 'modification' ) {
72
				$parametres = $this->traiterParametresModif();
72
				$parametres = $this->traiterParametresModif();
73
				$donnees    = array_merge( $parametres, $this->traiterDonneesFiles() );
73
				$donnees    = array_merge( $parametres, $this->traiterDonneesFiles() );
74
				$json       = $this->getDao()->modifier( $this->cel_url_tpl, $donnees );
74
				$json       = $this->getDao()->modifier( $this->cel_url_tpl, $donnees );
75
			} else {
75
			} else {
76
				$donnees = array_merge( $_POST, $this->traiterDonneesFiles() );
76
				$donnees = array_merge( $_POST, $this->traiterDonneesFiles() );
77
				// var_dump($donnees);
77
				// var_dump($donnees);
78
				$json    = $this->getDao()->ajouter( $this->cel_url_tpl, $donnees );
78
				$json    = $this->getDao()->ajouter( $this->cel_url_tpl, $donnees );
79
				$mode    = $this->parametres['mode'] = 'modification';
79
				$mode    = $this->parametres['mode'] = 'modification';
80
			}
80
			}
81
		}
81
		}
82
 
82
 
83
		$methode = $this->traiterNomMethodeExecuter( $mode );
83
		$methode = $this->traiterNomMethodeExecuter( $mode );
84
		if ( method_exists( $this, $methode ) ) {
84
		if ( method_exists( $this, $methode ) ) {
85
			$retour = $this->$methode();
85
			$retour = $this->$methode();
86
		} else {
86
		} else {
87
 
87
 
88
			$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
88
			$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
89
		}
89
		}
90
 
90
 
91
		$contenu = '';
91
		$contenu = '';
92
		if ( is_null( $retour ) ) {
92
		if ( is_null( $retour ) ) {
93
			$this->messages[] = 'La ressource demandée a retourné une valeur nulle.';
93
			$this->messages[] = 'La ressource demandée a retourné une valeur nulle.';
94
 
94
 
95
		} else {
95
		} else {
96
 
96
 
97
			if ( isset( $retour['donnees'] ) ) {
97
			if ( isset( $retour['donnees'] ) ) {
98
				$retour['donnees']['params']   = '&projet=' . $_POST['projet'] . '&langue=' . $_POST['langue'];
98
				$retour['donnees']['params']   = '&projet=' . $_POST['projet'] . '&langue=' . $_POST['langue'];
99
				$retour['donnees']['prod']     = ( $this->config['parametres']['modeServeur'] === 'prod' );
99
				$retour['donnees']['prod']     = ( $this->config['parametres']['modeServeur'] === 'prod' );
100
				$retour['donnees']['bar']      = $this->bar;
100
				$retour['donnees']['bar']      = $this->bar;
101
				$retour['donnees']['url_base'] = sprintf( $this->config['chemins']['baseURLAbsoluDyn'], '' );
101
				$retour['donnees']['url_base'] = sprintf( $this->config['chemins']['baseURLAbsoluDyn'], '' );
102
				$retour['donnees']['chemin_images'] = sprintf( $this->config['chemins']['baseURLAbsoluDyn'], $this->config['manager']['dossierTmp'] );
102
				$retour['donnees']['chemin_images'] = sprintf( $this->config['chemins']['baseURLAbsoluDyn'], $this->config['manager']['dossierTmp'] );
103
				$retour['donnees']['mode']     = $mode; //print_r($retour);
103
				$retour['donnees']['mode']     = $mode; //print_r($retour);
104
				$squelette = dirname( __FILE__ ) . self::DS . 'squelettes' . self::DS . $retour['squelette'] . '.tpl.html';
104
				$squelette = dirname( __FILE__ ) . self::DS . 'squelettes' . self::DS . $retour['squelette'] . '.tpl.html';
105
				$contenu   = $this->traiterSquelettePhp( $squelette, $retour['donnees'] );
105
				$contenu   = $this->traiterSquelettePhp( $squelette, $retour['donnees'] );
106
			} else {
106
			} else {
107
 
107
 
108
				$this->messages[] = 'Les données à transmettre au squelette sont nulles.';
108
				$this->messages[] = 'Les données à transmettre au squelette sont nulles.';
109
			}
109
			}
110
		}
110
		}
111
		$this->envoyer($contenu);
111
		$this->envoyer($contenu);
112
	}
112
	}
113
 
113
 
114
	private function executerManager() {
114
	private function executerManager() {
115
		$params = array();
115
		$params = array();
116
		$retour['squelette'] = 'manager';
116
		$retour['squelette'] = 'manager';
117
 
117
 
118
		foreach ( $this->parametres_autorises as $id => $pa ) {
118
		foreach ( $this->parametres_autorises as $id => $pa ) {
119
			if ( isset( $this->parametres[$pa] ) ) {
119
			if ( isset( $this->parametres[$pa] ) ) {
120
				$params[] = $pa . '=' . $this->parametres[$pa];
120
				$params[] = $pa . '=' . $this->parametres[$pa];
121
			}
121
			}
122
		}
122
		}
123
 
123
 
124
		$param = implode( $params, '&' );
124
		$param = implode( $params, '&' );
125
		$url   = $this->cel_url_tpl;
125
		$url   = $this->cel_url_tpl;
126
 
126
 
127
		if ( $param !== '' ) {
127
		if ( $param !== '' ) {
128
			$url .= '?' . $param;
128
			$url .= '?' . $param;
129
		}
129
		}
130
 
130
 
131
		$json = $this->getDao()->consulter( $url );
131
		$json = $this->getDao()->consulter( $url );
132
		$retour['donnees']['widget']        = (array) json_decode( $json, true );
132
		$retour['donnees']['widget']        = (array) json_decode( $json, true );
133
		$retour['donnees']['widgetUrlTpl']  = $this->config['manager']['widgetUrlTpl'];
133
		$retour['donnees']['widgetUrlTpl']  = $this->config['manager']['widgetUrlTpl'];
134
 
134
 
135
		return $retour;
135
		return $retour;
136
	}
136
	}
137
 
137
 
138
	private function executerCreation() {
138
	private function executerCreation() {
139
		//https://api.tela-botanica.org/service:cel:NomsChampsEtendus/cle
139
		//https://api.tela-botanica.org/service:cel:NomsChampsEtendus/cle
140
		$jsonlangue    = $this->getDao()->consulter( $this->config['manager']['languesUrl'] );
140
		$jsonlangue    = $this->getDao()->consulter( $this->config['manager']['languesUrl'] );
141
		$tableaulangue = (array) json_decode( $jsonlangue, true );
141
		$tableaulangue = (array) json_decode( $jsonlangue, true );
142
		$retour['squelette']          = 'creation';
142
		$retour['squelette']          = 'creation';
143
		$retour['donnees']['langues'] = $tableaulangue['resultat'] ;
143
		$retour['donnees']['langues'] = $tableaulangue['resultat'] ;
144
		$retour['donnees']['widget']  = array();
144
		$retour['donnees']['widget']  = array();
145
 
145
 
146
		if ( isset( $this->parametres['projet'] ) ) {
146
		if ( isset( $this->parametres['projet'] ) ) {
147
			$url     = $this->cel_url_tpl . '?projet=' . $this->parametres['projet'];
147
			$url     = $this->cel_url_tpl . '?projet=' . $this->parametres['projet'];
148
			$json    = $this->getDao()->consulter( $url );
148
			$json    = $this->getDao()->consulter( $url );
149
			$tableau = (array) json_decode( $json, true );
149
			$tableau = (array) json_decode( $json, true );
150
			$retour['donnees']['widget'] = $tableau[0];
150
			$retour['donnees']['widget'] = $tableau[0];
151
		}
151
		}
152
 
152
 
153
		$urltype     = $this->cel_url_tpl . '?esttype=1';
153
		$urltype     = $this->cel_url_tpl . '?esttype=1';
154
		$jsontype    = $this->getDao()->consulter( $urltype );
154
		$jsontype    = $this->getDao()->consulter( $urltype );
155
		$tableautype = (array) json_decode( $jsontype, true );
155
		$tableautype = (array) json_decode( $jsontype, true );
156
		$retour['donnees']['type'] = $tableautype;
156
		$retour['donnees']['type'] = $tableautype;
157
 
157
 
158
		return $retour;
158
		return $retour;
159
	}
159
	}
160
 
160
 
161
 
161
 
162
 
162
 
163
	private function executerModification() {
163
	private function executerModification() {
164
		$retour = array();
164
		$retour = array();
165
		if ( isset( $this->parametres['projet'] ) ) {
165
		if ( isset( $this->parametres['projet'] ) ) {
166
 
166
 
167
			$url     = $this->cel_url_tpl . '?projet=' . $this->parametres['projet'] . '&langue=' . $this->parametres['langue'];
167
			$url     = $this->cel_url_tpl . '?projet=' . $this->parametres['projet'] . '&langue=' . $this->parametres['langue'];
168
			$json    = $this->getDao()->consulter( $url );
168
			$json    = $this->getDao()->consulter( $url );
169
			$tableau = (array) json_decode( $json, true );
169
			$tableau = (array) json_decode( $json, true );
170
			$retour['squelette']         = 'creation';
170
			$retour['squelette']         = 'creation';
171
			$retour['donnees']['widget'] = $tableau[0];
171
			$retour['donnees']['widget'] = $tableau[0];
-
 
172
			// En prévision d'un service permettant la suppression/modification champs supp
-
 
173
			$retour['donnees']['widget']['chpSupp'] = $this->rechercherChampsSupp();
172
 
174
 
173
			$urltype     = $this->cel_url_tpl .'?esttype=1';
175
			$urltype     = $this->cel_url_tpl .'?esttype=1';
174
			$jsontype    = $this->getDao()->consulter( $urltype );
176
			$jsontype    = $this->getDao()->consulter( $urltype );
175
			$tableautype = (array) json_decode( $jsontype, true );
177
			$tableautype = (array) json_decode( $jsontype, true );
176
			$retour['donnees']['type'] = $tableautype;
178
			$retour['donnees']['type'] = $tableautype;
177
		}//print_r($retour['donnees']);
179
		}//print_r($retour['donnees']);
178
 
180
 
179
		return $retour;
181
		return $retour;
180
	}
182
	}
181
	private function traiterParametres() {
183
	private function traiterParametres() {
182
		$parametres_flux = '?';
184
		$parametres_flux = '?';
183
		$criteres        = array( 'projet', 'langue', 'titre' );
185
		$criteres        = array( 'projet', 'langue', 'titre' );
184
 
186
 
185
		foreach( $this->parametres as $nom_critere => $valeur_critere ) {
187
		foreach( $this->parametres as $nom_critere => $valeur_critere ) {
186
			if ( in_array( $nom_critere, $criteres ) ) {
188
			if ( in_array( $nom_critere, $criteres ) ) {
187
				$valeur_critere   = str_replace( ' ', '%20', $valeur_critere );
189
				$valeur_critere   = str_replace( ' ', '%20', $valeur_critere );
188
				$parametres_flux .= $nom_critere . '=' . $valeur_critere . '&';
190
				$parametres_flux .= $nom_critere . '=' . $valeur_critere . '&';
189
			}
191
			}
190
		}
192
		}
191
 
193
 
192
		$parametres_flux = ( $parametres_flux === '?' ) ? '' : rtrim( $parametres_flux, '&' );
194
		$parametres_flux = ( $parametres_flux === '?' ) ? '' : rtrim( $parametres_flux, '&' );
193
 
195
 
194
		return $parametres_flux;
196
		return $parametres_flux;
195
	}
197
	}
196
 
198
 
197
	private function traiterParametresModif() {
199
	private function traiterParametresModif() {
198
		$parametres_modif = array();
200
		$parametres_modif = array();
199
 
201
 
200
		foreach ( $_POST as $id => $parametres ) {
202
		foreach ( $_POST as $id => $parametres ) {
201
			if ($parametres !== '' ) {
203
			if ($parametres !== '' ) {
202
				$parametres_modif[$id] = $parametres;
204
				$parametres_modif[$id] = $parametres;
203
			} else {
205
			} else {
204
				$parametres_modif[$id] = ' ';
206
				$parametres_modif[$id] = ' ';
205
			}
207
			}
206
		}
208
		}
207
		return $parametres_modif;
209
		return $parametres_modif;
208
	}
210
	}
209
 
211
 
210
	private function traiterDonneesFiles() {
212
	private function traiterDonneesFiles() {
211
		$return = array();
213
		$return = array();
212
		$transmettre_donnees = false;
214
		$transmettre_donnees = false;
213
		$files_names = array();
215
		$files_names = array();
214
		$help_files_names = array();
216
		$help_files_names = array();
215
		$error =
217
		$error =
216
			"<div class=\"message-echec container\">Echec du téléchargement : ".
218
			"<div class=\"message-echec container\">Echec du téléchargement : ".
217
			"L\'extention de l\'image pour " . $nom . " n\'est pas bonne".
219
			"L\'extention de l\'image pour " . $nom . " n\'est pas bonne".
218
			", formats acceptés : png, gif, jpg, jpeg, ou csv.".
220
			", formats acceptés : png, gif, jpg, jpeg, ou csv.".
219
			"</div>";
221
			"</div>";
220
		$image_projet_langue = ( $this->parametres['langue'] !== 'fr' ) ? '_' . $this->parametres['langue'] : '';
222
		$image_projet_langue = ( $this->parametres['langue'] !== 'fr' ) ? '_' . $this->parametres['langue'] : '';
221
		$dossier_url = __DIR__ . '/squelettes/img/images_projets/' . $_POST['projet'] . $image_projet_langue . '/';
223
		$dossier_url = __DIR__ . '/squelettes/img/images_projets/' . $_POST['projet'] . $image_projet_langue . '/';
222
 
224
 
223
		foreach ( array_keys( $_FILES ) as $file ) {
225
		foreach ( array_keys( $_FILES ) as $file ) {
224
			if ( $_FILES[$file]['name'] !== '' ) {
226
			if ( $_FILES[$file]['name'] !== '' ) {
225
				$extension = $this->obtenirExtension( $_FILES[$file] );
227
				$extension = $this->obtenirExtension( $_FILES[$file] );
226
 
228
 
227
				if ( $extension ) {
229
				if ( $extension ) {
228
					$transmettre_donnees = true;
230
					$transmettre_donnees = true;
229
 
231
 
230
					if ( strstr( $file, 'help-') ) {
232
					if ( strstr( $file, 'help-') ) {
231
						// Pas besoin de $return :
233
						// Pas besoin de $return :
232
						// Type déjà transmis dans le json des champs supp
234
						// Type déjà transmis dans le json des champs supp
233
						$real_file_key = str_replace( 'help-', '', $file );
235
						$real_file_key = str_replace( 'help-', '', $file );
234
						$help_files_names[$real_file_key] = $real_file_key . '.' . $extension;
236
						$help_files_names[$real_file_key] = $real_file_key . '.' . $extension;
235
					} else {
237
					} else {
236
						$return[$file] = $_FILES[$file]['type'];
238
						$return[$file] = $_FILES[$file]['type'];
237
						$files_names[$file] = $file .'.' . $extension;
239
						$files_names[$file] = $file .'.' . $extension;
238
					}
240
					}
239
				} else {
241
				} else {
240
					echo (
242
					echo (
241
						"<div class=\"message-echec container\">Echec du téléchargement : ".
243
						"<div class=\"message-echec container\">Echec du téléchargement : ".
242
						"L\'extention de l\'image pour " . $nom . " n\'est pas bonne".
244
						"L\'extention de l\'image pour " . $nom . " n\'est pas bonne".
243
						", formats acceptés : png, gif, jpg, jpeg, ou csv.".
245
						", formats acceptés : png, gif, jpg, jpeg, ou csv.".
244
						"</div>"
246
						"</div>"
245
					);
247
					);
246
				}
248
				}
247
			}
249
			}
248
		}
250
		}
249
 
251
 
250
		if ( $transmettre_donnees ) {
252
		if ( $transmettre_donnees ) {
251
			if( !is_dir( $dossier_url ) ) {
253
			if( !is_dir( $dossier_url ) ) {
252
				mkdir( $dossier_url, 0755 );
254
				mkdir( $dossier_url, 0755 );
253
			}
255
			}
254
			// Téléversements
256
			// Téléversements
255
			if ( count( $files_names ) > 0 ) {
257
			if ( count( $files_names ) > 0 ) {
256
				foreach ( array_keys( $files_names ) as $file ) {
258
				foreach ( array_keys( $files_names ) as $file ) {
257
					$this->televerser( $file, $files_names[ $file ], $dossier_url );
259
					$this->televerser( $file, $files_names[ $file ], $dossier_url );
258
				}
260
				}
259
			}
261
			}
260
			if ( count( $help_files_names ) > 0 ) {
262
			if ( count( $help_files_names ) > 0 ) {
261
				foreach ( array_keys( $help_files_names ) as $file ) {
263
				foreach ( array_keys( $help_files_names ) as $file ) {
262
					$this->televerser( 'help-' . $file, $help_files_names[ $file ], $dossier_url );
264
					$this->televerser( 'help-' . $file, $help_files_names[ $file ], $dossier_url );
263
				}
265
				}
264
			}
266
			}
265
		}
267
		}
266
		return $return;
268
		return $return;
267
	}
269
	}
268
 
270
 
269
	private function televerser( $file, $full_name, $dossier_url ) {
271
	private function televerser( $file, $full_name, $dossier_url ) {
270
		$taille_maxi  = 5242880;
272
		$taille_maxi  = 5242880;
271
		$taille       = filesize( $_FILES[$file]['tmp_name'] );
273
		$taille       = filesize( $_FILES[$file]['tmp_name'] );
272
		$extension    = $this->obtenirExtension( $_FILES[$file] );
274
		$extension    = $this->obtenirExtension( $_FILES[$file] );
273
		$file_name    = str_replace( '.' . $extension, '', $full_name );
275
		$file_name    = str_replace( '.' . $extension, '', $full_name );
274
		$file_exists  = file_exists( $dossier_url . $full_name );
276
		$file_exists  = file_exists( $dossier_url . $full_name );
275
		$ex_file_name = $full_name;
277
		$ex_file_name = $full_name;
276
 
278
 
277
		// verifier l'existance d'un fichier avec une extention différente
279
		// verifier l'existance d'un fichier avec une extention différente
278
		// ex: logo.png vers logo.jpg
280
		// ex: logo.png vers logo.jpg
279
		if ( !$file_exists ) {
281
		if ( !$file_exists ) {
280
			switch ( $extension ) {
282
			switch ( $extension ) {
281
				case 'png':
283
				case 'png':
282
					$ex_file_name = $file_name . '.jpg';
284
					$ex_file_name = $file_name . '.jpg';
283
					break;
285
					break;
284
				case 'csv':
286
				case 'csv':
285
					$ex_file_name = $file_name . '.tsv';
287
					$ex_file_name = $file_name . '.tsv';
286
					break;
288
					break;
287
				case 'tsv':
289
				case 'tsv':
288
					$ex_file_name = $file_name . '.csv';
290
					$ex_file_name = $file_name . '.csv';
289
					break;
291
					break;
290
				case 'jpg':
292
				case 'jpg':
291
				default:
293
				default:
292
					$ex_file_name = $file_name . '.png';
294
					$ex_file_name = $file_name . '.png';
293
					break;
295
					break;
294
			}
296
			}
295
			$file_exists = file_exists( $dossier_url . $ex_file_name );
297
			$file_exists = file_exists( $dossier_url . $ex_file_name );
296
		}
298
		}
297
 
299
 
298
		//Début des vérifications de sécurité...
300
		//Début des vérifications de sécurité...
299
		if ( $file_exists ) {
301
		if ( $file_exists ) {
300
			if ( $this->parametres['mode'] === 'modification' ) {
302
			if ( $this->parametres['mode'] === 'modification' ) {
301
				// Le fichier existe déjà, c'est normal si on est en mode modification
303
				// Le fichier existe déjà, c'est normal si on est en mode modification
302
				unlink( $dossier_url . $ex_file_name );
304
				unlink( $dossier_url . $ex_file_name );
303
			} else {
305
			} else {
304
				$erreur =
306
				$erreur =
305
					"<div class=\"message-echec container\">Echec du téléchargement : ".
307
					"<div class=\"message-echec container\">Echec du téléchargement : ".
306
						"Un fichier pour \"" . $file_name.
308
						"Un fichier pour \"" . $file_name.
307
						"\", existe déjà dans un projet nommé \"" . $_POST['projet'] . "\".".
309
						"\", existe déjà dans un projet nommé \"" . $_POST['projet'] . "\".".
308
						"<br>Vérifiez que le nom du projet n'est pas déjà pris, ".
310
						"<br>Vérifiez que le nom du projet n'est pas déjà pris, ".
309
						"ou qu'un fichier \"" . $full_name . "\" n'ait pas déjà été téléchargé pour ce projet.".
311
						"ou qu'un fichier \"" . $full_name . "\" n'ait pas déjà été téléchargé pour ce projet.".
310
					"</div>";
312
					"</div>";
311
			}
313
			}
312
		}
314
		}
313
 
315
 
314
		if ( !$extension ) {
316
		if ( !$extension ) {
315
			//Si le format n'est pas bon
317
			//Si le format n'est pas bon
316
			$erreur =
318
			$erreur =
317
				"<div class=\"message-echec container\">".
319
				"<div class=\"message-echec container\">".
318
					"Echec du téléchargement pour ".
320
					"Echec du téléchargement pour ".
319
					"\"" . $file_name . "\" ".
321
					"\"" . $file_name . "\" ".
320
					", formats acceptés : png, gif, jpg, jpeg, ou csv".
322
					", formats acceptés : png, gif, jpg, jpeg, ou csv".
321
				"</div>";
323
				"</div>";
322
		}
324
		}
323
 
325
 
324
		if ( $taille > $taille_maxi ) {
326
		if ( $taille > $taille_maxi ) {
325
			$erreur =
327
			$erreur =
326
				"<div class=\"message-echec container\">".
328
				"<div class=\"message-echec container\">".
327
					"Echec du téléchargement pour ".
329
					"Echec du téléchargement pour ".
328
					"\"" . $file_name . "\" ".
330
					"\"" . $file_name . "\" ".
329
					": Max 5Mo".
331
					": Max 5Mo".
330
				"</div>";
332
				"</div>";
331
		}
333
		}
332
 
334
 
333
		if ( isset( $erreur ) ) {
335
		if ( isset( $erreur ) ) {
334
			echo $erreur;
336
			echo $erreur;
335
		} else {
337
		} else {
336
			$dest_file = $dossier_url . $this->remove_accents( $full_name );
338
			$dest_file = $dossier_url . $this->remove_accents( $full_name );
337
			if ( !move_uploaded_file( $_FILES[$file]['tmp_name'], $dest_file ) ) {
339
			if ( !move_uploaded_file( $_FILES[$file]['tmp_name'], $dest_file ) ) {
338
			// move_uploaded_file() renvoie false si l'upload a échoué
340
			// move_uploaded_file() renvoie false si l'upload a échoué
339
				echo
341
				echo
340
					"<div class=\"message-echec container\">".
342
					"<div class=\"message-echec container\">".
341
						"Erreur du téléchargement pour ".
343
						"Erreur du téléchargement pour ".
342
						"\"" . $file_name . "\"".
344
						"\"" . $file_name . "\"".
343
					"</div>";
345
					"</div>";
344
			} else {
346
			} else {
345
				chmod($dest_file, 0666);
347
				chmod($dest_file, 0666);
346
			}
348
			}
347
		}
349
		}
348
	}
350
	}
349
 
351
 
350
	private function obtenirExtension( $files ) {
352
	private function obtenirExtension( $files ) {
351
		$type = exif_imagetype( $files['tmp_name'] );
353
		$type = exif_imagetype( $files['tmp_name'] );
352
 
354
 
353
		//une vérif pas mal pour les types image
355
		//une vérif pas mal pour les types image
354
		if ( $type == ( IMAGETYPE_PNG || IMAGETYPE_JPEG || IMAGETYPE_GIF ) ) {
356
		if ( $type == ( IMAGETYPE_PNG || IMAGETYPE_JPEG || IMAGETYPE_GIF ) ) {
355
			switch ( $type ) {
357
			switch ( $type ) {
356
				case '1' :
358
				case '1' :
357
					$format = 'gif';
359
					$format = 'gif';
358
					break;
360
					break;
359
			 	case '2' :
361
			 	case '2' :
360
					$format = 'jpg';
362
					$format = 'jpg';
361
					break;
363
					break;
362
			 	case '3' :
364
			 	case '3' :
363
					$format = 'png';
365
					$format = 'png';
364
					break;
366
					break;
365
				default :
367
				default :
366
					break;
368
					break;
367
			}
369
			}
368
		} elseif ( str_replace( '.csv' , '', $files['name'] ) && substr( strrchr($files['type'], '/' ), 1 ) === 'csv' ) {
370
		} elseif ( str_replace( '.csv' , '', $files['name'] ) && substr( strrchr($files['type'], '/' ), 1 ) === 'csv' ) {
369
			// Pas trouvé mieux pour csv :
371
			// Pas trouvé mieux pour csv :
370
			// Les fonctions qui pourraient utiliser $_FILES[file]["tmp_path"] me répondent "text/plain"...
372
			// Les fonctions qui pourraient utiliser $_FILES[file]["tmp_path"] me répondent "text/plain"...
371
			$format = 'csv';
373
			$format = 'csv';
372
		} elseif ( str_replace( '.tsv' , '', $files['name'] ) && substr( strrchr($files['type'], '/' ), 1 ) === 'tsv' ) {
374
		} elseif ( str_replace( '.tsv' , '', $files['name'] ) && substr( strrchr($files['type'], '/' ), 1 ) === 'tsv' ) {
373
			$format = 'tsv';
375
			$format = 'tsv';
374
		} else {
376
		} else {
375
			return false;
377
			return false;
376
		}
378
		}
377
		return $format;
379
		return $format;
378
	}
380
	}
-
 
381
	// En prévision d'un service permettant la suppression/modification champs supp
-
 
382
	/* Recherche si un projet a des champs de saisie supplémentaire */
-
 
383
	private function rechercherChampsSupp() {
-
 
384
		$retour = array();
-
 
385
		$projet = $this->parametres['projet'];
-
 
386
		$url = $this->config['manager']['celChpSupTpl'] .'?projet=' . $projet . '&langue=' . $this->parametres['langue'];
-
 
387
		$json = $this->getDao()->consulter($url);
-
 
388
		$retour = (array) json_decode($json, true);
-
 
389
 
-
 
390
		foreach ( $retour[$projet]['champs-supp'] as $key => $chsup ) {
-
 
391
 
-
 
392
			$retour[$projet]['champs-supp'][$key]['name'] = $this->clean_string( $chsup['name'] );
-
 
393
			$retour[$projet]['champs-supp'][$key]['description'] = $this->clean_string( $chsup['description']);
-
 
394
			$retour[$projet]['champs-supp'][$key]['unit'] = $this->clean_string( $chsup['unit'] );
-
 
395
 
-
 
396
			if ( isset( $chsup['fieldValues'] ) ) {
-
 
397
				$retour[$projet]['champs-supp'][$key]['fieldValues'] = json_decode( $this->clean_string( $chsup['fieldValues'] ), true );
-
 
398
 
-
 
399
				if ( isset( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] ) ) {
-
 
400
					foreach( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] as $list_key => $list_value_array ) {
-
 
401
						// Obtenir une liste de valeurs utilisables dans les attributs for id ou name par exemple
-
 
402
						$retour[$projet]['champs-supp'][$key]['fieldValues']['cleanListValue'][] = ($list_value_array !== 'other') ? 'val-' . preg_replace( '/[^A-Za-z0-9_\-]/', '', $this->remove_accents( strtolower($list_value_array[0] ) ) ) : '';
-
 
403
					}
-
 
404
				}
-
 
405
			}
-
 
406
			$retour[$projet]['champs-supp'][$key]['mandatory'] = intval( $chsup['mandatory'] );
-
 
407
		}
-
 
408
		return $retour;
-
 
409
	}
-
 
410
 
-
 
411
	// En prévision d'un service permettant la suppression/modification champs supp
-
 
412
	private function clean_string( $string ) {
-
 
413
		// les fonctions de base de php ne parviennent pas à une conversion satisfaisante des codes ascii
-
 
414
		// qui ont été générés automatiquement lors de la transmission des chaines en json
-
 
415
		// dans le widget cel manager vers la base
-
 
416
		// Pour les mêmes raisons, @apos@ et @quot@ est une autre astuces utilisée dans ce même widget
-
 
417
		// pour permettre la transmission des apostrophes et guillements sans erreur
-
 
418
		$patterns = array( '/\@apos\@/', '/\@quot\@/', '/u00c0/', '/u00c1/', '/u00c2/', '/u00c3/', '/u00c4/', '/u00c5/', '/u00c6/', '/u00c7/', '/u00c8/', '/u00c9/', '/u00ca/', '/u00cb/', '/u00cc/', '/u00cd/', '/u00ce/', '/u00cf/', '/u00d1/', '/u00d2/', '/u00d3/', '/u00d4/', '/u00d5/', '/u00d6/', '/u00d8/', '/u00d9/', '/u00da/', '/u00db/', '/u00dc/', '/u00dd/', '/u00df/', '/u00e0/', '/u00e1/', '/u00e2/', '/u00e3/', '/u00e4/', '/u00e5/', '/u00e6/', '/u00e7/', '/u00e8/', '/u00e9/', '/u00ea/', '/u00eb/', '/u00ec/', '/u00ed/', '/u00ee/', '/u00ef/', '/u00f0/', '/u00f1/', '/u00f2/', '/u00f3/', '/u00f4/', '/u00f5/', '/u00f6/', '/u00f8/', '/u00f9/', '/u00fa/', '/u00fb/', '/u00fc/', '/u00fd/', '/u00ff/' );
-
 
419
		$replacements = array( '&apos;', '&quot;', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý','ÿ' );
-
 
420
 
-
 
421
		$clean_string = preg_replace( $patterns, $replacements, $string );
-
 
422
 
-
 
423
		return $clean_string;
-
 
424
	}
379
 
425
 
380
	private function remove_accents( $string ) {
426
	private function remove_accents( $string ) {
381
		if ( !preg_match( '/[\x80-\xff]/' , $string ) ) {
427
		if ( !preg_match( '/[\x80-\xff]/' , $string ) ) {
382
 
428
 
383
			return $string;
429
			return $string;
384
		}
430
		}
385
 
431
 
386
		$chars = array(
432
		$chars = array(
387
			// Decompositions for Latin-1 Supplement
433
			// Decompositions for Latin-1 Supplement
388
			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
434
			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
389
			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
435
			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
390
			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
436
			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
391
			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
437
			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
392
			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
438
			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
393
			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
439
			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
394
			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
440
			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
395
			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
441
			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
396
			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
442
			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
397
			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
443
			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
398
			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
444
			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
399
			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
445
			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
400
			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
446
			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
401
			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
447
			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
402
			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
448
			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
403
			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
449
			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
404
			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
450
			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
405
			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
451
			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
406
			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
452
			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
407
			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
453
			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
408
			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
454
			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
409
			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
455
			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
410
			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
456
			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
411
			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
457
			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
412
			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
458
			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
413
			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
459
			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
414
			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
460
			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
415
			chr(195).chr(191) => 'y',
461
			chr(195).chr(191) => 'y',
416
			// Decompositions for Latin Extended-A
462
			// Decompositions for Latin Extended-A
417
			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
463
			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
418
			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
464
			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
419
			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
465
			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
420
			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
466
			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
421
			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
467
			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
422
			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
468
			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
423
			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
469
			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
424
			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
470
			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
425
			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
471
			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
426
			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
472
			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
427
			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
473
			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
428
			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
474
			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
429
			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
475
			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
430
			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
476
			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
431
			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
477
			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
432
			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
478
			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
433
			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
479
			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
434
			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
480
			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
435
			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
481
			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
436
			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
482
			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
437
			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
483
			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
438
			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
484
			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
439
			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
485
			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
440
			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
486
			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
441
			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
487
			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
442
			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
488
			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
443
			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
489
			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
444
			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
490
			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
445
			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
491
			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
446
			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
492
			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
447
			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
493
			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
448
			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
494
			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
449
			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
495
			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
450
			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
496
			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
451
			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
497
			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
452
			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
498
			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
453
			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
499
			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
454
			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
500
			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
455
			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
501
			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
456
			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
502
			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
457
			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
503
			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
458
			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
504
			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
459
			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
505
			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
460
			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
506
			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
461
			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
507
			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
462
			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
508
			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
463
			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
509
			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
464
			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
510
			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
465
			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
511
			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
466
			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
512
			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
467
			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
513
			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
468
			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
514
			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
469
			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
515
			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
470
			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
516
			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
471
			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
517
			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
472
			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
518
			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
473
			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
519
			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
474
			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
520
			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
475
			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
521
			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
476
			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
522
			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
477
			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
523
			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
478
			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
524
			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
479
			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
525
			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
480
			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
526
			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
481
		);
527
		);
482
 
528
 
483
		$string = strtr( $string, $chars );
529
		$string = strtr( $string, $chars );
484
 
530
 
485
		return preg_replace( '/([^.a-z0-9]+)/i', '-', $string );
531
		return preg_replace( '/([^.a-z0-9]+)/i', '-', $string );
486
	}
532
	}
487
}
533
}