Subversion Repositories eFlore/Applications.del

Rev

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

Rev 2095 Rev 2125
Line 25... Line 25...
25
	private $bdd;
25
	private $bdd;
Line 26... Line 26...
26
 
26
 
27
	private $parametres = array();
27
	private $parametres = array();
28
	private $ressources = array();
28
	private $ressources = array();
-
 
29
	private $date_defaut = '1900-01-01';
29
	private $date_defaut = '1900-01-01';
30
	private $ordre_defaut = 'asc';
30
	private $idsObsImg = array();
31
	private $idsObsImg = array();
Line 31... Line 32...
31
	private $infosObsImg = array();
32
	private $infosObsImg = array();
Line 55... Line 56...
55
 
56
 
56
		if (!isset($parametres['date'])) {
57
		if (!isset($parametres['date'])) {
57
			$this->parametres['date'] = $this->date_defaut;
58
			$this->parametres['date'] = $this->date_defaut;
Line -... Line 59...
-
 
59
		}
-
 
60
 
-
 
61
		if (! isset($parametres['ordre'])) {
-
 
62
			$this->parametres['ordre'] = $this->ordre_defaut;
-
 
63
		} else {
-
 
64
 			$parametres['ordre'] = strtolower($parametres['ordre']);
-
 
65
 			if (! in_array($parametres['ordre'], array('asc', 'desc'))) {
-
 
66
 				$this->parametres['ordre'] = $this->ordre_defaut;
-
 
67
			}
58
		}
68
		}
59
 
69
 
60
		// Lancement du service
70
		// Lancement du service
61
		$this->idsObsImg = $this->getIdsObsImg();
71
		$this->idsObsImg = $this->getIdsObsImg();
62
		$infos = array();
72
		$infos = array();
Line 84... Line 94...
84
	private function getIdsObsImg() {
94
	private function getIdsObsImg() {
85
		$date_debut = "'{$this->parametres['date']}'";
95
		$date_debut = "'{$this->parametres['date']}'";
86
		$limite = @min(intval($this->parametres['navigation.limite']), 1000);
96
		$limite = @min(intval($this->parametres['navigation.limite']), 1000);
87
		$limite = $limite ? $limite : 10; // 0 => 10
97
		$limite = $limite ? $limite : 10; // 0 => 10
88
		$depart = intval(@$this->parametres['navigation.depart']);
98
		$depart = intval(@$this->parametres['navigation.depart']);
-
 
99
		$ordre = $this->parametres['ordre'];
Line 89... Line 100...
89
 
100
 
90
		$requete =
101
		$requete =
91
			'SELECT SQL_CALC_FOUND_ROWS p.id_observation, p.id_image, '.
102
			'SELECT SQL_CALC_FOUND_ROWS p.id_observation, p.id_image, '.
92
			'GROUP_CONCAT(iv.valeur) AS votes, '.
103
			'GROUP_CONCAT(iv.valeur) AS votes, '.
Line 115... Line 126...
115
			'	OR MAX(it.date) >= '.$date_debut.' '.
126
			'	OR MAX(it.date) >= '.$date_debut.' '.
116
			'	OR MAX(it.date_modification) >= '.$date_debut.' '.
127
			'	OR MAX(it.date_modification) >= '.$date_debut.' '.
117
			'	OR MAX(iv.date) >= '.$date_debut.' '.
128
			'	OR MAX(iv.date) >= '.$date_debut.' '.
118
			'	OR MAX(c.date) >= '.$date_debut.' '.
129
			'	OR MAX(c.date) >= '.$date_debut.' '.
119
			'	OR MAX(cv.date) >= '.$date_debut.' '.
130
			'	OR MAX(cv.date) >= '.$date_debut.' '.
120
			'ORDER BY modif_date DESC '.
131
			'ORDER BY modif_date ' . $ordre . ' '.
121
			'LIMIT '.$depart.', '.$limite.
132
			'LIMIT '.$depart.', '.$limite.
122
			' -- '.__FILE__.':'.__LINE__;
133
			' -- '.__FILE__.':'.__LINE__;
123
		//echo $requete; exit;
134
		//echo $requete; exit;
124
		// GROUP BY (très couteux) car multiples observations associées à une image
135
		// GROUP BY (très couteux) car multiples observations associées à une image
125
		// charlie est ici :-)
136
		// charlie est ici :-)
Line 274... Line 285...
274
		$ret = array();
285
		$ret = array();
275
		foreach ($obs as $o) {
286
		foreach ($obs as $o) {
276
			$ret[] = $o;
287
			$ret[] = $o;
277
		}
288
		}
Line 278... Line 289...
278
 
289
 
279
		function cmp($a, $b) {
290
		function cmpDesc($a, $b) {
280
			return ($a['date_changement'] < $b['date_changement']) ? 1 : -1;
291
			return ($a['date_changement'] < $b['date_changement']) ? 1 : -1;
-
 
292
		}
-
 
293
		function cmpAsc($a, $b) {
-
 
294
			return cmpDesc($b, $a);
Line -... Line 295...
-
 
295
		}
-
 
296
 
-
 
297
		if ($this->parametres['ordre'] == 'desc') {
281
		}
298
			usort($ret, 'cmpDesc');
-
 
299
		} else {
282
 
300
			usort($ret, 'cmpAsc');
283
		usort($ret, 'cmp');
301
		}
Line 284... Line 302...
284
		return $ret;
302
		return $ret;
285
	}
303
	}