Subversion Repositories eFlore/Applications.cel

Rev

Rev 3231 | Rev 3240 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3231 Rev 3239
Line 26... Line 26...
26
	const SERVICE_DEFAUT = 'saisie';
26
	const SERVICE_DEFAUT = 'saisie';
27
	const LANGUE_DEFAUT = 'fr';
27
	const LANGUE_DEFAUT = 'fr';
28
	const PROJET_DEFAUT = 'base';
28
	const PROJET_DEFAUT = 'base';
29
	const WS_NOM = 'noms';
29
	const WS_NOM = 'noms';
30
	const EFLORE_API_VERSION = '0.1';
30
	const EFLORE_API_VERSION = '0.1';
-
 
31
	const WS_UPLOAD = 'CelWidgetUploadImageTemp';
31
	private $cel_url_tpl = null;
32
	private $cel_url_tpl = null;
32
	/** Si spécifié, on ajoute une barre de navigation inter-applications */
33
	/** Si spécifié, on ajoute une barre de navigation inter-applications */
33
	private $bar;
34
	private $bar;
34
	//private $parametres_autorises = array('projet', 'type', 'langue', 'order');
35
	//private $parametres_autorises = array('projet', 'type', 'langue', 'order');
35
	private $parametres_autorises = array(
36
	private $parametres_autorises = array(
Line 90... Line 91...
90
			if (isset($retour['donnees'])) { 
91
			if (isset($retour['donnees'])) {
91
				$retour['donnees']['prod'] = ($this->config['parametres']['modeServeur'] == "prod");
92
				$retour['donnees']['prod'] = ($this->config['parametres']['modeServeur'] == "prod");
92
				$retour['donnees']['bar'] = $this->bar;
93
				$retour['donnees']['bar'] = $this->bar;
93
				$retour['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
94
				$retour['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
94
				$retour['donnees']['url_ws_annuaire'] = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], 'utilisateur/identite-par-courriel/');
95
				$retour['donnees']['url_ws_annuaire'] = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], 'utilisateur/identite-par-courriel/');
-
 
96
				$retour['donnees']['url_ws_upload'] = $widget['donnees']['url_ws_upload'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_UPLOAD);
95
				$retour['donnees']['authTpl'] = $this->config['manager']['authTpl'].'?projet='.$this->parametres['projet'].'&langue='.$this->parametres['langue'];
97
				$retour['donnees']['authTpl'] = $this->config['manager']['authTpl'].'?projet='.$this->parametres['projet'].'&langue='.$this->parametres['langue'];
96
				$retour['donnees']['mode'] = $mode;
98
				$retour['donnees']['mode'] = $mode;
97
				$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$retour['squelette'].'.tpl.html';
99
				$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$retour['squelette'].'.tpl.html';
98
				$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']);
100
				$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']);
99
			} else {
101
			} else {
Line 105... Line 107...
105
 
107
 
106
	
108
 
107
	private function executerSaisie() {
109
	private function executerSaisie() {
108
		$retour = array();
-
 
109
		$retour['squelette'] = 'saisie';
-
 
110
		$retour['donnees']['general'] = I18n::get('General');
110
		$retour = array();
111
		$retour['donnees']['aide'] = I18n::get('Aide');
111
		$retour['squelette'] = 'saisie';
112
		$retour['donnees']['observateur'] = I18n::get('Observateur');
112
		$retour['donnees']['observateur'] = I18n::get('Observateur');
113
		$retour['donnees']['observation'] = I18n::get('Observation');
113
        $retour['donnees']['observation'] = I18n::get('Observation');
114
		$retour['donnees']['image'] = I18n::get('Image');
114
        $retour['donnees']['image'] = I18n::get('Image');
Line 119... Line 119...
119
	}
119
	}
Line 120... Line 120...
120
	
120
 
121
	/* Recherche si le projet existe sinon va chercher les infos de base */
121
	/* Recherche si le projet existe sinon va chercher les infos de base */
122
	private function rechercherProjet() {
122
	private function rechercherProjet() {
123
		// projet avec un squelette défini (et non juste un mot-clé d'observation)
123
		// projet avec un squelette défini (et non juste un mot-clé d'observation)
-
 
124
		$estProjetDefini = true;
124
		$estProjetDefini = true; $tab = array();
125
		$tab = array();
125
		$url = $this->config['manager']['celUrlTpl'].'?projet='.$this->parametres['projet'].'&langue='.$this->parametres['langue'];
126
		$url = $this->config['manager']['celUrlTpl'].'?projet='.$this->parametres['projet'].'&langue='.$this->parametres['langue'];
126
		$json = $this->getDao()->consulter($url); 
-
 
127
		$tableau = json_decode($json, true);
-
 
128
		if ($tableau== array()) {
-
 
-
 
127
		$json = $this->getDao()->consulter($url);
129
			$estProjetDefini = false;
128
 
130
		} else {
129
		if ( $json ) {
-
 
130
			$tab = $this->rechercherChampsSupp();
-
 
131
		} else {
-
 
132
			$url = $this->config['manager']['celUrlTpl'].'?projet=base&langue='.$this->parametres['langue'];
-
 
133
			$json = $this->getDao()->consulter($url);
131
			$tab = $this->rechercherChampsSupp();
134
			$estProjetDefini = false;
132
		}
-
 
-
 
135
		}
133
		
136
		$tableau = json_decode($json, true);
134
		$tableau = $this->traiterParametres($estProjetDefini, $tableau[0]);
137
		$tableau = $this->traiterParametres($estProjetDefini, $tableau[0]);
135
		$tableau['especes'] = $this->rechercherInfosEspeces($tableau);
138
		$tableau['especes'] = $this->rechercherInfosEspeces($tableau);
136
		if ($tableau['milieux'] != "") { 
139
		if ($tableau['milieux'] != "") {
137
			$tableau['milieux']= explode(";", $tableau['milieux']);
140
			$tableau['milieux'] = explode(";", $tableau['milieux']);
138
		} else {
141
		} else {
139
			$tableau['milieux'] = array();
142
			$tableau['milieux'] = array();
140
		}
143
		}
-
 
144
		$tableau['chpSupp'] = $tab;
141
		$tableau['chpSupp'] = $tab; 
145
		$tableau['chemin_fichiers'] = sprintf( $this->config['chemins']['baseURLAbsoluDyn'], $this->config['manager']['dossierTmp'] . $tableau["projet"] . '/' );
142
		return $tableau;
146
		return $tableau;
Line 143... Line 147...
143
	}
147
	}
144
	
148
 
145
	/* Recherche si un projet a des champs de saisie supplémentaire */
149
	/* Recherche si un projet a des champs de saisie supplémentaire */
-
 
150
	private function rechercherChampsSupp() {
146
	private function rechercherChampsSupp() {
151
		$retour = array();
147
		$retour = array();
152
		$projet = $this->parametres['projet'];
148
		$url = $this->config['manager']['celChpSupTpl'].'?projet='.$this->parametres['projet'].'&langue='.$this->parametres['langue'];
153
		$url = $this->config['manager']['celChpSupTpl'] .'?projet=' . $projet . '&langue=' . $this->parametres['langue'];
-
 
154
		$json = $this->getDao()->consulter($url);
-
 
155
		$retour = (array) json_decode($json, true);
149
		$json = $this->getDao()->consulter($url);
156
		$patterns = array( '/\@apos\@/' , '/\@quot\@/' );
-
 
157
		$replacements = array( ''' , '"' );
-
 
158
		foreach ( $retour[$projet]['champs-supp'] as $key => $chsup ) {
-
 
159
 
-
 
160
 
-
 
161
			$retour[$projet]['champs-supp'][$key]['name'] = preg_replace( $patterns, $replacements, $chsup['name'] );
-
 
162
			$retour[$projet]['champs-supp'][$key]['description'] = preg_replace( $patterns, $replacements, $chsup['description']);
150
		$retour = (array) json_decode($json, true);
163
			$retour[$projet]['champs-supp'][$key]['unit'] = preg_replace( $patterns, $replacements, $chsup['unit'] );
151
		foreach ($retour['sauvagessupp']['champs-supp'] as $key => $chsup) {
164
 
-
 
165
			if ( isset( $chsup['fieldValues'] ) ) {
-
 
166
				$retour[$projet]['champs-supp'][$key]['fieldValues'] = json_decode( $chsup['fieldValues'], true );
-
 
167
				if ( isset($retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] ) ) {
-
 
168
					$retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] = preg_replace( $patterns, $replacements, $retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] );
152
			if (isset($chsup['fieldValues'])) {
169
				}
153
				$retour['sauvagessupp']['champs-supp'][$key]['fieldValues'] = json_decode($chsup['fieldValues'], true);
170
 
-
 
171
				if ( isset( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] ) ) {
-
 
172
					foreach( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] as $list_key => $list_value ) {
154
				if (isset($retour['sauvagessupp']['champs-supp'][$key]['fieldValues']["listValue"])) {
173
						$list_value = preg_replace( $patterns, $replacements, $list_value );
155
					foreach($retour['sauvagessupp']['champs-supp'][$key]['fieldValues']["listValue"] as $list_value) {
174
						$retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'][$list_key] = $list_value;
156
						// Obtenir une liste de valeurs utilisables dans les attributs for id ou name par exemple
175
						// Obtenir une liste de valeurs utilisables dans les attributs for id ou name par exemple
157
						$retour['sauvagessupp']['champs-supp'][$key]['fieldValues']['cleanListValue'][] = 'val-' . preg_replace('/[^A-Za-z0-9_\-]/', '',$this->remove_accents($list_value));
176
						$retour[$projet]['champs-supp'][$key]['fieldValues']['cleanListValue'][] = 'val-' . preg_replace('/[^A-Za-z0-9_\-]/', '', $this->remove_accents($list_value));
158
					}
177
					}
159
				}
178
				}
160
			}
179
			}
161
			$retour['sauvagessupp']['champs-supp'][$key]['mandatory'] = intval($chsup['mandatory']);
180
			$retour[$projet]['champs-supp'][$key]['mandatory'] = intval( $chsup['mandatory'] );
162
		}
181
		}
Line -... Line 182...
-
 
182
		return $retour;
-
 
183
	}
-
 
184
 
-
 
185
	private function remove_accents($string) {
-
 
186
		if ( !preg_match('/[\x80-\xff]/', $string) )
-
 
187
			return $string;
-
 
188
 
-
 
189
		$chars = array(
-
 
190
			// Decompositions for Latin-1 Supplement
-
 
191
			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
-
 
192
			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
-
 
193
			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
-
 
194
			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
-
 
195
			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
-
 
196
			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
-
 
197
			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
-
 
198
			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
-
 
199
			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
-
 
200
			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
-
 
201
			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
-
 
202
			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
-
 
203
			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
-
 
204
			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
-
 
205
			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
-
 
206
			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
-
 
207
			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
-
 
208
			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
-
 
209
			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
-
 
210
			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
-
 
211
			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
-
 
212
			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
-
 
213
			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
-
 
214
			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
-
 
215
			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
-
 
216
			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
-
 
217
			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
-
 
218
			chr(195).chr(191) => 'y',
-
 
219
			// Decompositions for Latin Extended-A
-
 
220
			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
-
 
221
			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
-
 
222
			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
-
 
223
			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
-
 
224
			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
-
 
225
			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
-
 
226
			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
-
 
227
			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
-
 
228
			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
-
 
229
			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
-
 
230
			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
-
 
231
			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
-
 
232
			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
-
 
233
			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
-
 
234
			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
-
 
235
			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
-
 
236
			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
-
 
237
			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
-
 
238
			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
-
 
239
			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
-
 
240
			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
-
 
241
			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
-
 
242
			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
-
 
243
			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
-
 
244
			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
-
 
245
			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
-
 
246
			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
-
 
247
			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
-
 
248
			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
-
 
249
			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
-
 
250
			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
-
 
251
			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
-
 
252
			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
-
 
253
			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
-
 
254
			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
-
 
255
			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
-
 
256
			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
-
 
257
			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
-
 
258
			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
-
 
259
			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
-
 
260
			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
-
 
261
			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
-
 
262
			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
-
 
263
			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
-
 
264
			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
-
 
265
			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
-
 
266
			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
-
 
267
			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
-
 
268
			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
-
 
269
			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
-
 
270
			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
-
 
271
			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
-
 
272
			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
-
 
273
			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
-
 
274
			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
-
 
275
			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
-
 
276
			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
-
 
277
			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
-
 
278
			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
-
 
279
			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
-
 
280
			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
-
 
281
			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
-
 
282
			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
-
 
283
			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
-
 
284
		);
-
 
285
 
-
 
286
		$string = strtr($string, $chars);
-
 
287
 
163
		return $retour;
288
		return $string;
164
	}
289
	}
165
	
290
 
166
	// remplace certains parametres définis en bd par les parametres définis dans l'url
291
	// remplace certains parametres définis en bd par les parametres définis dans l'url
167
	private function traiterParametres($estProjetDefini, $tableau) {
292
	private function traiterParametres($estProjetDefini, $tableau) {
Line 177... Line 302...
177
		return $tableau;
302
		return $tableau;
178
	}
303
	}
Line 179... Line 304...
179
	
304
 
-
 
305
 
180
	
306
	private function rechercherInfosEspeces( $infos_projets ) { //print_r($infos_projets);exit;
181
	private function rechercherInfosEspeces($infos_projets) { //print_r($infos_projets);exit;
307
		$retour = array();
182
		$retour = ""; $referentiel = $infos_projets['referentiel'];
308
		$referentiel = $infos_projets['referentiel'];
183
		$urlWsNsTpl = $this->config['chemins']['baseURLServicesEfloreTpl'];
309
		$urlWsNsTpl = $this->config['chemins']['baseURLServicesEfloreTpl'];
184
		$urlWsNs = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, $referentiel, self::WS_NOM);
310
		$urlWsNs = sprintf( $urlWsNsTpl, self::EFLORE_API_VERSION, $referentiel, self::WS_NOM );
185
		$urlWsNsSansRef = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, '{referentiel}', self::WS_NOM);
311
		$urlWsNsSansRef = sprintf( $urlWsNsTpl, self::EFLORE_API_VERSION, '{referentiel}', self::WS_NOM );
186
		$retour['url_ws_autocompletion_ns'] = $urlWsNs;
312
		$retour['url_ws_autocompletion_ns'] = $urlWsNs;
Line 187... Line 313...
187
		$retour['url_ws_autocompletion_ns_tpl'] = $urlWsNsSansRef;
313
		$retour['url_ws_autocompletion_ns_tpl'] = $urlWsNsSansRef;
-
 
314
		$retour['ns_referentiel'] = $referentiel;
188
		$retour['ns_referentiel'] = $referentiel;
315
 
189
	
-
 
190
		if (isset($infos_projets['type_especes'])) {
-
 
191
			switch ($infos_projets['type_especes']) {
316
		if ( isset( $infos_projets['type_especes'] ) ) {
192
				case "referentiel" : $referentiel = $infos_projets['referentiel']; break;
317
 
193
				case "liste" : $referentiel = $infos_projets['referentiel']; break;
318
			switch ( $infos_projets['type_especes'] ) {
-
 
319
				case "fixe" :
-
 
320
					$retour['especes'] = $this->chargerInfosTaxon( $infos_projets['referentiel'], $infos_projets['especes'] );
-
 
321
					break;
-
 
322
				case "referentiel" :
194
				case "fixe" : 
323
				case "liste" :
195
					$retour['especes'] = $this->chargerInfosTaxon($infos_projets['referentiel'], $infos_projets['especes']); 
324
					$referentiel = $infos_projets['referentiel'];
196
					break;
325
					break;
197
			}
326
			}
198
		} else if (isset($infos_projets['referentiel'])) {
327
		} else if ( isset( $infos_projets['referentiel'] ) ) {
Line 242... Line 371...
242
			}
371
			}
243
		}
372
		}
244
		return $retour;
373
		return $retour;
245
	}
374
	}
Line -... Line 375...
-
 
375
 
-
 
376
	protected function getReferentielImpose() {
-
 
377
		$referentiel_impose = true;
-
 
378
		if (!empty($_GET['referentiel']) && $_GET['referentiel'] != "autre") {
-
 
379
			$this->ns_referentiel = $_GET['referentiel'];
-
 
380
		} else if (isset($this->configProjet['referentiel'])) {
-
 
381
			$this->ns_referentiel = $this->configProjet['referentiel'];
-
 
382
		} else if (isset($this->configMission['referentiel'])) {
-
 
383
			$this->ns_referentiel = $this->configMission['referentiel'];
-
 
384
		} else {
-
 
385
			$referentiel_impose = false;
-
 
386
		}
246
	
387
		return $referentiel_impose;
Line 247... Line 388...
247
 
388
	}
248
 
389
 
249
	/**
390
	/**
250
	 * Trie par nom français les taxons lus dans le fichier tsv
391
	 * Trie par nom français les taxons lus dans le fichier tsv
Line 374... Line 515...
374
			$tableauJs = implode(',', $dimensions);
515
			$tableauJs = implode(',', $dimensions);
375
		}
516
		}
376
		return $tableauJs;
517
		return $tableauJs;
377
	}
518
	}
Line 378... Line -...
378
	
-
 
379
	private function remove_accents($string) {
-
 
380
		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
-
 
381
			
-
 
382
		$chars = array(
-
 
383
			// Decompositions for Latin-1 Supplement
-
 
384
			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
-
 
385
			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
-
 
386
			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
-
 
387
			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
-
 
388
			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
-
 
389
			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
-
 
390
			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
-
 
391
			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
-
 
392
			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
-
 
393
			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
-
 
394
			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
-
 
395
			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
-
 
396
			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
-
 
397
			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
-
 
398
			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
-
 
399
			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
-
 
400
			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
-
 
401
			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
-
 
402
			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
-
 
403
			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
-
 
404
			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
-
 
405
			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
-
 
406
			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
-
 
407
			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
-
 
408
			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
-
 
409
			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
-
 
410
			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
-
 
411
			chr(195).chr(191) => 'y',
-
 
412
			// Decompositions for Latin Extended-A
-
 
413
			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
-
 
414
			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
-
 
415
			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
-
 
416
			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
-
 
417
			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
-
 
418
			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
-
 
419
			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
-
 
420
			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
-
 
421
			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
-
 
422
			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
-
 
423
			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
-
 
424
			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
-
 
425
			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
-
 
426
			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
-
 
427
			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
-
 
428
			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
-
 
429
			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
-
 
430
			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
-
 
431
			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
-
 
432
			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
-
 
433
			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
-
 
434
			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
-
 
435
			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
-
 
436
			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
-
 
437
			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
-
 
438
			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
-
 
439
			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
-
 
440
			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
-
 
441
			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
-
 
442
			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
-
 
443
			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
-
 
444
			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
-
 
445
			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
-
 
446
			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
-
 
447
			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
-
 
448
			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
-
 
449
			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
-
 
450
			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
-
 
451
			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
-
 
452
			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
-
 
453
			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
-
 
454
			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
-
 
455
			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
-
 
456
			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
-
 
457
			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
-
 
458
			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
-
 
459
			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
-
 
460
			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
-
 
461
			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
-
 
462
			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
-
 
463
			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
-
 
464
			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
-
 
465
			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
-
 
466
			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
-
 
467
			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
-
 
468
			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
-
 
469
			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
-
 
470
			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
-
 
471
			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
-
 
472
			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
-
 
473
			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
-
 
474
			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
-
 
475
			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
-
 
476
			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
-
 
477
		);
-
 
478
			
-
 
479
		$string = strtr($string, $chars);
-
 
480
		return $string;
-
 
481
	}
-
 
482
 
519
 
483
}
520
}
484
?>
521
?>