Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 394 Rev 409
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
		$this->textes->setProjet('wikipedia');
41
		$donnees = $this->getCoste();
42
		$this->textes->setId($this->getIdWp());
42
		if ($donnees['description'] == 'n') {
43
		$this->textes->setSectionTitre('Description');
43
			$donnees = $this->getWikini();
-
 
44
		}
44
		$texte = $this->textes->getTexte();
45
		if ($donnees['description'] == '') {
45
		$donnees['texte'] = $texte['texte'];
46
			$donnees['description'] = 'Participez à la rédaction collaborative de cette description';
-
 
47
		}
46
		return $donnees;
48
		return $donnees;
47
	}
49
	}
48
 
50
 
49
	private function getWp() {
51
	private function getWp() {
50
		$wp = array();
52
		$wp = array();
51
		$this->textes->setProjet('wikipedia');
53
		$this->textes->setProjet('wikipedia');
52
		$this->textes->setId($this->getIdWp());
54
		$this->textes->setId($this->getIdWp());
53
		$texte = $this->textes->getTexte();
55
		$texte = $this->textes->getTexte();
54
		$wp['titre'] = $texte['titre'];
56
		$wp['titre'] = $texte['titre'];
55
		$wp['description'] = $texte['texte'];
57
		$wp['description'] = $texte['texte'];
56
		$this->meta->setProjet('wikipedia');
58
		$this->meta->setProjet('wikipedia');
57
		
59
		
58
		// 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
59
		// web wikipedia renverra les bonnes metadonnées
61
		// web wikipedia renverra les bonnes metadonnées
60
		//$meta = $this->meta->getMetaDonnees();
62
		//$meta = $this->meta->getMetaDonnees();
61
		//$titreMeta = $meta[0]['titre'];
63
		//$titreMeta = $meta[0]['titre'];
62
		$titreMeta = "Description issue de www.wikipedia.org";
64
		$titreMeta = "Description issue de www.wikipedia.org";
63
		$wp['meta']['titre'] = $titreMeta;
65
		$wp['meta']['titre'] = $titreMeta;
64
		$wp['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('wikipedia');
66
		$wp['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('wikipedia');
65
		
67
		
66
		return $wp;
68
		return $wp;
67
	}
69
	}
68
 
70
 
69
	private function getIdWp() {
71
	private function getIdWp() {
70
		$nomSci = $this->nomCourant->getNomRetenu()->get('nom_sci');
72
		$nomSci = $this->nomCourant->getNomRetenu()->get('nom_sci');
71
		$idWp = str_replace(' ', '_', $nomSci);
73
		$idWp = str_replace(' ', '_', $nomSci);
72
		$idWp = urlencode($idWp);
74
		$idWp = urlencode($idWp);
73
		return $idWp;
75
		return $idWp;
74
	}
76
	}
75
	
77
	
76
	private function getWikini() {	
78
	private function getWikini() {	
77
		$wikini = array();
79
		$wikini = array();
78
		$wikini['titre'] = 'Wikini';
80
		$wikini['titre'] = 'Wikini';
79
		$referentiel = $this->conteneur->getParametre('referentiel');
81
		$referentiel = $this->conteneur->getParametre('referentiel');
80
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
82
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
81
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
83
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
82
		$wikini['description'] = $this->wikini->getTexteFormate($page_wiki, 'description');
84
		$wikini['description'] = $this->wikini->getTexteFormate($page_wiki, 'description');
83
		return $wikini;
85
		return $wikini;
84
	}
86
	}
85
	
87
	
86
	private function getCoste() {
88
	private function getCoste() {
87
		$coste = array();
89
		$coste = array();
88
		$this->textes->setProjet('coste');
90
		$this->textes->setProjet('coste');
89
		$this->textes->setId('bdtfx.nn:'.$this->nomCourant->getNns());
91
		$this->textes->setId('bdtfx.nn:'.$this->nomCourant->getNns());
90
		$texte = $this->textes->getTexte();
92
		$texte = $this->textes->getTexte();
91
		$coste['titre'] = $texte['titre'];
93
		$coste['titre'] = $texte['titre'];
92
		$coste['description'] = $texte['texte'];
94
		$coste['description'] = $texte['texte'];
93
		$this->meta->setProjet('coste');
95
		$this->meta->setProjet('coste');
94
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
96
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
95
		return $coste;
97
		return $coste;
96
	}
98
	}
97
}
99
}
98
?>
100
?>