Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 1622 Rev 1765
Line 120... Line 120...
120
					$this->construireWhereProjet().
120
					$this->construireWhereProjet().
121
					$this->construireWhereTag().
121
					$this->construireWhereTag().
122
					$this->construireWhereNombreDeJours().
122
					$this->construireWhereNombreDeJours().
123
					' GROUP BY id_coord';
123
					' GROUP BY id_coord';
Line 124... Line 124...
124
		
124
		
125
		$resultats_emplacements = $this->executerRequete($requete);
125
		$resultats_emplacements = Cel::db()->executerRequete($requete);
126
		$emplacements = $this->traiterEmplacements($resultats_emplacements, $this->compterObservations($params));
126
		$emplacements = $this->traiterEmplacements($resultats_emplacements, $this->compterObservations($params));
127
		return $emplacements;
127
		return $emplacements;
Line 128... Line 128...
128
	}
128
	}
Line 156... Line 156...
156
					$this->construireWherePhotosSeulement().
156
					$this->construireWherePhotosSeulement().
157
					$this->construireWhereProjet().
157
					$this->construireWhereProjet().
158
					$this->construireWhereTag().
158
					$this->construireWhereTag().
159
					$this->construireWhereNombreDeJours();
159
					$this->construireWhereNombreDeJours();
Line 160... Line 160...
160
 
160
 
161
		$resultats_nb_obs = $this->executerRequete($requete);
161
		$resultats_nb_obs = Cel::db()->executerRequete($requete);
162
		return $resultats_nb_obs[0]['nb'];
162
		return $resultats_nb_obs[0]['nb'];
Line 163... Line 163...
163
	}
163
	}
164
 
164
 
Line 342... Line 342...
342
						$this->construireWhereTag().
342
						$this->construireWhereTag().
343
						$this->construireWhereNombreDeJours().
343
						$this->construireWhereNombreDeJours().
344
	                    'ORDER BY nom_sel ASC '.
344
	                    'ORDER BY nom_sel ASC '.
345
	                    "LIMIT {$this->start},{$this->limit} ";
345
	                    "LIMIT {$this->start},{$this->limit} ";
346
			//echo $requete;exit;
346
			//echo $requete;exit;
347
			$resultats = $this->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
347
			$resultats = Cel::db()->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
348
			$requete = 'SELECT FOUND_ROWS()';
348
			$requete = 'SELECT FOUND_ROWS()';
349
			$total = (int) $this->requeter($requete, self::SQL_RETOUR_COLONNE);
349
			$total = (int) Cel::db()->requeter($requete, self::SQL_RETOUR_COLONNE);
350
		}
350
		}
Line 351... Line 351...
351
 
351
 
352
		// Post-traitement
352
		// Post-traitement
353
		$observations = $this->traiterObservations($resultats, $total);
353
		$observations = $this->traiterObservations($resultats, $total);
Line 488... Line 488...
488
					$this->construireWhereTag().
488
					$this->construireWhereTag().
489
					$this->construireWhereNombreDeJours().
489
					$this->construireWhereNombreDeJours().
490
					'ORDER BY nom_ret ASC '.
490
					'ORDER BY nom_ret ASC '.
491
                    "LIMIT {$this->start},{$this->limit} ";
491
                    "LIMIT {$this->start},{$this->limit} ";
492
		//$this->debug[] = $requete;
492
		//$this->debug[] = $requete;
493
		$resultats = $this->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
493
		$resultats = Cel::db()->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
494
		//echo $requete;exit;
494
		//echo $requete;exit;
495
		$requete = 'SELECT FOUND_ROWS()';
495
		$requete = 'SELECT FOUND_ROWS()';
496
		$taxons['total'] = (int) $this->requeter($requete, self::SQL_RETOUR_COLONNE);
496
		$taxons['total'] = (int) Cel::db()->requeter($requete, self::SQL_RETOUR_COLONNE);
Line 497... Line 497...
497
 
497
 
498
		// Post-traitement
498
		// Post-traitement
Line 499... Line 499...
499
		$taxons['taxons'] = $this->traiterTaxons($resultats);
499
		$taxons['taxons'] = $this->traiterTaxons($resultats);
Line 523... Line 523...
523
		$sql = '';
523
		$sql = '';
524
		// Récupération des coordonnées depuis l'id station
524
		// Récupération des coordonnées depuis l'id station
525
		extract($this->decomposerParametreStation());
525
		extract($this->decomposerParametreStation());
526
		if (isset($type)) {
526
		if (isset($type)) {
527
			if ($type == self::MARQUEUR_COMMUNE) {
527
			if ($type == self::MARQUEUR_COMMUNE) {
528
				$lat = $this->proteger($lat.'%');
528
				$lat = Cel::db()->proteger($lat.'%');
529
				$lng = $this->proteger($lng.'%');
529
				$lng = Cel::db()->proteger($lng.'%');
530
				$sql = " AND wgs84_latitude LIKE $lat AND wgs84_longitude LIKE $lng ";
530
				$sql = " AND wgs84_latitude LIKE $lat AND wgs84_longitude LIKE $lng ";
531
			}  else if ($type == self::MARQUEUR_STATION) {
531
			}  else if ($type == self::MARQUEUR_STATION) {
532
				$lat = $this->proteger($lat.'%');
532
				$lat = Cel::db()->proteger($lat.'%');
533
				$lng = $this->proteger($lng.'%');
533
				$lng = Cel::db()->proteger($lng.'%');
534
				$sql = " AND (latitude LIKE $lat AND longitude LIKE $lng) ";
534
				$sql = " AND (latitude LIKE $lat AND longitude LIKE $lng) ";
535
			}
535
			}
536
		}
536
		}
537
		return $sql;
537
		return $sql;
538
	}
538
	}
Line 541... Line 541...
541
		$sql = '(';
541
		$sql = '(';
542
		// Récupération des coordonnées depuis l'id station
542
		// Récupération des coordonnées depuis l'id station
543
		extract($this->decomposerParametreStation());
543
		extract($this->decomposerParametreStation());
544
		if (isset($type)) {
544
		if (isset($type)) {
545
			if ($type == self::MARQUEUR_COMMUNE) {
545
			if ($type == self::MARQUEUR_COMMUNE) {
546
				$lat = $this->proteger($lat);
546
				$lat = Cel::db()->proteger($lat);
547
				$lng = $this->proteger($lng);
547
				$lng = Cel::db()->proteger($lng);
548
				$sql = " AND wgs84_latitude LIKE $lat AND wgs84_longitude LIKE $lng ";
548
				$sql = " AND wgs84_latitude LIKE $lat AND wgs84_longitude LIKE $lng ";
549
			}  else if ($type == self::MARQUEUR_STATION) {
549
			}  else if ($type == self::MARQUEUR_STATION) {
550
				$lat = $this->proteger($lat.'%');
550
				$lat = Cel::db()->proteger($lat.'%');
551
				$lng = $this->proteger($lng.'%');
551
				$lng = Cel::db()->proteger($lng.'%');
552
				$sql = " AND (latitude LIKE $lat AND longitude LIKE $lng) ";
552
				$sql = " AND (latitude LIKE $lat AND longitude LIKE $lng) ";
553
			}
553
			}
554
		}
554
		}
555
		$sql .= ' AND (mots_cles_texte IS NULL OR mots_cles_texte NOT LIKE "%sensible%" ) ';
555
		$sql .= ' AND (mots_cles_texte IS NULL OR mots_cles_texte NOT LIKE "%sensible%" ) ';
556
		return $sql;
556
		return $sql;
Line 558... Line 558...
558
 
558
 
559
	private function construireWhereCommentaire() {
559
	private function construireWhereCommentaire() {
560
		$sql = '';
560
		$sql = '';
561
		list($type, $commentaire) = $this->decomposerParametreCommentaire();
561
		list($type, $commentaire) = $this->decomposerParametreCommentaire();
562
		if (!$this->etreNull($commentaire)) {
562
		if (!$this->etreNull($commentaire)) {
563
			$commentaire = $this->proteger('%'.$commentaire.'%');
563
			$commentaire = Cel::db()->proteger('%'.$commentaire.'%');
564
			switch ($type) {
564
			switch ($type) {
565
				case '*' :
565
				case '*' :
566
					$sql = $this->obtenirConditionPourCommentaires($commentaire);
566
					$sql = $this->obtenirConditionPourCommentaires($commentaire);
567
					$sql = " AND (commentaire LIKE $commentaire OR ($sql)) ";
567
					$sql = " AND (commentaire LIKE $commentaire OR ($sql)) ";
Line 588... Line 588...
588
 
588
 
589
	private function construireWhereNomTaxon() {
589
	private function construireWhereNomTaxon() {
590
		$sql = '';
590
		$sql = '';
591
		list($type, $nom) = $this->decomposerParametreTaxon();
591
		list($type, $nom) = $this->decomposerParametreTaxon();
592
		if (!$this->etreNull($nom)) {
592
		if (!$this->etreNull($nom)) {
593
			$nom = $this->proteger($nom.'%');
593
			$nom = Cel::db()->proteger($nom.'%');
594
			switch ($type) {
594
			switch ($type) {
595
				case '*' :
595
				case '*' :
596
					$sql = " AND (nom_ret LIKE $nom OR nom_sel LIKE $nom OR famille LIKE $nom) ";
596
					$sql = " AND (nom_ret LIKE $nom OR nom_sel LIKE $nom OR famille LIKE $nom) ";
597
					break;
597
					break;
Line 613... Line 613...
613
	
613
	
614
	private function construireWhereReferentiel() {
614
	private function construireWhereReferentiel() {
615
		$sql = '';
615
		$sql = '';
616
		extract($this->parametres);
616
		extract($this->parametres);
617
		if (isset($referentiel) && !$this->etreNull($referentiel)) {
617
		if (isset($referentiel) && !$this->etreNull($referentiel)) {
618
			$referentiel = $this->proteger($referentiel.'%');
618
			$referentiel = Cel::db()->proteger($referentiel.'%');
619
			$sql = ' AND co.nom_referentiel LIKE '.$referentiel.' ';
619
			$sql = ' AND co.nom_referentiel LIKE '.$referentiel.' ';
620
		}
620
		}
621
		return $sql;
621
		return $sql;
Line 625... Line 625...
625
		$sql = '';
625
		$sql = '';
626
		// Récupération des coordonnées depuis l'id station
626
		// Récupération des coordonnées depuis l'id station
627
		list($type, $date) = $this->decomposerParametreDate();
627
		list($type, $date) = $this->decomposerParametreDate();
Line 628... Line 628...
628
 
628
 
629
		if (!$this->etreNull($date)) {
629
		if (!$this->etreNull($date)) {
630
			$date = $this->proteger($date.'%');
630
			$date = Cel::db()->proteger($date.'%');
631
			switch ($type) {
631
			switch ($type) {
632
				case '*' :
632
				case '*' :
633
					$sql = " AND (
633
					$sql = " AND (
634
						date_observation LIKE $date
634
						date_observation LIKE $date
Line 752... Line 752...
752
			$this->construireWhereProjet().
752
			$this->construireWhereProjet().
753
			$this->construireWhereTag().
753
			$this->construireWhereTag().
754
			'ORDER BY utilisateur ASC, ordre ASC';
754
			'ORDER BY utilisateur ASC, ordre ASC';
755
		//$this->debug[] = $requete;
755
		//$this->debug[] = $requete;
756
		//die($requete);
756
		//die($requete);
757
		$resultats = $this->executerRequete($requete);
757
		$resultats = Cel::db()->executerRequete($requete);
Line 758... Line 758...
758
 
758
 
759
		$observations = null;
759
		$observations = null;
760
		if ($resultats != false) {
760
		if ($resultats != false) {
761
			$observations = array();
761
			$observations = array();
Line 888... Line 888...
888
		// Récupération des coordonnées depuis l'id station
888
		// Récupération des coordonnées depuis l'id station
889
		extract($this->parametres);
889
		extract($this->parametres);
890
		if (isset($dept) && !$this->etreNull($dept)) {
890
		if (isset($dept) && !$this->etreNull($dept)) {
891
			$valeurs_a_proteger = explode(',',trim($dept));
891
			$valeurs_a_proteger = explode(',',trim($dept));
892
			foreach ($valeurs_a_proteger as $valeur) {
892
			foreach ($valeurs_a_proteger as $valeur) {
893
				$valeurs_protegees[] = '(ce_zone_geo LIKE '.$this->bdd->quote('INSEE-C:'.$valeur.'%').') ';
893
				$valeurs_protegees[] = '(ce_zone_geo LIKE '.Cel::db()->quote('INSEE-C:'.$valeur.'%').') ';
894
			}
894
			}
895
			$valeurs = implode(' OR ', $valeurs_protegees);
895
			$valeurs = implode(' OR ', $valeurs_protegees);
896
			$sql = " AND ($valeurs) ";
896
			$sql = " AND ($valeurs) ";
897
		}
897
		}
898
		return $sql;
898
		return $sql;
Line 901... Line 901...
901
	private function construireWhereCommune() {
901
	private function construireWhereCommune() {
902
		$sql = '';
902
		$sql = '';
903
		// Récupération des coordonnées depuis l'id station
903
		// Récupération des coordonnées depuis l'id station
904
		extract($this->parametres);
904
		extract($this->parametres);
905
		if (isset($this->parametres['commune']) && !$this->etreNull($commune)) {
905
		if (isset($this->parametres['commune']) && !$this->etreNull($commune)) {
906
			$commune = $this->proteger($commune);
906
			$commune = Cel::db()->proteger($commune);
907
			$sql = " AND zone_geo LIKE $commune ";
907
			$sql = " AND zone_geo LIKE $commune ";
908
		}
908
		}
909
		return $sql;
909
		return $sql;
910
	}
910
	}
Line 911... Line 911...
911
 
911
 
912
	private function construireWhereCommuneSansCoordonneesAvecSensibles() {
912
	private function construireWhereCommuneSansCoordonneesAvecSensibles() {
913
		$sql = '';
913
		$sql = '';
914
		// Récupération des coordonnées depuis l'id station
914
		// Récupération des coordonnées depuis l'id station
915
		extract($this->parametres);
915
		extract($this->parametres);
916
		if (isset($this->parametres['commune']) && !$this->etreNull($commune)) {
916
		if (isset($this->parametres['commune']) && !$this->etreNull($commune)) {
917
			$commune = $this->proteger($commune);
917
			$commune = Cel::db()->proteger($commune);
918
			$sql = " AND zone_geo LIKE $commune ";
918
			$sql = " AND zone_geo LIKE $commune ";
919
			$sql .= " AND (
919
			$sql .= " AND (
920
			           		(
920
			           		(
921
			           			(latitude = '000null' OR latitude = '' OR latitude = 0 OR latitude IS NULL) ".
921
			           			(latitude = '000null' OR latitude = '' OR latitude = 0 OR latitude IS NULL) ".
Line 941... Line 941...
941
		$sql = '';
941
		$sql = '';
942
		// TODO tester si l'on recoit un id, un mail ou bien un nom ou prenom
942
		// TODO tester si l'on recoit un id, un mail ou bien un nom ou prenom
943
		// pour en faire une fonction polyvalente
943
		// pour en faire une fonction polyvalente
944
		extract($this->parametres);
944
		extract($this->parametres);
945
		if (isset($this->parametres['utilisateur']) && !$this->etreNull($utilisateur)) {
945
		if (isset($this->parametres['utilisateur']) && !$this->etreNull($utilisateur)) {
946
			$utilisateur = $this->proteger($utilisateur);
946
			$utilisateur = Cel::db()->proteger($utilisateur);
947
			$sql = " AND co.courriel_utilisateur = $utilisateur ";
947
			$sql = " AND co.courriel_utilisateur = $utilisateur ";
948
		}
948
		}
949
		return $sql;
949
		return $sql;
950
	}
950
	}
Line 953... Line 953...
953
	private function construireWhereNumTaxon() {
953
	private function construireWhereNumTaxon() {
954
		$sql = '';
954
		$sql = '';
955
		// Récupération des coordonnées depuis l'id station
955
		// Récupération des coordonnées depuis l'id station
956
		extract($this->parametres);
956
		extract($this->parametres);
957
		if (isset($this->parametres['num_taxon']) && !$this->etreNull($num_taxon)) {
957
		if (isset($this->parametres['num_taxon']) && !$this->etreNull($num_taxon)) {
958
		$num_taxon = $this->proteger($num_taxon);
958
		$num_taxon = Cel::db()->proteger($num_taxon);
959
		$sql = " AND nt = $num_taxon ";
959
		$sql = " AND nt = $num_taxon ";
960
		}
960
		}
961
		return $sql;
961
		return $sql;
962
	}
962
	}
Line 965... Line 965...
965
		$sql = '';
965
		$sql = '';
966
		// Récupération des coordonnées depuis l'id station
966
		// Récupération des coordonnées depuis l'id station
967
		extract($this->parametres);
967
		extract($this->parametres);
968
		if (isset($this->parametres['num_taxon']) && !$this->etreNull($num_taxon)) {
968
		if (isset($this->parametres['num_taxon']) && !$this->etreNull($num_taxon)) {
969
			$sous_taxons = $this->obtenirSousTaxons($this->parametres['num_taxon']);
969
			$sous_taxons = $this->obtenirSousTaxons($this->parametres['num_taxon']);
970
			$num_taxon = $this->proteger($num_taxon);
970
			$num_taxon = Cel::db()->proteger($num_taxon);
971
			if(!empty($sous_taxons)) {
971
			if(!empty($sous_taxons)) {
972
				$sql_in_sous_tax = implode(',', $sous_taxons);
972
				$sql_in_sous_tax = implode(',', $sous_taxons);
973
				$sql = " AND (nt = $num_taxon OR ".
973
				$sql = " AND (nt = $num_taxon OR ".
974
							"nom_sel_nn IN (".$sql_in_sous_tax.") OR ".
974
							"nom_sel_nn IN (".$sql_in_sous_tax.") OR ".
975
							"nom_ret_nn IN (".$sql_in_sous_tax.") ".
975
							"nom_ret_nn IN (".$sql_in_sous_tax.") ".
Line 1010... Line 1010...
1010
	 * Traitement de $projet pour construction du filtre dans la requête
1010
	 * Traitement de $projet pour construction du filtre dans la requête
1011
	 */
1011
	 */
1012
	private function getSqlWhereProjet($projet) {
1012
	private function getSqlWhereProjet($projet) {
1013
		$sql = null;
1013
		$sql = null;
1014
		if (isset($projet) && !$this->etreNull($projet)) {
1014
		if (isset($projet) && !$this->etreNull($projet)) {
1015
			$sql = 'co.mots_cles_texte LIKE '.$this->proteger('%'.$projet.'%');
1015
			$sql = 'co.mots_cles_texte LIKE '.Cel::db()->proteger('%'.$projet.'%');
1016
		}
1016
		}
1017
		return $sql;
1017
		return $sql;
1018
	}
1018
	}
Line 1019... Line 1019...
1019
	
1019
	
Line 1029... Line 1029...
1029
	
1029
	
1030
	private function construireWhereNombreDeJours() {
1030
	private function construireWhereNombreDeJours() {
1031
		$sql = null;
1031
		$sql = null;
1032
		extract($this->parametres);
1032
		extract($this->parametres);
1033
		if (isset($nbjours) && !$this->etreNull($nbjours)) {
1033
		if (isset($nbjours) && !$this->etreNull($nbjours)) {
1034
			$sql = ' AND DATEDIFF(CURDATE(),co.date_creation) <= '.$this->proteger($nbjours).' ';
1034
			$sql = ' AND DATEDIFF(CURDATE(),co.date_creation) <= '.Cel::db()->proteger($nbjours).' ';
1035
		}
1035
		}
1036
		return $sql;
1036
		return $sql;
Line 1037... Line 1037...
1037
	}
1037
	}
Line 1061... Line 1061...
1061
						$this->construireWhereProjet().
1061
						$this->construireWhereProjet().
1062
						(!$this->etreNull($tag_sql) ? "AND ($tag_sql) " : '').
1062
						(!$this->etreNull($tag_sql) ? "AND ($tag_sql) " : '').
1063
						'ORDER BY utilisateur ASC, ci.ordre ASC';
1063
						'ORDER BY utilisateur ASC, ci.ordre ASC';
1064
			//$this->debug[] = $requete;
1064
			//$this->debug[] = $requete;
1065
			//die($requete);
1065
			//die($requete);
1066
			$elements_tag = $this->executerRequete($requete);
1066
			$elements_tag = Cel::db()->executerRequete($requete);
Line 1067... Line 1067...
1067
			
1067
			
1068
			$requete_tag = array();
1068
			$requete_tag = array();
Line 1069... Line 1069...
1069
			if ($elements_tag != false && count($elements_tag) > 0) {
1069
			if ($elements_tag != false && count($elements_tag) > 0) {
Line 1132... Line 1132...
1132
		} else {
1132
		} else {
1133
			$mots_cles['motsCles'][] = $tags;
1133
			$mots_cles['motsCles'][] = $tags;
1134
		}
1134
		}
Line 1135... Line 1135...
1135
		
1135
		
1136
		foreach ($mots_cles['motsCles'] as $mot) {
1136
		foreach ($mots_cles['motsCles'] as $mot) {
1137
			$mots_cles['motsClesEncodesProteges'][] = $this->bdd->quote('%'.$mot.'%');
1137
			$mots_cles['motsClesEncodesProteges'][] = Cel::db()->quote('%'.$mot.'%');
1138
		}
1138
		}
1139
		$this->debug[] = $mots_cles;
1139
		$this->debug[] = $mots_cles;
1140
		return $mots_cles;
1140
		return $mots_cles;