71 |
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 Fiche extends aControleur {
|
291 |
jpm |
16 |
|
230 |
delphine |
17 |
private $onglet = 'synthese';
|
291 |
jpm |
18 |
private $parametres = array();
|
|
|
19 |
private $conteneur = null;
|
238 |
delphine |
20 |
private $num_nom = 0;
|
376 |
delphine |
21 |
private $nom_retenu = '';
|
651 |
mathilde |
22 |
private $url;
|
291 |
jpm |
23 |
|
|
|
24 |
|
216 |
delphine |
25 |
public function initialiser() {
|
|
|
26 |
$this->capturerParametres();
|
500 |
jpm |
27 |
$this->conteneur = new Conteneur($this->parametres);
|
651 |
mathilde |
28 |
$this->url = $this->conteneur->getAppUrls();
|
376 |
delphine |
29 |
$this->nom_retenu = $this->conteneur->getNomCourant()->getNomRetenu();
|
238 |
delphine |
30 |
spl_autoload_register(array($this, 'chargerClassesOnglets'));
|
216 |
delphine |
31 |
}
|
291 |
jpm |
32 |
|
|
|
33 |
private function capturerParametres() {
|
|
|
34 |
if (isset($_GET['num_nom'])) {
|
|
|
35 |
$this->parametres['num_nom'] = $_GET['num_nom'];
|
|
|
36 |
}
|
|
|
37 |
if (isset($_GET['nom'])) {
|
|
|
38 |
$this->parametres['nom'] = $_GET['nom'];
|
|
|
39 |
}
|
|
|
40 |
if (isset($_GET['type_nom'])) {
|
|
|
41 |
$this->parametres['type_nom'] = $_GET['type_nom'];
|
|
|
42 |
}
|
395 |
aurelien |
43 |
if (isset($_GET['referentiel'])) {
|
|
|
44 |
$this->parametres['referentiel'] = $_GET['referentiel'];
|
939 |
aurelien |
45 |
Registre::set('parametres.referentiel', $_GET['referentiel']);
|
395 |
aurelien |
46 |
}
|
291 |
jpm |
47 |
if (isset($_GET['niveau'])) {
|
|
|
48 |
Registre::set('parametres.niveau', $_GET['niveau']);
|
|
|
49 |
}
|
|
|
50 |
if (isset($_GET['onglet'])) {
|
|
|
51 |
$this->onglet = $_GET['onglet'];
|
|
|
52 |
}
|
|
|
53 |
}
|
|
|
54 |
|
238 |
delphine |
55 |
private function chargerClassesOnglets($classe) {
|
|
|
56 |
$base = dirname(__FILE__).DS;
|
|
|
57 |
$cheminFormateurs = $base.'formateurs'.DS;
|
|
|
58 |
$dossiers = array($base, $cheminFormateurs);
|
|
|
59 |
foreach ($dossiers as $chemin) {
|
|
|
60 |
$fichierATester = $chemin.$classe.'.php';
|
|
|
61 |
if (file_exists($fichierATester)) {
|
|
|
62 |
include_once $fichierATester;
|
|
|
63 |
return null;
|
|
|
64 |
}
|
|
|
65 |
}
|
|
|
66 |
}
|
291 |
jpm |
67 |
|
71 |
delphine |
68 |
public function executerActionParDefaut() {
|
|
|
69 |
$this->executerFiche();
|
|
|
70 |
}
|
291 |
jpm |
71 |
|
141 |
delphine |
72 |
public function executerFiche(){
|
1105 |
jpm |
73 |
|
525 |
gduche |
74 |
$squelette = 'fiche_'.$this->onglet;
|
1105 |
jpm |
75 |
|
525 |
gduche |
76 |
//Gestion du niveau
|
545 |
gduche |
77 |
$niveau = isset($_GET['niveau']) ? $_GET['niveau'] : 2;
|
525 |
gduche |
78 |
if ($this->onglet == 'synthese' && $niveau != null) {
|
|
|
79 |
$squelette .= '_niveau'.$niveau;
|
|
|
80 |
}
|
1105 |
jpm |
81 |
|
979 |
delphine |
82 |
// Récupération parametres et données
|
1144 |
raphael |
83 |
$donnees = array_merge($this->obtenirDonnees(), $this->parametres);
|
979 |
delphine |
84 |
$donnees['i18n'] = I18n::get('Fiche');
|
1144 |
raphael |
85 |
$verna = isset($donnees['ethnobotanique']['nomsVerna']) && count($donnees['ethnobotanique']['nomsVerna']) ? $donnees['ethnobotanique']['nomsVerna'][0]['nom_vernaculaire'] : "";
|
1105 |
jpm |
86 |
|
979 |
delphine |
87 |
// titre, description et tag de la page
|
|
|
88 |
$this->setSortie('titre', $this->nom_retenu->get('nom_sci'));
|
1144 |
raphael |
89 |
// ( <meta name="description" ...> )
|
|
|
90 |
$this->setSortie('description', sprintf("Fiche descriptive de %s %s (%s)", $this->nom_retenu->get('nom_sci'), $verna ? ('/ ' . $verna) : '', $donnees['description']['titre']));
|
|
|
91 |
|
979 |
delphine |
92 |
$this->setSortie('tags', $this->nom_retenu->get('nom_sci').",".$verna.
|
|
|
93 |
",botanique,plante,description,ecologie,reconnaitre,fiche espece");
|
1105 |
jpm |
94 |
|
979 |
delphine |
95 |
// titre de la fiche
|
982 |
delphine |
96 |
$donnees['nom_retenu_html'] = $this->nom_retenu->get('nom_sci_html').' '.$this->nom_retenu->get('auteur');
|
|
|
97 |
$donnees['nom_retenu'] = $this->nom_retenu->get('nom_sci');
|
380 |
delphine |
98 |
$donnees['famille'] = $this->nom_retenu->getTaxonSupRang('180');
|
979 |
delphine |
99 |
$donnees['nom_vernaculaire'] = $verna;
|
1105 |
jpm |
100 |
|
979 |
delphine |
101 |
// moteur de recherche
|
291 |
jpm |
102 |
$this->executerAction('Recherche', 'executerAccueil', $this->parametres);
|
1105 |
jpm |
103 |
|
979 |
delphine |
104 |
// page synthese
|
291 |
jpm |
105 |
$blocs_niveaux = $this->conteneur->getParametreTableau('blocs_fiche_defaut');
|
219 |
delphine |
106 |
$donnees['blocs'] = '"'.str_replace('|', '","', $blocs_niveaux[Registre::get('parametres.niveau')]).'"';
|
291 |
jpm |
107 |
|
979 |
delphine |
108 |
// onglet
|
238 |
delphine |
109 |
$donnees['onglet'] = $this->onglet;
|
525 |
gduche |
110 |
$donnees['contenu_onglet'] = $this->getVue($squelette, $donnees);
|
907 |
aurelien |
111 |
$donnees['base_url_onglets'] = Config::get('base_url_application_onglets');
|
1105 |
jpm |
112 |
|
545 |
gduche |
113 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('fiche_accueil_niveau'.$niveau, $donnees), true);
|
709 |
aurelien |
114 |
$this->ajouterPiedDePage();
|
71 |
delphine |
115 |
}
|
291 |
jpm |
116 |
|
651 |
mathilde |
117 |
public function ajouterLienModuleExport() {
|
677 |
mathilde |
118 |
$donnees['lien'] = $this->url->obtenirUrlPdfExport($this->parametres['num_nom']);
|
709 |
aurelien |
119 |
$export = $this->getVue('fiche_pdf_lien', $donnees);
|
|
|
120 |
return $export;
|
651 |
mathilde |
121 |
}
|
1105 |
jpm |
122 |
|
709 |
aurelien |
123 |
public function ajouterPiedDePage() {
|
|
|
124 |
$description = new Description($this->conteneur);
|
1145 |
raphael |
125 |
$taxons = new Taxons();
|
709 |
aurelien |
126 |
$referentiel = $this->conteneur->getParametre('referentiel');
|
1105 |
jpm |
127 |
$urlMobile = $this->url->obtenirUrlMobile($this->parametres['num_nom']);
|
983 |
aurelien |
128 |
$donnees = array('wikipedia' => $description->getUrlWikipedia(),
|
990 |
isa |
129 |
'export_pdf' => $this->ajouterLienModuleExport(),
|
|
|
130 |
'permalien_num_nom' => $taxons->getUrlPermalienNumNom($referentiel, 1, $this->conteneur->getNomCourant()->getNns()),
|
|
|
131 |
'permalien_taxon' => $taxons->getUrlPermalienTaxon($referentiel, 1, $this->conteneur->getNomCourant()->getNt()),
|
|
|
132 |
'nn' => $this->conteneur->getNomCourant()->getNns(),
|
|
|
133 |
'nt' => $this->conteneur->getNomCourant()->getNt(),
|
|
|
134 |
'wiki' => $description->getLienWikini(),
|
|
|
135 |
'nom_retenu' => $this->nom_retenu->get('nom_sci'),
|
|
|
136 |
'mobile' => $urlMobile,
|
|
|
137 |
'qr_code_png' => $this->obtenirUrlQrCode($urlMobile)
|
|
|
138 |
);
|
709 |
aurelien |
139 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('fiche_pied_page', $donnees), true);
|
|
|
140 |
}
|
1105 |
jpm |
141 |
|
990 |
isa |
142 |
private function obtenirUrlQrCode($urlMobile) {
|
|
|
143 |
$qr = $this->conteneur->getQrCode();
|
|
|
144 |
$qr->setUrl(htmlspecialchars_decode($urlMobile));
|
|
|
145 |
$idQrCode = $this->conteneur->getNomCourant()->getNns();
|
|
|
146 |
$urlQrCode = $qr->dessiner($idQrCode);
|
|
|
147 |
return $urlQrCode;
|
|
|
148 |
}
|
1105 |
jpm |
149 |
|
230 |
delphine |
150 |
public function executerOnglet(){
|
913 |
aurelien |
151 |
$this->viderSorties();
|
238 |
delphine |
152 |
$donnees = $this->obtenirDonnees();
|
291 |
jpm |
153 |
header('Content-type: text/html');
|
500 |
jpm |
154 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('fiche_'.$this->onglet, $donnees));
|
230 |
delphine |
155 |
}
|
291 |
jpm |
156 |
|
|
|
157 |
private function obtenirDonnees() {
|
|
|
158 |
$classe = ucfirst($this->onglet);
|
1058 |
raphael |
159 |
$onglet = new $classe($this->conteneur); // grep-friendly: new Synthese()
|
1144 |
raphael |
160 |
return $onglet->obtenirDonnees();
|
238 |
delphine |
161 |
}
|
71 |
delphine |
162 |
}
|
|
|
163 |
?>
|