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