Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 409 Rev 412
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
 
22
 
23
	public function __construct(Conteneur $conteneur) {
23
	public function __construct(Conteneur $conteneur) {
24
		$this->conteneur = $conteneur;
24
		$this->conteneur = $conteneur;
25
		$this->nomCourant = $this->conteneur->getNomCourant();
25
		$this->nomCourant = $this->conteneur->getNomCourant();
26
		$this->textes = $this->conteneur->getApiTextes();
26
		$this->textes = $this->conteneur->getApiTextes();
27
		$this->wikini = $this->conteneur->getApiWikini();
27
		$this->wikini = $this->conteneur->getApiWikini();
28
		$this->meta = $this->conteneur->getApiMetaDonnees();
28
		$this->meta = $this->conteneur->getApiMetaDonnees();
29
		$this->appUrls = $this->conteneur->getAppUrls();
29
		$this->appUrls = $this->conteneur->getAppUrls();
30
	}
30
	}
31
 
31
 
32
	public function obtenirDonnees() {
32
	public function obtenirDonnees() {
33
		$donnees = array();
33
		$donnees = array();
34
		$donnees['wp'] = $this->getWp();
34
		$donnees['wp'] = $this->getWp();
35
		$donnees['coste'] = $this->getCoste();
35
		$donnees['coste'] = $this->getCoste();
36
		$donnees['wikini'] = $this->getWikini();
36
		$donnees['wikini'] = $this->getWikini();
37
		return $donnees;
37
		return $donnees;
38
	}
38
	}
39
 
39
 
40
	public function getBloc() {
40
	public function getBloc() {
41
		$donnees = $this->getCoste();
-
 
42
		if ($donnees['description'] == 'n') {
41
		$donnees['titre'] = "Description de Coste";
43
			$donnees = $this->getWikini();
42
		$description = $this->getCoste();
44
		}
-
 
45
		if ($donnees['description'] == '') {
43
		if ($description['description'] == 'n') {
46
			$donnees['description'] = 'Participez à la rédaction collaborative de cette description';
44
			$donnees['titre'] = "Description collaborative";
-
 
45
			$description = $this->getWikini();
47
		}
46
		}
-
 
47
		$donnees['description'] = $description['description'];
48
		return $donnees;
48
		return $donnees;
49
	}
49
	}
50
 
50
 
51
	private function getWp() {
51
	private function getWp() {
52
		$wp = array();
52
		$wp = array();
53
		$this->textes->setProjet('wikipedia');
53
		$this->textes->setProjet('wikipedia');
54
		$this->textes->setId($this->getIdWp());
54
		$this->textes->setId($this->getIdWp());
55
		$texte = $this->textes->getTexte();
55
		$texte = $this->textes->getTexte();
56
		$wp['titre'] = $texte['titre'];
56
		$wp['titre'] = $texte['titre'];
57
		$wp['description'] = $texte['texte'];
57
		$wp['description'] = $texte['texte'];
58
		$this->meta->setProjet('wikipedia');
58
		$this->meta->setProjet('wikipedia');
59
		
59
		
60
		// TODO: décommenter ceci et remplacer le titre en dur lorsque le service
60
		// TODO: décommenter ceci et remplacer le titre en dur lorsque le service
61
		// web wikipedia renverra les bonnes metadonnées
61
		// web wikipedia renverra les bonnes metadonnées
62
		//$meta = $this->meta->getMetaDonnees();
62
		//$meta = $this->meta->getMetaDonnees();
63
		//$titreMeta = $meta[0]['titre'];
63
		//$titreMeta = $meta[0]['titre'];
64
		$titreMeta = "Description issue de www.wikipedia.org";
64
		$titreMeta = "Description issue de www.wikipedia.org";
65
		$wp['meta']['titre'] = $titreMeta;
65
		$wp['meta']['titre'] = $titreMeta;
66
		$wp['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('wikipedia');
66
		$wp['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('wikipedia');
67
		
67
		
68
		return $wp;
68
		return $wp;
69
	}
69
	}
70
 
70
 
71
	private function getIdWp() {
71
	private function getIdWp() {
72
		$nomSci = $this->nomCourant->getNomRetenu()->get('nom_sci');
72
		$nomSci = $this->nomCourant->getNomRetenu()->get('nom_sci');
73
		$idWp = str_replace(' ', '_', $nomSci);
73
		$idWp = str_replace(' ', '_', $nomSci);
74
		$idWp = urlencode($idWp);
74
		$idWp = urlencode($idWp);
75
		return $idWp;
75
		return $idWp;
76
	}
76
	}
77
	
77
	
78
	private function getWikini() {	
78
	private function getWikini() {	
79
		$wikini = array();
79
		$wikini = array();
80
		$wikini['titre'] = 'Wikini';
80
		$wikini['titre'] = 'Wikini';
81
		$referentiel = $this->conteneur->getParametre('referentiel');
81
		$referentiel = $this->conteneur->getParametre('referentiel');
82
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
82
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
83
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
83
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
84
		$wikini['description'] = $this->wikini->getTexteFormate($page_wiki, 'description');
84
		$wikini['description'] = $this->wikini->getTexteFormate($page_wiki, 'description');
85
		return $wikini;
85
		return $wikini;
86
	}
86
	}
87
	
87
	
88
	private function getCoste() {
88
	private function getCoste() {
89
		$coste = array();
89
		$coste = array();
90
		$this->textes->setProjet('coste');
90
		$this->textes->setProjet('coste');
91
		$this->textes->setId('bdtfx.nn:'.$this->nomCourant->getNns());
91
		$this->textes->setId('bdtfx.nn:'.$this->nomCourant->getNns());
92
		$texte = $this->textes->getTexte();
92
		$texte = $this->textes->getTexte();
93
		$coste['titre'] = $texte['titre'];
93
		$coste['titre'] = $texte['titre'];
94
		$coste['description'] = $texte['texte'];
94
		$coste['description'] = $texte['texte'];
95
		$this->meta->setProjet('coste');
95
		$this->meta->setProjet('coste');
96
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
96
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
97
		return $coste;
97
		return $coste;
98
	}
98
	}
99
}
99
}
100
?>
100
?>