Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1387 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1387 Rev 1391
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Classe mère du module Liste.
4
 * Classe mère du module Liste.
5
 *
5
 *
6
 * @category	PHP 5.2
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @copyright	2011 Tela-Botanica
10
 * @copyright	2011 Tela-Botanica
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @version		$Id$
13
 * @version		$Id$
14
 */
14
 */
15
class Nomenclature extends aControleur {
15
class Nomenclature extends aControleur {
16
 
16
 
17
	private $conteneur = null;
17
	private $conteneur = null;
18
	private $nomCourant = null;
18
	private $nomCourant = null;
19
	private $noms = null;
19
	private $noms = null;
20
	private $meta = null;
20
	private $meta = null;
21
	private $referentiel = 'bdtfx';
21
	private $referentiel = 'bdtfx';
22
	private $donnees = array();
22
	private $donnees = array();
23
 
23
 
24
	public function __construct(Conteneur $conteneur) {
24
	public function __construct(Conteneur $conteneur) {
25
		$this->conteneur = $conteneur;
25
		$this->conteneur = $conteneur;
26
		$this->nomCourant = $this->conteneur->getNomCourant();
26
		$this->nomCourant = $this->conteneur->getNomCourant();
27
		$this->referentiel = $this->conteneur->getParametre('referentiel');
27
		$this->referentiel = $this->conteneur->getParametre('referentiel');
28
		$this->taxons = $this->conteneur->getApiTaxons();
28
		$this->taxons = $this->conteneur->getApiTaxons();
29
		$this->noms = $this->conteneur->getApiNoms();
29
		$this->noms = $this->conteneur->getApiNoms();
30
		$this->meta = $this->conteneur->getApiMetaDonnees();
30
		$this->meta = $this->conteneur->getApiMetaDonnees();
31
		$this->appUrls = $this->conteneur->getAppUrls();
31
		$this->appUrls = $this->conteneur->getAppUrls();
32
		$this->wikini = $this->conteneur->getApiWikini();
32
		$this->wikini = $this->conteneur->getApiWikini();
33
		//print_r($_GET['niveau']);
33
		//print_r($_GET['niveau']);
34
		//Registre::set('parametres.niveau', 2);
34
		//Registre::set('parametres.niveau', 2);
35
	}
35
	}
36
 
36
 
37
	public function obtenirDonnees() {
37
	public function obtenirDonnees() {
38
		$this->donnees['baseUrlIco'] = $this->appUrls->obtenirUrlBaseDossier();
38
		$this->donnees['baseUrlIco'] = $this->appUrls->obtenirUrlBaseDossier();
39
		$this->donnees['referentiel'] = $this->referentiel;
39
		$this->donnees['referentiel'] = $this->referentiel;
40
		$this->getFlores();
40
		$this->getFlores();
41
		$this->donnees['synonymes']['noms'] = $this->trierSynonymesParBasionyme($this->getSynonymes());
41
		$this->donnees['synonymes']['noms'] = $this->trierSynonymesParBasionyme($this->getSynonymes());
42
		$this->donnees['date_maj'] = $this->nomCourant->getNomRetenu()->get('maj_modif');
42
		$this->donnees['date_maj'] = $this->nomCourant->getNomRetenu()->get('maj_modif');
43
		$meta = $this->meta->getMetaDonnees();
43
		$meta = $this->meta->getMetaDonnees();
44
		$this->donnees['synonymes']['meta'] = $meta[0];
44
		$this->donnees['synonymes']['meta'] = $meta[0];
45
		$this->donnees['synonymes']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($this->referentiel);
45
		$this->donnees['synonymes']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($this->referentiel);
46
		$this->donnees['num_type'] = $this->nomCourant->getNomSelectionne()->get('num_type');
46
		$this->donnees['num_type'] = $this->nomCourant->getNomSelectionne()->get('num_type');
47
		$this->donnees['urls'] = $this->appUrls;
47
		$this->donnees['urls'] = $this->appUrls;
48
		$this->donnees['nom_retenu_formate'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html_complet');
48
		$this->donnees['nom_retenu_formate'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html_complet');
49
		$this->donnees['nom_retenu_nn'] = $this->nomCourant->getNomRetenu()->get('nom_retenu.id');
49
		$this->donnees['nom_retenu_nn'] = $this->nomCourant->getNomRetenu()->get('nom_retenu.id');
-
 
50
		$this->donnees['nom_retenu_source'] = $this->nomCourant->getNomRetenu()->get('source_biblio');
50
		$this->donnees['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet');
51
		$this->donnees['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet');
51
		$this->donnees['basionyme_nom_retenu_nn'] = $this->nomCourant->getNomRetenu()->get('basionyme.id');
52
		$this->donnees['basionyme_nom_retenu_nn'] = $this->nomCourant->getNomRetenu()->get('basionyme.id');
52
		$this->donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html_complet');
53
		$this->donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html_complet');
53
		$this->donnees['nom_retenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci');
54
		$this->donnees['nom_retenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci');
54
		$this->donnees['wikini'] = $this->getWikini(); 
55
		$this->donnees['wikini'] = $this->getWikini(); 
55
		$this->donnees['hybride_parent_01'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_01_html_complet');
56
		$this->donnees['hybride_parent_01'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_01_html_complet');
56
		$this->donnees['hybride_parent_02'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_02_html_complet');
57
		$this->donnees['hybride_parent_02'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_02_html_complet');
57
		$this->donnees['hybride_parent_01_nn'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_01.id');
58
		$this->donnees['hybride_parent_01_nn'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_01.id');
58
		$this->donnees['hybride_parent_02_nn'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_02.id');
59
		$this->donnees['hybride_parent_02_nn'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_02.id');
-
 
60
		
59
			
61
			
60
		
62
		
61
		$this->donnees['taxons_sup'] = $this->nomCourant->taxons_sup;
63
		$this->donnees['taxons_sup'] = $this->nomCourant->taxons_sup;
62
		$this->donnees['taxon_courant']['rang.libelle'] = $this->nomCourant->getNomRetenu()->get('rang.libelle');
64
		$this->donnees['taxon_courant']['rang.libelle'] = $this->nomCourant->getNomRetenu()->get('rang.libelle');
63
		$this->donnees['taxon_courant']['nom_sci'] = $this->nomCourant->getNomRetenu()->get('nom_sci');
65
		$this->donnees['taxon_courant']['nom_sci'] = $this->nomCourant->getNomRetenu()->get('nom_sci');
64
		$this->donnees['taxon_courant']['num_nom'] = $this->nomCourant->getNomRetenu()->get('id');
66
		$this->donnees['taxon_courant']['num_nom'] = $this->nomCourant->getNomRetenu()->get('id');
65
		$this->donnees['taxons_inf'] = $this->getTaxonsInferieurs();
67
		$this->donnees['taxons_inf'] = $this->getTaxonsInferieurs();
66
		
68
		
67
		return $this->donnees;
69
		return $this->donnees;
68
	}
70
	}
69
	
71
	
70
	private function trierSynonymesParBasionyme($synonymes) {
72
	private function trierSynonymesParBasionyme($synonymes) {
71
		$synonymes_t = array();
73
		$synonymes_t = array();
72
		$basionyme_inconnu = array();
74
		$basionyme_inconnu = array();
73
		foreach($synonymes as $num_nom => $syn) {
75
		foreach($synonymes as $num_nom => $syn) {
74
			if($syn['num_type'] != "")  {
76
			if($syn['num_type'] != "")  {
75
				$index = $syn['num_type'];
77
				$index = $syn['num_type'];
76
				// regroupement sous le 1er basionyme (num_type == num_nom)
78
				// regroupement sous le 1er basionyme (num_type == num_nom)
77
				if(!isset($synonymes_t[$index]['infos_basionyme'])) {
79
				if(!isset($synonymes_t[$index]['infos_basionyme'])) {
78
					$synonymes_t[$index]['infos_basionyme'] = $this->extraireInfosBasionymeDuSynonyme($syn);
80
					$synonymes_t[$index]['infos_basionyme'] = $this->extraireInfosBasionymeDuSynonyme($syn);
79
				}
81
				}
80
				$synonymes_t[$index]['synonymes'][$num_nom] = $syn;
82
				$synonymes_t[$index]['synonymes'][$num_nom] = $syn;
81
			} else {
83
			} else {
82
				$basionyme_inconnu['synonymes'][$num_nom] = $syn;
84
				$basionyme_inconnu['synonymes'][$num_nom] = $syn;
83
			}	
85
			}	
84
		}
86
		}
85
		// mise à la fin du tableau des noms sans basionymes
87
		// mise à la fin du tableau des noms sans basionymes
86
		if(!empty($basionyme_inconnu)) {
88
		if(!empty($basionyme_inconnu)) {
87
			$synonymes_t['basionyme_inconnu'] = $basionyme_inconnu;
89
			$synonymes_t['basionyme_inconnu'] = $basionyme_inconnu;
88
		}
90
		}
89
 
91
 
90
		return $synonymes_t;
92
		return $synonymes_t;
91
	}
93
	}
92
	
94
	
93
	private function extraireInfosBasionymeDuSynonyme($synonyme) {
95
	private function extraireInfosBasionymeDuSynonyme($synonyme) {
94
		return array(
96
		return array(
95
			'basionyme.id' => $synonyme['basionyme.id'],
97
			'basionyme.id' => $synonyme['basionyme.id'],
96
			'basionyme.libelle' => $synonyme['basionyme.libelle'],
98
			'basionyme.libelle' => $synonyme['basionyme.libelle'],
97
			'basionyme_html' => $synonyme['basionyme_html'],
99
			'basionyme_html' => $synonyme['basionyme_html'],
98
			'basionyme_complet' => $synonyme['basionyme_complet'],
100
			'basionyme_complet' => $synonyme['basionyme_complet'],
99
			'basionyme_html_complet' => $synonyme['basionyme_html_complet'],
101
			'basionyme_html_complet' => $synonyme['basionyme_html_complet'],
100
			'basionyme.href' => $synonyme['basionyme.href']
102
			'basionyme.href' => $synonyme['basionyme.href']
101
		);
103
		);
102
	}
104
	}
103
	
105
	
104
	private function getTaxonsInferieurs() {
106
	private function getTaxonsInferieurs() {
105
		$num_nom = $this->nomCourant->getNomRetenu()->get('id');
107
		$num_nom = $this->nomCourant->getNomRetenu()->get('id');
106
		$resultat = $this->taxons->getTaxonsInf($num_nom);
108
		$resultat = $this->taxons->getTaxonsInf($num_nom);
107
		// TODO: le webservice retourne le taxon demandé comme l'un des taxon inférieurs
109
		// TODO: le webservice retourne le taxon demandé comme l'un des taxon inférieurs
108
		// workaround: on le supprime ici car l'on ignore si d'autre app' dépendent de ce comportement
110
		// workaround: on le supprime ici car l'on ignore si d'autre app' dépendent de ce comportement
109
		unset($resultat[$num_nom][$num_nom]);
111
		unset($resultat[$num_nom][$num_nom]);
110
		return $resultat[$num_nom];
112
		return $resultat[$num_nom];
111
	}
113
	}
112
	
114
	
113
	public function obtenirVersionDonnees() {
115
	public function obtenirVersionDonnees() {
114
		$meta = $this->meta->getMetaDonnees();
116
		$meta = $this->meta->getMetaDonnees();
115
		$this->donnees['version'] = $meta[0]['code'].' v.'.$meta[0]['version'];
117
		$this->donnees['version'] = $meta[0]['code'].' v.'.$meta[0]['version'];
116
		return $this->donnees;
118
		return $this->donnees;
117
	}
119
	}
118
	
120
	
119
 
121
 
120
	public function getBloc() {
122
	public function getBloc() {
121
		$this->donnees['urls'] = $this->appUrls;
123
		$this->donnees['urls'] = $this->appUrls;
122
		$this->donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html_complet');
124
		$this->donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html_complet');
123
		$this->donnees['nom_retenu_formate'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html_complet');
125
		$this->donnees['nom_retenu_formate'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html_complet');
124
		$this->donnees['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet');
126
		$this->donnees['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet');
125
		$synonymes = $this->getSynonymes();
127
		$synonymes = $this->getSynonymes();
126
		$this->donnees['synonymes'] = array_slice($synonymes, 0, 3);
128
		$this->donnees['synonymes'] = array_slice($synonymes, 0, 3);
127
		$this->donnees['autresSynonymesNbre'] = count($synonymes) - 3;
129
		$this->donnees['autresSynonymesNbre'] = count($synonymes) - 3;
128
		
130
		
129
		$this->donnees['taxons_sup'] = $this->nomCourant->taxons_sup;
131
		$this->donnees['taxons_sup'] = $this->nomCourant->taxons_sup;
130
		$this->donnees['taxons_inf'] = $this->getTaxonsInferieurs();
132
		$this->donnees['taxons_inf'] = $this->getTaxonsInferieurs();
131
		$this->donnees['taxons_sup'] = is_array($this->donnees['taxons_sup']) ? array_slice($this->donnees['taxons_sup'], -3 , 3) : array();
133
		$this->donnees['taxons_sup'] = is_array($this->donnees['taxons_sup']) ? array_slice($this->donnees['taxons_sup'], -3 , 3) : array();
132
		$this->donnees['taxons_inf'] = is_array($this->donnees['taxons_inf']) ? array_slice($this->donnees['taxons_inf'], 0 , 3) : array();
134
		$this->donnees['taxons_inf'] = is_array($this->donnees['taxons_inf']) ? array_slice($this->donnees['taxons_inf'], 0 , 3) : array();
133
	
135
	
134
		return $this->donnees;
136
		return $this->donnees;
135
	}
137
	}
136
 
138
 
137
	private function getFlores() {
139
	private function getFlores() {
138
		if (Config::get($this->referentiel.'.baseFloresRef') != "") {
140
		if (Config::get($this->referentiel.'.baseFloresRef') != "") {
139
			$nnr = $this->nomCourant->getNnr();
141
			$nnr = $this->nomCourant->getNnr();
140
			$flores = $this->noms->getFlores($nnr);
142
			$flores = $this->noms->getFlores($nnr);
141
			$this->donnees['flores_synonymes'] =  (isset($flores['resultat']) && is_array($flores['resultat'])) ? $flores['resultat'] : array();
143
			$this->donnees['flores_synonymes'] =  (isset($flores['resultat']) && is_array($flores['resultat'])) ? $flores['resultat'] : array();
142
		}
144
		}
143
	}
145
	}
144
 
146
 
145
	private function getSynonymes() {
147
	private function getSynonymes() {
146
		$nns = $this->nomCourant->getNns();
148
		$nns = $this->nomCourant->getNns();
147
		$synonymesReponse = $this->noms->getSynonymes($nns);
149
		$synonymesReponse = $this->noms->getSynonymes($nns);
148
 
150
 
149
		$synonymes = array();
151
		$synonymes = array();
150
		if (isset($synonymesReponse['resultat']) && is_array($synonymesReponse['resultat'])) {
152
		if (isset($synonymesReponse['resultat']) && is_array($synonymesReponse['resultat'])) {
151
			$synonymes = $synonymesReponse['resultat'];
153
			$synonymes = $synonymesReponse['resultat'];
152
			if (array_key_exists($this->nomCourant->getNnr(), $synonymes)) {
154
			if (array_key_exists($this->nomCourant->getNnr(), $synonymes)) {
153
				unset($synonymes[$this->nomCourant->getNnr()]);
155
				unset($synonymes[$this->nomCourant->getNnr()]);
154
			}
156
			}
155
		}
157
		}
156
		return $synonymes;
158
		return $synonymes;
157
	}
159
	}
158
 
160
 
159
	private function getWikini() {
161
	private function getWikini() {
160
		$wikini = array();
162
		$wikini = array();
161
		$wikini['titre'] = 'Wikini';
163
		$wikini['titre'] = 'Wikini';
162
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
164
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
163
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($this->referentiel, $num_tax);
165
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($this->referentiel, $num_tax);
164
		$wikini['nomenclature'] = $this->wikini->getTexteFormate($page_wiki, 'nomenclature');
166
		$wikini['nomenclature'] = $this->wikini->getTexteFormate($page_wiki, 'nomenclature');
165
		return $wikini;
167
		return $wikini;
166
	}
168
	}
167
}
169
}
168
?>
170
?>