Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 541 | Rev 570 | 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 Description extends aControleur {
291 jpm 16
 
17
	private $conteneur = null;
294 delphine 18
	private $nomCourant = null;
291 jpm 19
	private $textes = null;
20
	private $meta = null;
394 aurelien 21
	private $wikini = null;
541 mathilde 22
	private $informations = null;
23
	private $mois = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août',
24
						'septembre', 'octobre', 'novembre', 'décembre');
25
 
291 jpm 26
	public function __construct(Conteneur $conteneur) {
27
		$this->conteneur = $conteneur;
294 delphine 28
		$this->nomCourant = $this->conteneur->getNomCourant();
291 jpm 29
		$this->textes = $this->conteneur->getApiTextes();
394 aurelien 30
		$this->wikini = $this->conteneur->getApiWikini();
291 jpm 31
		$this->meta = $this->conteneur->getApiMetaDonnees();
541 mathilde 32
		$this->informations = $this->conteneur->getApiInformations();
291 jpm 33
		$this->appUrls = $this->conteneur->getAppUrls();
34
	}
35
 
36
	public function obtenirDonnees() {
37
		$donnees = array();
541 mathilde 38
		$donnees['wikipedia'] = $this->getWikipedia();
322 delphine 39
		$donnees['coste'] = $this->getCoste();
394 aurelien 40
		$donnees['wikini'] = $this->getWikini();
541 mathilde 41
		$donnees['baseflor'] = $this->getBaseflor();
272 delphine 42
		return $donnees;
43
	}
541 mathilde 44
 
45
	private function getBaseflor() {
46
		$baseflor = array();
47
		$this->informations ->setProjet('baseflor');
48
		$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
49
		$this->informations ->setNum_nom($this->conteneur->getParametre('num_nom'));
50
		$informations = $this->informations->getInformations();
560 mathilde 51
		if ($informations){
52
			$baseflor['chorologie'] = $informations['chorologie'];
53
			$baseflor['inflorescence'] = $informations['inflorescence'];
54
			$baseflor['sexualite'] = $informations['sexualite'];
55
			$baseflor['ordre_maturation'] = $informations['ordre_maturation'];
56
			$baseflor['pollinisation'] = $informations['pollinisation'];
57
			$baseflor['dissemination'] = $informations['dissemination'];
58
			$baseflor['fruit'] = $informations['fruit'];
59
			$baseflor['couleur_fleur'] = $informations['couleur_fleur'];
60
			$baseflor['macule'] = $informations['macule'];
61
			$baseflor['floraison'] = $this->changerFloraisonEnChaine($informations['floraison']);
62
			//récupérer dans ontologies
63
			$baseflor['type_bio'] = $informations['type_bio.libelle'];
64
			$baseflor['form_vegetale'] = $informations['form_vegetale'];
65
			$baseflor['description']=$baseflor;
66
			$this->meta->setProjet('baseflor');
67
			$meta = $this->meta->getMetaDonnees();
68
			$citation = $meta[0]['citation'];
69
			$baseflor['meta']['citation'] = $citation;
70
			$baseflor['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseflor');
71
 
72
		}
541 mathilde 73
		return $baseflor;
74
	}
75
 
76
	public function changerFloraisonEnChaine($floraison){
77
		$chaine = "";
78
		if ($floraison != ""){
79
			$mois_fleurs=preg_match('/-/',$floraison) ? preg_split('/-/',$floraison) : $floraison;
80
			if (is_array($mois_fleurs)){
81
				$chaine = "de ".$this->mois[(int)$mois_fleurs[0]]." à ".$this->mois[(int)$mois_fleurs[1]];
82
 
83
			}else { $chaine = "en ".$this->mois[(int)$mois_fleurs];
84
			}
85
		}
86
		return $chaine;
87
	}
291 jpm 88
 
541 mathilde 89
 
291 jpm 90
	public function getBloc() {
541 mathilde 91
 
412 delphine 92
		$donnees['titre'] = "Description de Coste";
93
		$description = $this->getCoste();
451 delphine 94
		if ($description['description'] == '') {
541 mathilde 95
			$donnees['titre'] = "Description Baseflor";
96
			$description = $this->getBaseflor();
97
		}
560 mathilde 98
		if (empty($description['description'])) {
412 delphine 99
			$donnees['titre'] = "Description collaborative";
100
			$description = $this->getWikini();
409 delphine 101
		}
412 delphine 102
		$donnees['description'] = $description['description'];
291 jpm 103
		return $donnees;
104
	}
105
 
541 mathilde 106
	private function getWikipedia() {
291 jpm 107
		$wp = array();
108
		$this->textes->setProjet('wikipedia');
109
		$this->textes->setId($this->getIdWp());
110
		$wp['titre'] = $texte['titre'];
435 aurelien 111
		$wp['lien'] = $this->textes->getPageUrl();
291 jpm 112
		$wp['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('wikipedia');
328 aurelien 113
 
291 jpm 114
		return $wp;
115
	}
116
 
117
	private function getIdWp() {
294 delphine 118
		$nomSci = $this->nomCourant->getNomRetenu()->get('nom_sci');
291 jpm 119
		$idWp = str_replace(' ', '_', $nomSci);
295 jpm 120
		$idWp = urlencode($idWp);
291 jpm 121
		return $idWp;
122
	}
322 delphine 123
 
394 aurelien 124
	private function getWikini() {
125
		$wikini = array();
126
		$wikini['titre'] = 'Wikini';
127
		$referentiel = $this->conteneur->getParametre('referentiel');
128
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
129
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
130
		$wikini['description'] = $this->wikini->getTexteFormate($page_wiki, 'description');
131
		return $wikini;
132
	}
133
 
322 delphine 134
	private function getCoste() {
135
		$coste = array();
136
		$this->textes->setProjet('coste');
448 delphine 137
		$this->textes->setId('bdtfx.nn:'.$this->nomCourant->getNnr());
322 delphine 138
		$texte = $this->textes->getTexte();
139
		$coste['titre'] = $texte['titre'];
140
		$coste['description'] = $texte['texte'];
141
		$this->meta->setProjet('coste');
444 delphine 142
		$meta = $this->meta->getMetaDonnees();
143
		$citation = $meta[0]['citation'];
144
		$coste['meta']['citation'] = $citation;
448 delphine 145
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
322 delphine 146
		return $coste;
147
	}
272 delphine 148
}
149
?>