Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 363 Rev 562
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
* Description :
4
* Description :
5
* Classe CommunNomsTaxons.php
5
* Classe CommunNomsTaxons.php
6
* Encodage en entrée : utf8
6
* Encodage en entrée : utf8
7
* Encodage en sortie : utf8
7
* Encodage en sortie : utf8
8
* @package framework-v3
8
* @package framework-v3
9
* @author Jennifer Dhé <jennifer.dhe@tela-botanica.org>
9
* @author Jennifer Dhé <jennifer.dhe@tela-botanica.org>
10
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
10
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
11
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
11
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
12
* @version 1.0
12
* @version 1.0
13
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
13
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
14
*/
14
*/
15
 
15
 
16
 
16
 
17
abstract class CommunNomsTaxons extends Commun {
17
abstract class CommunNomsTaxons extends Commun {
18
 
18
 
19
	/** Tableau de correspondance entre les noms des champs et les codes de l'ontologie.*/
19
	/** Tableau de correspondance entre les noms des champs et les codes de l'ontologie.*/
20
	private $relationsChampsCodesOntologie = null;
20
	private $relationsChampsCodesOntologie = null;
21
	protected $table_retour; //Permet de stocker le tableau de résultat (non encodé en json)
21
	protected $table_retour; //Permet de stocker le tableau de résultat (non encodé en json)
22
	protected $resultat_req; // Permet de stocker le résultat de la requete principale.
22
	protected $resultat_req; // Permet de stocker le résultat de la requete principale.
23
	protected $compo_nom = null; //Stocke sous forme de tableau les composant du nom à ajouter au nom scientifique
23
	protected $compo_nom = null; //Stocke sous forme de tableau les composant du nom à ajouter au nom scientifique
24
	protected $table;// Nom de la table dans laquelle on récupèrera les données dans les requetes SQL
24
	protected $table;// Nom de la table dans laquelle on récupèrera les données dans les requetes SQL
25
	protected $total_resultat = null;
25
	protected $total_resultat = null;
26
	 /** Stocke le service appelé correspondant. Est utilisé principalement lors de l'affichage du href d'un synonyme
26
	 /** Stocke le service appelé correspondant. Est utilisé principalement lors de l'affichage du href d'un synonyme
27
	  (ex id=12, basionyme num 25 est un synonyme) dans le service taxon */
27
	  (ex id=12, basionyme num 25 est un synonyme) dans le service taxon */
28
	protected $service_href = null;
28
	protected $service_href = null;
29
	protected $erreursParametres = null;
29
	protected $erreursParametres = null;
30
 
30
 
31
//+------------------------------- PARAMÈTRES ---------------------------------------------------------------+
31
//+------------------------------- PARAMÈTRES ---------------------------------------------------------------+
32
 
32
 
33
	public function traiterParametres() {
33
	public function traiterParametres() {
34
		$this->definirParametresParDefaut();
34
		$this->definirParametresParDefaut();
35
		$this->verifierParametres();
35
		$this->verifierParametres();
36
 
36
 
37
		if (isset($this->parametres) && count($this->parametres) > 0) {
37
		if (isset($this->parametres) && count($this->parametres) > 0) {
38
			foreach ($this->parametres as $param => $val) {
38
			foreach ($this->parametres as $param => $val) {
39
				switch ($param) {
39
				switch ($param) {
40
					case 'ns.structure' :
40
					case 'ns.structure' :
41
						$this->remplirTableCompositionNom($val);
41
						$this->remplirTableCompositionNom($val);
42
						$this->requete_champ .= ' ,'.implode(', ',$this->compo_nom);
42
						$this->requete_champ .= ' ,'.implode(', ',$this->compo_nom);
43
						break;
43
						break;
44
					case 'navigation.depart' :
44
					case 'navigation.depart' :
45
							$this->limite_requete['depart'] = $val;
45
							$this->limite_requete['depart'] = $val;
46
						break;
46
						break;
47
					case 'navigation.limite' :
47
					case 'navigation.limite' :
48
							$this->limite_requete['limite'] = $val;
48
							$this->limite_requete['limite'] = $val;
49
						break;
49
						break;
50
				}
50
				}
51
			}
51
			}
52
			$this->traiterParametresSpecifiques();
52
			$this->traiterParametresSpecifiques();
53
		}
53
		}
54
	}
54
	}
55
 
55
 
56
	protected function definirParametresParDefaut() {
56
	protected function definirParametresParDefaut() {
57
		if (empty($this->parametres['recherche'])) {
57
		if (empty($this->parametres['recherche'])) {
58
			$this->parametres['recherche'] = 'stricte';
58
			$this->parametres['recherche'] = 'stricte';
59
		}
59
		}
60
		if (empty($this->parametres['ns.format'])) {
60
		if (empty($this->parametres['ns.format'])) {
61
			$this->parametres['ns.format'] =  'txt';
61
			$this->parametres['ns.format'] =  'txt';
62
		}
62
		}
63
		if (empty($this->parametres['retour.format'])) {
63
		if (empty($this->parametres['retour.format'])) {
64
			$this->parametres['retour.format'] = 'max';
64
			$this->parametres['retour.format'] = 'max';
65
		}
65
		}
66
		if (empty($this->parametres['ns.structure'])) {
66
		if (empty($this->parametres['ns.structure'])) {
67
			$this->parametres['ns.structure'] = 'au,an,bib';
67
			$this->parametres['ns.structure'] = 'au,an,bib';
68
		}
68
		}
69
	}
69
	}
70
 
70
 
71
	public function verifierParametres() {
71
	public function verifierParametres() {
72
		$this->verifierParametresAPI();
72
		$this->verifierParametresAPI();
73
 
73
 
74
		$this->verifierParametre('recherche', 'stricte|floue|etendue');
74
		$this->verifierParametre('recherche', 'stricte|floue|etendue');
75
		$this->verifierParametre('ns.format', 'htm|txt');
75
		$this->verifierParametre('ns.format', 'htm|txt');
76
		$this->verifierParametre('retour.format', 'min|max|oss|perso');
76
		$this->verifierParametre('retour.format', 'min|max|oss|perso');
77
		$this->verifierParametreAvecValeurMultipe('ns.structure', 'an|au|bib|ad');
77
		$this->verifierParametreAvecValeurMultipe('ns.structure', 'an|au|bib|ad');
78
 
78
 
79
		if (count($this->erreursParametres) > 0) {
79
		if (count($this->erreursParametres) > 0) {
80
			$m = 'Erreur dans votre requête : '.implode('<br/>', $this->erreursParametres);
80
			$m = 'Erreur dans votre requête : '.implode('<br/>', $this->erreursParametres);
81
			$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $m);
81
			$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $m);
82
		}
82
		}
83
	}
83
	}
84
 
84
 
85
	public function verifierParametresAPI() {
85
	public function verifierParametresAPI() {
86
		$parametresApi = $this->recupererTableauConfig('parametresAPI');
86
		$parametresApi = $this->recupererTableauConfig('parametresAPI');
87
		while (!is_null($parametre = key($this->parametres))) {
87
		while (!is_null($parametre = key($this->parametres))) {
88
			if (!in_array($parametre, $parametresApi)) {
88
			if (!in_array($parametre, $parametresApi)) {
89
				$this->erreursParametres[] = "Le paramètre '$parametre' n'est pas pris en compte par cette version de l'API.";
89
				$this->erreursParametres[] = "Le paramètre '$parametre' n'est pas pris en compte par cette version de l'API.";
90
			}
90
			}
91
			next($this->parametres);
91
			next($this->parametres);
92
		}
92
		}
93
	}
93
	}
94
 
94
 
95
	public function verifierParametre($parametre, $valeursPermises) {
95
	public function verifierParametre($parametre, $valeursPermises) {
96
		if (isset($this->parametres[$parametre]) && !empty($this->parametres[$parametre])) {
96
		if (isset($this->parametres[$parametre]) && !empty($this->parametres[$parametre])) {
97
			$valeur = $this->parametres[$parametre];
97
			$valeur = $this->parametres[$parametre];
98
			$this->verifierValeursPermises($parametre, $valeur, $valeursPermises);
98
			$this->verifierValeursPermises($parametre, $valeur, $valeursPermises);
99
		}
99
		}
100
	}
100
	}
101
 
101
 
102
	public function verifierParametreAvecValeurMultipe($parametre, $valeursPermises) {
102
	public function verifierParametreAvecValeurMultipe($parametre, $valeursPermises) {
103
		if (isset($this->parametres[$parametre]) && !empty($this->parametres[$parametre])) {
103
		if (isset($this->parametres[$parametre]) && !empty($this->parametres[$parametre])) {
104
			$valeursConcatenees = $this->parametres[$parametre];
104
			$valeursConcatenees = $this->parametres[$parametre];
105
			$valeurs = explode(',', $valeursConcatenees);
105
			$valeurs = explode(',', $valeursConcatenees);
106
			foreach ($valeurs as $valeur) {
106
			foreach ($valeurs as $valeur) {
107
				$this->verifierValeursPermises($parametre, $valeur, $valeursPermises);
107
				$this->verifierValeursPermises($parametre, $valeur, $valeursPermises);
108
			}
108
			}
109
		}
109
		}
110
	}
110
	}
111
 
111
 
112
	private function verifierValeursPermises($parametre, $valeur, $valeursPermises) {
112
	private function verifierValeursPermises($parametre, $valeur, $valeursPermises) {
113
		if (!in_array($valeur, explode('|', $valeursPermises))) {
113
		if (!in_array($valeur, explode('|', $valeursPermises))) {
114
			$this->erreursParametres[] = "Le paramètre '$parametre' ne peut pas prendre la valeur '$valeur'. Valeurs permises : $valeursPermises";
114
			$this->erreursParametres[] = "Le paramètre '$parametre' ne peut pas prendre la valeur '$valeur'. Valeurs permises : $valeursPermises";
115
		}
115
		}
116
	}
116
	}
117
 
117
 
118
	public function traiterParametresCommuns() {
118
	public function traiterParametresCommuns() {
119
 
119
 
120
	}
120
	}
121
 
121
 
122
	public function ajouterFiltreMasque($nom_champ, $valeur) {
122
	public function ajouterFiltreMasque($nom_champ, $valeur) {
123
		if ($nom_champ == 'annee' || $nom_champ == 'rang') {
123
		if ($nom_champ == 'annee' || $nom_champ == 'rang') {
124
			$this->requete_condition []= "$nom_champ = ".$this->getBdd()->proteger($valeur);
124
			$this->requete_condition []= "$nom_champ = ".$this->getBdd()->proteger($valeur);
125
		} else {
125
		} else {
126
			if ($this->parametres['recherche'] == 'etendue') {
126
			if ($this->parametres['recherche'] == 'etendue') {
127
				$valeur = $this->modifierValeur($valeur);
127
				$valeur = $this->modifierValeur($valeur);
128
				$this->requete_condition[] = "$nom_champ LIKE ".$this->getBdd()->proteger($valeur);
128
				$this->requete_condition[] = "$nom_champ LIKE ".$this->getBdd()->proteger($valeur);
129
			} elseif ($this->parametres['recherche'] == 'floue') {
129
			} elseif ($this->parametres['recherche'] == 'floue') {
130
				$valeur = $this->getBdd()->proteger($valeur);
130
				$valeur = $this->getBdd()->proteger($valeur);
131
				$this->requete_condition[] = "( SOUNDEX($nom_champ) = SOUNDEX($valeur))".
131
				$this->requete_condition[] = "( SOUNDEX($nom_champ) = SOUNDEX($valeur))".
132
						" OR ( SOUNDEX(REVERSE($nom_champ)) = SOUNDEX(REVERSE($valeur)))";
132
						" OR ( SOUNDEX(REVERSE($nom_champ)) = SOUNDEX(REVERSE($valeur)))";
133
			} else {
133
			} else {
134
				$this->requete_condition[] = "$nom_champ LIKE ".$this->getBdd()->proteger($valeur);
134
				$this->requete_condition[] = "$nom_champ LIKE ".$this->getBdd()->proteger($valeur);
135
			}
135
			}
136
		}
136
		}
137
		$this->masque[$nom_champ] = "$nom_champ=$valeur";
137
		$this->masque[$nom_champ] = "$nom_champ=$valeur";
138
	}
138
	}
139
 
139
 
140
	private function modifierValeur($valeur) {
140
	private function modifierValeur($valeur) {
141
		$valeur = $this->remplacerCaractereHybrideEtChimere($valeur);
141
		$valeur = $this->remplacerCaractereHybrideEtChimere($valeur);
142
		$valeur = $this->preparerChainePourRechercheEtendue($valeur);
142
		$valeur = $this->preparerChainePourRechercheEtendue($valeur);
143
		return $valeur;
143
		return $valeur;
144
	}
144
	}
145
 
145
 
146
	private function remplacerCaractereHybrideEtChimere($valeur) {
146
	private function remplacerCaractereHybrideEtChimere($valeur) {
147
		$caracteres = array('×', '%D7', '+', '%2B');
147
		$caracteres = array('×', '%D7', '+', '%2B');
148
		$remplacements = array('x ','x ', '+', '+');
148
		$remplacements = array('x ','x ', '+', '+');
149
		$valeur = str_replace($caracteres, $remplacements, $valeur);
149
		$valeur = str_replace($caracteres, $remplacements, $valeur);
150
		return $valeur;
150
		return $valeur;
151
	}
151
	}
152
 
152
 
153
	private function preparerChainePourRechercheEtendue($valeur) {
153
	private function preparerChainePourRechercheEtendue($valeur) {
154
		$valeur = str_replace(' ', '% ', trim($valeur));
154
		$valeur = str_replace(' ', '% ', trim($valeur));
155
		$valeur = $valeur.'%';
155
		$valeur = $valeur.'%';
156
		return $valeur;
156
		return $valeur;
157
	}
157
	}
158
 
158
 
159
	//+-------------------------------Fonctions d'analyse des ressources-------------------------------------+
159
	//+-------------------------------Fonctions d'analyse des ressources-------------------------------------+
160
 
160
 
161
	private function etreRessourceId() {
161
	private function etreRessourceId() {
162
		$ok = false;
162
		$ok = false;
163
		if ($this->estUnIdentifiant() && count($this->ressources) == 1) {
163
		if ($this->estUnIdentifiant() && count($this->ressources) == 1) {
164
			$ok = true;
164
			$ok = true;
165
		}
165
		}
166
		return $ok;
166
		return $ok;
167
	}
167
	}
168
 
168
 
169
	public function traiterRessources() {
169
	public function traiterRessources() {
170
		if (isset($this->ressources) && count($this->ressources) > 0) {
170
		if (isset($this->ressources) && count($this->ressources) > 0) {
171
			if ($this->ressources[0] == 'relations') {
171
			if ($this->ressources[0] == 'relations') {
172
				$this->traiterRessourceRelations();
172
				$this->traiterRessourceRelations();
173
			} elseif ($this->estUnIdentifiant()) { //l'identifiant peut etre de type /#id ou /nt:#id
173
			} elseif ($this->estUnIdentifiant()) { //l'identifiant peut etre de type /#id ou /nt:#id
174
				$this->traiterRessourcesIdentifiant(); // dans le service noms ou taxons
174
				$this->traiterRessourcesIdentifiant(); // dans le service noms ou taxons
175
			} elseif ($this->ressources[0] == 'stats') { //ressource = noms/stats
175
			} elseif ($this->ressources[0] == 'stats') { //ressource = noms/stats
176
				$this->traiterRessourcesStats();
176
				$this->traiterRessourcesStats();
177
			} else {
177
			} else {
178
				$e = 'Erreur dans votre requete </br> Ressources disponibles : <br/>
178
				$e = 'Erreur dans votre requete </br> Ressources disponibles : <br/>
179
					 <li> /'.$this->service.'/#id (id : L\'identifiant du nom rechercher)</li>
179
					 <li> /'.$this->service.'/#id (id : L\'identifiant du nom rechercher)</li>
180
					 <li> /'.$this->service.'/nt:#id (id : Numero du taxon recherche)</li>
180
					 <li> /'.$this->service.'/nt:#id (id : Numero du taxon recherche)</li>
181
					 <li> /'.$this->service.'/stats </li>';
181
					 <li> /'.$this->service.'/stats </li>';
182
				$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
182
				$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
183
			}
183
			}
184
		}
184
		}
185
	}
185
	}
186
 
186
 
187
	public function traiterRessourcesStats() {
187
	public function traiterRessourcesStats() {
188
		$this->format_reponse = $this->service.'/stats';
188
		$this->format_reponse = $this->service.'/stats';
189
 
189
 
190
		$e = "Erreur dans votre requête </br> Ressources disponibles : $this->service/stats/[annees|rangs|initiales]";
190
		$e = "Erreur dans votre requête </br> Ressources disponibles : $this->service/stats/[annees|rangs|initiales]";
191
		if (isset($this->ressources[1]) && !empty($this->ressources[1])) {
191
		if (isset($this->ressources[1]) && !empty($this->ressources[1])) {
192
			switch ($this->ressources[1]) {
192
			switch ($this->ressources[1]) {
193
				case 'annees' :
193
				case 'annees' :
194
					$this->traiterRessourceStatsAnnees();
194
					$this->traiterRessourceStatsAnnees();
195
					break;
195
					break;
196
				case 'rangs' :
196
				case 'rangs' :
197
					$this->traiterRessourceStatsRangs();
197
					$this->traiterRessourceStatsRangs();
198
					break;
198
					break;
199
				case 'initiales' :
199
				case 'initiales' :
200
					$this->traiterRessourceStatsInitiales();
200
					$this->traiterRessourceStatsInitiales();
201
					break;
201
					break;
202
				default :
202
				default :
203
					$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
203
					$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
204
					break;
204
					break;
205
			}
205
			}
206
		} else {
206
		} else {
207
			$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
207
			$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
208
		}
208
		}
209
	}
209
	}
210
 
210
 
211
	/** Vérifie si la première valeur de la table de ressource est un identifiant :
211
	/** Vérifie si la première valeur de la table de ressource est un identifiant :
212
	 * un numerique ou un numéro taxonomique sous la forme nt:xx */
212
	 * un numerique ou un numéro taxonomique sous la forme nt:xx */
213
	public function estUnIdentifiant() {
213
	public function estUnIdentifiant() {
214
		return (is_numeric($this->ressources[0]) || (strrpos($this->ressources[0],'nt:') !== false
214
		return (is_numeric($this->ressources[0]) || (strrpos($this->ressources[0],'nt:') !== false
215
				&& is_numeric(str_replace('nt:','',$this->ressources[0]))));
215
				&& is_numeric(str_replace('nt:','',$this->ressources[0]))));
216
	}
216
	}
217
 
217
 
218
	//+------------------------------------------------------------------------------------------------------+
218
	//+------------------------------------------------------------------------------------------------------+
219
	// Fonction d'analyse des parametres
219
	// Fonction d'analyse des parametres
220
 
220
 
221
	/** Permet de remplir le tableau compo_nom. Il comprendra en fct du paramètre ns.structure les éléments à rajouter
221
	/** Permet de remplir le tableau compo_nom. Il comprendra en fct du paramètre ns.structure les éléments à rajouter
222
	 * au nom_sci (annee, auteur, biblio ou addendum). */
222
	 * au nom_sci (annee, auteur, biblio ou addendum). */
223
	public function remplirTableCompositionNom($valeur) {
223
	public function remplirTableCompositionNom($valeur) {
224
		$structure_nom = explode(',', $valeur);
224
		$structure_nom = explode(',', $valeur);
225
		foreach ($structure_nom as $structure) {
225
		foreach ($structure_nom as $structure) {
226
			$this->compo_nom[$structure] = str_replace(array('an', 'au', 'bib', 'ad'),
226
			$this->compo_nom[$structure] = str_replace(array('an', 'au', 'bib', 'ad'),
227
				array('annee', 'auteur', 'biblio_origine', 'nom_addendum'), $structure);
227
				array('annee', 'auteur', 'biblio_origine', 'nom_addendum'), $structure);
228
		}
228
		}
229
	}
229
	}
230
 
230
 
231
	public function mettreAuFormat() {
231
	public function mettreAuFormat() {
232
		if ($this->parametres['ns.format'] == 'htm') {
232
		if ($this->parametres['ns.format'] == 'htm') {
233
			if (strrpos($this->requete_champ, 'nom_sci_html as nom_sci') === false) {
233
			if (strrpos($this->requete_champ, 'nom_sci_html as nom_sci') === false) {
234
				$this->requete_champ = str_replace('nom_sci', 'nom_sci_html as nom_sci', $this->requete_champ);
234
				$this->requete_champ = str_replace('nom_sci', 'nom_sci_html as nom_sci', $this->requete_champ);
235
			}
235
			}
236
		}
236
		}
237
	}
237
	}
238
 
238
 
239
	//+------------------------------------------------------------------------------------------------------+
239
	//+------------------------------------------------------------------------------------------------------+
240
	// Fonctions de formatage
240
	// Fonctions de formatage
241
 
241
 
242
	/** Fonction permettant de creer la table dont le nom est passé en paramètre (champs_api, champs_bdtfx,
242
	/** Fonction permettant de creer la table dont le nom est passé en paramètre (champs_api, champs_bdtfx,
243
	 * correspondance_champs...). Les données de chaque table sont présentes dans le fichier de configuration config.ini
243
	 * correspondance_champs...). Les données de chaque table sont présentes dans le fichier de configuration config.ini
244
	 * @param String $table : Peut contenir plusieurs nom de table dont on souhaite récupérer les données : table,table,table. */
244
	 * @param String $table : Peut contenir plusieurs nom de table dont on souhaite récupérer les données : table,table,table. */
245
	public function recupererTableSignification($table) {
245
	public function recupererTableSignification($table) {
246
		$tables = explode(',', $table);
246
		$tables = explode(',', $table);
247
		foreach ($tables as $tab) {
247
		foreach ($tables as $tab) {
248
			if ($tab == 'champs_comp') {
248
			if ($tab == 'champs_comp') {
249
				$champ_bdnff_api = array_keys($this->champs_api); //on recupère le nom des champ ds la bdd
249
				$champ_bdnff_api = array_keys($this->champs_api); //on recupère le nom des champ ds la bdd
250
				$this->champs_comp = array_diff($this->champs_table, $champ_bdnff_api);
250
				$this->champs_comp = array_diff($this->champs_table, $champ_bdnff_api);
251
			} elseif ($tab == 'champs_api') {
251
			} elseif ($tab == 'champs_api') {
252
				foreach ($this->correspondance_champs as $key => $val) {
252
				foreach ($this->correspondance_champs as $key => $val) {
253
					preg_match('/(hybride[.]parent_0[12](?:[.]notes)?|nom_sci[.][^.]+|[^.]+)(?:[.](id|code))?/', $val, $match);
253
					preg_match('/(hybride[.]parent_0[12](?:[.]notes)?|nom_sci[.][^.]+|[^.]+)(?:[.](id|code))?/', $val, $match);
254
					$val = $match[1];
254
					$val = $match[1];
255
					$this->champs_api[$key] = $val;
255
					$this->champs_api[$key] = $val;
256
				}
256
				}
257
			} else {
257
			} else {
258
				$this->$tab = $this->recupererTableauConfig($tab);
258
				$this->$tab = $this->recupererTableauConfig($tab);
259
			}
259
			}
260
		}
260
		}
261
	}
261
	}
262
 
262
 
263
	public function formaterEnOss($resultat) {
263
	public function formaterEnOss($resultat) {
264
		$table_nom = array();
264
		$table_nom = array();
265
		$oss = '';
265
		$oss = '';
266
		foreach ($resultat as $tab) {
266
		foreach ($resultat as $tab) {
267
			if (isset($tab['nom_sci']) ) {
267
			if (isset($tab['nom_sci']) ) {
268
				if (!in_array($tab['nom_sci'], $table_nom)) {
268
				if (!in_array($tab['nom_sci'], $table_nom)) {
269
					$table_nom[] = $tab['nom_sci'];
269
					$table_nom[] = $tab['nom_sci'];
270
					$oss [] = $tab['nom_sci'].$this->ajouterCompositionNom($tab);
270
					$oss [] = $tab['nom_sci'].$this->ajouterCompositionNom($tab);
271
				}
271
				}
272
			}
272
			}
273
		}
273
		}
274
		if (isset($this->masque)) $masque = implode('&', $this->masque);
274
		if (isset($this->masque)) $masque = implode('&', $this->masque);
275
		else $masque = 'Pas de masque';
275
		else $masque = 'Pas de masque';
276
		$table_retour_oss = array($masque, $oss);
276
		$table_retour_oss = array($masque, $oss);
277
		return $table_retour_oss;
277
		return $table_retour_oss;
278
	}
278
	}
279
 
279
 
280
	public function afficherEnteteResultat($url_service) {
280
	public function afficherEnteteResultat($url_service) {
281
		$this->table_retour['depart'] = $this->limite_requete['depart'];
281
		$this->table_retour['depart'] = $this->limite_requete['depart'];
282
		$this->table_retour['limite'] = $this->limite_requete['limite'];
282
		$this->table_retour['limite'] = $this->limite_requete['limite'];
283
		$this->table_retour['total']  = $this->total_resultat;
283
		$this->table_retour['total']  = $this->total_resultat;
284
		$url = $this->formulerUrl($this->total_resultat, $url_service);
284
		$url = $this->formulerUrl($this->total_resultat, $url_service);
285
		if (isset($url['precedent']) && $url['precedent'] != '') {
285
		if (isset($url['precedent']) && $url['precedent'] != '') {
286
			$this->table_retour['href.precedent'] = $url['precedent'];
286
			$this->table_retour['href.precedent'] = $url['precedent'];
287
		}
287
		}
288
		if (isset($url['suivant']) && $url['suivant']   != '') {
288
		if (isset($url['suivant']) && $url['suivant']   != '') {
289
			$this->table_retour['href.suivant']   = $url['suivant'];
289
			$this->table_retour['href.suivant']   = $url['suivant'];
290
		}
290
		}
291
	}
291
	}
292
 
292
 
293
	public function afficherNomHrefRetenu($tab, $num) {
293
	public function afficherNomHrefRetenu($tab, $num) {
294
		$this->resultat_req = $tab;
294
		$this->resultat_req = $tab;
295
		$this->afficherDonnees('num_nom', $num);
295
		$this->afficherDonnees('num_nom', $num);
296
		if ($this->parametres['retour.format'] == 'min') { // sinon est affiché ds afficherDonnees(num_nom, $val) ci-dessus
296
		if ($this->parametres['retour.format'] == 'min') { // sinon est affiché ds afficherDonnees(num_nom, $val) ci-dessus
297
			 $this->table_retour['nom_sci'] = $tab['nom_sci'];
297
			 $this->table_retour['nom_sci'] = $tab['nom_sci'];
298
			 $this->table_retour['nom_sci_complet'] = $tab['nom_sci'].$this->ajouterCompositionNom($tab);
298
			 $this->table_retour['nom_sci_complet'] = $tab['nom_sci'].$this->ajouterCompositionNom($tab);
299
		}
299
		}
-
 
300
		if ($tab['num_nom_retenu'] != '') {
300
		$this->table_retour['retenu'] = ($tab['num_nom_retenu'] == $num) ? 'true' : 'false';
301
			$retenu = ($tab['num_nom_retenu'] == $num) ? 'true' : 'false';
-
 
302
		} else {
-
 
303
			$retenu = 'absent';
-
 
304
		}
-
 
305
		$this->table_retour['retenu'] = $retenu;
301
		unset($this->table_retour['id']);
306
		unset($this->table_retour['id']);
302
	}
307
	}
303
 
308
 
304
 
309
 
305
	//+------------------------------------------------------------------------------------------------------+
310
	//+------------------------------------------------------------------------------------------------------+
306
	// Fonction de formatage pour les services /#id/
311
	// Fonction de formatage pour les services /#id/
307
 
312
 
308
	public function formaterId($resultat) {
313
	public function formaterId($resultat) {
309
		$this->recupererTableSignification('correspondance_champs,champs_api,champs_comp');
314
		$this->recupererTableSignification('correspondance_champs,champs_api,champs_comp');
310
		$this->resultat_req = $resultat;
315
		$this->resultat_req = $resultat;
311
 
316
 
312
		foreach ($resultat as $cle => $valeur) {
317
		foreach ($resultat as $cle => $valeur) {
313
			if ($valeur != '') {
318
			if ($valeur != '') {
314
				$this->afficherDonnees($cle, $valeur);
319
				$this->afficherDonnees($cle, $valeur);
315
			}
320
			}
316
		}
321
		}
317
		if (isset($this->parametres['retour.champs']) && $this->format_reponse == 'noms/id') {
322
		if (isset($this->parametres['retour.champs']) && $this->format_reponse == 'noms/id') {
318
			$retour = $this->table_retour;
323
			$retour = $this->table_retour;
319
			$this->table_retour = array();
324
			$this->table_retour = array();
320
			$champs = explode(',', $this->parametres['retour.champs']);
325
			$champs = explode(',', $this->parametres['retour.champs']);
321
			$this->ajouterChampsPersonnalises($champs, $retour);
326
			$this->ajouterChampsPersonnalises($champs, $retour);
322
		}
327
		}
323
		unset($this->table_retour['href']);
328
		unset($this->table_retour['href']);
324
		return $this->table_retour;
329
		return $this->table_retour;
325
	}
330
	}
326
 
331
 
327
	public function formaterIdChamp($resultat) {
332
	public function formaterIdChamp($resultat) {
328
		$this->recupererTableSignification('correspondance_champs,champs_api,champs_comp');
333
		$this->recupererTableSignification('correspondance_champs,champs_api,champs_comp');
329
		$reponse_id = $this->formaterId($resultat);
334
		$reponse_id = $this->formaterId($resultat);
330
		$this->table_retour = array();
335
		$this->table_retour = array();
331
		$champs = explode(' ', $this->ressources[1]);
336
		$champs = explode(' ', $this->ressources[1]);
332
		$this->ajouterChampsPersonnalises($champs, $reponse_id);
337
		$this->ajouterChampsPersonnalises($champs, $reponse_id);
333
		return $this->table_retour;
338
		return $this->table_retour;
334
	}
339
	}
335
 
340
 
336
	protected function ajouterChampsPersonnalises($champs, $reponse_id) {
341
	protected function ajouterChampsPersonnalises($champs, $reponse_id) {
337
		$champs_a_libeller = array('nom_retenu', 'rang', 'basionyme', 'hybride', 'hybride.parent_01',
342
		$champs_a_libeller = array('nom_retenu', 'rang', 'basionyme', 'hybride', 'hybride.parent_01',
338
			 'hybride.parent_02', 'presence', 'tax_sup', 'statut_origine', 'statut_culture', 'statut_introduction');
343
			 'hybride.parent_02', 'presence', 'tax_sup', 'statut_origine', 'statut_culture', 'statut_introduction');
339
		if (! is_null($champs) && is_array($champs) && count($champs) > 0) {
344
		if (! is_null($champs) && is_array($champs) && count($champs) > 0) {
340
			foreach ($champs as $champ) {
345
			foreach ($champs as $champ) {
341
				if ($this->verifierValiditeChamp($champ)) {
346
				if ($this->verifierValiditeChamp($champ)) {
342
					if (strrpos($champ, '.*') !== false) {
347
					if (strrpos($champ, '.*') !== false) {
343
						$this->afficherPointEtoile($champ, $reponse_id);
348
						$this->afficherPointEtoile($champ, $reponse_id);
344
					} elseif (in_array($champ, $champs_a_libeller)) {
349
					} elseif (in_array($champ, $champs_a_libeller)) {
345
						$this->table_retour[$champ.'.libelle'] = 
350
						$this->table_retour[$champ.'.libelle'] = 
346
							(isset($reponse_id[$champ.'.libelle'])) ? $reponse_id[$champ.'.libelle'] : null;
351
							(isset($reponse_id[$champ.'.libelle'])) ? $reponse_id[$champ.'.libelle'] : null;
347
					} else {
352
					} else {
348
						$champ = $this->trouverChampBddCorrespondant($champ);
353
						$champ = $this->trouverChampBddCorrespondant($champ);
349
						$this->table_retour[$champ] = (isset($reponse_id[$champ])) ? $reponse_id[$champ] : null;
354
						$this->table_retour[$champ] = (isset($reponse_id[$champ])) ? $reponse_id[$champ] : null;
350
					}
355
					}
351
				}
356
				}
352
			}
357
			}
353
		}
358
		}
354
	}
359
	}
355
 
360
 
356
	public function afficherPointEtoile($champ, $reponse) {
361
	public function afficherPointEtoile($champ, $reponse) {
357
		preg_match('/^([^.]+\.)\*$/', $champ, $match);
362
		preg_match('/^([^.]+\.)\*$/', $champ, $match);
358
		if ($match[1] == 'nom_sci') {
363
		if ($match[1] == 'nom_sci') {
359
			$this->afficherNomSciPointEpithete($this->resultat_req);
364
			$this->afficherNomSciPointEpithete($this->resultat_req);
360
		} else {
365
		} else {
361
			foreach ($reponse as $chp => $valeur) {
366
			foreach ($reponse as $chp => $valeur) {
362
				if (strrpos($chp, $match[1]) !== false) {
367
				if (strrpos($chp, $match[1]) !== false) {
363
					if ($valeur != '') {
368
					if ($valeur != '') {
364
						$this->table_retour[$chp] = $valeur;
369
						$this->table_retour[$chp] = $valeur;
365
					} else {
370
					} else {
366
						$this->table_retour[$chp] = null;
371
						$this->table_retour[$chp] = null;
367
					}
372
					}
368
				}
373
				}
369
			}
374
			}
370
		}
375
		}
371
	}
376
	}
372
 
377
 
373
	public function decomposerNomChamp($champ) {
378
	public function decomposerNomChamp($champ) {
374
		$decomposition = false;
379
		$decomposition = false;
375
		if (preg_match('/^(?:([^.]+\.parent_0[12]|[^.]+))(?:\.(.+))?$/', $champ, $match)) {
380
		if (preg_match('/^(?:([^.]+\.parent_0[12]|[^.]+))(?:\.(.+))?$/', $champ, $match)) {
376
			$radical_champ = $match[1];
381
			$radical_champ = $match[1];
377
			$suffixe = (isset($match[2])) ? $match[2] : "";
382
			$suffixe = (isset($match[2])) ? $match[2] : "";
378
			$decomposition = array($radical_champ, $suffixe);
383
			$decomposition = array($radical_champ, $suffixe);
379
		}
384
		}
380
		return $decomposition;
385
		return $decomposition;
381
	}
386
	}
382
 
387
 
383
	public function verifierValiditeChamp($champ) {
388
	public function verifierValiditeChamp($champ) {
384
		$decomposition = $this->decomposerNomChamp($champ);
389
		$decomposition = $this->decomposerNomChamp($champ);
385
		$validite_ressource = true;
390
		$validite_ressource = true;
386
		if ($decomposition) {
391
		if ($decomposition) {
387
			list($radical, $suffixe) = $decomposition;
392
			list($radical, $suffixe) = $decomposition;
388
			$champs_complementaire = array('nom_retenu_complet', 'basionyme_complet');
393
			$champs_complementaire = array('nom_retenu_complet', 'basionyme_complet');
389
			// on verifie si le nom du champ existe bien
394
			// on verifie si le nom du champ existe bien
390
			if (!$this->estChampApi($radical) && !$this->estChampComplementaire($radical)) {
395
			if (!$this->estChampApi($radical) && !$this->estChampComplementaire($radical)) {
391
				if (!in_array($radical, $champs_complementaire)) {
396
				if (!in_array($radical, $champs_complementaire)) {
392
					$validite_ressource = false;
397
					$validite_ressource = false;
393
					$e = 'Le champ "'.$radical.'" n\'existe pas dans la base. <br/><br/>';
398
					$e = 'Le champ "'.$radical.'" n\'existe pas dans la base. <br/><br/>';
394
					$this->renvoyerErreur( RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
399
					$this->renvoyerErreur( RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
395
				}
400
				}
396
			} elseif ($this->estUnPoint($champ)) {
401
			} elseif ($this->estUnPoint($champ)) {
397
				$validite_ressource = $this->verifierValiditeSuffixe($suffixe, $radical);
402
				$validite_ressource = $this->verifierValiditeSuffixe($suffixe, $radical);
398
			}
403
			}
399
		}
404
		}
400
		return $validite_ressource;
405
		return $validite_ressource;
401
	}
406
	}
402
 
407
 
403
	public function estChampApi($radical_champ) {
408
	public function estChampApi($radical_champ) {
404
		$champ_api_ok = false;
409
		$champ_api_ok = false;
405
		if (in_array($radical_champ, $this->champs_api) || in_array($radical_champ, $this->correspondance_champs)) {
410
		if (in_array($radical_champ, $this->champs_api) || in_array($radical_champ, $this->correspondance_champs)) {
406
			$champ_api_ok = true;
411
			$champ_api_ok = true;
407
		}
412
		}
408
		return $champ_api_ok;
413
		return $champ_api_ok;
409
	}
414
	}
410
 
415
 
411
	public function estChampComplementaire($radical_champ) {
416
	public function estChampComplementaire($radical_champ) {
412
		$champ_complementaire_ok = in_array($radical_champ, $this->champs_comp) ? true : false;
417
		$champ_complementaire_ok = in_array($radical_champ, $this->champs_comp) ? true : false;
413
		return	$champ_complementaire_ok;
418
		return	$champ_complementaire_ok;
414
	}
419
	}
415
 
420
 
416
	public function verifierValiditeSuffixe($suffixe, $radical_champ) {
421
	public function verifierValiditeSuffixe($suffixe, $radical_champ) {
417
		$validite_ressource = true;
422
		$validite_ressource = true;
418
		if ($this->correspondAUnId($radical_champ) || $radical_champ == 'id') {
423
		if ($this->correspondAUnId($radical_champ) || $radical_champ == 'id') {
419
			$this->verificationSuffixesIdentifiant($suffixe, $radical_champ, $validite_ressource);
424
			$this->verificationSuffixesIdentifiant($suffixe, $radical_champ, $validite_ressource);
420
		} elseif ($this->correspondAUnCode($radical_champ)) {
425
		} elseif ($this->correspondAUnCode($radical_champ)) {
421
			$this->verificationSuffixesCodes($suffixe, $radical_champ, $validite_ressource);
426
			$this->verificationSuffixesCodes($suffixe, $radical_champ, $validite_ressource);
422
		} elseif ($radical_champ == 'nom_sci') {
427
		} elseif ($radical_champ == 'nom_sci') {
423
			if ($suffixe != '*') {
428
			if ($suffixe != '*') {
424
				$validite_ressource = false;
429
				$validite_ressource = false;
425
				$m = 'Erreur : Le suffixe demandé n\'existe pas pour le champ "'.$radical_champ.'".<br/>
430
				$m = 'Erreur : Le suffixe demandé n\'existe pas pour le champ "'.$radical_champ.'".<br/>
426
					Les suffixes possibles sont les suivants : <li> * </li>';
431
					Les suffixes possibles sont les suivants : <li> * </li>';
427
				$this->renvoyerErreur( RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $m);
432
				$this->renvoyerErreur( RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $m);
428
			}
433
			}
429
		} else {
434
		} else {
430
			$validite_ressource = false;
435
			$validite_ressource = false;
431
			$m = 'Erreur : Le paramètre "'.$radical_champ.'" ne peut pas présenter de suffixe. <br/><br/>';
436
			$m = 'Erreur : Le paramètre "'.$radical_champ.'" ne peut pas présenter de suffixe. <br/><br/>';
432
			$this->renvoyerErreur( RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $m);
437
			$this->renvoyerErreur( RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $m);
433
		}
438
		}
434
		return $validite_ressource;
439
		return $validite_ressource;
435
	}
440
	}
436
 
441
 
437
	public function verificationSuffixesCodes(&$suffixe, &$radical_champ, &$validite_ressource ) {
442
	public function verificationSuffixesCodes(&$suffixe, &$radical_champ, &$validite_ressource ) {
438
		if (!in_array($suffixe, array('*', 'code', 'href', 'details'))) {
443
		if (!in_array($suffixe, array('*', 'code', 'href', 'details'))) {
439
			$validite_ressource = false;
444
			$validite_ressource = false;
440
			$e = 'Erreur : Le suffixe demandé n\'existe pas pour le champ "'.$radical_champ.'.<br/> Les suffixes '
445
			$e = 'Erreur : Le suffixe demandé n\'existe pas pour le champ "'.$radical_champ.'.<br/> Les suffixes '
441
				.'possibles sont les suivants : <li> .* </li><li> .code </li><li> .href </li><li> .details </li>';
446
				.'possibles sont les suivants : <li> .* </li><li> .code </li><li> .href </li><li> .details </li>';
442
			$this->renvoyerErreur( RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
447
			$this->renvoyerErreur( RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
443
		}
448
		}
444
	}
449
	}
445
 
450
 
446
	public function verificationSuffixesIdentifiant(&$suffixe, &$radical_champ, &$validite_ressource) {
451
	public function verificationSuffixesIdentifiant(&$suffixe, &$radical_champ, &$validite_ressource) {
447
		if ((strrpos($radical_champ, 'parent') !== false && !in_array($suffixe, array('*', 'id', 'href', 'details', 'notes')))
452
		if ((strrpos($radical_champ, 'parent') !== false && !in_array($suffixe, array('*', 'id', 'href', 'details', 'notes')))
448
			|| !in_array($suffixe, array('*', 'id', 'href', 'details')) && strrpos($radical_champ, 'parent') === false) {
453
			|| !in_array($suffixe, array('*', 'id', 'href', 'details')) && strrpos($radical_champ, 'parent') === false) {
449
			$validite_ressource = false;
454
			$validite_ressource = false;
450
			$e = 'Erreur : Le suffixe demandé n\'existe pas pour le champ "'.$radical_champ.'".<br/> Les suffixes '
455
			$e = 'Erreur : Le suffixe demandé n\'existe pas pour le champ "'.$radical_champ.'".<br/> Les suffixes '
451
				.'possibles sont les suivants : <li> .* </li><li> .id </li><li> .href </li><li> .details </li>'
456
				.'possibles sont les suivants : <li> .* </li><li> .id </li><li> .href </li><li> .details </li>'
452
				.'<li> .notes (seulement pour les hybride.parent)';
457
				.'<li> .notes (seulement pour les hybride.parent)';
453
			$this->renvoyerErreur( RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
458
			$this->renvoyerErreur( RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
454
		}
459
		}
455
	}
460
	}
456
 
461
 
457
 
462
 
458
//------------------------------fonction de formatage pour les services /stats/-----------------------------------------
463
//------------------------------fonction de formatage pour les services /stats/-----------------------------------------
459
 
464
 
460
	public function formaterStatsAnnee($resultat) {
465
	public function formaterStatsAnnee($resultat) {
461
		foreach ($resultat as $cle_annee) {
466
		foreach ($resultat as $cle_annee) {
462
			$annee = ($cle_annee['annee'] != '') ? $cle_annee['annee'] : 'ND';
467
			$annee = ($cle_annee['annee'] != '') ? $cle_annee['annee'] : 'ND';
463
			$nb = $cle_annee['nombre'];
468
			$nb = $cle_annee['nombre'];
464
			$retour_stats_annee[$annee] = $nb;
469
			$retour_stats_annee[$annee] = $nb;
465
		}
470
		}
466
		return $retour_stats_annee;
471
		return $retour_stats_annee;
467
	}
472
	}
468
 
473
 
469
	public function formaterStatsRang($resultat) {
474
	public function formaterStatsRang($resultat) {
470
		foreach ($resultat as $rangs) {
475
		foreach ($resultat as $rangs) {
471
			if ($rangs['rang'] != 0) {
476
			if ($rangs['rang'] != 0) {
472
				$rang = $rangs['rang'];
477
				$rang = $rangs['rang'];
473
				if ($this->parametres['retour.format'] == 'max') {
478
				if ($this->parametres['retour.format'] == 'max') {
474
					$retour_rang[$rang]['rang'] = $this->ajouterSignificationCode('rang',$rang);
479
					$retour_rang[$rang]['rang'] = $this->ajouterSignificationCode('rang',$rang);
475
				}
480
				}
476
				$nombre = $rangs['nombre'];
481
				$nombre = $rangs['nombre'];
477
				$retour_rang[$rang]['nombre'] = $nombre;
482
				$retour_rang[$rang]['nombre'] = $nombre;
478
			}
483
			}
479
		}
484
		}
480
		return $retour_rang;
485
		return $retour_rang;
481
	}
486
	}
482
 
487
 
483
	public function formaterStatsInitiales($resultat) {
488
	public function formaterStatsInitiales($resultat) {
484
		$rang = null;
489
		$rang = null;
485
		$table_rang = array();
490
		$table_rang = array();
486
		foreach ($resultat as $tuple) {
491
		foreach ($resultat as $tuple) {
487
			if ($tuple['rang'] != 0) {
492
			if ($tuple['rang'] != 0) {
488
				$this->memoriserRang($table_rang, $tuple, $rang);
493
				$this->memoriserRang($table_rang, $tuple, $rang);
489
				if ($tuple['lettre'] == 'x ') {
494
				if ($tuple['lettre'] == 'x ') {
490
					$this->ajouterHybrideChimere('hybride', $rang, $tuple);
495
					$this->ajouterHybrideChimere('hybride', $rang, $tuple);
491
				} elseif ($tuple['lettre'] == '+ ') {
496
				} elseif ($tuple['lettre'] == '+ ') {
492
					$this->ajouterHybrideChimere('chimere', $rang, $tuple);
497
					$this->ajouterHybrideChimere('chimere', $rang, $tuple);
493
				} else {
498
				} else {
494
					$l = substr($tuple['lettre'], 0, 1);
499
					$l = substr($tuple['lettre'], 0, 1);
495
					if (isset($this->table_retour[$rang][$l])) {
500
					if (isset($this->table_retour[$rang][$l])) {
496
						$this->table_retour[$rang][substr($tuple['lettre'], 0, 1)] += floatval($tuple['nb']);
501
						$this->table_retour[$rang][substr($tuple['lettre'], 0, 1)] += floatval($tuple['nb']);
497
					} else {
502
					} else {
498
						$this->table_retour[$rang][substr($tuple['lettre'], 0, 1)] = floatval($tuple['nb']);
503
						$this->table_retour[$rang][substr($tuple['lettre'], 0, 1)] = floatval($tuple['nb']);
499
					}
504
					}
500
				}
505
				}
501
			}
506
			}
502
		}
507
		}
503
		return $this->table_retour;
508
		return $this->table_retour;
504
	}
509
	}
505
 
510
 
506
	public function memoriserRang(&$table_rang, $tuple, &$rang) {
511
	public function memoriserRang(&$table_rang, $tuple, &$rang) {
507
		if (is_array($table_rang)) {
512
		if (is_array($table_rang)) {
508
			if (!in_array($tuple['rang'], $table_rang)) {
513
			if (!in_array($tuple['rang'], $table_rang)) {
509
				$rang = $tuple['rang'];
514
				$rang = $tuple['rang'];
510
				$table_rang[] = $rang;
515
				$table_rang[] = $rang;
511
				if ($this->parametres['retour.format'] == 'max') {
516
				if ($this->parametres['retour.format'] == 'max') {
512
					$rang = $this->ajouterSignificationCode('rang', $rang);
517
					$rang = $this->ajouterSignificationCode('rang', $rang);
513
				}
518
				}
514
			}
519
			}
515
		}
520
		}
516
	}
521
	}
517
 
522
 
518
	public function ajouterHybrideChimere($groupe, &$rang, &$tuple) {
523
	public function ajouterHybrideChimere($groupe, &$rang, &$tuple) {
519
		if (isset($this->table_retour[$rang][str_replace('hybride', 'hyb', $groupe)])) {
524
		if (isset($this->table_retour[$rang][str_replace('hybride', 'hyb', $groupe)])) {
520
			$this->table_retour[$rang][$groupe] += floatval($tuple['nb']);
525
			$this->table_retour[$rang][$groupe] += floatval($tuple['nb']);
521
		} else {
526
		} else {
522
			$this->table_retour[$rang][$groupe] = floatval($tuple['nb']);
527
			$this->table_retour[$rang][$groupe] = floatval($tuple['nb']);
523
		}
528
		}
524
	}
529
	}
525
 
530
 
526
	//-----------------------------Fonctions d'affichage utiliser dans les fonctions de formatage---------------------------
531
	//-----------------------------Fonctions d'affichage utiliser dans les fonctions de formatage---------------------------
527
 
532
 
528
	public function afficherDonnees($champApi, $valeur) {
533
	public function afficherDonnees($champApi, $valeur) {
529
		$champBdd = $this->trouverChampBddCorrespondant($champApi);
534
		$champBdd = $this->trouverChampBddCorrespondant($champApi);
530
		if ($this->parametres['retour.format'] == 'min') {
535
		if ($this->parametres['retour.format'] == 'min') {
531
			if ($champApi == 'nom_sci') {
536
			if ($champApi == 'nom_sci') {
532
				$valeur = $valeur.$this->ajouterCompositionNom($this->resultat_req);
537
				$valeur = $valeur.$this->ajouterCompositionNom($this->resultat_req);
533
			}
538
			}
534
			if ($champApi == 'nom_sci_html') {
539
			if ($champApi == 'nom_sci_html') {
535
				$valeur = $valeur.$this->ajouterCompositionNom($this->resultat_req, 'htm');
540
				$valeur = $valeur.$this->ajouterCompositionNom($this->resultat_req, 'htm');
536
			}
541
			}
537
			$this->table_retour[$champBdd] = $valeur;
542
			$this->table_retour[$champBdd] = $valeur;
538
		} else {
543
		} else {
539
			$this->afficherToutesLesInfos($champBdd, $valeur);
544
			$this->afficherToutesLesInfos($champBdd, $valeur);
540
		}
545
		}
541
	}
546
	}
542
 
547
 
543
	public function trouverChampBddCorrespondant($champApi) {
548
	public function trouverChampBddCorrespondant($champApi) {
544
		if (array_key_exists($champApi, $this->champs_api)) {
549
		if (array_key_exists($champApi, $this->champs_api)) {
545
			$champBdd = $this->correspondance_champs[$champApi];
550
			$champBdd = $this->correspondance_champs[$champApi];
546
		} else {
551
		} else {
547
			$champBdd = $champApi;
552
			$champBdd = $champApi;
548
		}
553
		}
549
		return $champBdd;
554
		return $champBdd;
550
	}
555
	}
551
 
556
 
552
	public function afficherToutesLesInfos($nom_champ_api, $valeur) {
557
	public function afficherToutesLesInfos($nom_champ_api, $valeur) {
553
		if ($this->presentePlusieursId($nom_champ_api, $valeur)) {
558
		if ($this->presentePlusieursId($nom_champ_api, $valeur)) {
554
			preg_match('/^([^.]+\.parent_0[12]|[^.]+)(?:\.id)?$/', $nom_champ_api, $match);
559
			preg_match('/^([^.]+\.parent_0[12]|[^.]+)(?:\.id)?$/', $nom_champ_api, $match);
555
			$this->afficherInfosPrecises($match[1], 'details', $valeur);
560
			$this->afficherInfosPrecises($match[1], 'details', $valeur);
556
			$this->table_retour[$nom_champ_api] = $valeur;
561
			$this->table_retour[$nom_champ_api] = $valeur;
557
 
562
 
558
		} elseif (strrpos($nom_champ_api, 'parent') !== false && strrpos($nom_champ_api, 'notes') !== false) {
563
		} elseif (strrpos($nom_champ_api, 'parent') !== false && strrpos($nom_champ_api, 'notes') !== false) {
559
			$this->table_retour[$nom_champ_api] = $valeur;
564
			$this->table_retour[$nom_champ_api] = $valeur;
560
 
565
 
561
		} elseif (($this->correspondAUnId($nom_champ_api) || $nom_champ_api == 'id' && $valeur != '0')) {
566
		} elseif (($this->correspondAUnId($nom_champ_api) || $nom_champ_api == 'id' && $valeur != '0')) {
562
			preg_match('/^([^.]+\.parent_0[12]|[^.]+)(?:\.id)?$/', $nom_champ_api, $match);
567
			preg_match('/^([^.]+\.parent_0[12]|[^.]+)(?:\.id)?$/', $nom_champ_api, $match);
563
			$this->afficherInfosPrecises($match[1], 'id,signification,href', $valeur);
568
			$this->afficherInfosPrecises($match[1], 'id,signification,href', $valeur);
564
 
569
 
565
		} elseif ($this->correspondAUnCode($nom_champ_api)) {
570
		} elseif ($this->correspondAUnCode($nom_champ_api)) {
566
			preg_match('/^([^.]+)(?:\.code)?$/', $nom_champ_api, $match);
571
			preg_match('/^([^.]+)(?:\.code)?$/', $nom_champ_api, $match);
567
			$this->afficherInfosPrecises($match[1], 'code,signification,href', $valeur);
572
			$this->afficherInfosPrecises($match[1], 'code,signification,href', $valeur);
568
 
573
 
569
		} elseif ($nom_champ_api == 'nom_sci_html') {
574
		} elseif ($nom_champ_api == 'nom_sci_html') {
570
			$this->table_retour['nom_sci_html'] = $valeur;
575
			$this->table_retour['nom_sci_html'] = $valeur;
571
			$this->table_retour['nom_sci_html_complet'] = $valeur.$this->ajouterCompositionNom($this->resultat_req, 'htm');
576
			$this->table_retour['nom_sci_html_complet'] = $valeur.$this->ajouterCompositionNom($this->resultat_req, 'htm');
572
		}elseif ($nom_champ_api != 'nom_sci') {
577
		}elseif ($nom_champ_api != 'nom_sci') {
573
			$this->table_retour[$nom_champ_api] = $valeur;
578
			$this->table_retour[$nom_champ_api] = $valeur;
574
		}
579
		}
575
	}
580
	}
576
 
581
 
577
	public function presentePlusieursId($ressource, $valeur = null) {
582
	public function presentePlusieursId($ressource, $valeur = null) {
578
		if ($valeur) {
583
		if ($valeur) {
579
			$presente = strrpos($ressource, 'proparte') !== false && strrpos($valeur, ',') !== false;
584
			$presente = strrpos($ressource, 'proparte') !== false && strrpos($valeur, ',') !== false;
580
		} else { //pour la vérification du champ, on ignore alors la valeur de la ressource
585
		} else { //pour la vérification du champ, on ignore alors la valeur de la ressource
581
			$presente = strrpos($ressource, 'proparte') !== false;
586
			$presente = strrpos($ressource, 'proparte') !== false;
582
		}
587
		}
583
		return $presente;
588
		return $presente;
584
	}
589
	}
585
 
590
 
586
	public function afficherInfosPrecises($champ, $suffixe, $valeur) {
591
	public function afficherInfosPrecises($champ, $suffixe, $valeur) {
587
		$suffixes = explode(',', $suffixe);
592
		$suffixes = explode(',', $suffixe);
588
		//on initialise au service appelé. Sera potentiellement modifié dans la fonction afficherSignification()
593
		//on initialise au service appelé. Sera potentiellement modifié dans la fonction afficherSignification()
589
		$this->service_href = $this->service;
594
		$this->service_href = $this->service;
590
		foreach ($suffixes  as $suffixe) {
595
		foreach ($suffixes  as $suffixe) {
591
			switch ($suffixe) {
596
			switch ($suffixe) {
592
				case 'id' 			 :
597
				case 'id' 			 :
593
					$this->table_retour[str_replace('id.id', 'id', $champ.'.id')] = $valeur;
598
					$this->table_retour[str_replace('id.id', 'id', $champ.'.id')] = $valeur;
594
					break;
599
					break;
595
				case 'details' 		 :
600
				case 'details' 		 :
596
					$this->afficherTableDetails($champ, $valeur);
601
					$this->afficherTableDetails($champ, $valeur);
597
					break;
602
					break;
598
				case 'signification' :
603
				case 'signification' :
599
					$this->afficherSignification($champ, $valeur);
604
					$this->afficherSignification($champ, $valeur);
600
					break;
605
					break;
601
				case 'href' 		 :
606
				case 'href' 		 :
602
					$url = $this->creerUrl($champ, $valeur);
607
					$url = $this->creerUrl($champ, $valeur);
603
					$this->table_retour[str_replace('id.href', 'href', $champ.'.href')] = $url;
608
					$this->table_retour[str_replace('id.href', 'href', $champ.'.href')] = $url;
604
					break;
609
					break;
605
				case 'code' 		 :
610
				case 'code' 		 :
606
					$this->table_retour[$champ.'.code'] = $this->obtenirCode($champ, $valeur);
611
					$this->table_retour[$champ.'.code'] = $this->obtenirCode($champ, $valeur);
607
					break;
612
					break;
608
				case 'notes' 		 :
613
				case 'notes' 		 :
609
					$this->table_retour[$champ.'.notes'] = $this->resultat_req[str_replace('.', '_', $champ).'_notes'];
614
					$this->table_retour[$champ.'.notes'] = $this->resultat_req[str_replace('.', '_', $champ).'_notes'];
610
					break;
615
					break;
611
				default : break;
616
				default : break;
612
			}
617
			}
613
		}
618
		}
614
	}
619
	}
615
 
620
 
616
	public function afficherTableDetails($nom_champ_api, $valeur) {
621
	public function afficherTableDetails($nom_champ_api, $valeur) {
617
		$tab_id = explode(',', $valeur);
622
		$tab_id = explode(',', $valeur);
618
		$tab_res = $this->table_retour;
623
		$tab_res = $this->table_retour;
619
		$this->table_retour = array();
624
		$this->table_retour = array();
620
		foreach ($tab_id as $id) {
625
		foreach ($tab_id as $id) {
621
			$this->afficherInfosPrecises($nom_champ_api, 'id,signification,href', $id);
626
			$this->afficherInfosPrecises($nom_champ_api, 'id,signification,href', $id);
622
			$tab_res[$nom_champ_api.'.details'][] = $this->table_retour;
627
			$tab_res[$nom_champ_api.'.details'][] = $this->table_retour;
623
			$this->table_retour = array();
628
			$this->table_retour = array();
624
		}
629
		}
625
		$this->table_retour = $tab_res;
630
		$this->table_retour = $tab_res;
626
	}
631
	}
627
 
632
 
628
	private function obtenirCode($champ, $valeur) {
633
	private function obtenirCode($champ, $valeur) {
629
		$code = $this->transformerChampEnCode($champ);
634
		$code = $this->transformerChampEnCode($champ);
630
		return "bdnt.$code:$valeur";
635
		return "bdnt.$code:$valeur";
631
	}
636
	}
632
 
637
 
633
	private function transformerChampEnCode($champ) {
638
	private function transformerChampEnCode($champ) {
634
		if (is_null($this->relationsChampsCodesOntologie)) {
639
		if (is_null($this->relationsChampsCodesOntologie)) {
635
			$this->relationsChampsCodesOntologie = Outils::recupererTableauConfig('ChampsCodesOntologie');
640
			$this->relationsChampsCodesOntologie = Outils::recupererTableauConfig('ChampsCodesOntologie');
636
		}
641
		}
637
 
642
 
638
		$code = $champ;
643
		$code = $champ;
639
		if (array_key_exists($champ, $this->relationsChampsCodesOntologie)) {
644
		if (array_key_exists($champ, $this->relationsChampsCodesOntologie)) {
640
			$code = $this->relationsChampsCodesOntologie[$champ];
645
			$code = $this->relationsChampsCodesOntologie[$champ];
641
		}
646
		}
642
		return $code;
647
		return $code;
643
	}
648
	}
644
 
649
 
645
	public function creerUrl($champ, $valeur) {
650
	public function creerUrl($champ, $valeur) {
646
		if ($this->correspondAUnId($champ) || $champ == 'id') {
651
		if ($this->correspondAUnId($champ) || $champ == 'id') {
647
			$service = $this->service_href;
652
			$service = $this->service_href;
648
			$url = $this->ajouterHref($service, $valeur);
653
			$url = $this->ajouterHref($service, $valeur);
649
		} else {
654
		} else {
650
			$code = $this->transformerChampEnCode($champ);
655
			$code = $this->transformerChampEnCode($champ);
651
			$url = $this->ajouterHrefAutreProjet('ontologies', "$code:", $valeur, 'bdnt');
656
			$url = $this->ajouterHrefAutreProjet('ontologies', "$code:", $valeur, 'bdnt');
652
		}
657
		}
653
		return $url;
658
		return $url;
654
	}
659
	}
655
 
660
 
656
	public function afficherSignification($champ, $valeur) {
661
	public function afficherSignification($champ, $valeur) {
657
		if ($champ == 'id' && isset($this->resultat_req['nom_sci']) && $this->resultat_req['num_nom'] == $valeur) {
662
		if ($champ == 'id' && isset($this->resultat_req['nom_sci']) && $this->resultat_req['num_nom'] == $valeur) {
658
			//si le nom_sci du num_nom que l'on veut afficher est déjà dans la table de résultat :
663
			//si le nom_sci du num_nom que l'on veut afficher est déjà dans la table de résultat :
659
			$this->table_retour['nom_sci'] = $this->resultat_req['nom_sci'];
664
			$this->table_retour['nom_sci'] = $this->resultat_req['nom_sci'];
660
			$this->table_retour['nom_sci_complet'] = $this->resultat_req['nom_sci'].
665
			$this->table_retour['nom_sci_complet'] = $this->resultat_req['nom_sci'].
661
				$this->ajouterCompositionNom($this->resultat_req);
666
				$this->ajouterCompositionNom($this->resultat_req);
662
		} elseif ($this->correspondAUnId($champ) || $champ == 'id') {
667
		} elseif ($this->correspondAUnId($champ) || $champ == 'id') {
663
			$nom = $this->recupererNomSci($valeur);
668
			$nom = $this->recupererNomSci($valeur);
664
			if ($nom != array()) {
669
			if ($nom != array()) {
665
				$this->table_retour[$champ.'.libelle'] = $nom['nom_sci'];
670
				$this->table_retour[$champ.'.libelle'] = $nom['nom_sci'];
666
				$this->table_retour[$champ.'_html'] = $nom['nom_sci_html'];
671
				$this->table_retour[$champ.'_html'] = $nom['nom_sci_html'];
667
				$this->table_retour[$champ.'_complet'] = $nom['nom_sci_complet'];
672
				$this->table_retour[$champ.'_complet'] = $nom['nom_sci_complet'];
668
				$this->table_retour[$champ.'_html_complet'] = $nom['nom_sci_complet_html'];
673
				$this->table_retour[$champ.'_html_complet'] = $nom['nom_sci_complet_html'];
669
				$this->service_href = $nom['service'];
674
				$this->service_href = $nom['service'];
670
			}
675
			}
671
		} elseif ($this->correspondAUnCode($champ)) {
676
		} elseif ($this->correspondAUnCode($champ)) {
672
			$this->table_retour[$champ.'.libelle'] = $this->ajouterSignificationCode($champ, $valeur);
677
			$this->table_retour[$champ.'.libelle'] = $this->ajouterSignificationCode($champ, $valeur);
673
		}
678
		}
674
	}
679
	}
675
 
680
 
676
	/** Permet d'afficher les élements nomenclatural du nom_sci lors de l'appel dans le service noms/id/champ du champ^nom_sci.*/
681
	/** Permet d'afficher les élements nomenclatural du nom_sci lors de l'appel dans le service noms/id/champ du champ^nom_sci.*/
677
	public function afficherNomSciPointEpithete($resultat) {
682
	public function afficherNomSciPointEpithete($resultat) {
678
		$tab_nom_sci   = array('nom_supra_generique', 'genre', 'epithete_infra_generique', 'epithete_sp',
683
		$tab_nom_sci   = array('nom_supra_generique', 'genre', 'epithete_infra_generique', 'epithete_sp',
679
		'type_epithete', 'epithete_infra_sp', 'cultivar_groupe', 'cultivar', 'nom_commercial');
684
		'type_epithete', 'epithete_infra_sp', 'cultivar_groupe', 'cultivar', 'nom_commercial');
680
		foreach ($tab_nom_sci as $compo_nom) {
685
		foreach ($tab_nom_sci as $compo_nom) {
681
			if (isset($resultat[$compo_nom]) && !empty($resultat[$compo_nom])) {
686
			if (isset($resultat[$compo_nom]) && !empty($resultat[$compo_nom])) {
682
				$this->table_retour['nom_sci.'.$compo_nom] = $resultat[$compo_nom];
687
				$this->table_retour['nom_sci.'.$compo_nom] = $resultat[$compo_nom];
683
			}
688
			}
684
		}
689
		}
685
	}
690
	}
686
 
691
 
687
	public function ajouterSignificationCode($champ, $valeur) {
692
	public function ajouterSignificationCode($champ, $valeur) {
688
		$champ = ($champ == 'rang') ? 'rangTaxo' : rtrim($champ, '_Co,_Ga');
693
		$champ = ($champ == 'rang') ? 'rangTaxo' : rtrim($champ, '_Co,_Ga');
689
		if (preg_match('/^([^_-]+)(?:_|-)([^_-]+)$/', $champ, $match)) {
694
		if (preg_match('/^([^_-]+)(?:_|-)([^_-]+)$/', $champ, $match)) {
690
			$champ = $match[1].ucfirst($match[2]);
695
			$champ = $match[1].ucfirst($match[2]);
691
		}
696
		}
692
		$url = Config::get('url_ontologie').$champ.':'.$valeur.'/nom';
697
		$url = Config::get('url_ontologie').$champ.':'.$valeur.'/nom';
693
		$res = $this->consulterHref($url); //dans commun.php
698
		$res = $this->consulterHref($url); //dans commun.php
694
		$nom_code = $valeur;
699
		$nom_code = $valeur;
695
		if (is_object($res)) {
700
		if (is_object($res)) {
696
			$nom_code = $res->nom;
701
			$nom_code = $res->nom;
697
		}
702
		}
698
		return $nom_code;
703
		return $nom_code;
699
	}
704
	}
700
 
705
 
701
	public function recupererNomSci($id) {
706
	public function recupererNomSci($id) {
702
		$nom = array();
707
		$nom = array();
703
		if ($id != 0) {
708
		if ($id != 0) {
704
			if ($this->compo_nom == null) {
709
			if ($this->compo_nom == null) {
705
				$req = 'SELECT nom_sci, num_nom_retenu, nom_sci_html FROM '.$this->table.' WHERE num_nom = '.$id;
710
				$req = 'SELECT nom_sci, num_nom_retenu, nom_sci_html FROM '.$this->table.' WHERE num_nom = '.$id;
706
			} else { //on ajoute à la requete sql, les champs de ns.structure
711
			} else { //on ajoute à la requete sql, les champs de ns.structure
707
				//print_r($this->compo_nom);
712
				//print_r($this->compo_nom);
708
				$req = 'SELECT nom_sci, num_nom_retenu, nom_sci_html, '.implode(', ', $this->compo_nom)
713
				$req = 'SELECT nom_sci, num_nom_retenu, nom_sci_html, '.implode(', ', $this->compo_nom)
709
						.' FROM '.$this->table
714
						.' FROM '.$this->table
710
						.' WHERE num_nom = '.$id;
715
						.' WHERE num_nom = '.$id;
711
			}
716
			}
712
			if ($this->parametres['ns.format'] == 'htm') {
717
			if ($this->parametres['ns.format'] == 'htm') {
713
				$req = str_replace('nom_sci', 'nom_sci_html as nom_sci', $req);
718
				$req = str_replace('nom_sci', 'nom_sci_html as nom_sci', $req);
714
			}
719
			}
715
			$res = $this->getBdd()->recuperer($req);
720
			$res = $this->getBdd()->recuperer($req);
716
			if ($res) {
721
			if ($res) {
717
				$nom['nom_sci']	= $res['nom_sci'];
722
				$nom['nom_sci']	= $res['nom_sci'];
718
				$nom['nom_sci_html']	= $res['nom_sci_html'];
723
				$nom['nom_sci_html']	= $res['nom_sci_html'];
719
				$nom['nom_sci_complet']	= $res['nom_sci'].$this->ajouterCompositionNom($res);
724
				$nom['nom_sci_complet']	= $res['nom_sci'].$this->ajouterCompositionNom($res);
720
				$nom['nom_sci_complet_html']	= $res['nom_sci_html'].$this->ajouterCompositionNom($res, 'htm');
725
				$nom['nom_sci_complet_html']	= $res['nom_sci_html'].$this->ajouterCompositionNom($res, 'htm');
721
				$nom['service'] = ($res['num_nom_retenu'] == $id && $this->service == 'taxons') ? 'taxons' : 'noms';
726
				$nom['service'] = ($res['num_nom_retenu'] == $id && $this->service == 'taxons') ? 'taxons' : 'noms';
722
			}
727
			}
723
		}
728
		}
724
		return $nom;
729
		return $nom;
725
	}
730
	}
726
 
731
 
727
	/** Permet de retourner une chaine de caractère composée des parametres du nom (ns.structure : annnée, auteur,
732
	/** Permet de retourner une chaine de caractère composée des parametres du nom (ns.structure : annnée, auteur,
728
	 * bibilio et addendum). A ajouter au nom scientifique */
733
	 * bibilio et addendum). A ajouter au nom scientifique */
729
	public function ajouterCompositionNom($tab_res, $format = '') {
734
	public function ajouterCompositionNom($tab_res, $format = '') {
730
		$format = ($format == '') ? $this->parametres['ns.format'] : $format;
735
		$format = ($format == '') ? $this->parametres['ns.format'] : $format;
731
		$nom = '';
736
		$nom = '';
732
		if (isset($this->compo_nom)) {
737
		if (isset($this->compo_nom)) {
733
			if ($format == 'htm') {
738
			if ($format == 'htm') {
734
				$format = array(
739
				$format = array(
735
					'au' => '<span class="auteur">%s</span>',
740
					'au' => '<span class="auteur">%s</span>',
736
					'an' => '[<span class="annee">%s</span>]',
741
					'an' => '[<span class="annee">%s</span>]',
737
					'an_bib' => '[<span class="annee">%s</span>, <span class="biblio">%s</span>]',
742
					'an_bib' => '[<span class="annee">%s</span>, <span class="biblio">%s</span>]',
738
					'bib' => '[<span class="biblio">%s</span>]',
743
					'bib' => '[<span class="biblio">%s</span>]',
739
					'ad' => '[<span class="adendum">%s</span>]');
744
					'ad' => '[<span class="adendum">%s</span>]');
740
			} else {
745
			} else {
741
				$format = array(
746
				$format = array(
742
					'au' => '%s',
747
					'au' => '%s',
743
					'an' => '[%s]',
748
					'an' => '[%s]',
744
					'an_bib' => '[%s, %s]',
749
					'an_bib' => '[%s, %s]',
745
					'bib' => '[%s]',
750
					'bib' => '[%s]',
746
					'ad' => '[%s]');
751
					'ad' => '[%s]');
747
			}
752
			}
748
			$compo_nom = array();
753
			$compo_nom = array();
749
			foreach ($this->compo_nom as $key => $champ) {
754
			foreach ($this->compo_nom as $key => $champ) {
750
				if (isset($tab_res[$champ]) && !empty($tab_res[$champ])) {
755
				if (isset($tab_res[$champ]) && !empty($tab_res[$champ])) {
751
					$compo_nom[$key] = $tab_res[$champ];
756
					$compo_nom[$key] = $tab_res[$champ];
752
				}
757
				}
753
			}
758
			}
754
			$nom_complet = $this->formerNomComplet($compo_nom, $format);
759
			$nom_complet = $this->formerNomComplet($compo_nom, $format);
755
			$nom = ' '.implode(' ', $nom_complet);
760
			$nom = ' '.implode(' ', $nom_complet);
756
		}
761
		}
757
		return rtrim($nom, ' ');
762
		return rtrim($nom, ' ');
758
	}
763
	}
759
 
764
 
760
 
765
 
761
	public function formerNomComplet($compo_nom, $format) {
766
	public function formerNomComplet($compo_nom, $format) {
762
		$nom_complet = array();
767
		$nom_complet = array();
763
		extract($compo_nom);
768
		extract($compo_nom);
764
		if (isset($au)) $nom_complet[] = sprintf($format['au'], $au);
769
		if (isset($au)) $nom_complet[] = sprintf($format['au'], $au);
765
		if (isset($an)) {
770
		if (isset($an)) {
766
			if (isset($bib)) {
771
			if (isset($bib)) {
767
				$nom_complet[] = sprintf($format['an_bib'], $an, $bib);
772
				$nom_complet[] = sprintf($format['an_bib'], $an, $bib);
768
			} else {
773
			} else {
769
				$nom_complet[] = sprintf($format['an'], $an);
774
				$nom_complet[] = sprintf($format['an'], $an);
770
			}
775
			}
771
		} elseif (isset($bib)) {
776
		} elseif (isset($bib)) {
772
			$nom_complet[] = sprintf($format['bib'], $bib);
777
			$nom_complet[] = sprintf($format['bib'], $bib);
773
		}
778
		}
774
		if (isset($ad)) $nom_complet[] = sprintf($format['ad'], $ad);
779
		if (isset($ad)) $nom_complet[] = sprintf($format['ad'], $ad);
775
		return $nom_complet;
780
		return $nom_complet;
776
	}
781
	}
777
 
782
 
778
 
783
 
779
	public function correspondAUnCode($key) {
784
	public function correspondAUnCode($key) {
780
		return (strrpos($key, '.code') !== false) || (in_array($key.'.code', $this->correspondance_champs));
785
		return (strrpos($key, '.code') !== false) || (in_array($key.'.code', $this->correspondance_champs));
781
	}
786
	}
782
 
787
 
783
	public function correspondAUnId($key) {
788
	public function correspondAUnId($key) {
784
		return (strrpos($key, '.id') !== false) || (in_array($key.'.id', $this->correspondance_champs));
789
		return (strrpos($key, '.id') !== false) || (in_array($key.'.id', $this->correspondance_champs));
785
	}
790
	}
786
 
791
 
787
	public function estUnPoint($key) {
792
	public function estUnPoint($key) {
788
		if (strrpos($key, 'hybride.parent') !== false) {
793
		if (strrpos($key, 'hybride.parent') !== false) {
789
			$key = str_replace('hybride.parent', 'hybride_parent', $key);
794
			$key = str_replace('hybride.parent', 'hybride_parent', $key);
790
		}
795
		}
791
		return (strrpos($key, '.') !== false);
796
		return (strrpos($key, '.') !== false);
792
	}
797
	}
793
 
798
 
794
	public function recupererMasquePrincipal() {
799
	public function recupererMasquePrincipal() {
795
		$masque = null;
800
		$masque = null;
796
		$tab_masque   = array(
801
		$tab_masque   = array(
797
			'masque' => 'nom_sci',
802
			'masque' => 'nom_sci',
798
			'masque_sg' => 'nom_supra_generique',
803
			'masque_sg' => 'nom_supra_generique',
799
			'masque_gen' => 'genre',
804
			'masque_gen' => 'genre',
800
			'masque_sp' => 'epithete_sp',
805
			'masque_sp' => 'epithete_sp',
801
			'masque_ssp' => 'epithete_infra_sp',
806
			'masque_ssp' => 'epithete_infra_sp',
802
			'masque_au' => 'auteur',
807
			'masque_au' => 'auteur',
803
			'masque_an' => 'annee',
808
			'masque_an' => 'annee',
804
			'masque_bib' => 'biblio_origine',
809
			'masque_bib' => 'biblio_origine',
805
			'masque_ad' => 'addendum',
810
			'masque_ad' => 'addendum',
806
			'masque_rg' => 'rang');
811
			'masque_rg' => 'rang');
807
		$liste_masque = array();
812
		$liste_masque = array();
808
 
813
 
809
		if (isset($this->masque['num_nom'])) {
814
		if (isset($this->masque['num_nom'])) {
810
			$liste_masque[] = $this->masque['num_nom'];
815
			$liste_masque[] = $this->masque['num_nom'];
811
		}
816
		}
812
 
817
 
813
		foreach ($tab_masque as $key => $filtre) {
818
		foreach ($tab_masque as $key => $filtre) {
814
            if (isset($this->masque[$filtre])) {
819
            if (isset($this->masque[$filtre])) {
815
            	if (!isset($masque) && !in_array($filtre, array('rang', 'annee'))) {
820
            	if (!isset($masque) && !in_array($filtre, array('rang', 'annee'))) {
816
            		$masque = array($key, $filtre);
821
            		$masque = array($key, $filtre);
817
            	}
822
            	}
818
                $liste_masque[] = $this->masque[$filtre];
823
                $liste_masque[] = $this->masque[$filtre];
819
            }
824
            }
820
        }
825
        }
821
        $this->masque = $liste_masque;
826
        $this->masque = $liste_masque;
822
        return $masque;
827
        return $masque;
823
	}
828
	}
824
}
829
}
825
?>
830
?>