Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1130 | Rev 1252 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1130 Rev 1248
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->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['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet');
50
		$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');
51
		$this->donnees['basionyme_nom_retenu_nn'] = $this->nomCourant->getNomRetenu()->get('basionyme.id');
52
		$this->donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html');
52
		$this->donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html');
53
		$this->donnees['nom_retenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci');
53
		$this->donnees['nom_retenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci');
54
		$this->donnees['wikini'] = $this->getWikini(); 
54
		$this->donnees['wikini'] = $this->getWikini(); 
55
		$this->donnees['hybride_parent_01'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_01_html_complet');
55
		$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');
56
		$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');
57
		$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');
58
		$this->donnees['hybride_parent_02_nn'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_02.id');
59
			
59
			
60
		
60
		
61
		$this->donnees['taxons_sup'] = $this->nomCourant->taxons_sup;
61
		$this->donnees['taxons_sup'] = $this->nomCourant->taxons_sup;
62
		$this->donnees['taxon_courant']['rang.libelle'] = $this->nomCourant->getNomRetenu()->get('rang.libelle');
62
		$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');
63
		$this->donnees['taxon_courant']['nom_sci'] = $this->nomCourant->getNomRetenu()->get('nom_sci');
64
		$this->donnees['taxon_courant']['num_nom'] = $this->nomCourant->getNomRetenu()->get('id');
64
		$this->donnees['taxon_courant']['num_nom'] = $this->nomCourant->getNomRetenu()->get('id');
65
		$this->donnees['taxons_inf'] = $this->getTaxonsInferieurs();
65
		$this->donnees['taxons_inf'] = $this->getTaxonsInferieurs();
-
 
66
		
66
		return $this->donnees;
67
		return $this->donnees;
67
	}
68
	}
-
 
69
	
-
 
70
	private function trierSynonymesParBasionyme($synonymes) {
-
 
71
		$synonymes_t = array();
-
 
72
		$basionyme_inconnu = array();
-
 
73
		foreach($synonymes as $num_nom => $syn) {
-
 
74
			if($syn['basionyme.id'] != "")  {
-
 
75
				$index = $syn['basionyme.id'];
-
 
76
				$synonymes_t[$index]['synonymes'][$num_nom] = $syn;
-
 
77
					
-
 
78
				if(!isset($synonymes_t[$index]['infos_basionyme'])) {
-
 
79
					$synonymes_t[$index]['infos_basionyme'] = $this->extraireInfosBasionymeDuSynonyme($syn);
-
 
80
				}
-
 
81
			} else {
-
 
82
				$basionyme_inconnu['synonymes'][$num_nom] = $syn;
-
 
83
			}
-
 
84
			
-
 
85
		}
-
 
86
		// mise à la fin du tableau des noms sans basionymes
-
 
87
		$synonymes_t['basionyme_inconnu'] = $basionyme_inconnu;
-
 
88
 
-
 
89
		return $synonymes_t;
-
 
90
	}
-
 
91
	
-
 
92
	private function extraireInfosBasionymeDuSynonyme($synonyme) {
-
 
93
		return array(
-
 
94
			'basionyme.id' => $synonyme['basionyme.id'],
-
 
95
			'basionyme.libelle' => $synonyme['basionyme.libelle'],
-
 
96
			'basionyme_html' => $synonyme['basionyme_html'],
-
 
97
			'basionyme_complet' => $synonyme['basionyme_complet'],
-
 
98
			'basionyme_html_complet' => $synonyme['basionyme_html_complet'],
-
 
99
			'basionyme.href' => $synonyme['basionyme.href']
-
 
100
		);
68
	
101
	}
69
	
102
	
70
	private function getTaxonsInferieurs() {
103
	private function getTaxonsInferieurs() {
71
		$num_nom = $this->nomCourant->getNomRetenu()->get('id');
104
		$num_nom = $this->nomCourant->getNomRetenu()->get('id');
72
		$resultat = $this->taxons->getTaxonsInf($num_nom);
105
		$resultat = $this->taxons->getTaxonsInf($num_nom);
73
		// TODO: le webservice retourne le taxon demandé comme l'un des taxon inférieurs
106
		// TODO: le webservice retourne le taxon demandé comme l'un des taxon inférieurs
74
		// workaround: on le supprime ici car l'on ignore si d'autre app' dépendent de ce comportement
107
		// workaround: on le supprime ici car l'on ignore si d'autre app' dépendent de ce comportement
75
		unset($resultat[$num_nom][$num_nom]);
108
		unset($resultat[$num_nom][$num_nom]);
76
		return $resultat[$num_nom];
109
		return $resultat[$num_nom];
77
	}
110
	}
78
	
111
	
79
	public function obtenirVersionDonnees() {
112
	public function obtenirVersionDonnees() {
80
		$meta = $this->meta->getMetaDonnees();
113
		$meta = $this->meta->getMetaDonnees();
81
		$this->donnees['version'] = $meta[0]['code'].' v.'.$meta[0]['version'];
114
		$this->donnees['version'] = $meta[0]['code'].' v.'.$meta[0]['version'];
82
		return $this->donnees;
115
		return $this->donnees;
83
	}
116
	}
84
	
117
	
85
 
118
 
86
	public function getBloc() {
119
	public function getBloc() {
87
		$this->donnees['urls'] = $this->appUrls;
120
		$this->donnees['urls'] = $this->appUrls;
88
		$this->donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html_complet');
121
		$this->donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html_complet');
89
		$this->donnees['nom_retenu_formate'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html_complet');
122
		$this->donnees['nom_retenu_formate'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html_complet');
90
		$this->donnees['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet');
123
		$this->donnees['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet');
91
		$synonymes = $this->getSynonymes();
124
		$synonymes = $this->getSynonymes();
92
		$this->donnees['synonymes'] = array_slice($synonymes, 0, 3);
125
		$this->donnees['synonymes'] = array_slice($synonymes, 0, 3);
93
		$this->donnees['autresSynonymesNbre'] = count($synonymes) - 3;
126
		$this->donnees['autresSynonymesNbre'] = count($synonymes) - 3;
94
		
127
		
95
		$this->donnees['taxons_sup'] = $this->nomCourant->taxons_sup;
128
		$this->donnees['taxons_sup'] = $this->nomCourant->taxons_sup;
96
		$this->donnees['taxons_inf'] = $this->getTaxonsInferieurs();
129
		$this->donnees['taxons_inf'] = $this->getTaxonsInferieurs();
97
		$this->donnees['taxons_sup'] = is_array($this->donnees['taxons_sup']) ? array_slice($this->donnees['taxons_sup'], -3 , 3) : array();
130
		$this->donnees['taxons_sup'] = is_array($this->donnees['taxons_sup']) ? array_slice($this->donnees['taxons_sup'], -3 , 3) : array();
98
		$this->donnees['taxons_inf'] = is_array($this->donnees['taxons_inf']) ? array_slice($this->donnees['taxons_inf'], 0 , 3) : array();
131
		$this->donnees['taxons_inf'] = is_array($this->donnees['taxons_inf']) ? array_slice($this->donnees['taxons_inf'], 0 , 3) : array();
99
	
132
	
100
		return $this->donnees;
133
		return $this->donnees;
101
	}
134
	}
102
 
135
 
103
	private function getFlores() {
136
	private function getFlores() {
104
		if (Config::get($this->referentiel.'.baseFloresRef') != "") {
137
		if (Config::get($this->referentiel.'.baseFloresRef') != "") {
105
			$nnr = $this->nomCourant->getNnr();
138
			$nnr = $this->nomCourant->getNnr();
106
			$flores = $this->noms->getFlores($nnr);
139
			$flores = $this->noms->getFlores($nnr);
107
			$this->donnees['flores_synonymes'] =  (isset($flores['resultat']) && is_array($flores['resultat'])) ? $flores['resultat'] : array();
140
			$this->donnees['flores_synonymes'] =  (isset($flores['resultat']) && is_array($flores['resultat'])) ? $flores['resultat'] : array();
108
		}
141
		}
109
	}
142
	}
110
 
143
 
111
	private function getSynonymes() {
144
	private function getSynonymes() {
112
		$nns = $this->nomCourant->getNns();
145
		$nns = $this->nomCourant->getNns();
113
		$synonymesReponse = $this->noms->getSynonymes($nns);
146
		$synonymesReponse = $this->noms->getSynonymes($nns);
114
 
147
 
115
		$synonymes = array();
148
		$synonymes = array();
116
		if (isset($synonymesReponse['resultat']) && is_array($synonymesReponse['resultat'])) {
149
		if (isset($synonymesReponse['resultat']) && is_array($synonymesReponse['resultat'])) {
117
			$synonymes = $synonymesReponse['resultat'];
150
			$synonymes = $synonymesReponse['resultat'];
118
			if (array_key_exists($this->nomCourant->getNnr(), $synonymes)) {
151
			if (array_key_exists($this->nomCourant->getNnr(), $synonymes)) {
119
				unset($synonymes[$this->nomCourant->getNnr()]);
152
				unset($synonymes[$this->nomCourant->getNnr()]);
120
			}
153
			}
121
		}
154
		}
122
		return $synonymes;
155
		return $synonymes;
123
	}
156
	}
124
 
157
 
125
	private function getWikini() {
158
	private function getWikini() {
126
		$wikini = array();
159
		$wikini = array();
127
		$wikini['titre'] = 'Wikini';
160
		$wikini['titre'] = 'Wikini';
128
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
161
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
129
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($this->referentiel, $num_tax);
162
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($this->referentiel, $num_tax);
130
		$wikini['nomenclature'] = $this->wikini->getTexteFormate($page_wiki, 'nomenclature');
163
		$wikini['nomenclature'] = $this->wikini->getTexteFormate($page_wiki, 'nomenclature');
131
		return $wikini;
164
		return $wikini;
132
	}
165
	}
133
}
166
}
134
?>
167
?>