Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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