Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 959 Rev 964
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 Ethnobotanique extends aControleur {
15
class Ethnobotanique extends aControleur {
16
 
16
 
17
	private $conteneur = null;
17
	private $conteneur = null;
18
	private $nomCourant = null;
18
	private $nomCourant = null;
19
	private $nomsVernaculaires = null;
19
	private $nomsVernaculaires = null;
20
	private $wikini;
20
	private $wikini;
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->nomsVernaculaires = $this->conteneur->getApiNomsVernaculaires();
27
		$this->nomsVernaculaires = $this->conteneur->getApiNomsVernaculaires();
28
		$this->referentiel = $this->conteneur->getParametre('referentiel');
28
		$this->referentiel = $this->conteneur->getParametre('referentiel');
29
		$this->wikini = $this->conteneur->getApiWikini();
29
		$this->wikini = $this->conteneur->getApiWikini();
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
	}
32
	}
33
 
33
 
34
	public function obtenirDonnees() {
34
	public function obtenirDonnees() {
35
		$this->getNomsVernaculaires();
35
		$this->getNomsVernaculaires('.referentielVerna');
-
 
36
		$this->getNomsVernaculaires('.referentielVernaGrec');
36
		$this->getChorologie();
37
		$this->getChorologie();
37
		$this->donnees['wikini'] = $this->getWikini();
38
		$this->donnees['wikini'] = $this->getWikini();
38
		return $this->donnees;
39
		return $this->donnees;
39
	}
40
	}
40
 
41
 
41
	private function getNomsVernaculaires() {
42
	private function getNomsVernaculaires($projet) {
42
		$projet = Config::get($this->referentiel.'.referentielVerna');
43
		$projet = Config::get($this->referentiel.$projet);
43
		if ($projet != "") {
44
		if ($projet != "") {
44
			$nt = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
45
			$nt = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
45
			$nomsVerna = $this->nomsVernaculaires->getRechercheComplete($nt);
46
			$nomsVerna = $this->nomsVernaculaires->getRechercheComplete($projet, $nt);
46
			$this->donnees[$projet]['noms'] = $nomsVerna['resultat'];
47
			$this->donnees[$projet]['noms'] = $nomsVerna['resultat'];
47
			$this->meta->setProjet($projet);
48
			$this->meta->setProjet($projet);
48
			$meta = $this->meta->getMetaDonnees();
49
			$meta = $this->meta->getMetaDonnees();
49
			$titreMeta = $meta[0]['titre'];
50
			$titreMeta = $meta[0]['titre'];
50
			$this->donnees[$projet]['meta']['titre'] = $titreMeta;
51
			$this->donnees[$projet]['meta']['titre'] = $titreMeta;
51
			$this->donnees[$projet]['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
52
			$this->donnees[$projet]['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
52
		}
53
		}
53
	}
54
	}
54
	
55
	
55
	public function getBloc() {
56
	public function getBloc() {
56
		$nt = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
57
		$nt = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
-
 
58
		$projet = Config::get($this->referentiel.'.referentielVerna');
-
 
59
		if ($projet != "") {
57
		$nomsVerna = $this->nomsVernaculaires->getRechercheLimitee($nt);
60
			$nomsVerna = $this->nomsVernaculaires->getRechercheLimitee($projet, $nt);
58
		$this->donnees['nomsVerna'] = (isset($nomsVerna['resultat']) && is_array($nomsVerna['resultat'])) ? array_slice($nomsVerna['resultat'], 0, 3) : array();
61
			$this->donnees['nomsVerna'] = (isset($nomsVerna['resultat']) && is_array($nomsVerna['resultat'])) ? array_slice($nomsVerna['resultat'], 0, 3) : array();
59
		$this->donnees['autresNomsVerna'] = count($nomsVerna['resultat']) - 3;
62
			$this->donnees['autresNomsVerna'] = count($nomsVerna['resultat']) - 3;
-
 
63
		}
60
		$this->donnees['wikini'] = $this->getWikini();
64
		$this->donnees['wikini'] = $this->getWikini();
61
		return $this->donnees;
65
		return $this->donnees;
62
	}
66
	}
63
		
67
		
64
	private function getChorologie() {
68
	private function getChorologie() {
65
		$infos_choro = $this->nomCourant->getNomRetenu()->getInfos();
69
		$infos_choro = $this->nomCourant->getNomRetenu()->getInfos();
66
		$this->donnees['chorologie'] = $this->traiterTableauChorologie($infos_choro);
70
		$this->donnees['chorologie'] = $this->traiterTableauChorologie($infos_choro);
67
		$this->meta->setProjet($this->referentiel);
71
		$this->meta->setProjet($this->referentiel);
68
		$meta = $this->meta->getMetaDonnees();
72
		$meta = $this->meta->getMetaDonnees();
69
		$titreMeta = $meta[0]['titre'];
73
		$titreMeta = $meta[0]['titre'];
70
		$this->donnees['chorologie']['meta']['titre'] = $titreMeta;
74
		$this->donnees['chorologie']['meta']['titre'] = $titreMeta;
71
		$this->donnees['chorologie']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($this->referentiel);
75
		$this->donnees['chorologie']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($this->referentiel);
72
	}
76
	}
73
	
77
	
74
	private function traiterTableauChorologie($infos_choro) {
78
	private function traiterTableauChorologie($infos_choro) {
75
		$donnees_choro = array();
79
		$donnees_choro = array();
76
		$colonnes = array();
80
		$colonnes = array();
77
		foreach ($infos_choro as $param => $valeur) {
81
		foreach ($infos_choro as $param => $valeur) {
78
			if(substr($param, 0, 8) == 'presence') {	
82
			if(substr($param, 0, 8) == 'presence') {	
79
				$lieu = $this->obtenirLieuPourCodePresence($param);
83
				$lieu = $this->obtenirLieuPourCodePresence($param);
80
				if($lieu != '') {
84
				if($lieu != '') {
81
					$donnees_choro['Présence'][$lieu] = $valeur;
85
					$donnees_choro['Présence'][$lieu] = $valeur;
82
					if(!in_array($lieu, $colonnes)) {
86
					if(!in_array($lieu, $colonnes)) {
83
						$colonnes[] = $lieu;
87
						$colonnes[] = $lieu;
84
					}
88
					}
85
				}
89
				}
86
			} else {
90
			} else {
87
				$donnees_choro = $this->traiterChampsStatuts($donnees_choro, $param, $valeur);
91
				$donnees_choro = $this->traiterChampsStatuts($donnees_choro, $param, $valeur);
88
			}
92
			}
89
		}
93
		}
90
 
94
 
91
		ksort($donnees_choro);	
95
		ksort($donnees_choro);	
92
		$donnees = array('colonnes' => $colonnes, 'donnees' => $donnees_choro);
96
		$donnees = array('colonnes' => $colonnes, 'donnees' => $donnees_choro);
93
		
97
		
94
		return $donnees;
98
		return $donnees;
95
	}
99
	}
96
	
100
	
97
	private function traiterChampsStatuts($tableau_donnees, $code, $valeur) {
101
	private function traiterChampsStatuts($tableau_donnees, $code, $valeur) {
98
		if ($code == 'statut_origine.libelle') {
102
		if ($code == 'statut_origine.libelle') {
99
			$tableau_donnees['Statut d\'origine']['France'] = $valeur;
103
			$tableau_donnees['Statut d\'origine']['France'] = $valeur;
100
		} elseif ($code == 'statut_introduction.libelle') {
104
		} elseif ($code == 'statut_introduction.libelle') {
101
			$tableau_donnees['Statut d\'introduction']['France'] = $valeur;
105
			$tableau_donnees['Statut d\'introduction']['France'] = $valeur;
102
		} elseif ($code == 'statut_culture.libelle') {
106
		} elseif ($code == 'statut_culture.libelle') {
103
			$tableau_donnees['Statut de culture']['France'] = $valeur;
107
			$tableau_donnees['Statut de culture']['France'] = $valeur;
104
		}
108
		}
105
		
109
		
106
		return $tableau_donnees;
110
		return $tableau_donnees;
107
	}
111
	}
108
	
112
	
109
	private function obtenirLieuPourCodePresence($code) {
113
	private function obtenirLieuPourCodePresence($code) {
110
		$tableau_presence = explode('_', $code, 2);
114
		$tableau_presence = explode('_', $code, 2);
111
		$prefixe = (count($tableau_presence) == 2) ? $tableau_presence[0] : '';
115
		$prefixe = (count($tableau_presence) == 2) ? $tableau_presence[0] : '';
112
		$lieu = (count($tableau_presence) == 2) ? $tableau_presence[1] : '';
116
		$lieu = (count($tableau_presence) == 2) ? $tableau_presence[1] : '';
113
			
117
			
114
		if($code == 'presence.libelle') {
118
		if($code == 'presence.libelle') {
115
			$lieu = 'France';
119
			$lieu = 'France';
116
		} elseif (($lieu != '') && strpos($lieu , '.') === false) {
120
		} elseif (($lieu != '') && strpos($lieu , '.') === false) {
117
			$lieu = 'France ('.$this->getCorrespondanceLieu($lieu).')';
121
			$lieu = 'France ('.$this->getCorrespondanceLieu($lieu).')';
118
		} else {
122
		} else {
119
			$lieu = '';
123
			$lieu = '';
120
		}
124
		}
121
		return $lieu;
125
		return $lieu;
122
	}
126
	}
123
	
127
	
124
	private function getCorrespondanceLieu($lieu) {
128
	private function getCorrespondanceLieu($lieu) {
125
		switch(strtolower($lieu)) {
129
		switch(strtolower($lieu)) {
126
			case 'ga':
130
			case 'ga':
127
				$lieu = 'Hors Corse';
131
				$lieu = 'Hors Corse';
128
				break;
132
				break;
129
			case 'co':
133
			case 'co':
130
				$lieu = 'Corse';
134
				$lieu = 'Corse';
131
				break;
135
				break;
132
		}
136
		}
133
	
137
	
134
		return $lieu;
138
		return $lieu;
135
	}
139
	}
136
	
140
	
137
	private function getWikini() {
141
	private function getWikini() {
138
		$wikini = array();
142
		$wikini = array();
139
		$wikini['titre'] = 'Wikini';
143
		$wikini['titre'] = 'Wikini';
140
		$referentiel = $this->conteneur->getParametre('referentiel');
144
		$referentiel = $this->conteneur->getParametre('referentiel');
141
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
145
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
142
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
146
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
143
		$wikini['noms_communs'] = $this->wikini->getTexteFormate($page_wiki, 'noms communs');
147
		$wikini['noms_communs'] = $this->wikini->getTexteFormate($page_wiki, 'noms communs');
144
		$wikini['culture_et_arts'] = $this->wikini->getTexteFormate($page_wiki, 'culture et arts');
148
		$wikini['culture_et_arts'] = $this->wikini->getTexteFormate($page_wiki, 'culture et arts');
145
		$wikini['usage'] = $this->wikini->getTexteFormate($page_wiki, 'usage');
149
		$wikini['usage'] = $this->wikini->getTexteFormate($page_wiki, 'usage');
146
		return $wikini;
150
		return $wikini;
147
	}
151
	}
148
}
152
}
149
?>
153
?>