Subversion Repositories eFlore/Applications.del

Rev

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

Rev 1853 Rev 1871
Line 17... Line 17...
17
 * @license   CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
17
 * @license   CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
18
 * @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
18
 * @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
19
 */
19
 */
20
class ParametresFiltrage {
20
class ParametresFiltrage {
Line -... Line 21...
-
 
21
 
-
 
22
	const APPLI_IMG = 'IMG';
-
 
23
	const APPLI_OBS = 'OBS';
21
 
24
 
22
	const LISTE_OBS_MAX_RESULT_LIMIT = 1000;
25
	const LISTE_OBS_MAX_RESULT_LIMIT = 1000;
23
	const LISTE_OBS_MAX_ID_OBS = 10e7;
26
	const LISTE_OBS_MAX_ID_OBS = 10e7;
24
	const LISTE_OBS_MAX_BDTFX_NT = 1000000; // SELECT MAX(num_taxonomique) FROM bdtfx_v2_00; // 44378 + 1000
27
	const LISTE_OBS_MAX_BDTFX_NT = 1000000; // SELECT MAX(num_taxonomique) FROM bdtfx_v2_00; // 44378 + 1000
Line 25... Line 28...
25
	const LISTE_OBS_MAX_BDTFX_NN = 1000000; // SELECT MAX(num_nom) FROM bdtfx_v2_00;// 120816 + 10000
28
	const LISTE_OBS_MAX_BDTFX_NN = 1000000; // SELECT MAX(num_nom) FROM bdtfx_v2_00;// 120816 + 10000
26
 
29
 
27
	private $conteneur;
30
	private $conteneur;
28
	private $contexte;
31
	private $contexte;
-
 
32
	private $parametres = array();
Line 29... Line 33...
29
	private $parametres = array();
33
	private $parametresFiltres = array();
30
	private $parametresFiltres = array();
34
	private $appli;
31
 
35
 
32
	public function __construct($conteneur) {
36
	public function __construct($conteneur) {
33
		$this->conteneur = $conteneur;
37
		$this->conteneur = $conteneur;
Line -... Line 38...
-
 
38
		$this->contexte = $this->conteneur->getContexte();
-
 
39
		$this->parametres = $this->contexte->getQS();
-
 
40
	}
-
 
41
 
-
 
42
	private function etreAppliImg() {
-
 
43
		return $this->appli === 'IMG' ? true : false;
-
 
44
	}
-
 
45
 
34
		$this->contexte = $this->conteneur->getContexte();
46
	private function etreAppliObs() {
-
 
47
		return $this->appli === 'OBS' ? true : false;
35
		$this->parametres = $this->contexte->getQS();
48
	}
Line 36... Line 49...
36
	}
49
 
37
 
50
	public function filtrerUrlParamsAppliImg() {
Line 57... Line 70...
57
		$this->supprimerParametresFiltresInvalides();
70
		$this->supprimerParametresFiltresInvalides();
58
		return $this->parametresFiltres;
71
		return $this->parametresFiltres;
59
	}
72
	}
Line 60... Line 73...
60
 
73
 
-
 
74
	public function filtrerUrlParamsAppliObs() {
61
	public function filtrerUrlParamsAppliObs() {
75
		$this->appli = self::APPLI_OBS;
Line 62... Line 76...
62
		$this->maintenirCompatibilitesParametres();
76
		$this->maintenirCompatibilitesParametres();
63
 
77
 
Line 79... Line 93...
79
	}
93
	}
Line 80... Line 94...
80
 
94
 
81
	private function maintenirCompatibilitesParametres() {
95
	private function maintenirCompatibilitesParametres() {
Line 82... Line 96...
82
		$this->renommerParametres();
96
		$this->renommerParametres();
83
 
97
 
-
 
98
		if ($this->etreAppliImg() && !isset($this->parametres['masque.tag_del']) && isset($this->parametres['masque.tag'])) {
-
 
99
			$this->parametres['masque.tag_del'] = $this->parametres['masque.tag'];
-
 
100
			unset($this->parametres['masque.tag']);
-
 
101
		}
-
 
102
		if ($this->etreAppliobs() && !isset($this->parametres['masque.tag_cel']) && isset($this->parametres['masque.tag'])) {
84
		if (!isset($this->parametres['masque.tag_del']) && isset($this->parametres['masque.tag'])) {
103
			$this->parametres['masque.tag_cel'] = $this->parametres['masque.tag'];
85
			$this->parametres['masque.tag_del'] = $this->parametres['masque.tag'];
104
			unset($this->parametres['masque.tag']);
Line 86... Line 105...
86
		}
105
		}
87
	}
106
	}
Line 172... Line 191...
172
		$this->filtrerFamille();
191
		$this->filtrerFamille();
173
		$this->filtrerIdZoneGeo();
192
		$this->filtrerIdZoneGeo();
174
		$this->filtrerCommune();
193
		$this->filtrerCommune();
175
		$this->filtrerType();
194
		$this->filtrerType();
Line 176... Line -...
176
 
-
 
177
		$this->filtrerTag();
195
 
178
		$this->filtrerTagCel();
196
		$this->filtrerTagCel();
179
		$this->filtrerTagDel();
197
		$this->filtrerTagDel();
Line 245... Line 263...
245
	}
263
	}
Line 246... Line 264...
246
 
264
 
247
	private function filtrerDate() {
265
	private function filtrerDate() {
248
		if (isset($this->parametres['masque.date'])) {
266
		if (isset($this->parametres['masque.date'])) {
249
			$date = $this->parametres['masque.date'];
-
 
250
			// une année, TODO: masque.annee
267
			$date = $this->parametres['masque.date'];
251
			$paramFiltre = null;
268
			$paramFiltre = null;
-
 
269
			if (preg_match('/^\d{4}$/', $date)) {
-
 
270
				$paramFiltre = $date;
-
 
271
			} else if (strpos($date, '/') !== false) {
-
 
272
				// Format d'entrée DEL : jj/mm/yyyy
-
 
273
				list($jour, $mois, $annee) = explode('/', $date);
-
 
274
				$paramFiltre = "$annee-$mois-$jour";
252
			if (is_numeric($date)) {
275
			} else if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $date)) {
253
				$paramFiltre = $date;
-
 
254
			} elseif(strpos($date, '/' !== false) && ($x = strtotime(str_replace('/', '-', $date)))) {
-
 
255
				$paramFiltre = $x;
-
 
256
			} elseif(strpos($date, '-' !== false) && ($x = strtotime($date)) ) {
-
 
257
				$paramFiltre = $x;
276
				$paramFiltre = $date;
258
			}
277
			}
259
			$this->parametresFiltres['masque.date'] = $paramFiltre;
278
			$this->parametresFiltres['masque.date'] = $paramFiltre;
260
		}
279
		}
Line 320... Line 339...
320
			$paramFiltre = str_replace(array('-',' '), '_', $this->parametres['masque.commune']);
339
			$paramFiltre = str_replace(array('-',' '), '_', $this->parametres['masque.commune']);
321
			$this->parametresFiltres['masque.commune'] = $paramFiltre;
340
			$this->parametresFiltres['masque.commune'] = $paramFiltre;
322
		}
341
		}
323
	}
342
	}
Line 324... Line -...
324
 
-
 
325
	// masque.tag, idem que pour masque.genre et masque.commune
-
 
326
	private function filtrerTag() {
-
 
327
		if (isset($this->parametres['masque.tag'])) {
-
 
328
			$tagsArray = explode(',', $this->parametres['masque.tag']);
-
 
329
			$tagsTrimes = array_map('trim', $tagsArray);
-
 
330
			$tagsFiltres = array_filter($tagsTrimes);
-
 
331
			$paramFiltre = implode('|', $tagsFiltres);
-
 
332
			$this->parametresFiltres['masque.tag'] = $paramFiltre;
-
 
333
		}
-
 
334
	}
-
 
335
 
343
 
336
	private function filtrerTagCel() {
344
	private function filtrerTagCel() {
337
		if (isset($this->parametres['masque.tag_cel'])) {
345
		if (isset($this->parametres['masque.tag_cel'])) {
338
			$this->parametresFiltres['masque.tag_cel'] = $this->construireTableauTags($this->parametres['masque.tag_cel'], 'OR', ',');
346
			$this->parametresFiltres['masque.tag_cel'] = $this->construireTableauTags($this->parametres['masque.tag_cel'], 'OR', ',');
339
		} else if (isset($this->parametres['masque'])) {
347
		} else if (isset($this->parametres['masque'])) {