Subversion Repositories eFlore/Applications.del

Rev

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

Rev 1922 Rev 1933
Line 63... Line 63...
63
		$resultat->corps = array('entete' => $this->navigation->getEntete(), 'resultats' => array());
63
		$resultat->corps = array('entete' => $this->navigation->getEntete(), 'resultats' => array());
64
		if (count($this->idsObsOrdonnees) > 0) {
64
		if (count($this->idsObsOrdonnees) > 0) {
Line 65... Line 65...
65
 
65
 
66
			// 2) récupération des données nécessaires pour ces observations (obs + images)
66
			// 2) récupération des données nécessaires pour ces observations (obs + images)
67
			$this->infosObs = $this->getInfosObs();
-
 
68
 
67
			$this->infosObs = $this->getInfosObs();
69
			// 3) suppression, merge des données en tableau assez représentatif du futur JSON en output
68
			// 3) suppression, merge des données en tableau assez représentatif du futur JSON en output
70
			$this->infosObsOrdonnees = $this->formaterObservations();
-
 
71
 
69
			$this->infosObsOrdonnees = $this->formaterObservations();
72
			// 4) Ajouter commentaires + votes à $this->infosObsOrdonnees
70
			// 4) Ajouter commentaires + votes à $this->infosObsOrdonnees
Line 73... Line 71...
73
			$this->chargerDeterminations();
71
			$this->chargerDeterminations();
74
 
72
 
75
			$resultat->corps = array(
73
			$resultat->corps = array(
76
				'entete' => $this->navigation->getEntete(),
74
				'entete' => $this->navigation->getEntete(),	
77
				//'resultats' => array_values($this->infosObsOrdonnees));
75
				// 5) Applatissage du tableau afin de garder l'ordre de tri
78
				// TODO : renvoyer un vrai tableau et non un objet
76
				// (qui n'est pas garanti dans un objet json)
79
				'resultats' => $this->infosObsOrdonnees);
77
				'resultats' => array_values($this->infosObsOrdonnees));
80
		}
78
		}
Line 81... Line 79...
81
		return $resultat;
79
		return $resultat;
Line 185... Line 183...
185
		$requete = 'SELECT * '.
183
		$requete = 'SELECT * '.
186
			'FROM del_commentaire AS dc '.
184
			'FROM del_commentaire AS dc '.
187
			'WHERE dc.nom_sel IS NOT NULL '.
185
			'WHERE dc.nom_sel IS NOT NULL '.
188
			"AND ce_observation IN ($idObsConcat) ".
186
			"AND ce_observation IN ($idObsConcat) ".
189
			'-- '.__FILE__.':'.__LINE__;
187
			'-- '.__FILE__.':'.__LINE__;
-
 
188
		
-
 
189
		$commentaires = $this->chargerNombreCommentaireObs();
Line 190... Line 190...
190
 
190
 
191
		$propositions = $this->bdd->recupererTous($requete);
191
		$propositions = $this->bdd->recupererTous($requete);
192
		if ($propositions) {
192
		if ($propositions) {
193
			foreach ($propositions as $proposition) {
193
			foreach ($propositions as $proposition) {
194
				$idObs = $proposition['ce_observation'];
194
				$idObs = $proposition['ce_observation'];
195
				$idComment = $proposition['id_commentaire'];
195
				$idComment = $proposition['id_commentaire'];
196
				$comment = $this->formaterDetermination($idComment, $proposition);
196
				$comment = $this->formaterDetermination($idComment, $proposition);
197
				if ($comment) {
197
				if ($comment) {
198
					$this->infosObsOrdonnees[$idObs]['commentaires'][$idComment] = $comment;
198
					$this->infosObsOrdonnees[$idObs]['commentaires'][$idComment] = $comment;
-
 
199
				}
199
				}
200
				$this->infosObsOrdonnees[$idObs]['nb_commentaires'] = isset($commentaires[$idObs]) ? $commentaires[$idObs] : 0;
200
			}
201
			}
201
		}
202
		}
Line 202... Line 203...
202
	}
203
	}
Line 233... Line 234...
233
		foreach ($vote as $nomChamp => $valeur) {
234
		foreach ($vote as $nomChamp => $valeur) {
234
			$voteFormate[$this->mappings['votes'][$nomChamp]] = $valeur;
235
			$voteFormate[$this->mappings['votes'][$nomChamp]] = $valeur;
235
		}
236
		}
236
		return $voteFormate;
237
		return $voteFormate;
237
	}
238
	}
-
 
239
	
-
 
240
	private function chargerNombreCommentaireObs() {
-
 
241
		$idObsConcat = implode(',', $this->idsObsOrdonnees);	
-
 
242
		$requete = 'SELECT ce_observation, COUNT( id_commentaire ) AS nb '.
-
 
243
				'FROM del_commentaire '.
-
 
244
				"WHERE ce_observation IN ($idObsConcat) ".
-
 
245
				'GROUP BY ce_observation '.
-
 
246
				'-- '.__FILE__.':'.__LINE__;
-
 
247
		$commentaires = $this->bdd->recupererTous($requete);
-
 
248
		
-
 
249
		$commentaires_par_obs = array();
-
 
250
		foreach($commentaires as $commentaire) {
-
 
251
			$commentaires_par_obs[$commentaire['ce_observation']] = $commentaire['nb'];
-
 
252
		}
-
 
253
		
-
 
254
		return $commentaires_par_obs;
-
 
255
	}
Line 238... Line 256...
238
 
256
 
239
	private function chargerNombreCommentaire($propositionId) {
257
	private function chargerNombreCommentaire($propositionId) {
240
		$requete = 'SELECT COUNT( id_commentaire ) AS nb '.
258
		$requete = 'SELECT COUNT( id_commentaire ) AS nb '.
241
			'FROM del_commentaire '.
259
			'FROM del_commentaire '.