Subversion Repositories eFlore/Applications.del

Compare Revisions

Ignore whitespace Rev 1932 → Rev 1933

/trunk/services/modules/0.1/observations/ListeObservations.php
65,18 → 65,16
 
// 2) récupération des données nécessaires pour ces observations (obs + images)
$this->infosObs = $this->getInfosObs();
 
// 3) suppression, merge des données en tableau assez représentatif du futur JSON en output
$this->infosObsOrdonnees = $this->formaterObservations();
 
// 4) Ajouter commentaires + votes à $this->infosObsOrdonnees
$this->chargerDeterminations();
 
$resultat->corps = array(
'entete' => $this->navigation->getEntete(),
//'resultats' => array_values($this->infosObsOrdonnees));
// TODO : renvoyer un vrai tableau et non un objet
'resultats' => $this->infosObsOrdonnees);
'entete' => $this->navigation->getEntete(),
// 5) Applatissage du tableau afin de garder l'ordre de tri
// (qui n'est pas garanti dans un objet json)
'resultats' => array_values($this->infosObsOrdonnees));
}
return $resultat;
}
187,6 → 185,8
'WHERE dc.nom_sel IS NOT NULL '.
"AND ce_observation IN ($idObsConcat) ".
'-- '.__FILE__.':'.__LINE__;
$commentaires = $this->chargerNombreCommentaireObs();
 
$propositions = $this->bdd->recupererTous($requete);
if ($propositions) {
197,6 → 197,7
if ($comment) {
$this->infosObsOrdonnees[$idObs]['commentaires'][$idComment] = $comment;
}
$this->infosObsOrdonnees[$idObs]['nb_commentaires'] = isset($commentaires[$idObs]) ? $commentaires[$idObs] : 0;
}
}
}
235,6 → 236,23
}
return $voteFormate;
}
private function chargerNombreCommentaireObs() {
$idObsConcat = implode(',', $this->idsObsOrdonnees);
$requete = 'SELECT ce_observation, COUNT( id_commentaire ) AS nb '.
'FROM del_commentaire '.
"WHERE ce_observation IN ($idObsConcat) ".
'GROUP BY ce_observation '.
'-- '.__FILE__.':'.__LINE__;
$commentaires = $this->bdd->recupererTous($requete);
$commentaires_par_obs = array();
foreach($commentaires as $commentaire) {
$commentaires_par_obs[$commentaire['ce_observation']] = $commentaire['nb'];
}
return $commentaires_par_obs;
}
 
private function chargerNombreCommentaire($propositionId) {
$requete = 'SELECT COUNT( id_commentaire ) AS nb '.