Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 1106 Rev 1132
Line 29... Line 29...
29
	/**
29
	/**
30
	 * Méthode appelée avec une requête de type GET.
30
	 * Méthode appelée avec une requête de type GET.
31
	 */
31
	 */
32
	public function getElement($ressources) {
32
	public function getElement($ressources) {
33
		$retour = null;
33
		$retour = null;
-
 
34
		if($this->parametres == null) {
-
 
35
			$this->parametres = array();
-
 
36
		}
34
		extract($this->parametres);
37
		extract($this->parametres);
35
		//Chronometre::chrono("Avant groupage");
38
		//Chronometre::chrono("Avant groupage");
Line 36... Line 39...
36
 
39
 
37
		$action = array_shift($ressources);
40
		$action = array_shift($ressources);
Line 241... Line 244...
241
		$marqueurs = array(
244
		$marqueurs = array(
242
			'stats' => array('stations' => 0, 'communes' => 0, 'observations' => 0),
245
			'stats' => array('stations' => 0, 'communes' => 0, 'observations' => 0),
243
			'points' => null
246
			'points' => null
244
		);
247
		);
Line 245... Line 248...
245
 
248
 
246
		if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
249
		if (isset($this->parametres['ne']) && $this->parametres['sw'] && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
247
			$ne = $this->decomposerLatLng($this->parametres['ne']);
250
			$ne = $this->decomposerLatLng($this->parametres['ne']);
248
			$sw = $this->decomposerLatLng($this->parametres['sw']);
251
			$sw = $this->decomposerLatLng($this->parametres['sw']);
Line 249... Line 252...
249
			$marqueurs['points'] = CartoGroupage::creerGroupesQuadtree($emplacements, $ne['lat'], $ne['lng'], $sw['lat'], $sw['lng'], $zoom);
252
			$marqueurs['points'] = CartoGroupage::creerGroupesQuadtree($emplacements, $ne['lat'], $ne['lng'], $sw['lat'], $sw['lng'], $zoom);
Line 318... Line 321...
318
					}
321
					}
319
				}
322
				}
320
			}
323
			}
321
		}
324
		}
Line 322... Line 325...
322
 
325
 
323
		if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
326
		if (isset($this->parametres['ne']) && $this->parametres['sw'] && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
324
			$ne = $this->decomposerLatLng($this->parametres['ne']);
327
			$ne = $this->decomposerLatLng($this->parametres['ne']);
325
			$sw = $this->decomposerLatLng($this->parametres['sw']);
328
			$sw = $this->decomposerLatLng($this->parametres['sw']);
326
			$marqueurs['points'] = CartoGroupage::creerGroupesQuadtree(&$points, $ne['lat'], $ne['lng'], $sw['lat'], $sw['lng'], $zoom);
329
			$marqueurs['points'] = CartoGroupage::creerGroupesQuadtree(&$points, $ne['lat'], $ne['lng'], $sw['lat'], $sw['lng'], $zoom);
327
		} else {
330
		} else {
Line 383... Line 386...
383
	 * Données pour l'affichage des obs d'une station
386
	 * Données pour l'affichage des obs d'une station
384
	 */
387
	 */
385
	public function getObservations($params) {
388
	public function getObservations($params) {
386
		$resultats = array();
389
		$resultats = array();
387
		$total = 0;
390
		$total = 0;
388
		if (!$this->etreNull($this->parametres['station'])) {
391
		if (isset($this->parametres['station']) && !$this->etreNull($this->parametres['station'])) {
389
			$requete = 	'SELECT SQL_CALC_FOUND_ROWS id, identifiant, nom_sel, nom_ret, num_nom_sel, num_nom_ret, num_taxon, famille, '.
392
			$requete = 	'SELECT SQL_CALC_FOUND_ROWS id, identifiant, nom_sel, nom_ret, num_nom_sel, num_nom_ret, num_taxon, famille, '.
390
						'	lieudit, location, date_observation, milieu, commentaire, '.
393
						'	lieudit, location, date_observation, milieu, commentaire, '.
391
						'	sector, x_utm, y_utm, insee_code, date_transmission '.
394
						'	sector, x_utm, y_utm, insee_code, date_transmission '.
392
						'FROM cel_inventory AS i '.
395
						'FROM cel_inventory AS i '.
393
						'	LEFT JOIN locations AS l '.
396
						'	LEFT JOIN locations AS l '.
Line 842... Line 845...
842
		return $sql;
845
		return $sql;
843
	}
846
	}
Line 844... Line 847...
844
 
847
 
845
	private function construireWhereRectangleStation() {
848
	private function construireWhereRectangleStation() {
846
		$sql = '';
849
		$sql = '';
847
		if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
850
		if (isset($this->parametres['ne']) && isset($this->parametres['sw']) && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
848
			$ne = $this->decomposerLatLng($this->parametres['ne']);
851
			$ne = $this->decomposerLatLng($this->parametres['ne']);
Line 849... Line 852...
849
			$sw = $this->decomposerLatLng($this->parametres['sw']);
852
			$sw = $this->decomposerLatLng($this->parametres['sw']);
850
 
853
 
Line 864... Line 867...
864
		return $sql;
867
		return $sql;
865
	}
868
	}
Line 866... Line 869...
866
 
869
 
867
	private function construireWhereRectangleStationOR() {
870
	private function construireWhereRectangleStationOR() {
868
		$sql = '';
871
		$sql = '';
869
		if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
872
		if (isset($this->parametres['ne']) && isset($this->parametres['sw']) && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
870
			$ne = $this->decomposerLatLng($this->parametres['ne']);
873
			$ne = $this->decomposerLatLng($this->parametres['ne']);
Line 871... Line 874...
871
			$sw = $this->decomposerLatLng($this->parametres['sw']);
874
			$sw = $this->decomposerLatLng($this->parametres['sw']);
872
 
875
 
Line 886... Line 889...
886
		return $sql;
889
		return $sql;
887
	}
890
	}
Line 888... Line 891...
888
 
891
 
889
	private function construireWhereRectangleCommune() {
892
	private function construireWhereRectangleCommune() {
890
		$sql = '';
893
		$sql = '';
891
		if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
894
		if (isset($this->parametres['ne']) && isset($this->parametres['sw']) && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
892
			$ne = $this->decomposerLatLng($this->parametres['ne']);
895
			$ne = $this->decomposerLatLng($this->parametres['ne']);
Line 893... Line 896...
893
			$sw = $this->decomposerLatLng($this->parametres['sw']);
896
			$sw = $this->decomposerLatLng($this->parametres['sw']);
894
 
897
 
Line 907... Line 910...
907
		return $sql;
910
		return $sql;
908
	}
911
	}
Line 909... Line 912...
909
 
912
 
910
	private function construireWhereRectangleCommuneOR() {
913
	private function construireWhereRectangleCommuneOR() {
911
		$sql = '';
914
		$sql = '';
912
		if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
915
		if (isset($this->parametres['ne']) && isset($this->parametres['sw']) && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
913
			$ne = $this->decomposerLatLng($this->parametres['ne']);
916
			$ne = $this->decomposerLatLng($this->parametres['ne']);
Line 914... Line 917...
914
			$sw = $this->decomposerLatLng($this->parametres['sw']);
917
			$sw = $this->decomposerLatLng($this->parametres['sw']);
915
 
918
 
Line 930... Line 933...
930
 
933
 
931
	private function construireWhereDept() {
934
	private function construireWhereDept() {
932
		$sql = '';
935
		$sql = '';
933
		// Récupération des coordonnées depuis l'id station
936
		// Récupération des coordonnées depuis l'id station
934
		extract($this->parametres);
937
		extract($this->parametres);
935
		if (!$this->etreNull($dept)) {
938
		if (isset($this->parametres['dept']) && !$this->etreNull($dept)) {
936
			$dept = $this->traiterValeursMultiples($dept);
939
			$dept = $this->traiterValeursMultiples($dept);
937
			$sql = " AND code IN ($dept) ";
940
			$sql = " AND code IN ($dept) ";
938
		}
941
		}
939
		return $sql;
942
		return $sql;
Line 940... Line 943...
940
	}
943
	}
941
 
944
 
942
	private function construireWhereCommune() {
945
	private function construireWhereCommune() {
943
		$sql = '';
946
		$sql = '';
944
		// Récupération des coordonnées depuis l'id station
947
		// Récupération des coordonnées depuis l'id station
945
		extract($this->parametres);
948
		extract($this->parametres);
946
		if (!$this->etreNull($commune)) {
949
		if (isset($this->parametres['commune']) && !$this->etreNull($commune)) {
947
			$commune = $this->proteger($commune);
950
			$commune = $this->proteger($commune);
948
			$sql = " AND location LIKE $commune ";
951
			$sql = " AND location LIKE $commune ";
949
		}
952
		}
Line 950... Line 953...
950
		return $sql;
953
		return $sql;
951
	}
954
	}
952
 
955
 
953
	private function construireWhereCommuneSansCoordonneesAvecSensibles() {
956
	private function construireWhereCommuneSansCoordonneesAvecSensibles() {
954
		$sql = '';
957
		$sql = '';
955
		// Récupération des coordonnées depuis l'id station
958
		// Récupération des coordonnées depuis l'id station
956
		extract($this->parametres);
959
		extract($this->parametres);
957
		if (!$this->etreNull($commune)) {
960
		if (isset($this->parametres['commune']) && !$this->etreNull($commune)) {
958
			$commune = $this->proteger($commune);
961
			$commune = $this->proteger($commune);
959
			$sql = " AND location LIKE $commune ";
962
			$sql = " AND location LIKE $commune ";
Line 971... Line 974...
971
 
974
 
972
	private function construireWhereUtilisateur() {
975
	private function construireWhereUtilisateur() {
973
		$sql = '';
976
		$sql = '';
974
		// Récupération des coordonnées depuis l'id station
977
		// Récupération des coordonnées depuis l'id station
975
		extract($this->parametres);
978
		extract($this->parametres);
976
		if (!$this->etreNull($utilisateur)) {
979
		if (isset($this->parametres['utilisateur']) && !$this->etreNull($utilisateur)) {
977
			$utilisateur = $this->proteger($utilisateur);
980
			$utilisateur = $this->proteger($utilisateur);
978
			$sql = " AND identifiant = $utilisateur ";
981
			$sql = " AND identifiant = $utilisateur ";
979
		}
982
		}
980
		return $sql;
983
		return $sql;
Line 981... Line 984...
981
	}
984
	}
982
 
985
 
983
	private function construireWhereNumTaxon() {
986
	private function construireWhereNumTaxon() {
984
		$sql = '';
987
		$sql = '';
985
		// Récupération des coordonnées depuis l'id station
988
		// Récupération des coordonnées depuis l'id station
986
		extract($this->parametres);
989
		extract($this->parametres);
987
		if (!$this->etreNull($num_taxon)) {
990
		if (isset($this->parametres['num_taxon']) && !$this->etreNull($num_taxon)) {
988
			$num_taxon = $this->proteger($num_taxon);
991
			$num_taxon = $this->proteger($num_taxon);
989
			$sql = " AND num_taxon = $num_taxon ";
992
			$sql = " AND num_taxon = $num_taxon ";
990
		}
993
		}
Line 991... Line 994...
991
		return $sql;
994
		return $sql;
992
	}
995
	}
993
 
996
 
994
	private function construireWhereProjet() {
997
	private function construireWhereProjet() {
-
 
998
		$sql = '';
995
		$sql = '';
999
		// Récupération des coordonnées depuis l'id station
996
		// Récupération des coordonnées depuis l'id station
1000
		extract($this->parametres);
997
		extract($this->parametres);
1001
		if(isset($this->parametres['projet']) ) {
-
 
1002
			$projet_sql = $this->getSqlWhereProjet($projet);
998
		$projet_sql = $this->getSqlWhereProjet($projet);
1003
			if (!$this->etreNull($projet_sql)) {
999
		if (!$this->etreNull($projet_sql)) {
1004
				$sql = " AND ($projet_sql) ";
1000
			$sql = " AND ($projet_sql) ";
1005
			}
Line 1001... Line 1006...
1001
		}
1006
		}
Line 1036... Line 1041...
1036
 
1041
 
1037
	private function construireWhereTag() {
1042
	private function construireWhereTag() {
1038
		$sql = '';
1043
		$sql = '';
1039
		// Récupération des coordonnées depuis l'id station
1044
		// Récupération des coordonnées depuis l'id station
-
 
1045
		extract($this->parametres);
1040
		extract($this->parametres);
1046
		if(isset($this->parametres['tag']) ) {
1041
		$tag_sql = $this->getSqlWhereObsAvecImagesTaguees($tag);
1047
			$tag_sql = $this->getSqlWhereObsAvecImagesTaguees($tag);
1042
		if (!$this->etreNull($tag_sql)) {
1048
			if (!$this->etreNull($tag_sql)) {
-
 
1049
				$sql = " AND ($tag_sql) ";
1043
			$sql = " AND ($tag_sql) ";
1050
			}
1044
		}
1051
		}
1045
		return $sql;
1052
		return $sql;
Line 1046... Line 1053...
1046
	}
1053
	}
Line 1210... Line 1217...
1210
		}
1217
		}
1211
		return $station_infos;
1218
		return $station_infos;
1212
	}
1219
	}
Line 1213... Line 1220...
1213
 
1220
 
1214
	private function decomposerParametreDate() {
1221
	private function decomposerParametreDate() {
1215
		$date_infos = array();
1222
		$date_infos = array(null,null);
1216
		if (isset($this->parametres['date'])) {
1223
		if (isset($this->parametres['date'])) {
1217
			$date = $this->parametres['date'];
1224
			$date = $this->parametres['date'];
1218
			if (strpos($date, ':')) {
1225
			if (strpos($date, ':')) {
1219
				list($type, $date) = explode(':', $date);
1226
				list($type, $date) = explode(':', $date);
Line 1230... Line 1237...
1230
		}
1237
		}
1231
		return $date_infos;
1238
		return $date_infos;
1232
	}
1239
	}
Line 1233... Line 1240...
1233
 
1240
 
1234
	private function decomposerParametreTaxon() {
1241
	private function decomposerParametreTaxon() {
1235
		$nom_infos = array();
1242
		$nom_infos = array(null,null);
1236
		if (isset($this->parametres['taxon'])) {
1243
		if (isset($this->parametres['taxon'])) {
1237
			$taxon = $this->parametres['taxon'];
1244
			$taxon = $this->parametres['taxon'];
1238
			if (strpos($taxon, ':')) {
1245
			if (strpos($taxon, ':')) {
1239
				$nom_infos = explode(':', $taxon);
1246
				$nom_infos = explode(':', $taxon);
Line 1243... Line 1250...
1243
		}
1250
		}
1244
		return $nom_infos;
1251
		return $nom_infos;
1245
	}
1252
	}
Line 1246... Line 1253...
1246
 
1253
 
1247
	private function decomposerParametreCommentaire() {
1254
	private function decomposerParametreCommentaire() {
1248
		$commentaire_infos = array();
1255
		$commentaire_infos = array(null,null);
1249
		if (isset($this->parametres['commentaire'])) {
1256
		if (isset($this->parametres['commentaire'])) {
1250
			$commentaire = $this->parametres['commentaire'];
1257
			$commentaire = $this->parametres['commentaire'];
1251
			if (strpos($commentaire, ':')) {
1258
			if (strpos($commentaire, ':')) {
1252
				$commentaire_infos = explode(':', $commentaire);
1259
				$commentaire_infos = explode(':', $commentaire);