Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 2143 Rev 2446
Line 60... Line 60...
60
	 * Les stations de la carte par défaut
60
	 * Les stations de la carte par défaut
61
	 */
61
	 */
62
	public function getStations($params) {
62
	public function getStations($params) {
63
		$json = null;
63
		$json = null;
64
		$requete =  'SELECT utm_secteur, utm_x, utm_y, wgs84_latitude AS latitude, wgs84_longitude AS longitude '.
64
		$requete =  'SELECT utm_secteur, utm_x, utm_y, wgs84_latitude AS latitude, wgs84_longitude AS longitude '.
65
                    'FROM cel_obs AS co '.
65
			'FROM cel_obs AS co '.
66
                    '   LEFT JOIN cel_zones_geo AS l '.
66
			'	LEFT JOIN cel_zones_geo AS l '.
67
                    '       ON (l.id_zone_geo = co.ce_zone_geo) '.
67
			'		ON (l.id_zone_geo = co.ce_zone_geo) '.
68
                    "WHERE transmission = '1' ".
68
			"WHERE transmission = '1' ".
69
					$this->construireWhereDept().
69
					$this->construireWhereDept().
70
                    $this->construireWhereCommune().
70
					$this->construireWhereCommune().
71
					$this->construireWherePhotosSeulement().
71
					$this->construireWherePhotosSeulement().
72
                    $this->construireWhereUtilisateur().
72
					$this->construireWhereUtilisateur().
73
					$this->construireWhereNumTaxon().
73
					$this->construireWhereNumTaxon().
74
					$this->construireWhereNomTaxon().
74
					$this->construireWhereNomTaxon().
75
					$this->construireWhereDate().
75
					$this->construireWhereDate().
76
					$this->construireWhereCommentaire().
76
					$this->construireWhereCommentaire().
77
					$this->construireWhereProjet().
77
					$this->construireWhereProjet().
Line 131... Line 131...
131
	public function getObservations($params) {
131
	public function getObservations($params) {
132
		$resultats = array();
132
		$resultats = array();
133
		$total = 0;
133
		$total = 0;
134
		if (!$this->etreNull($this->parametres['station'])) {
134
		if (!$this->etreNull($this->parametres['station'])) {
135
			$requete = 	'SELECT SQL_CALC_FOUND_ROWS id_observation, ce_utilisateur, courriel_utilisateur, '.
135
			$requete = 	'SELECT SQL_CALC_FOUND_ROWS id_observation, ce_utilisateur, courriel_utilisateur, '.
136
			            '   nom_sel, nom_ret, nom_sel_nn, nom_ret_nn, nt, famille, '.
136
				'	nom_sel, nom_ret, nom_sel_nn, nom_ret_nn, nt, famille, '.
137
						'	lieudit, zone_geo, date_observation, milieu, commentaire, '.
137
				'	lieudit, zone_geo, date_observation, milieu, commentaire, '.
138
						'	utm_secteur, utm_x, utm_y, id_zone_geo, date_transmission, nom_referentiel '.
138
				'	utm_secteur, utm_x, utm_y, id_zone_geo, date_transmission, nom_referentiel '.
139
						'FROM cel_obs AS co '.
139
				'FROM cel_obs AS co '.
140
						'	LEFT JOIN cel_zones_geo AS l '.
140
				'	LEFT JOIN cel_zones_geo AS l '.
141
						"		ON (l.id_zone_geo = co.ce_zone_geo) ".
141
				"		ON (l.id_zone_geo = co.ce_zone_geo) ".
142
						"WHERE transmission = '1' ".
142
				"WHERE transmission = '1' ".
143
						$this->construireWhereCoordonnees().
143
				$this->construireWhereCoordonnees().
144
						$this->construireWherePhotosSeulement().
144
				$this->construireWherePhotosSeulement().
145
						$this->construireWhereUtilisateur().
145
				$this->construireWhereUtilisateur().
146
						$this->construireWhereNumTaxon().
146
				$this->construireWhereNumTaxon().
147
						$this->construireWhereNomTaxon().
147
				$this->construireWhereNomTaxon().
148
						$this->construireWhereDate().
148
				$this->construireWhereDate().
149
						$this->construireWhereCommentaire().
149
				$this->construireWhereCommentaire().
150
						$this->construireWhereProjet().
150
				$this->construireWhereProjet().
151
						$this->construireWhereTag().
151
				$this->construireWhereTag().
152
	                    'ORDER BY nom_sel ASC '.
152
				'ORDER BY nom_sel ASC '.
153
	                    "LIMIT {$this->start},{$this->limit} ";
153
				"LIMIT {$this->start},{$this->limit} ";
154
			//die($requete);
154
			//die($requete);
155
			$resultats = Cel::db()->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
155
			$resultats = Cel::db()->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
Line 156... Line 156...
156
 
156
 
157
			$requete = 'SELECT FOUND_ROWS()';
157
			$requete = 'SELECT FOUND_ROWS()';
Line 350... Line 350...
350
		if (!$this->etreNull($commentaire)) {
350
		if (!$this->etreNull($commentaire)) {
351
			$commentaire = Cel::db()->proteger('%'.$commentaire.'%');
351
			$commentaire = Cel::db()->proteger('%'.$commentaire.'%');
352
			switch ($type) {
352
			switch ($type) {
353
				case '*' :
353
				case '*' :
354
					$sql = $this->obtenirConditionPourCommentaires($commentaire);
354
					$sql = $this->obtenirConditionPourCommentaires($commentaire);
355
					$sql = " AND (commentaire LIKE $commentaire OR ($sql)) ";
355
					$sql = " AND (ci.commentaire LIKE $commentaire OR ($sql)) ";
356
					break;
356
					break;
357
				case 'observation' :
357
				case 'observation' :
358
					$sql = " AND co.commentaire LIKE $commentaire ";
358
					$sql = " AND co.commentaire LIKE $commentaire ";
359
					break;
359
					break;
360
				case 'photo' :
360
				case 'photo' :
Line 503... Line 503...
503
	 * Récupération des identifiant d'utilisateur et des ordres des observations correspondant à une date.
503
	 * Récupération des identifiant d'utilisateur et des ordres des observations correspondant à une date.
504
	 * Retour sous forme de tableau : array[identifiant] = array(ordre, ordre...);
504
	 * Retour sous forme de tableau : array[identifiant] = array(ordre, ordre...);
505
	 */
505
	 */
506
	private function obtenirObsLieesImg($type, $param) {
506
	private function obtenirObsLieesImg($type, $param) {
507
		// Construction de la requête
507
		// Construction de la requête
508
		$requete = 	'SELECT DISTINCT id_observation AS id_obs, ce_utilisateur AS utilisateur '.
508
		$requete = 	'SELECT DISTINCT id_observation AS id_obs, co.ce_utilisateur AS utilisateur '.
509
			'FROM  cel_images ci'.
509
			'FROM cel_images ci'.
510
			'	LEFT JOIN cel_obs_images coi '.
-
 
511
			'		ON (coi.id_image = ci.id_image) '.
-
 
512
			'	LEFT JOIN cel_obs AS co '.
510
			'	INNER JOIN cel_obs AS co '.
513
			'		ON coi.id_observation = co.id_observation '.
511
			'		ON ci.ce_observation = co.id_observation '.
514
			'	LEFT JOIN locations AS l '.
512
			'	LEFT JOIN locations AS l '.
515
			'		ON (l.id_zone_geo = co.ce_zone_geo) '.
513
			'		ON (l.id_zone_geo = co.ce_zone_geo) '.
516
			"WHERE  transmission = '1' ".
514
			"WHERE co.transmission = '1' ".
517
			($type == 'date.photo' ? " AND (date_prise_de_vue LIKE ".str_replace('-', ':', $param).") " : '').
515
			($type == 'date.photo' ? " AND (date_prise_de_vue LIKE ".str_replace('-', ':', $param).") " : '').
518
			($type == 'date.ajout' ? " AND date_creation LIKE $param " : '').
516
			($type == 'date.ajout' ? " AND ci.date_creation LIKE $param " : '').
519
			($type == 'date.liaison' ? " AND date_liaison LIKE $param " : '').
517
			($type == 'date.liaison' ? " AND ci.date_liaison LIKE $param " : '').
520
			// TODO: recherche sur le xml
518
			// TODO: recherche sur le xml
521
			//($type == 'commentaire.meta' ? " AND ci.commentaire LIKE $param " : '').
519
			//($type == 'commentaire.meta' ? " AND ci.commentaire LIKE $param " : '').
522
			($type == 'commentaire.utilisateur' ? "	AND ci.commentaire LIKE $param " : '').
520
			($type == 'commentaire.utilisateur' ? "	AND ci.commentaire LIKE $param " : '').
523
			($type == 'commentaire.*' ? " AND (ci.commentaire LIKE $param) " : '').
521
			($type == 'commentaire.*' ? " AND (ci.commentaire LIKE $param) " : '').
524
			$this->construireWhereCoordonnees().
522
			$this->construireWhereCoordonnees().
Line 597... Line 595...
597
	}
595
	}
Line 598... Line 596...
598
 
596
 
599
	private function construireWherePhotosSeulement() {
597
	private function construireWherePhotosSeulement() {
600
		$sql = '';
598
		$sql = '';
601
		if (isset($this->parametres['photos']) && $this->parametres['photos'] == 1) {
599
		if (isset($this->parametres['photos']) && $this->parametres['photos'] == 1) {
602
			$sql = 'AND co.id_observation IN (SELECT DISTINCT id_observation FROM cel_obs_images) ';
600
			$sql = 'AND co.id_observation IN (SELECT DISTINCT ce_observation FROM cel_images) ';
603
		}
601
		}
604
		return $sql;
602
		return $sql;
Line 665... Line 663...
665
	private function getSqlWhereObsAvecImagesTaguees($tag) {
663
	private function getSqlWhereObsAvecImagesTaguees($tag) {
666
		$sql = null;
664
		$sql = null;
667
		if (isset($tag) && !$this->etreNull($tag)) {
665
		if (isset($tag) && !$this->etreNull($tag)) {
668
			$tag_sql = $this->getSqlWhereMotsCles($tag);
666
			$tag_sql = $this->getSqlWhereMotsCles($tag);
669
			// Construction de la requête
667
			// Construction de la requête
670
			$requete = 	'SELECT DISTINCT coi.id_observation AS id_obs,  ci.ce_utilisateur AS utilisateur '.
668
			$requete = 	'SELECT DISTINCT co.id_observation AS id_obs, ci.ce_utilisateur AS utilisateur '.
671
						'FROM cel_images ci'.
669
						'FROM cel_images ci'.
672
						'	LEFT JOIN cel_obs_images coi'.
-
 
673
						'		ON (ci.id_image = coi.id_image) '.
-
 
674
						'	LEFT JOIN cel_obs AS co '.
670
						'	INNER JOIN cel_obs AS co '.
675
						'		ON (coi.id_observation = co.id_observation) '.
671
						'		ON (ci.ce_observation = co.id_observation) '.
676
						'	LEFT JOIN cel_zones_geo AS l '.
672
						'	LEFT JOIN cel_zones_geo AS l '.
677
						"		ON (l.id_zone_geo = co.ce_zone_geo) ".
673
						"		ON (l.id_zone_geo = co.ce_zone_geo) ".
678
						"WHERE transmission = '1' ".
674
						"WHERE co.transmission = '1' ".
679
						$this->construireWhereCoordonnees().
675
						$this->construireWhereCoordonnees().
680
						$this->construireWhereUtilisateur().
676
						$this->construireWhereUtilisateur().
681
						$this->construireWhereNumTaxon().
677
						$this->construireWhereNumTaxon().
682
						$this->construireWhereNomTaxon().
678
						$this->construireWhereNomTaxon().
683
						$this->construireWhereProjet().
679
						$this->construireWhereProjet().
Line 741... Line 737...
741
		$where_mots_cles_images = implode(' '.$mots_cles_encodes['type'].' ', $where_mots_cles_images);
737
		$where_mots_cles_images = implode(' '.$mots_cles_encodes['type'].' ', $where_mots_cles_images);
742
		return $where_mots_cles_images;
738
		return $where_mots_cles_images;
743
	}
739
	}
Line 744... Line 740...
744
 
740
 
745
	private function decomposerParametreTag($tags) {
-
 
746
 
741
	private function decomposerParametreTag($tags) {
747
		$mots_cles = array('type' => null, 'motsCles' => null, 'motsClesEncodesProteges' => null);
742
		$mots_cles = array('type' => null, 'motsCles' => null, 'motsClesEncodesProteges' => null);
748
		if (preg_match('/.+OU.+/', $tags)) {
743
		if (preg_match('/.+OU.+/', $tags)) {
749
			$mots_cles['type'] = 'OR';
744
			$mots_cles['type'] = 'OR';
750
			$mots_cles['motsCles'] = explode('OU', $tags);
745
			$mots_cles['motsCles'] = explode('OU', $tags);