Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 829 | Rev 944 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
272 delphine 1
<?php
2
// declare(encoding='UTF-8');
3
/**
4
 * Classe mère du module Liste.
5
 *
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @copyright	2011 Tela-Botanica
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
13
 * @version		$Id$
14
 */
15
class Nomenclature extends aControleur {
291 jpm 16
 
17
	private $conteneur = null;
294 delphine 18
	private $nomCourant = null;
291 jpm 19
	private $noms = null;
20
	private $meta = null;
21
 
22
	public function __construct(Conteneur $conteneur) {
23
		$this->conteneur = $conteneur;
294 delphine 24
		$this->nomCourant = $this->conteneur->getNomCourant();
829 delphine 25
		$this->taxons = $this->conteneur->getApiTaxons();
291 jpm 26
		$this->noms = $this->conteneur->getApiNoms();
326 aurelien 27
		$this->meta = $this->conteneur->getApiMetaDonnees();
291 jpm 28
		$this->appUrls = $this->conteneur->getAppUrls();
463 delphine 29
		$this->wikini = $this->conteneur->getApiWikini();
272 delphine 30
	}
291 jpm 31
 
32
	public function obtenirDonnees() {
498 jpm 33
 
291 jpm 34
		$donnees = array();
336 aurelien 35
		$donnees['flores_synonymes'] = $this->getFlores();
332 aurelien 36
		$donnees['synonymes']['noms'] = $this->getSynonymes();
373 aurelien 37
		$donnees['date_maj'] = $this->nomCourant->getNomRetenu()->get('maj_modif');
326 aurelien 38
		$meta = $this->meta->getMetaDonnees();
39
		$titreMeta = $meta[0]['titre'];
40
		$donnees['synonymes']['meta']['titre'] = $titreMeta;
41
		$donnees['synonymes']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('bdtfx');
332 aurelien 42
		$donnees['num_type'] = $this->nomCourant->getNomSelectionne()->get('num_type');
334 aurelien 43
		$donnees['urls'] = $this->appUrls;
378 delphine 44
		$donnees['nom_retenu_formate'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html_complet');
584 aurelien 45
		$donnees['nom_retenu_nn'] = $this->nomCourant->getNomRetenu()->get('nom_retenu.id');
378 delphine 46
		$donnees['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet');
584 aurelien 47
		$donnees['basionyme_nom_retenu_nn'] = $this->nomCourant->getNomRetenu()->get('basionyme.id');
448 delphine 48
		$donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html');
49
		$donnees['nom_retenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
914 delphine 50
		$donnees['wikini'] = $this->getWikini();
51
		$donnees['hybride_parent_01'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_01_html_complet');
52
		$donnees['hybride_parent_02'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_02_html_complet');
53
		$donnees['hybride_parent_01_nn'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_01.id');
54
		$donnees['hybride_parent_02_nn'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_02.id');
55
 
829 delphine 56
 
57
		$donnees['taxons_sup'] = $this->nomCourant->taxons_sup;
58
		$donnees['taxon_courant']['rang.libelle'] = $this->nomCourant->getNomRetenu()->get('rang.libelle');
59
		$donnees['taxon_courant']['nom_sci'] = $this->nomCourant->getNomRetenu()->get('nom_sci');
60
		$donnees['taxon_courant']['num_nom'] = $this->nomCourant->getNomRetenu()->get('id');
61
		$donnees['taxons_inf'] = $this->getTaxonsInferieurs();
272 delphine 62
		return $donnees;
63
	}
712 mathilde 64
 
829 delphine 65
 
66
	private function getTaxonsInferieurs() {
67
	$num_nom = $this->nomCourant->getNomRetenu()->get('id');
68
	$resultat = $this->taxons->getTaxonsInf($num_nom);
69
 
70
	return $resultat[$num_nom];
71
	}
72
 
712 mathilde 73
	public function obtenirVersionDonnees() {
74
		$meta = $this->meta->getMetaDonnees();
75
		$donnees['version'] = $meta[0]['code'].' v.'.$meta[0]['version'];
76
		return $donnees;
77
	}
78
 
291 jpm 79
 
80
	public function getBloc() {
469 delphine 81
		$donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html_complet');
378 delphine 82
		$donnees['nom_retenu_formate'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html_complet');
83
		$donnees['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet');
291 jpm 84
		$synonymes = $this->getSynonymes();
372 aurelien 85
		$donnees['synonymes'] = array_slice($synonymes, 0, 3);
86
		$donnees['autresSynonymesNbre'] = count($synonymes) - 3;
829 delphine 87
 
88
		$donnees['taxons_sup'] = $this->nomCourant->taxons_sup;
89
		$donnees['taxons_inf'] = $this->getTaxonsInferieurs();
90
		$donnees['taxons_sup'] = is_array($donnees['taxons_sup']) ? array_slice($donnees['taxons_sup'], -3 , 3) : array();
91
		$donnees['taxons_inf'] = is_array($donnees['taxons_inf']) ? array_slice($donnees['taxons_inf'], 0 , 3) : array();
92
 
291 jpm 93
		return $donnees;
94
	}
498 jpm 95
 
336 aurelien 96
	private function getFlores() {
448 delphine 97
		$nnr = $this->nomCourant->getNnr();
98
		$flores = $this->noms->getFlores($nnr);
336 aurelien 99
		$flores['resultat'] = (isset($flores['resultat']) && is_array($flores['resultat'])) ? $flores['resultat'] : array();
100
		return $flores['resultat'];
101
	}
291 jpm 102
 
103
	private function getSynonymes() {
294 delphine 104
		$nns = $this->nomCourant->getNns();
498 jpm 105
		$synonymesReponse = $this->noms->getSynonymes($nns);
106
 
107
		$synonymes = array();
565 delphine 108
		if (isset($synonymesReponse['resultat']) && is_array($synonymesReponse['resultat'])) {
498 jpm 109
			$synonymes = $synonymesReponse['resultat'];
110
			if (array_key_exists($this->nomCourant->getNnr(), $synonymes)) {
111
				unset($synonymes[$this->nomCourant->getNnr()]);
112
			}
469 delphine 113
		}
498 jpm 114
		return $synonymes;
291 jpm 115
	}
498 jpm 116
 
463 delphine 117
	private function getWikini() {
118
		$wikini = array();
119
		$wikini['titre'] = 'Wikini';
120
		$referentiel = $this->conteneur->getParametre('referentiel');
121
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
122
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
123
		$wikini['nomenclature'] = $this->wikini->getTexteFormate($page_wiki, 'nomenclature');
124
		return $wikini;
125
	}
272 delphine 126
}
127
?>