Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 269 | Rev 291 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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 {
230 delphine 16
	private $onglet = 'synthese';
238 delphine 17
	private $num_nom = 0;
230 delphine 18
 
238 delphine 19
 
216 delphine 20
	public function initialiser() {
21
		$this->capturerParametres();
238 delphine 22
		spl_autoload_register(array($this, 'chargerClassesOnglets'));
216 delphine 23
	}
71 delphine 24
 
238 delphine 25
	private function chargerClassesOnglets($classe) {
26
		$base = dirname(__FILE__).DS;
27
		$cheminFormateurs = $base.'formateurs'.DS;
28
		$dossiers = array($base, $cheminFormateurs);
29
		foreach ($dossiers as $chemin) {
30
			$fichierATester = $chemin.$classe.'.php';
31
			if (file_exists($fichierATester)) {
32
				include_once $fichierATester;
33
				return null;
34
			}
35
		}
36
	}
37
 
71 delphine 38
	public function executerActionParDefaut() {
39
		$this->executerFiche();
40
	}
41
 
141 delphine 42
	public function executerFiche(){
238 delphine 43
		$donnees = array('type_nom' => $this->type_nom, 'nom' => $this->nom);
44
		$this->executerAction('Recherche', 'executerAccueil', $donnees);
45
		$donnees['num_nom'] = $this->num_nom;
219 delphine 46
		$blocs_niveaux = $this->recupererTableauConfig('blocs_fiche_defaut');
47
		$donnees['blocs'] = '"'.str_replace('|', '","', $blocs_niveaux[Registre::get('parametres.niveau')]).'"';
238 delphine 48
		$donnees = $this->obtenirDonnees($donnees);
49
		$donnees['onglet'] = $this->onglet;
50
		$donnees['contenu_onglet'] = $this->getVue('fiche_'.$this->onglet, $donnees);
244 delphine 51
		$donnees['nom_retenu'] = $this->nom_retenu;
231 aurelien 52
		$this->setSortie(self::RENDU_CORPS, $this->getVue('fiche_accueil', $donnees), true);
71 delphine 53
	}
216 delphine 54
 
230 delphine 55
	public function executerOnglet(){
238 delphine 56
		$donnees = $this->obtenirDonnees();
231 aurelien 57
		header('Content-type: text/html');
230 delphine 58
		echo $this->getVue('fiche_'.$this->onglet, $donnees);
231 aurelien 59
		exit;
230 delphine 60
	}
61
 
238 delphine 62
	private function obtenirDonnees($donnees = array()) {
276 gduche 63
		if ($this->onglet == 'synthese') {
64
			$serviceRepartition = new Repartition($this->num_nom, 'nn', "190x178");
65
			$donnees['repartition_vignette'] = $serviceRepartition->getUrlPng();
66
		} else {
269 delphine 67
			$classe = ucfirst($this->onglet);
68
			$metier = new $classe();
69
			$donnees = $metier->obtenirDonnees($this->num_nom);
238 delphine 70
		}
71
		return $donnees;
72
	}
73
 
216 delphine 74
	private function capturerParametres() {
238 delphine 75
		if (isset($_GET['num_nom'])) {
76
			$this->num_nom = $_GET['num_nom'];
77
		}
244 delphine 78
 
249 delphine 79
		if (isset($_GET['nom_retenu'])) {
244 delphine 80
			$this->nom_retenu = $_GET['nom_retenu'];
81
		}
82
 
216 delphine 83
		if (isset($_GET['nom'])) {
84
			$this->nom = $_GET['nom'];
85
		}
86
		if (isset($_GET['type_nom'])) {
87
			$this->type_nom = $_GET['type_nom'];
88
		}
89
 
90
		if (isset($_GET['niveau'])) {
91
			Registre::set('parametres.niveau', $_GET['niveau']);
92
		}
230 delphine 93
		if (isset($_GET['onglet'])) {
94
			$this->onglet = $_GET['onglet'];
95
		}
216 delphine 96
	}
219 delphine 97
 
98
	protected function recupererTableauConfig($param) {
99
		$tableau = array();
100
		$tableauPartiel = explode(',', Config::get($param));
101
		$tableauPartiel = array_map('trim', $tableauPartiel);
102
		foreach ($tableauPartiel as $champ) {
103
			if (strpos($champ, '=') === false) {
104
				$tableau[] = $champ;
105
			} else {
106
				list($cle, $val) = explode('=', $champ);
107
				$tableau[$cle] = $val;
108
			}
109
		}
110
		return $tableau;
111
	}
71 delphine 112
}
113
?>