Subversion Repositories eFlore/Applications.del

Rev

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

Rev 1997 Rev 2009
Line 3... Line 3...
3
 * Widget fournissant des stats graphiques du CEL.
3
 * Widget fournissant des stats graphiques du CEL.
4
 * Encodage en entrée : utf8
4
 * Encodage en entrée : utf8
5
 * Encodage en sortie : utf8
5
 * Encodage en sortie : utf8
6
 *
6
 *
7
 * @author Jean-Pascal MILCENT <jpm@clapas.org>
7
 * @author Jean-Pascal MILCENT <jpm@clapas.org>
-
 
8
 * @author Mathias CHOUET <mathias@tela-botanica.org>
8
 * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
9
 * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
9
 * @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
10
 * @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
10
 * @version $Id$
11
 * @version $Id$
11
 * @copyright © 2010, Jean-Pascal MILCENT
-
 
12
 */
12
 */
Line 13... Line 13...
13
 
13
 
14
restore_error_handler();
14
restore_error_handler();
15
restore_exception_handler();
15
restore_exception_handler();
Line 19... Line 19...
19
class Statistiques extends WidgetCommun {
19
class Statistiques extends WidgetCommun {
Line 20... Line 20...
20
 
20
 
21
	const DS = DIRECTORY_SEPARATOR;
21
	const DS = DIRECTORY_SEPARATOR;
Line 22... Line 22...
22
	const PAGE_DEFAUT = 'defaut';
22
	const PAGE_DEFAUT = 'defaut';
23
 
23
 
Line 24... Line 24...
24
	private $page;
24
	protected $page;
25
	private $annee;
25
	protected $annee;
26
 
26
 
27
	/**
27
	/**
Line 32... Line 32...
32
 
32
 
33
		extract($this->parametres);
33
		extract($this->parametres);
34
		$this->page = (isset($page)) ? $page : self::PAGE_DEFAUT;
34
		$this->page = (isset($page)) ? $page : self::PAGE_DEFAUT;
Line 35... Line 35...
35
		$this->annee = (isset($annee)) ? $annee : null;
35
		$this->annee = (isset($annee)) ? $annee : null;
36
 
36
 
37
		$methode = $this->traiterNomMethodeExecuter($this->page);
37
		/*$methode = $this->traiterNomMethodeExecuter($this->page);
38
		if (method_exists($this, $methode)) {
38
		if (method_exists($this, $methode)) {
39
			$retour = $this->$methode();
39
			$retour = $this->$methode();
-
 
40
		} else {
-
 
41
			$this->messages[] = "Le type de statistiques '$methode' n'est pas disponible.";
-
 
42
		}*/
-
 
43
		if ($this->page == "defaut") {
-
 
44
			$retour = $this->executerDefaut();
-
 
45
		} else {
-
 
46
			// magical cracratitude is so pratique (un super nom pour un album de rock-electro hipster)
40
		} else {
47
			$idRessource = $this->traiterNomRessourceTirets($this->page);
Line 41... Line 48...
41
			$this->messages[] = "Le type de statistiques '$methode' n'est pas disponible.";
48
			$retour = $this->executerGenerique($idRessource);
42
		}
49
		}
43
 
50
 
Line 76... Line 83...
76
			$widget['donnees']['annee'] = $this->annee;
83
			$widget['donnees']['annee'] = $this->annee;
77
		}
84
		}
78
		return $widget;
85
		return $widget;
79
	}
86
	}
Line -... Line 87...
-
 
87
 
-
 
88
	/**
-
 
89
	 * Méthode magique qui appelle la méthode chargée de ramener les
-
 
90
	 * stats, et effectue le rendu dans le template adéquat
80
 
91
	 */
81
	public function executerObservations() {
92
	protected function executerGenerique($id) {
82
		$widget = null;
93
		$widget = null;
Line 83... Line 94...
83
		$widget['donnees'] = (array) $this->statsObservations();
94
		$widget['donnees'] = (array) $this->statsGenerique($id);
84
 
95
 
85
		if (!is_null($widget)) {
96
		if (!is_null($widget)) {
86
			$widget['squelette'] = 'observations';
97
			$widget['squelette'] = $id;
Line 87... Line 98...
87
			$widget['donnees']['annee'] = $this->annee;
98
			$widget['donnees']['annee'] = $this->annee;
88
		}
99
		}
-
 
100
 
-
 
101
		return $widget;
-
 
102
	}
-
 
103
	// peut être encore plus factorisé mais on ne sait jamais si on a besoin
-
 
104
	// d'un truc spécifique dans une méthode ou l'autre
-
 
105
	/*public function executerObservations() {
-
 
106
		return $this->executerGenerique('observations');
-
 
107
	}
-
 
108
	public function executerPropositions() {
-
 
109
		return $this->executerGenerique('propositions');
-
 
110
	}
-
 
111
	public function executerUtilisateursIp() {
-
 
112
		return $this->executerGenerique('utilisateursIp');
-
 
113
	}
-
 
114
	public function executerListeMeilleursProposeurs() {
-
 
115
		return $this->executerGenerique('listeMeilleursProposeurs');
-
 
116
	}
-
 
117
	public function executerListeMeilleursVoteurs() {
-
 
118
		return $this->executerGenerique('listeMeilleursProposeurs');
-
 
119
	}
-
 
120
	public function executerImages() {
-
 
121
		return $this->executerGenerique('images');
-
 
122
	}
-
 
123
	public function executerTags() {
-
 
124
		return $this->executerGenerique('tags');
-
 
125
	}
-
 
126
	public function executerUtilisateursPf() {
-
 
127
		return $this->executerGenerique('utilisateursPf');
-
 
128
	}
-
 
129
	public function executerListeMeilleursTags() {
-
 
130
		return $this->executerGenerique('listeMeilleursTags');
-
 
131
	}
Line -... Line 132...
-
 
132
	public function executerListeMeilleursTagueurs() {
-
 
133
		return $this->executerGenerique('listeMeilleursTagueurs');
-
 
134
	}*/
-
 
135
 
-
 
136
	/**
89
 
137
	 * Méthode magique qui appelle le service:del:statistiques pour
90
		return $widget;
138
	 * obtenir les données demandées pour l'année demandée
91
	}
139
	 * @return array
92
 
140
	 */
93
	private function statsObservations() {
141
	protected function statsGenerique($id) {
94
		// Récupération des données au format Json
142
		// Récupération des données au format Json
95
		$service = "statistiques/observations";
143
		$service = "statistiques/$id";
96
 
144
	
97
		$parametres = array();
145
		$parametres = array();
98
		if (isset($this->parametres['annee'])) {
146
		if (isset($this->parametres['annee'])) {
99
			$parametres[] = 'annee='.$this->parametres['annee'];
147
			$parametres[] = 'annee='.$this->parametres['annee'];
100
		}
148
		}
101
		$service .= (count($parametres) > 0) ? '?'.implode('&', $parametres) : '';
149
		$service .= (count($parametres) > 0) ? '?'.implode('&', $parametres) : '';
102
 
150
	
103
		$url = sprintf($this->config['chemins']['baseURLServicesDelTpl'], $service);
151
		$url = sprintf($this->config['chemins']['baseURLServicesDelTpl'], $service);
104
		$json = $this->getDao()->consulter($url);
152
		$json = $this->getDao()->consulter($url);
105
 
153