Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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