Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 451 | Rev 560 | 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();
51
		$baseflor['chorologie'] = $informations['chorologie'];
52
		$baseflor['inflorescence'] = $informations['inflorescence'];
53
		$baseflor['sexualite'] = $informations['sexualite'];
54
		$baseflor['ordre_maturation'] = $informations['ordre_maturation'];
55
		$baseflor['pollinisation'] = $informations['pollinisation'];
56
		$baseflor['dissemination'] = $informations['dissemination'];
57
		$baseflor['fruit'] = $informations['fruit'];
58
		$baseflor['couleur_fleur'] = $informations['couleur_fleur'];
59
		$baseflor['macule'] = $informations['macule'];
60
		$baseflor['floraison'] = $this->changerFloraisonEnChaine($informations['floraison']);
61
		//récupérer dans ontologies
62
		$baseflor['type_bio'] = $informations['type_bio.libelle'];
63
		$baseflor['form_vegetale'] = $informations['form_vegetale'];
64
		$baseflor['description']=$baseflor;
65
		$this->meta->setProjet('baseflor');
66
		$meta = $this->meta->getMetaDonnees();
67
		$citation = $meta[0]['citation'];
68
		$baseflor['meta']['citation'] = $citation;
69
		$baseflor['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseflor');
70
 
71
		return $baseflor;
72
	}
73
 
74
	public function changerFloraisonEnChaine($floraison){
75
		$chaine = "";
76
		if ($floraison != ""){
77
			$mois_fleurs=preg_match('/-/',$floraison) ? preg_split('/-/',$floraison) : $floraison;
78
			if (is_array($mois_fleurs)){
79
				$chaine = "de ".$this->mois[(int)$mois_fleurs[0]]." à ".$this->mois[(int)$mois_fleurs[1]];
80
 
81
			}else { $chaine = "en ".$this->mois[(int)$mois_fleurs];
82
			}
83
		}
84
		return $chaine;
85
	}
291 jpm 86
 
541 mathilde 87
 
291 jpm 88
	public function getBloc() {
541 mathilde 89
 
412 delphine 90
		$donnees['titre'] = "Description de Coste";
91
		$description = $this->getCoste();
451 delphine 92
		if ($description['description'] == '') {
541 mathilde 93
			$donnees['titre'] = "Description Baseflor";
94
			$description = $this->getBaseflor();
95
		}
96
		if ($description['description'] == '') {
412 delphine 97
			$donnees['titre'] = "Description collaborative";
98
			$description = $this->getWikini();
409 delphine 99
		}
412 delphine 100
		$donnees['description'] = $description['description'];
291 jpm 101
		return $donnees;
102
	}
103
 
541 mathilde 104
	private function getWikipedia() {
291 jpm 105
		$wp = array();
106
		$this->textes->setProjet('wikipedia');
107
		$this->textes->setId($this->getIdWp());
108
		$wp['titre'] = $texte['titre'];
435 aurelien 109
		$wp['lien'] = $this->textes->getPageUrl();
291 jpm 110
		$wp['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('wikipedia');
328 aurelien 111
 
291 jpm 112
		return $wp;
113
	}
114
 
115
	private function getIdWp() {
294 delphine 116
		$nomSci = $this->nomCourant->getNomRetenu()->get('nom_sci');
291 jpm 117
		$idWp = str_replace(' ', '_', $nomSci);
295 jpm 118
		$idWp = urlencode($idWp);
291 jpm 119
		return $idWp;
120
	}
322 delphine 121
 
394 aurelien 122
	private function getWikini() {
123
		$wikini = array();
124
		$wikini['titre'] = 'Wikini';
125
		$referentiel = $this->conteneur->getParametre('referentiel');
126
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
127
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
128
		$wikini['description'] = $this->wikini->getTexteFormate($page_wiki, 'description');
129
		return $wikini;
130
	}
131
 
322 delphine 132
	private function getCoste() {
133
		$coste = array();
134
		$this->textes->setProjet('coste');
448 delphine 135
		$this->textes->setId('bdtfx.nn:'.$this->nomCourant->getNnr());
322 delphine 136
		$texte = $this->textes->getTexte();
137
		$coste['titre'] = $texte['titre'];
138
		$coste['description'] = $texte['texte'];
139
		$this->meta->setProjet('coste');
444 delphine 140
		$meta = $this->meta->getMetaDonnees();
141
		$citation = $meta[0]['citation'];
142
		$coste['meta']['citation'] = $citation;
448 delphine 143
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
322 delphine 144
		return $coste;
145
	}
272 delphine 146
}
147
?>