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(){
|
979 |
delphine |
73 |
|
525 |
gduche |
74 |
$squelette = 'fiche_'.$this->onglet;
|
|
|
75 |
|
|
|
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 |
}
|
|
|
81 |
|
979 |
delphine |
82 |
// Récupération parametres et données
|
525 |
gduche |
83 |
$donnees = $this->parametres;
|
979 |
delphine |
84 |
$donnees = array_merge($this->obtenirDonnees(), $donnees);
|
|
|
85 |
$donnees['i18n'] = I18n::get('Fiche');
|
|
|
86 |
$verna = (isset($donnees['ethnobotanique']['nomsVerna'])) ? $donnees['ethnobotanique']['nomsVerna'][0]['nom_vernaculaire'] : "";
|
|
|
87 |
|
|
|
88 |
// titre, description et tag de la page
|
|
|
89 |
$this->setSortie('titre', $this->nom_retenu->get('nom_sci'));
|
|
|
90 |
$this->setSortie('description', "Fiche descriptive de ".$this->nom_retenu->get('nom_sci')." ".
|
|
|
91 |
$verna." ".$donnees['description']['titre']." ".implode(" ", $donnees['description']['description']));
|
|
|
92 |
$this->setSortie('tags', $this->nom_retenu->get('nom_sci').",".$verna.
|
|
|
93 |
",botanique,plante,description,ecologie,reconnaitre,fiche espece");
|
|
|
94 |
|
|
|
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;
|
|
|
100 |
|
|
|
101 |
// moteur de recherche
|
291 |
jpm |
102 |
$this->executerAction('Recherche', 'executerAccueil', $this->parametres);
|
979 |
delphine |
103 |
|
|
|
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');
|
651 |
mathilde |
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 |
}
|
|
|
122 |
|
709 |
aurelien |
123 |
public function ajouterPiedDePage() {
|
|
|
124 |
$description = new Description($this->conteneur);
|
|
|
125 |
$taxons = new Taxons($this->conteneur);
|
|
|
126 |
$referentiel = $this->conteneur->getParametre('referentiel');
|
990 |
isa |
127 |
$urlMobile = $this->url->obtenirUrlMobile($this->parametres['num_nom'], $this->parametres['type_nom'], $this->parametres['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 |
}
|
|
|
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 |
}
|
|
|
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 |
$donnees = array();
|
|
|
159 |
$classe = ucfirst($this->onglet);
|
1058 |
raphael |
160 |
$onglet = new $classe($this->conteneur); // grep-friendly: new Synthese()
|
291 |
jpm |
161 |
$donnees = $onglet->obtenirDonnees();
|
238 |
delphine |
162 |
return $donnees;
|
|
|
163 |
}
|
71 |
delphine |
164 |
}
|
|
|
165 |
?>
|