Subversion Repositories eFlore/Applications.cel

Rev

Rev 712 | Rev 917 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 712 Rev 719
Line 20... Line 20...
20
 */
20
 */
21
class Saisie extends WidgetCommun {
21
class Saisie extends WidgetCommun {
Line 22... Line 22...
22
	
22
	
23
	const DS = DIRECTORY_SEPARATOR;
23
	const DS = DIRECTORY_SEPARATOR;
-
 
24
	const PROJET_DEFAUT = 'biodiversite34';
-
 
25
	private $projet = null;
24
	const PROJET_DEFAUT = 'biodiversite34';
26
	private $configProjet = null;
25
	
27
	 
26
	/**
28
	/**
27
	 * Méthode appelée par défaut pour charger ce widget.
29
	 * Méthode appelée par défaut pour charger ce widget.
28
	 */
30
	 */
29
	public function executer() {
31
	public function executer() {
30
		$retour = null;
32
		$retour = null;
Line 31... Line 33...
31
		extract($this->parametres);
33
		extract($this->parametres);
32
 
34
 
-
 
35
		if (!isset($projet)) {
-
 
36
			$this->projet = self::PROJET_DEFAUT;
33
		if (!isset($projet)) {
37
		} else {
-
 
38
			$this->projet = $projet;
Line -... Line 39...
-
 
39
		}
34
			$projet = self::PROJET_DEFAUT;
40
		$this->chargerConfigProjet();
35
		}
41
		
36
		
42
		$service = (isset($service)) ? $service : $this->projet;
37
		$methode = $this->traiterNomMethodeExecuter($projet);
43
		$methode = $this->traiterNomMethodeExecuter($service);
38
		if (method_exists($this, $methode)) {
44
		if (method_exists($this, $methode)) {
39
			$retour = $this->$methode();
45
			$retour = $this->$methode();
Line 40... Line 46...
40
		} else {
46
		} else {
41
			$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
47
			$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
42
		}
48
		}
-
 
49
 
43
 
50
		if (is_null($retour)) {
44
		if (is_null($retour)) {
51
			$contenu = 'Un problème est survenu : '.print_r($this->messages, true);
45
			$contenu = 'Un problème est survenu : '.print_r($this->messages, true);
52
		} else {
46
		} else {
53
			$ext = (isset($retour['squelette_ext'])) ? $retour['squelette_ext'] : '.tpl.html';
47
			$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$projet.self::DS.$retour['squelette'].'.tpl.html';
54
			$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$this->projet.self::DS.$retour['squelette'].$ext;
Line -... Line 55...
-
 
55
			$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']);
-
 
56
		}
-
 
57
		$this->envoyer($contenu);
-
 
58
	}
-
 
59
	
-
 
60
	private function chargerConfigProjet() {
-
 
61
		$fichier_config = dirname(__FILE__).self::DS.'configurations'.self::DS.$this->projet.'.ini';
-
 
62
		if (file_exists($fichier_config)) {
-
 
63
			if (!$this->configProjet	= parse_ini_file($fichier_config)) {
-
 
64
				$this->messages[] = "Le fichier ini '$fichier_config' du projet n'a pu être chargé.";
-
 
65
			} 
48
			$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']);
66
		} else {
49
		}
67
			$this->messages[] = "Le fichier ini '$fichier_config' du projet n'existe pas.";
50
		$this->envoyer($contenu);
68
		}
51
	}
69
	}
52
	
70
	
-
 
71
	public function executerBiodiversite34() {
53
	public function executerBiodiversite34() {
72
		$widget['squelette'] = $this->projet;
54
		$widget['squelette'] = 'biodiversite34';
73
		$widget['donnees'] = array();
-
 
74
		$widget['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
-
 
75
		$widget['donnees']['taxons'] = $this->recupererListeTaxonBiodiversite34();
-
 
76
		$widget['donnees']['milieux'] = $this->parserMilieuxBiodiversite34();
-
 
77
		return  $widget;
-
 
78
	}
-
 
79
	public function executerTaxons() {
-
 
80
		$widget['squelette'] = $this->projet.'_taxons';
-
 
81
		$widget['squelette_ext'] = '.tpl.js';
-
 
82
		$widget['donnees'] = array();
-
 
83
		$methode = 'recupererListeTaxon'.str_replace(' ', '', ucwords(str_replace('-', ' ', strtolower($this->projet))));
-
 
84
		$taxons = $this->$methode();
-
 
85
		$taxons_tries = array();
-
 
86
		foreach ($taxons as $taxon) {
-
 
87
			$taxons_tries[$taxon['num_nom_sel']] = $taxon;
-
 
88
		}
-
 
89
		$widget['donnees']['taxons'] = json_encode($taxons_tries);
-
 
90
		return  $widget;
-
 
91
	}
-
 
92
	
-
 
93
	private function parserMilieuxBiodiversite34() {
-
 
94
		$infosMilieux = array();
-
 
95
		$milieux = explode('|', $this->configProjet['milieux']);
-
 
96
		foreach ($milieux as $milieu) {
-
 
97
			$details = explode(';', $milieu);
-
 
98
			if (isset($details[1])) {
-
 
99
				$infosMilieux[$details[0]] = $details[1];
-
 
100
			} else {
Line 55... Line 101...
55
		$widget['donnees'] = array();
101
				$infosMilieux[$details[0]] = '';
56
		$widget['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
102
			}
57
		$widget['donnees']['taxons'] = $this->recupererListeTaxonBiodiversite34();
103
		}
58
		return  $widget;
104
		return $infosMilieux;