Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 3260 Rev 3268
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 Saisie2 extends WidgetCommun {
23
class Saisie2 extends WidgetCommun {
24
 
24
 
25
	const DS = DIRECTORY_SEPARATOR;
25
	const DS = DIRECTORY_SEPARATOR;
26
	const SERVICE_DEFAUT = 'saisie';
26
	const SERVICE_DEFAUT = 'saisie';
27
	const WS_SAISIE = 'CelWidgetSaisie';
27
	const WS_SAISIE = 'CelWidgetSaisie';
28
	const WS_UPLOAD = 'CelWidgetUploadImageTemp';
28
	const WS_UPLOAD = 'CelWidgetUploadImageTemp';
29
	const WS_OBS = 'CelObs';
29
	const WS_OBS = 'CelObs';
30
	const LANGUE_DEFAUT = 'fr';
30
	const LANGUE_DEFAUT = 'fr';
31
	const PROJET_DEFAUT = 'base';
31
	const PROJET_DEFAUT = 'base';
32
	const WS_NOM = 'noms';
32
	const WS_NOM = 'noms';
33
	const EFLORE_API_VERSION = '0.1';
33
	const EFLORE_API_VERSION = '0.1';
34
	private $cel_url_tpl = null;
34
	private $cel_url_tpl = null;
35
	/** Si spécifié, on ajoute une barre de navigation inter-applications */
35
	/** Si spécifié, on ajoute une barre de navigation inter-applications */
36
	private $bar;
36
	private $bar;
37
	//private $parametres_autorises = array('projet', 'type', 'langue', 'order');
37
	//private $parametres_autorises = array('projet', 'type', 'langue', 'order');
38
	private $parametres_autorises = array(
38
	private $parametres_autorises = array(
39
			'projet' => 'projet',
39
			'projet' => 'projet',
40
			'type' => 'type',
40
			'type' => 'type',
41
			'langue' => 'langue',
41
			'langue' => 'langue',
42
			'order' => 'order'
42
			'order' => 'order'
43
	);
43
	);
44
	/**
44
	/**
45
	 * Méthode appelée par défaut pour charger ce widget.
45
	 * Méthode appelée par défaut pour charger ce widget.
46
	 */
46
	 */
47
	public function executer() {
47
	public function executer() {
48
		$retour = null;
48
		$retour = null;
49
		// Pour la création de l'id du cache nous ne tenons pas compte du paramètre de l'url callback
49
		// Pour la création de l'id du cache nous ne tenons pas compte du paramètre de l'url callback
50
		unset($this->parametres['callback']);
50
		unset($this->parametres['callback']);
51
		extract($this->parametres);
51
		extract($this->parametres);
52
		$this->bar = (isset($bar)) ? $bar : false;
52
		$this->bar = (isset($bar)) ? $bar : false;
53
		/* Le fichier Framework.php du Framework de Tela Botanica doit être appelé avant tout autre chose dans l'application.
53
		/* Le fichier Framework.php du Framework de Tela Botanica doit être appelé avant tout autre chose dans l'application.
54
		 Sinon, rien ne sera chargé.
54
		 Sinon, rien ne sera chargé.
55
		 L'emplacement du Framework peut varier en fonction de l'environnement (test, prod...). Afin de faciliter la configuration
55
		 L'emplacement du Framework peut varier en fonction de l'environnement (test, prod...). Afin de faciliter la configuration
56
		 de l'emplacement du Framework, un fichier framework.defaut.php doit être renommé en framework.php et configuré pour chaque installation de
56
		 de l'emplacement du Framework, un fichier framework.defaut.php doit être renommé en framework.php et configuré pour chaque installation de
57
		 l'application.
57
		 l'application.
58
		 Chemin du fichier chargeant le framework requis */
58
		 Chemin du fichier chargeant le framework requis */
59
		$framework = dirname(__FILE__).'/framework.php';
59
		$framework = dirname(__FILE__).'/framework.php';
60
		if (!file_exists($framework)) {
60
		if (!file_exists($framework)) {
61
			$e = "Veuillez paramêtrer l'emplacement et la version du Framework dans le fichier $framework";
61
			$e = "Veuillez paramêtrer l'emplacement et la version du Framework dans le fichier $framework";
62
			trigger_error($e, E_USER_ERROR);
62
			trigger_error($e, E_USER_ERROR);
63
		} else {
63
		} else {
64
			// Inclusion du Framework
64
			// Inclusion du Framework
65
			require_once $framework;
65
			require_once $framework;
66
			// Ajout d'information concernant cette application
66
			// Ajout d'information concernant cette application
67
			Framework::setCheminAppli(__FILE__);// Obligatoire
67
			Framework::setCheminAppli(__FILE__);// Obligatoire
68
			Framework::setInfoAppli(Config::get('info'));// Optionnel
68
			Framework::setInfoAppli(Config::get('info'));// Optionnel
69
 
69
 
70
		}
70
		}
71
		$langue = (isset($langue)) ? $langue : self::LANGUE_DEFAUT;
71
		$langue = (isset($langue)) ? $langue : self::LANGUE_DEFAUT;
72
		$this->langue = I18n::setLangue($langue);
72
		$this->langue = I18n::setLangue($langue);
73
		$this->parametres['langue'] = $langue;
73
		$this->parametres['langue'] = $langue;
74
 
74
 
75
		if (!isset($mode)) {
75
		if (!isset($mode)) {
76
			$mode = self::SERVICE_DEFAUT;
76
			$mode = self::SERVICE_DEFAUT;
77
		}
77
		}
78
		if (!isset($projet)) {
78
		if (!isset($projet)) {
79
			$this->parametres['projet'] = self::PROJET_DEFAUT;
79
			$this->parametres['projet'] = self::PROJET_DEFAUT;
80
		}
80
		}
81
 
81
 
82
		$methode = $this->traiterNomMethodeExecuter($mode);
82
		$methode = $this->traiterNomMethodeExecuter($mode);
83
		if (method_exists($this, $methode)) {
83
		if (method_exists($this, $methode)) {
84
			$retour = $this->$methode();
84
			$retour = $this->$methode();
85
		} else {
85
		} else {
86
			$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
86
			$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
87
		}
87
		}
88
 
88
 
89
		$contenu = ''; //print_r($retour);exit;
89
		$contenu = ''; //print_r($retour);exit;
90
		if (is_null($retour)) {
90
		if (is_null($retour)) {
91
			$this->messages[] = 'La ressource demandée a retourné une valeur nulle.';
91
			$this->messages[] = 'La ressource demandée a retourné une valeur nulle.';
92
		} else {
92
		} else {
93
			if (isset($retour['donnees'])) {
93
			if (isset($retour['donnees'])) {
94
				$retour['donnees']['conf_mode'] = $this->config['parametres']['modeServeur'];
94
				$retour['donnees']['conf_mode'] = $this->config['parametres']['modeServeur'];
95
				$retour['donnees']['prod'] = ($this->config['parametres']['modeServeur'] === 'prod');
95
				$retour['donnees']['prod'] = ($this->config['parametres']['modeServeur'] === 'prod');
96
				$retour['donnees']['bar'] = $this->bar;
96
				$retour['donnees']['bar'] = $this->bar;
97
				$retour['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
97
				$retour['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], $this->config['manager']['cheminDos']);
98
				$retour['donnees']['url_ws_annuaire'] = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], 'utilisateur/identite-par-courriel/');
98
				$retour['donnees']['url_ws_annuaire'] = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], 'utilisateur/identite-par-courriel/');
99
				$retour['donnees']['url_ws_saisie'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_SAISIE);
99
				$retour['donnees']['url_ws_saisie'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_SAISIE);
100
				$retour['donnees']['url_ws_obs'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_OBS);
100
				$retour['donnees']['url_ws_obs'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_OBS);
101
				$retour['donnees']['url_ws_upload'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_UPLOAD);
101
				$retour['donnees']['url_ws_upload'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_UPLOAD);
102
				$retour['donnees']['authTpl'] = $this->config['manager']['authTpl'].'?projet='.$this->parametres['projet'].'&langue='.$this->parametres['langue'];
102
				$retour['donnees']['authTpl'] = $this->config['manager']['authTpl'].'?projet='.$this->parametres['projet'].'&langue='.$this->parametres['langue'];
103
				$retour['donnees']['mode'] = $mode;
103
				$retour['donnees']['mode'] = $mode;
104
				if( isset( $this->parametres['squelette'] ) ) {
104
				if( isset( $this->parametres['squelette'] ) ) {
105
					$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS. $this->parametres['squelette'].'.tpl.html';
105
					$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS. $this->parametres['squelette'].'.tpl.html';
106
				} else {
106
				} else {
107
					$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$retour['squelette'].'.tpl.html';
107
					$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$retour['squelette'].'.tpl.html';
108
				}
108
				}
109
				$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']);
109
				$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']);
110
			} else {
110
			} else {
111
				$this->messages[] = 'Les données à transmettre au squelette sont nulles.';
111
				$this->messages[] = 'Les données à transmettre au squelette sont nulles.';
112
			}
112
			}
113
		}
113
		}
114
		$this->envoyer($contenu);
114
		$this->envoyer($contenu);
115
	}
115
	}
116
 
116
 
117
 
117
 
118
	private function executerSaisie() {
118
	private function executerSaisie() {
119
		$retour = array();
119
		$retour = array();
120
		$retour['squelette'] = 'saisie';
120
		$retour['squelette'] = 'saisie';
121
		$retour['donnees']['general'] = I18n::get('General');
121
		$retour['donnees']['general'] = I18n::get('General');
122
		$retour['donnees']['aide'] = I18n::get('Aide');
122
		$retour['donnees']['aide'] = I18n::get('Aide');
123
		$retour['donnees']['observateur'] = I18n::get('Observateur');
123
		$retour['donnees']['observateur'] = I18n::get('Observateur');
124
		$retour['donnees']['observation'] = I18n::get('Observation');
124
		$retour['donnees']['observation'] = I18n::get('Observation');
125
		$retour['donnees']['image'] = I18n::get('Image');
125
		$retour['donnees']['image'] = I18n::get('Image');
126
 		$retour['donnees']['chpsupp'] = I18n::get('Chpsupp');
126
 		$retour['donnees']['chpsupp'] = I18n::get('Chpsupp');
127
 		$retour['donnees']['resume'] = I18n::get('Resume');
127
 		$retour['donnees']['resume'] = I18n::get('Resume');
128
		$retour['donnees']['widget'] = $this->rechercherProjet();
128
		$retour['donnees']['widget'] = $this->rechercherProjet();
129
		return $retour;
129
		return $retour;
130
	}
130
	}
131
 
131
 
132
	/* Recherche si le projet existe sinon va chercher les infos de base */
132
	/* Recherche si le projet existe sinon va chercher les infos de base */
133
	private function rechercherProjet() {
133
	private function rechercherProjet() {
134
		// projet avec un squelette défini (et non juste un mot-clé d'observation)
134
		// projet avec un squelette défini (et non juste un mot-clé d'observation)
135
		$estProjetDefini = true;
135
		$estProjetDefini = true;
136
		$tab = array();
136
		$tab = array();
137
		$url = $this->config['manager']['celUrlTpl'].'?projet='.$this->parametres['projet'].'&langue='.$this->parametres['langue'];
137
		$url = $this->config['manager']['celUrlTpl'].'?projet='.$this->parametres['projet'].'&langue='.$this->parametres['langue'];
138
		$json = $this->getDao()->consulter($url);
138
		$json = $this->getDao()->consulter($url);
139
 
139
 
140
		if ( $json !== "[]" ) {
140
		if ( $json !== "[]" ) {
141
			$tab = $this->rechercherChampsSupp();
141
			$tab = $this->rechercherChampsSupp();
142
		} else {
142
		} else {
143
			$url = $this->config['manager']['celUrlTpl'].'?projet=base&langue='.$this->parametres['langue'];
143
			$url = $this->config['manager']['celUrlTpl'].'?projet=base&langue='.$this->parametres['langue'];
144
			$json = $this->getDao()->consulter($url);
144
			$json = $this->getDao()->consulter($url);
145
			$estProjetDefini = false;
145
			$estProjetDefini = false;
146
		}
146
		}
147
		$tableau = json_decode($json, true);
147
		$tableau = json_decode($json, true);
148
		$tableau = $this->traiterParametres($estProjetDefini, $tableau[0]);
148
		$tableau = $this->traiterParametres($estProjetDefini, $tableau[0]);
149
		$tableau['especes'] = $this->rechercherInfosEspeces($tableau);
149
		$tableau['especes'] = $this->rechercherInfosEspeces($tableau);
150
		if ($tableau['milieux'] != '') {
150
		if ($tableau['milieux'] != '') {
151
			$tableau['milieux'] = explode(';', $tableau['milieux']);
151
			$tableau['milieux'] = explode(';', $tableau['milieux']);
152
		} else {
152
		} else {
153
			$tableau['milieux'] = array();
153
			$tableau['milieux'] = array();
154
		}
154
		}
155
		$tableau['chpSupp'] = $tab;
155
		$tableau['chpSupp'] = $tab;
156
		$langue_projet_url = ( isset ( $this->parametres['langue'] ) && $this->parametres['langue'] !== 'fr' ) ? '_' . $this->parametres['langue'] : '';
156
		$langue_projet_url = ( isset ( $this->parametres['langue'] ) && $this->parametres['langue'] !== 'fr' ) ? '_' . $this->parametres['langue'] : '';
157
		$tableau['chemin_fichiers'] = sprintf( $this->config['chemins']['baseURLAbsoluDyn'], $this->config['manager']['dossierTmp'] . $tableau['projet'] . $langue_projet_url . '/' );
157
		$tableau['chemin_fichiers'] = sprintf( $this->config['chemins']['baseURLAbsoluDyn'], $this->config['manager']['dossierTmp'] . $tableau['projet'] . $langue_projet_url . '/' );
158
		return $tableau;
158
		return $tableau;
159
	}
159
	}
160
 
160
 
161
	/* Recherche si un projet a des champs de saisie supplémentaire */
161
	/* Recherche si un projet a des champs de saisie supplémentaire */
162
	private function rechercherChampsSupp() {
162
	private function rechercherChampsSupp() {
163
		$retour = array();
163
		$retour = array();
164
		$projet = $this->parametres['projet'];
164
		$projet = $this->parametres['projet'];
165
		$url = $this->config['manager']['celChpSupTpl'] .'?projet=' . $projet . '&langue=' . $this->parametres['langue'];
165
		$url = $this->config['manager']['celChpSupTpl'] .'?projet=' . $projet . '&langue=' . $this->parametres['langue'];
166
		$json = $this->getDao()->consulter($url);
166
		$json = $this->getDao()->consulter($url);
167
		$retour = (array) json_decode($json, true);
167
		$retour = (array) json_decode($json, true);
168
 
168
 
169
		foreach ( $retour[$projet]['champs-supp'] as $key => $chsup ) {
169
		foreach ( $retour[$projet]['champs-supp'] as $key => $chsup ) {
170
 
170
 
171
 
171
 
172
			$retour[$projet]['champs-supp'][$key]['name'] = $this->clean_string( $chsup['name'] );
172
			$retour[$projet]['champs-supp'][$key]['name'] = $this->clean_string( $chsup['name'] );
173
			$retour[$projet]['champs-supp'][$key]['description'] = $this->clean_string( $chsup['description']);
173
			$retour[$projet]['champs-supp'][$key]['description'] = $this->clean_string( $chsup['description']);
174
			$retour[$projet]['champs-supp'][$key]['unit'] = $this->clean_string( $chsup['unit'] );
174
			$retour[$projet]['champs-supp'][$key]['unit'] = $this->clean_string( $chsup['unit'] );
175
 
175
 
176
			if ( isset( $chsup['fieldValues'] ) ) {
176
			if ( isset( $chsup['fieldValues'] ) ) {
177
				$retour[$projet]['champs-supp'][$key]['fieldValues'] = json_decode( $chsup['fieldValues'], true );
177
				$retour[$projet]['champs-supp'][$key]['fieldValues'] = json_decode( $chsup['fieldValues'], true );
178
				if ( isset($retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] ) ) {
178
				if ( isset($retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] ) ) {
179
					$retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] = $this->clean_string( $retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] );
179
					$retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] = $this->clean_string( $retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] );
180
				}
180
				}
181
 
181
 
182
				if ( isset( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] ) ) {
182
				if ( isset( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] ) ) {
183
					foreach( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] as $list_key => $list_value ) {
183
					foreach( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] as $list_key => $list_value ) {
184
						$retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'][$list_key] = $this->clean_string( $list_value );
184
						$retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'][$list_key] = $this->clean_string( $list_value );
185
						// Obtenir une liste de valeurs utilisables dans les attributs for id ou name par exemple
185
						// Obtenir une liste de valeurs utilisables dans les attributs for id ou name par exemple
186
						$retour[$projet]['champs-supp'][$key]['fieldValues']['cleanListValue'][] = 'val-' . preg_replace( '/[^A-Za-z0-9_\-]/', '', $this->remove_accents( $list_value ) );
186
						$retour[$projet]['champs-supp'][$key]['fieldValues']['cleanListValue'][] = 'val-' . preg_replace( '/[^A-Za-z0-9_\-]/', '', $this->remove_accents( $list_value ) );
187
					}
187
					}
188
				}
188
				}
189
			}
189
			}
190
			$retour[$projet]['champs-supp'][$key]['mandatory'] = intval( $chsup['mandatory'] );
190
			$retour[$projet]['champs-supp'][$key]['mandatory'] = intval( $chsup['mandatory'] );
191
		}
191
		}
192
		return $retour;
192
		return $retour;
193
	}
193
	}
194
 
194
 
195
	private function clean_string( $string ) {
195
	private function clean_string( $string ) {
196
		// les fonctions de base de php ne parviennent pas à une conversion satisfaisante des codes ascii
196
		// les fonctions de base de php ne parviennent pas à une conversion satisfaisante des codes ascii
197
		// qui ont été générés automatiquement lors de la transmission des chaines en json
197
		// qui ont été générés automatiquement lors de la transmission des chaines en json
198
		// dans le widget cel manager vers la base
198
		// dans le widget cel manager vers la base
199
		// Pour les mêmes raisons, @apos@ et @quot@ est une autre astuces utilisée dans ce même widget
199
		// Pour les mêmes raisons, @apos@ et @quot@ est une autre astuces utilisée dans ce même widget
200
		// pour permettre la transmission des apostrophes et guillements sans erreur
200
		// pour permettre la transmission des apostrophes et guillements sans erreur
201
		$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/' );
201
		$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/' );
202
		$replacements = array( '&apos;', '&quot;', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý','ÿ' );
202
		$replacements = array( '&apos;', '&quot;', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý','ÿ' );
203
 
203
 
204
		$clean_string = preg_replace( $patterns, $replacements, $string );
204
		$clean_string = preg_replace( $patterns, $replacements, $string );
205
 
205
 
206
		return $clean_string;
206
		return $clean_string;
207
	}
207
	}
208
 
208
 
209
 
209
 
210
 
210
 
211
	// remplace certains parametres définis en bd par les parametres définis dans l'url
211
	// remplace certains parametres définis en bd par les parametres définis dans l'url
212
	private function traiterParametres($estProjetDefini, $tableau) {
212
	private function traiterParametres($estProjetDefini, $tableau) {
213
		$criteres = array('tag', 'motcle', 'projet', 'titre', 'logo');
213
		$criteres = array('tag', 'motcle', 'projet', 'titre', 'logo');
214
		$criteresProjetNonDefini = array('commune', 'num_nom', 'referentiel');
214
		$criteresProjetNonDefini = array('commune', 'num_nom', 'referentiel');
215
		foreach($this->parametres as $nom_critere => $valeur_critere) {
215
		foreach($this->parametres as $nom_critere => $valeur_critere) {
216
			if (($estProjetDefini == false || $tableau['projet'] == 'base') && in_array($nom_critere, $criteresProjetNonDefini)) {
216
			if (($estProjetDefini == false || $tableau['projet'] == 'base') && in_array($nom_critere, $criteresProjetNonDefini)) {
217
				$tableau[$nom_critere] = $valeur_critere;
217
				$tableau[$nom_critere] = $valeur_critere;
218
			} else if (in_array($nom_critere, $criteres)) {
218
			} else if (in_array($nom_critere, $criteres)) {
219
				$tableau[$nom_critere] = $valeur_critere;
219
				$tableau[$nom_critere] = $valeur_critere;
220
			}
220
			}
221
		}
221
		}
222
		return $tableau;
222
		return $tableau;
223
	}
223
	}
224
 
224
 
225
 
225
 
226
	private function rechercherInfosEspeces( $infos_projets ) { //print_r($infos_projets);exit;
226
	private function rechercherInfosEspeces( $infos_projets ) { //print_r($infos_projets);exit;
227
		$retour = array();
227
		$retour = array();
228
		$referentiel = $infos_projets['referentiel'];
228
		$referentiel = $infos_projets['referentiel'];
229
		$urlWsNsTpl = $this->config['chemins']['baseURLServicesEfloreTpl'];
229
		$urlWsNsTpl = $this->config['chemins']['baseURLServicesEfloreTpl'];
230
		$retour['url_ws_autocompletion_ns'] = sprintf( $urlWsNsTpl, self::EFLORE_API_VERSION, $referentiel, self::WS_NOM );;
230
		$retour['url_ws_autocompletion_ns'] = sprintf( $urlWsNsTpl, self::EFLORE_API_VERSION, $referentiel, self::WS_NOM );;
231
		$retour['url_ws_autocompletion_ns_tpl'] = sprintf( $urlWsNsTpl, self::EFLORE_API_VERSION, '{referentiel}', self::WS_NOM );
231
		$retour['url_ws_autocompletion_ns_tpl'] = sprintf( $urlWsNsTpl, self::EFLORE_API_VERSION, '{referentiel}', self::WS_NOM );
232
		$retour['ns_referentiel'] = $referentiel;
232
		$retour['ns_referentiel'] = $referentiel;
233
 
233
 
234
		if ( isset( $infos_projets['type_especes'] ) ) {
234
		if ( isset( $infos_projets['type_especes'] ) ) {
235
 
235
 
236
			switch ( $infos_projets['type_especes'] ) {
236
			switch ( $infos_projets['type_especes'] ) {
237
				case 'fixe' :
237
				case 'fixe' :
238
					$retour = $this->chargerInfosTaxon( $infos_projets['referentiel'], $infos_projets['especes'] );
238
					$retour = $this->chargerInfosTaxon( $infos_projets['referentiel'], $infos_projets['especes'] );
239
					break;
239
					break;
240
				case 'referentiel' : break;
240
				case 'referentiel' : break;
241
				case 'liste' :
241
				case 'liste' :
242
					$referentiel = $infos_projets['referentiel'];
242
					$referentiel = $infos_projets['referentiel'];
243
////////////////////// temporaire test transmission liste taxons
243
////////////////////// temporaire test transmission liste taxons
244
					$retour['taxons'] = $this->recupererListeNomsSci();
244
					$retour['taxons'] = $this->recupererListeNomsSci();
245
					break;
245
					break;
246
			}
246
			}
247
		} else if ( isset( $infos_projets['referentiel'] ) ) {
247
		} else if ( isset( $infos_projets['referentiel'] ) ) {
248
			$referentiel = $infos_projets['referentiel'];
248
			$referentiel = $infos_projets['referentiel'];
249
			if ( isset($infos_projets['num_nom'] ) ) {
249
			if ( isset($infos_projets['num_nom'] ) ) {
250
				$retour = $this->chargerInfosTaxon( $infos_projets['referentiel'], $infos_projets['num_nom'] );
250
				$retour = $this->chargerInfosTaxon( $infos_projets['referentiel'], $infos_projets['num_nom'] );
251
			}
251
			}
252
		}
252
		}
253
		return $retour;
253
		return $retour;
254
	}
254
	}
255
 
255
 
256
	/**
256
	/**
257
	 * Consulte un webservice pour obtenir des informations sur le taxon dont le
257
	 * Consulte un webservice pour obtenir des informations sur le taxon dont le
258
	 * numéro nomenclatural est $num_nom (ce sont donc plutôt des infos sur le nom
258
	 * numéro nomenclatural est $num_nom (ce sont donc plutôt des infos sur le nom
259
	 * et non le taxon?)
259
	 * et non le taxon?)
260
	 * @param string|int $num_nom
260
	 * @param string|int $num_nom
261
	 * @return array
261
	 * @return array
262
	 */
262
	 */
263
	protected function chargerInfosTaxon( $referentiel, $num_nom ) {
263
	protected function chargerInfosTaxon( $referentiel, $num_nom ) {
264
		$url_service_infos = sprintf( $this->config['chemins']['infosTaxonUrl'], $referentiel, $num_nom );
264
		$url_service_infos = sprintf( $this->config['chemins']['infosTaxonUrl'], $referentiel, $num_nom );
265
		$infos = json_decode( file_get_contents( $url_service_infos ) );
265
		$infos = json_decode( file_get_contents( $url_service_infos ) );
266
		// trop de champs injectés dans les infos espèces peuvent
266
		// trop de champs injectés dans les infos espèces peuvent
267
		// faire planter javascript
267
		// faire planter javascript
268
		$champs_a_garder = array( 'id', 'nom_sci','nom_sci_complet', 'nom_complet',
268
		$champs_a_garder = array( 'id', 'nom_sci','nom_sci_complet', 'nom_complet',
269
				'famille','nom_retenu.id', 'nom_retenu_complet', 'num_taxonomique' );
269
				'famille','nom_retenu.id', 'nom_retenu_complet', 'num_taxonomique' );
270
		$resultat = array();
270
		$resultat = array();
271
		$retour = array();
271
		$retour = array();
272
		if ( isset( $infos ) && !empty( $infos ) ) {
272
		if ( isset( $infos ) && !empty( $infos ) ) {
273
			$infos = (array) $infos;
273
			$infos = (array) $infos;
274
			if ( isset( $infos['nom_sci'] ) && $infos['nom_sci'] !== '' ) {
274
			if ( isset( $infos['nom_sci'] ) && $infos['nom_sci'] !== '' ) {
275
				$resultat = array_intersect_key( $infos, array_flip($champs_a_garder ) );
275
				$resultat = array_intersect_key( $infos, array_flip($champs_a_garder ) );
276
				$resultat['retenu'] = ( $infos['id'] == $infos['nom_retenu.id'] ) ? 'true' : 'false';
276
				$resultat['retenu'] = ( $infos['id'] == $infos['nom_retenu.id'] ) ? 'true' : 'false';
277
				$retour['espece_imposee'] = true;
277
				$retour['espece_imposee'] = true;
278
				$retour['nn_espece_defaut'] = $nnEspeceImposee;
278
				$retour['nn_espece_defaut'] = $nnEspeceImposee;
279
				$retour['nom_sci_espece_defaut'] = $resultat['nom_complet'];
279
				$retour['nom_sci_espece_defaut'] = $resultat['nom_complet'];
280
				$retour['infos_espece'] = $this->array2js( $resultat, true );
280
				$retour['infos_espece'] = $this->array2js( $resultat, true );
281
			}
281
			}
282
		}
282
		}
283
		return $retour;
283
		return $retour;
284
	}
284
	}
285
 
285
 
286
	protected function getReferentielImpose() {
286
	protected function getReferentielImpose() {
287
		$referentiel_impose = true;
287
		$referentiel_impose = true;
288
		if (!empty($_GET['referentiel']) && $_GET['referentiel'] !== 'autre') {
288
		if (!empty($_GET['referentiel']) && $_GET['referentiel'] !== 'autre') {
289
			$this->ns_referentiel = $_GET['referentiel'];
289
			$this->ns_referentiel = $_GET['referentiel'];
290
		} else if (isset($this->configProjet['referentiel'])) {
290
		} else if (isset($this->configProjet['referentiel'])) {
291
			$this->ns_referentiel = $this->configProjet['referentiel'];
291
			$this->ns_referentiel = $this->configProjet['referentiel'];
292
		} else if (isset($this->configMission['referentiel'])) {
292
		} else if (isset($this->configMission['referentiel'])) {
293
			$this->ns_referentiel = $this->configMission['referentiel'];
293
			$this->ns_referentiel = $this->configMission['referentiel'];
294
		} else {
294
		} else {
295
			$referentiel_impose = false;
295
			$referentiel_impose = false;
296
		}
296
		}
297
		return $referentiel_impose;
297
		return $referentiel_impose;
298
	}
298
	}
299
 
299
 
300
	/**
300
	/**
301
	 * Trie par nom français les taxons lus dans le fichier csv
301
	 * Trie par nom français les taxons lus dans le fichier csv
302
	 */
302
	 */
303
	protected function recupererListeNomsSci() {
303
	protected function recupererListeNomsSci() {
304
		$taxons = $this->recupererListeTaxon();
304
		$taxons = $this->recupererListeTaxon();
305
		if (is_array($taxons)) {
305
		if (is_array($taxons)) {
306
			$taxons = self::trierTableauMd($taxons, array('nom_fr' => SORT_ASC));
306
			$taxons = self::trierTableauMd($taxons, array('nom_fr' => SORT_ASC));
307
		}
307
		}
308
		return $taxons;
308
		return $taxons;
309
	}
309
	}
310
 
310
 
311
	/**
311
	/**
312
	 * @TODO documenter
312
	 * @TODO documenter
313
	 * @return array
313
	 * @return array
314
	 */
314
	 */
315
	protected function recupererListeNoms() {
315
	protected function recupererListeNoms() {
316
		$taxons = $this->recupererListeTaxon();
316
		$taxons = $this->recupererListeTaxon();
317
		$nomsAAfficher = array();
317
		$nomsAAfficher = array();
318
		$nomsSpeciaux = array();
318
		$nomsSpeciaux = array();
319
		if (is_array($taxons)) {
319
		if (is_array($taxons)) {
320
			foreach ($taxons as $taxon) {
320
			foreach ($taxons as $taxon) {
321
				$nomSciTitle = $taxon['nom_ret'].
321
				$nomSciTitle = $taxon['nom_ret'].
322
				($taxon['nom_fr'] != '' ? ' - '.$taxon['nom_fr'] : '' ).
322
				($taxon['nom_fr'] != '' ? ' - '.$taxon['nom_fr'] : '' ).
323
				($taxon['nom_fr_autre'] != '' ? ' - '.$taxon['nom_fr_autre'] : '' );
323
				($taxon['nom_fr_autre'] != '' ? ' - '.$taxon['nom_fr_autre'] : '' );
324
				$nomFrTitle = $taxon['nom_sel'].
324
				$nomFrTitle = $taxon['nom_sel'].
325
				($taxon['nom_ret'] != $taxon['nom_sel']? ' - '.$taxon['nom_ret'] : '' ).
325
				($taxon['nom_ret'] != $taxon['nom_sel']? ' - '.$taxon['nom_ret'] : '' ).
326
				($taxon['nom_fr_autre'] != '' ? ' - '.$taxon['nom_fr_autre'] : '' );
326
				($taxon['nom_fr_autre'] != '' ? ' - '.$taxon['nom_fr_autre'] : '' );
327
 
327
 
328
				if ($taxon['groupe'] == 'special') {
328
				if ($taxon['groupe'] == 'special') {
329
					$nomsSpeciaux[] = array(
329
					$nomsSpeciaux[] = array(
330
							'num_nom' => $taxon['num_nom_sel'],
330
							'num_nom' => $taxon['num_nom_sel'],
331
							'nom_a_afficher' => $taxon['nom_fr'],
331
							'nom_a_afficher' => $taxon['nom_fr'],
332
							'nom_a_sauver' => $taxon['nom_sel'],
332
							'nom_a_sauver' => $taxon['nom_sel'],
333
							'nom_title' => $nomSciTitle,
333
							'nom_title' => $nomSciTitle,
334
							'nom_type' => 'nom-special');
334
							'nom_type' => 'nom-special');
335
				} else {
335
				} else {
336
					$nomsAAfficher[] = array(
336
					$nomsAAfficher[] = array(
337
							'num_nom' => $taxon['num_nom_sel'],
337
							'num_nom' => $taxon['num_nom_sel'],
338
							'nom_a_afficher' => $taxon['nom_sel'],
338
							'nom_a_afficher' => $taxon['nom_sel'],
339
							'nom_a_sauver' => $taxon['nom_sel'],
339
							'nom_a_sauver' => $taxon['nom_sel'],
340
							'nom_title' => $nomSciTitle,
340
							'nom_title' => $nomSciTitle,
341
							'nom_type' => 'nom-sci');
341
							'nom_type' => 'nom-sci');
342
					$nomsAAfficher[] = array(
342
					$nomsAAfficher[] = array(
343
							'num_nom' => $taxon['num_nom_sel'],
343
							'num_nom' => $taxon['num_nom_sel'],
344
							'nom_a_afficher' => $taxon['nom_fr'],
344
							'nom_a_afficher' => $taxon['nom_fr'],
345
							'nom_a_sauver' => $taxon['nom_fr'],
345
							'nom_a_sauver' => $taxon['nom_fr'],
346
							'nom_title' => $nomFrTitle,
346
							'nom_title' => $nomFrTitle,
347
							'nom_type' => 'nom-fr');
347
							'nom_type' => 'nom-fr');
348
				}
348
				}
349
			}
349
			}
350
			$nomsAAfficher = self::trierTableauMd($nomsAAfficher, array('nom_a_afficher' => SORT_ASC));
350
			$nomsAAfficher = self::trierTableauMd($nomsAAfficher, array('nom_a_afficher' => SORT_ASC));
351
			$nomsSpeciaux = self::trierTableauMd($nomsSpeciaux, array('nom_a_afficher' => SORT_ASC));
351
			$nomsSpeciaux = self::trierTableauMd($nomsSpeciaux, array('nom_a_afficher' => SORT_ASC));
352
		}
352
		}
353
		return array('speciaux' => $nomsSpeciaux, 'sci-et-fr' => $nomsAAfficher);
353
		return array('speciaux' => $nomsSpeciaux, 'sci-et-fr' => $nomsAAfficher);
354
	}
354
	}
355
 
355
 
356
	/**
356
	/**
357
	 * Lit une liste de taxons depuis un fichier csv fourni
357
	 * Lit une liste de taxons depuis un fichier csv fourni
358
	 */
358
	 */
359
	protected function recupererListeTaxon() {
359
	protected function recupererListeTaxon() {
360
		$taxons = array();
360
		$taxons = array();
361
		$langue_projet_url = ( isset ( $this->parametres['langue'] ) && $this->parametres['langue'] !== 'fr' ) ? '_' . $this->parametres['langue'] : '';
361
		$langue_projet_url = ( isset ( $this->parametres['langue'] ) && $this->parametres['langue'] !== 'fr' ) ? '_' . $this->parametres['langue'] : '';
362
		$chemin_images = dirname(__FILE__) . self::DS . '..' . self::DS . 'manager' . self::DS . 'squelettes' . self::DS . 'img' . self::DS . 'images_projets' . self::DS;
362
		$chemin_images = dirname(__FILE__) . self::DS . '..' . self::DS . 'manager' . self::DS . 'squelettes' . self::DS . 'img' . self::DS . 'images_projets' . self::DS;
363
		$fichier_csv = $chemin_images . $this->parametres['projet'] . $langue_projet_url . self::DS . 'especes.csv';
363
		$fichier_csv = $chemin_images . $this->parametres['projet'] . $langue_projet_url . self::DS . 'especes.csv';
364
 
364
 
365
		if ( file_exists( $fichier_csv ) && is_readable( $fichier_csv ) ) {
365
		if ( file_exists( $fichier_csv ) && is_readable( $fichier_csv ) ) {
366
			$taxons = $this->decomposerFichierCsv( $fichier_csv );
366
			$taxons = $this->decomposerFichierCsv( $fichier_csv );
367
		} else {
367
		} else {
368
			$this->debug[] = "Impossible d'ouvrir le fichier '$fichier_csv'.";
368
			$this->debug[] = "Impossible d'ouvrir le fichier '$fichier_csv'.";
369
		}
369
		}
370
		return $taxons;
370
		return $taxons;
371
	}
371
	}
372
 
372
 
373
	/**
373
	/**
374
	 * Découpe un fihcier csv
374
	 * Découpe un fihcier csv
375
	 */
375
	 */
376
	protected function decomposerFichierCsv($fichier, $delimiter = "\t"){
376
	protected function decomposerFichierCsv($fichier, $delimiter = "\t"){
377
		$header = null;
377
		$header = null;
378
		$data = array();
378
		$data = array();
379
		if (($handle = fopen($fichier, "r")) !== FALSE) {
379
		if (($handle = fopen($fichier, "r")) !== FALSE) {
380
			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {
380
			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {
381
				if (!$header) {
381
				if (!$header) {
382
					$header = $row;
382
					$header = $row;
383
				} else {
383
				} else {
384
					$data[] = array_combine($header, $row);
384
					$data[] = array_combine($header, $row);
385
				}
385
				}
386
			}
386
			}
387
			fclose($handle);
387
			fclose($handle);
388
		}
388
		}
389
		return $data;
389
		return $data;
390
	}
390
	}
391
 
391
 
392
	/**
392
	/**
393
	 * Convertit un tableau PHP en Javascript - @WTF pourquoi ne pas faire un json_encode ?
393
	 * Convertit un tableau PHP en Javascript - @WTF pourquoi ne pas faire un json_encode ?
394
	 * @param array $array
394
	 * @param array $array
395
	 * @param boolean $show_keys
395
	 * @param boolean $show_keys
396
	 * @return une portion de JSON représentant le tableau
396
	 * @return une portion de JSON représentant le tableau
397
	 */
397
	 */
398
	protected function array2js($array,$show_keys) {
398
	protected function array2js($array,$show_keys) {
399
		$tableauJs = '{}';
399
		$tableauJs = '{}';
400
		if (!empty($array)) {
400
		if (!empty($array)) {
401
			$total = count($array) - 1;
401
			$total = count($array) - 1;
402
			$i = 0;
402
			$i = 0;
403
			$dimensions = array();
403
			$dimensions = array();
404
			foreach ($array as $key => $value) {
404
			foreach ($array as $key => $value) {
405
				if (is_array($value)) {
405
				if (is_array($value)) {
406
					$dimensions[$i] = array2js($value,$show_keys);
406
					$dimensions[$i] = array2js($value,$show_keys);
407
					if ($show_keys) {
407
					if ($show_keys) {
408
						$dimensions[$i] = '\"'.$key.'\":'.$dimensions[$i];
408
						$dimensions[$i] = '\"'.$key.'\":'.$dimensions[$i];
409
					}
409
					}
410
				} else {
410
				} else {
411
					$dimensions[$i] = '\"'.addslashes($value).'\"';
411
					$dimensions[$i] = '\"'.addslashes($value).'\"';
412
					if ($show_keys) {
412
					if ($show_keys) {
413
						$dimensions[$i] = '\"'.$key.'\":'.$dimensions[$i];
413
						$dimensions[$i] = '\"'.$key.'\":'.$dimensions[$i];
414
					}
414
					}
415
				}
415
				}
416
				if ($i == 0) {
416
				if ($i == 0) {
417
					$dimensions[$i] = '{'.$dimensions[$i];
417
					$dimensions[$i] = '{'.$dimensions[$i];
418
				}
418
				}
419
				if ($i == $total) {
419
				if ($i == $total) {
420
					$dimensions[$i].= '}';
420
					$dimensions[$i].= '}';
421
				}
421
				}
422
				$i++;
422
				$i++;
423
			}
423
			}
424
			$tableauJs = implode(',', $dimensions);
424
			$tableauJs = implode(',', $dimensions);
425
		}
425
		}
426
		return $tableauJs;
426
		return $tableauJs;
427
	}
427
	}
428
 
428
 
429
	private function remove_accents($string) {
429
	private function remove_accents($string) {
430
	    if ( !preg_match('/[\x80-\xff]/', $string) )
430
	    if ( !preg_match('/[\x80-\xff]/', $string) )
431
	        return $string;
431
	        return $string;
432
 
432
 
433
	        $chars = array(
433
	        $chars = array(
434
	            // Decompositions for Latin-1 Supplement
434
	            // Decompositions for Latin-1 Supplement
435
	            chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
435
	            chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
436
	            chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
436
	            chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
437
	            chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
437
	            chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
438
	            chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
438
	            chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
439
	            chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
439
	            chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
440
	            chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
440
	            chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
441
	            chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
441
	            chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
442
	            chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
442
	            chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
443
	            chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
443
	            chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
444
	            chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
444
	            chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
445
	            chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
445
	            chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
446
	            chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
446
	            chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
447
	            chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
447
	            chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
448
	            chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
448
	            chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
449
	            chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
449
	            chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
450
	            chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
450
	            chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
451
	            chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
451
	            chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
452
	            chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
452
	            chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
453
	            chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
453
	            chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
454
	            chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
454
	            chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
455
	            chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
455
	            chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
456
	            chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
456
	            chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
457
	            chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
457
	            chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
458
	            chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
458
	            chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
459
	            chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
459
	            chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
460
	            chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
460
	            chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
461
	            chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
461
	            chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
462
	            chr(195).chr(191) => 'y',
462
	            chr(195).chr(191) => 'y',
463
	            // Decompositions for Latin Extended-A
463
	            // Decompositions for Latin Extended-A
464
	            chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
464
	            chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
465
	            chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
465
	            chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
466
	            chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
466
	            chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
467
	            chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
467
	            chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
468
	            chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
468
	            chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
469
	            chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
469
	            chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
470
	            chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
470
	            chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
471
	            chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
471
	            chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
472
	            chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
472
	            chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
473
	            chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
473
	            chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
474
	            chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
474
	            chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
475
	            chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
475
	            chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
476
	            chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
476
	            chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
477
	            chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
477
	            chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
478
	            chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
478
	            chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
479
	            chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
479
	            chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
480
	            chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
480
	            chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
481
	            chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
481
	            chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
482
	            chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
482
	            chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
483
	            chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
483
	            chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
484
	            chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
484
	            chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
485
	            chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
485
	            chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
486
	            chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
486
	            chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
487
	            chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
487
	            chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
488
	            chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
488
	            chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
489
	            chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
489
	            chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
490
	            chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
490
	            chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
491
	            chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
491
	            chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
492
	            chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
492
	            chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
493
	            chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
493
	            chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
494
	            chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
494
	            chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
495
	            chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
495
	            chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
496
	            chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
496
	            chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
497
	            chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
497
	            chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
498
	            chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
498
	            chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
499
	            chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
499
	            chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
500
	            chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
500
	            chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
501
	            chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
501
	            chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
502
	            chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
502
	            chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
503
	            chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
503
	            chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
504
	            chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
504
	            chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
505
	            chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
505
	            chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
506
	            chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
506
	            chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
507
	            chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
507
	            chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
508
	            chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
508
	            chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
509
	            chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
509
	            chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
510
	            chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
510
	            chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
511
	            chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
511
	            chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
512
	            chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
512
	            chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
513
	            chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
513
	            chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
514
	            chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
514
	            chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
515
	            chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
515
	            chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
516
	            chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
516
	            chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
517
	            chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
517
	            chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
518
	            chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
518
	            chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
519
	            chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
519
	            chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
520
	            chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
520
	            chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
521
	            chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
521
	            chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
522
	            chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
522
	            chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
523
	            chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
523
	            chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
524
	            chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
524
	            chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
525
	            chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
525
	            chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
526
	            chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
526
	            chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
527
	            chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
527
	            chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
528
	        );
528
	        );
529
	        
529
	        
530
	        $string = strtr($string, $chars);
530
	        $string = strtr($string, $chars);
531
	        
531
	        
532
	        return $string;
532
	        return $string;
533
	}
533
	}
534
}
534
}
535
?>
535
?>