Line 31... |
Line 31... |
31 |
error_reporting(E_ALL);
|
31 |
error_reporting(E_ALL);
|
Line 32... |
Line 32... |
32 |
|
32 |
|
Line 33... |
Line 33... |
33 |
class ListeObservations2 {
|
33 |
class ListeObservations2 {
|
34 |
|
- |
|
35 |
private $conteneur;
|
- |
|
36 |
private $navigation;
|
34 |
|
37 |
private $masque;
|
35 |
private $conteneur;
|
38 |
private $gestionBdd;
|
36 |
private $gestionBdd;
|
39 |
private $bdd;
|
37 |
private $bdd;
|
40 |
private $parametres = array();
|
- |
|
41 |
private $ressources = array();
|
- |
|
Line 42... |
Line 38... |
42 |
private $tri = 'date_transmission';
|
38 |
private $parametres = array();
|
43 |
private $directionTri = 'desc';
|
39 |
private $ressources = array();
|
44 |
|
40 |
|
45 |
static $tris_possibles = array('date_observation');
|
41 |
static $tris_possibles = array('date_observation');
|
Line 64... |
Line 60... |
64 |
'ce_zone_geo AS id_zone_geo', 'zone_geo', 'lieudit',
|
60 |
'ce_zone_geo AS id_zone_geo', 'zone_geo', 'lieudit',
|
65 |
'station', 'milieu', 'date_observation', 'mots_cles_texte', 'date_transmission',
|
61 |
'station', 'milieu', 'date_observation', 'mots_cles_texte', 'date_transmission',
|
66 |
'ce_utilisateur AS `auteur.id`', 'prenom_utilisateur AS `auteur.prenom`',
|
62 |
'ce_utilisateur AS `auteur.id`', 'prenom_utilisateur AS `auteur.prenom`',
|
67 |
'nom_utilisateur AS `auteur.nom`', 'courriel_utilisateur AS observateur',
|
63 |
'nom_utilisateur AS `auteur.nom`', 'courriel_utilisateur AS observateur',
|
68 |
'commentaire'),
|
64 |
'commentaire'),
|
69 |
'di' => array('id_image', 'date_prise_de_vue AS `date`', 'hauteur' , 'largeur' /* 'nom_original'//apparemment inutilisé */),
|
65 |
'di' => array('id_image', 'date_prise_de_vue AS `date`', 'hauteur',/* 'largeur','nom_original' // apparemment inutilisés */),
|
70 |
'du' => array('prenom', 'nom', 'courriel'),
|
66 |
'du' => array('prenom', 'nom', 'courriel'),
|
71 |
'dc' => array('commentaire')
|
67 |
'dc' => array('commentaire')
|
72 |
);
|
68 |
);
|
Line 82... |
Line 78... |
82 |
$this->masque = $conteneur->getMasque();
|
78 |
$this->masque = $conteneur->getMasque();
|
83 |
$this->gestionBdd = $conteneur->getGestionBdd();
|
79 |
$this->gestionBdd = $conteneur->getGestionBdd();
|
84 |
$this->bdd = $this->gestionBdd->getBdd();
|
80 |
$this->bdd = $this->gestionBdd->getBdd();
|
85 |
}
|
81 |
}
|
Line 86... |
Line 82... |
86 |
|
82 |
|
87 |
static function reformateObservation($obs, Conteneur $c = NULL) {
|
83 |
static function reformateObservation($obs, $url_pattern = '') {
|
88 |
$obs = array_map('array_filter', $obs);
|
84 |
$obs = array_map('array_filter', $obs);
|
89 |
$obs_merged = array();
|
85 |
$obs_merged = array();
|
90 |
foreach($obs as $o) {
|
86 |
foreach($obs as $o) {
|
- |
|
87 |
$id = $o['id_observation'];
|
- |
|
88 |
|
- |
|
89 |
// car auteur.id peut être un email, un hash, ou un annuaire_tela.U_ID
|
- |
|
90 |
// mais dans les deux premiers cas SELECT courriel AS observateur fait déjà l'affaire
|
- |
|
91 |
if(!is_numeric($o['auteur.id'])) $o['auteur.id'] = "0";
|
- |
|
92 |
if(!isset($o['auteur.nom'])) $o['auteur.nom'] = '[inconnu]';
|
91 |
$id = $o['id_observation'];
|
93 |
|
92 |
$image = array_intersect_key($o, array_flip(array('id_image', 'date', 'hauteur' , 'largeur', 'nom_original')));
|
94 |
$image = array_intersect_key($o, array_flip(array('id_image', 'date', 'hauteur' , 'largeur', 'nom_original')));
|
93 |
$image['binaire.href'] = sprintf($c->getParametre('url_images'), $image['id_image']);
|
95 |
$image['binaire.href'] = sprintf($url_pattern, $image['id_image']);
|
94 |
unset($o['id_image'], $o['date'], $o['hauteur'], $o['largeur'], $o['nom_original']);
|
96 |
unset($o['id_image'], $o['date'], $o['hauteur'], $o['largeur'], $o['nom_original']);
|
95 |
if(!isset($obs_merged['"' . $id . '"'])) $obs_merged['"' . $id . '"'] = $o;
|
97 |
if(!isset($obs_merged['"' . $id . '"'])) $obs_merged['"' . $id . '"'] = $o;
|
96 |
$obs_merged['"' . $id . '"']['images'][] = $image;
|
98 |
$obs_merged['"' . $id . '"']['images'][] = $image;
|
97 |
}
|
99 |
}
|
98 |
return $obs_merged;
|
100 |
return $obs_merged;
|
Line -... |
Line 101... |
- |
|
101 |
}
|
- |
|
102 |
|
- |
|
103 |
// utilisée uniquement par Observation.php
|
- |
|
104 |
static function reformateObservationSimpleIndex($obs, $url_pattern = '') {
|
- |
|
105 |
// XXX: cf Observation.php::consulter(), nous pourriouns ici
|
- |
|
106 |
// conserver les valeurs vides (pour les phptests notamment, ou non)
|
- |
|
107 |
$obs = array_map('array_filter', $obs);
|
- |
|
108 |
$obs_merged = array();
|
- |
|
109 |
foreach($obs as $o) {
|
- |
|
110 |
$id = $o['id_observation'];
|
- |
|
111 |
$image = array_intersect_key($o, array_flip(array('id_image', 'date', 'hauteur' , 'largeur', 'nom_original')));
|
- |
|
112 |
$image['binaire.href'] = sprintf($url_pattern, $image['id_image']);
|
- |
|
113 |
unset($o['id_image'], $o['date'], $o['hauteur'], $o['largeur'], $o['nom_original']);
|
- |
|
114 |
if(!isset($obs_merged[$id])) $obs_merged[$id] = $o;
|
- |
|
115 |
$obs_merged[$id]['images'][$image['id_image']] = $image;
|
- |
|
116 |
}
|
- |
|
117 |
return $obs_merged;
|
- |
|
118 |
}
|
- |
|
119 |
|
- |
|
120 |
|
- |
|
121 |
// utilisée uniquement par ListeImages.php
|
- |
|
122 |
static function reformateImagesDoubleIndex($obs, $url_pattern = '', $image_format = 'XL') {
|
- |
|
123 |
// XXX: cf Observation.php::consulter(), nous pourriouns ici
|
- |
|
124 |
// conserver les valeurs vides (pour les phptests notamment, ou non)
|
- |
|
125 |
// $obs = array_map('array_filter', $obs);
|
- |
|
126 |
$obs_merged = $obs_keyed_by_id_image = array();
|
- |
|
127 |
foreach($obs as $o) {
|
- |
|
128 |
// ceci nous complique la tâche pour le reste du processing...
|
- |
|
129 |
$id = $o['jsonindex'];
|
- |
|
130 |
// ainsi nous utilisons deux tableaux: le final, indexé par couple d'id(image-obs)
|
- |
|
131 |
// et celui indexé par simple id_image qui est fort utile pour mapVotesToImages()
|
- |
|
132 |
// mais tout deux partage leur référence à "protocole"
|
- |
|
133 |
$image = array(
|
- |
|
134 |
'id_image' => $o['id_image'],
|
- |
|
135 |
'binaire.href' => sprintf($url_pattern, $o['id_image'], $image_format),
|
- |
|
136 |
'mots_cles_texte' => @$o['i_mots_cles_texte'], // @, peut avoir été filtré par array_map() ci-dessus
|
- |
|
137 |
);
|
- |
|
138 |
unset($o['id_image'], $o['i_mots_cles_texte'], $o['jsonindex']);
|
- |
|
139 |
if(!isset($obs_merged[$id])) $obs_merged[$id] = $image;
|
- |
|
140 |
$obs_merged[$id]['observation'] = $o;
|
- |
|
141 |
$obs_merged[$id]['protocoles_votes'] = array();
|
- |
|
142 |
|
- |
|
143 |
$obs_keyed_by_id_image[$image['id_image']]['protocoles_votes'] = &$obs_merged[$id]['protocoles_votes'];
|
- |
|
144 |
}
|
- |
|
145 |
|
- |
|
146 |
return array($obs_merged,$obs_keyed_by_id_image);
|
99 |
}
|
147 |
}
|
100 |
|
148 |
|
101 |
/**
|
149 |
/**
|
102 |
* Méthode principale de la classe.
|
150 |
* Méthode principale de la classe.
|
103 |
* Lance la récupération des images dans la base et les place dans un objet ResultatService
|
151 |
* Lance la récupération des images dans la base et les place dans un objet ResultatService
|
Line 112... |
Line 160... |
112 |
$req['groupby'][] = 'dob.id_observation';
|
160 |
$req['groupby'][] = 'dob.id_observation';
|
Line 113... |
Line 161... |
113 |
|
161 |
|
Line 114... |
Line 162... |
114 |
$db = $this->bdd;
|
162 |
$db = $this->bdd;
|
115 |
|
163 |
|
116 |
// filtrage de l'INPUT
|
164 |
// filtrage de l'INPUT
|
117 |
$params = self::requestFilterParams($parametres, $this->conteneur);
|
165 |
$params = self::requestFilterParams($parametres, self::$parametres_autorises, $this->conteneur);
|
Line 118... |
Line 166... |
118 |
// création des contraintes (masques)
|
166 |
// création des contraintes (masques)
|
119 |
self::sqlAddConstraint($params, $db, $req, $this->conteneur);
|
167 |
self::sqlAddConstraint($params, $db, $req, $this->conteneur);
|
Line 128... |
Line 176... |
128 |
|
176 |
|
129 |
// 2) récupération des données nécessaires pour ces observations (obs + images)
|
177 |
// 2) récupération des données nécessaires pour ces observations (obs + images)
|
Line 130... |
Line 178... |
130 |
$obs_unfmt = self::getInfos($idobs, $db);
|
178 |
$obs_unfmt = self::getInfos($idobs, $db);
|
131 |
|
179 |
|
Line 132... |
Line 180... |
132 |
// 3) suppression, merge des données en tableau assez représentatif du futur JSON en output
|
180 |
// 3) suppression, merge des données en tableau assez représentatif du futur JSON en output
|
133 |
$observations = self::reformateObservation($obs_unfmt, $this->conteneur);
|
181 |
$observations = self::reformateObservation($obs_unfmt, $this->conteneur->getParametre('url_images'));
|
134 |
|
182 |
|
135 |
// 4) récupération des données nécessaires pour ces observations (commentaires + votes)
|
183 |
// 4) récupération des données nécessaires pour ces observations (commentaires + votes)
|
Line 144... |
Line 192... |
144 |
$total = 0;
|
192 |
$total = 0;
|
145 |
}
|
193 |
}
|
Line 146... |
Line 194... |
146 |
|
194 |
|
147 |
// 6) JSON output
|
195 |
// 6) JSON output
|
148 |
$resultat = new ResultatService();
|
- |
|
149 |
|
- |
|
150 |
$prev_url = $next_url = NULL;
|
- |
|
151 |
|
- |
|
152 |
$next_offset = $params['navigation.depart'] + $params['navigation.limite'];
|
- |
|
153 |
if($next_offset < $total) {
|
- |
|
154 |
$next_url = sprintf("http://%s?%s", isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : Config::get('url_service'),
|
- |
|
155 |
http_build_query(array_merge($params, array('navigation.depart' => $next_offset))));
|
- |
|
156 |
}
|
- |
|
157 |
$prev_offset = $params['navigation.depart'] - $params['navigation.limite'];
|
- |
|
158 |
if($prev_offset > 0) {
|
196 |
$resultat = new ResultatService();
|
159 |
$prev_url = sprintf("http://%s?%s", isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : Config::get('url_service'),
|
- |
|
160 |
http_build_query(array_merge($params, array('navigation.depart' => $prev_offset))));
|
- |
|
161 |
}
|
- |
|
162 |
|
- |
|
163 |
$resultat->corps = array('entete' => array(
|
- |
|
164 |
'masque' => http_build_query(array_diff_key($params, array_flip(array('navigation.depart', 'navigation.limite', 'tri', 'ordre')))),
|
- |
|
165 |
'total' => $total,
|
- |
|
166 |
'depart' => $params['navigation.depart'],
|
- |
|
167 |
'limite' => $params['navigation.limite'],
|
- |
|
168 |
'href.precedent' => $prev_url,
|
- |
|
169 |
'href.suivant' => $next_url
|
- |
|
170 |
),
|
197 |
$resultat->corps = array('entete' => self::makeJSONHeader($total, $params, Config::get('url_service')),
|
Line 171... |
Line 198... |
171 |
'resultats' => $observations);
|
198 |
'resultats' => $observations);
|
172 |
|
199 |
|
Line 315... |
Line 342... |
315 |
}
|
342 |
}
|
316 |
if(!empty($p['masque.ns'])) {
|
343 |
if(!empty($p['masque.ns'])) {
|
317 |
$req['where'][] = 'dob.nom_sel LIKE '.$db->proteger($p['masque.ns'].'%');
|
344 |
$req['where'][] = 'dob.nom_sel LIKE '.$db->proteger($p['masque.ns'].'%');
|
318 |
}
|
345 |
}
|
319 |
if(!empty($p['masque.nn'])) {
|
346 |
if(!empty($p['masque.nn'])) {
|
320 |
$req['where'][] = sprintf('dob.nom_sel_nn = %d', $p['masque.nn']);
|
347 |
$req['where'][] = sprintf('dob.nom_sel_nn = %1$d OR dob.nom_ret_nn = %1$d', $p['masque.nn']);
|
321 |
}
|
348 |
}
|
322 |
if(!empty($p['masque.referentiel'])) {
|
349 |
if(!empty($p['masque.referentiel'])) {
|
323 |
$req['where'][] = sprintf('dob.nom_referentiel = %s', $db->proteger($p['masque.referentiel']));
|
350 |
$req['where'][] = sprintf('dob.nom_referentiel LIKE %s', $db->proteger($p['masque.referentiel'].'%'));
|
324 |
}
|
351 |
}
|
325 |
if(!empty($p['masque.commune'])) {
|
352 |
if(!empty($p['masque.commune'])) {
|
326 |
$req['where'][] = 'dob.zone_geo LIKE '.$db->proteger($p['masque.commune'].'%');
|
353 |
$req['where'][] = 'dob.zone_geo LIKE '.$db->proteger($p['masque.commune'].'%');
|
327 |
}
|
354 |
}
|
328 |
if(!empty($p['masque.tag'])) {
|
355 |
if(!empty($p['masque.tag'])) {
|
Line 348... |
Line 375... |
348 |
'masque.ns' => $p['masque'],
|
375 |
'masque.ns' => $p['masque'],
|
349 |
'masque.famille' => $p['masque'],
|
376 |
'masque.famille' => $p['masque'],
|
350 |
'masque.date' => $p['masque'],
|
377 |
'masque.date' => $p['masque'],
|
351 |
'masque.genre' => $p['masque'],
|
378 |
'masque.genre' => $p['masque'],
|
352 |
/* milieu: TODO */ );
|
379 |
/* milieu: TODO */ );
|
353 |
$or_masque = self::requestFilterParams($or_params, $c);
|
380 |
$or_masque = self::requestFilterParams($or_params, array_keys($or_params), $c);
|
354 |
// $or_req = array('select' => array(), 'join' => array(), 'where' => array(), 'groupby' => array(), 'having' => array());
|
381 |
// $or_req = array('select' => array(), 'join' => array(), 'where' => array(), 'groupby' => array(), 'having' => array());
|
355 |
$or_req = array('join' => array(), 'where' => array());
|
382 |
$or_req = array('join' => array(), 'where' => array());
|
356 |
self::sqlAddConstraint($or_masque, $db, $or_req);
|
383 |
self::sqlAddConstraint($or_masque, $db, $or_req);
|
Line 357... |
Line 384... |
357 |
|
384 |
|
Line 417... |
Line 444... |
417 |
*/
|
444 |
*/
|
418 |
static function addTypeConstraints($val, $db, &$req, Conteneur $c) {
|
445 |
static function addTypeConstraints($val, $db, &$req, Conteneur $c) {
|
419 |
if(array_key_exists('adeterminer', $val)) {
|
446 |
if(array_key_exists('adeterminer', $val)) {
|
420 |
//On récupère toutes les observations qui on le tag "aDeterminer" *ou* qui n'ont pas de nom d'espèce
|
447 |
//On récupère toutes les observations qui on le tag "aDeterminer" *ou* qui n'ont pas de nom d'espèce
|
421 |
$req['where'][] = '(' . implode(' OR ', array(
|
448 |
$req['where'][] = '(' . implode(' OR ', array(
|
422 |
'dob.certitude = "aDeterminer"'.
|
449 |
'dob.certitude = "aDeterminer"',
|
423 |
'dob.mots_cles_texte LIKE "%aDeterminer%"',
|
450 |
'dob.mots_cles_texte LIKE "%aDeterminer%"',
|
424 |
'dob.nom_sel_nn IS NULL', // TODO: ensure pas d'entrée à 0
|
451 |
'dob.nom_sel_nn IS NULL', // TODO: ensure pas d'entrée à 0
|
425 |
)) . ')';
|
452 |
)) . ')';
|
426 |
}
|
453 |
}
|
427 |
if(array_key_exists('aconfirmer', $val)) {
|
454 |
if(array_key_exists('aconfirmer', $val)) {
|
Line 462... |
Line 489... |
462 |
__FILE__ . ':' . __LINE__);
|
489 |
__FILE__ . ':' . __LINE__);
|
463 |
$propositions = $this->bdd->recupererTous($r);
|
490 |
$propositions = $this->bdd->recupererTous($r);
|
464 |
if(!$propositions) return;
|
491 |
if(!$propositions) return;
|
465 |
foreach ($propositions as $proposition) {
|
492 |
foreach ($propositions as $proposition) {
|
466 |
$idObs = $proposition['ce_observation'];
|
493 |
$idObs = $proposition['ce_observation'];
|
- |
|
494 |
$idComment = $proposition['id_commentaire'];
|
- |
|
495 |
$comment = $this->formaterDetermination($idComment, $proposition);
|
467 |
$observations['"' . $idObs . '"']['commentaires'][] = $this->formaterDeterminations($proposition);
|
496 |
if($comment) $observations['"' . $idObs . '"']['commentaires'][$idComment] = $comment;
|
- |
|
497 |
|
468 |
}
|
498 |
}
|
469 |
}
|
499 |
}
|
Line -... |
Line 500... |
- |
|
500 |
|
- |
|
501 |
private function formaterDetermination($commentId, $proposition) {
|
470 |
|
502 |
if(!$proposition) return NULL;
|
- |
|
503 |
|
- |
|
504 |
$proposition_formatee = array('nb_commentaires' => '0');
|
471 |
/**
|
505 |
foreach ($this->mappingCommentaire as $nomOriginal => $nomFinal) {
|
472 |
* Charger les votes sur les déterminations
|
506 |
if (isset($proposition[$nomOriginal])) {
|
473 |
* @param Array $observations le tableau des observations à mettre à jour
|
507 |
$proposition_formatee[$nomFinal] = $proposition[$nomOriginal];
|
- |
|
508 |
}
|
- |
|
509 |
}
|
474 |
* */
|
510 |
|
475 |
private function chargerVotes($ids_proposition, &$propositions) {
|
511 |
// Charger les votes sur les déterminations
|
476 |
$resultatsVotes = $this->bdd->recupererTous(sprintf('SELECT * FROM del_commentaire_vote WHERE ce_proposition IN (%s)',
|
512 |
$resultatsVotes = $this->bdd->recupererTous(
|
- |
|
513 |
sprintf('SELECT * FROM del_commentaire_vote WHERE ce_proposition = %d', $commentId));
|
477 |
implode(',', $ids_proposition)));
|
514 |
|
478 |
foreach ($resultatsVotes as $vote) {
|
515 |
foreach ($resultatsVotes as $vote) {
|
479 |
$propositions[$vote['ce_proposition']]['votes'][$vote['id_vote']] = $this->formaterVote($vote);
|
516 |
$proposition_formatee['votes'][$vote['id_vote']] = $this->formaterVote($vote);
|
480 |
}
|
- |
|
Line 481... |
Line 517... |
481 |
}
|
517 |
}
|
- |
|
518 |
|
482 |
|
519 |
|
483 |
/**
|
- |
|
484 |
* Charger le nombre de commentaires (sans détermination) associé à l'observation
|
- |
|
485 |
* @param Array $observations le tableau des observatins à mettre à jour
|
520 |
// chargerNombreCommentaire()
|
486 |
* */
|
521 |
// Charger le nombre de commentaires (sans détermination) associé à l'observation
|
487 |
private function chargerNombreCommentaire($ids_proposition, &$propositions) {
|
522 |
$listeCommentaires = $this->bdd->recupererTous(sprintf(
|
488 |
$listeCommentaires = $this->bdd->recupererTous(sprintf('SELECT ce_commentaire_parent, ce_proposition, COUNT( id_commentaire ) AS nb '.
|
523 |
'SELECT ce_commentaire_parent, ce_proposition, COUNT( id_commentaire ) AS nb '.
|
489 |
'FROM del_commentaire WHERE ce_proposition IN (%s) GROUP BY ce_proposition',
|
524 |
'FROM del_commentaire WHERE ce_proposition = %d GROUP BY ce_proposition -- %s',
|
490 |
implode(',', $ids_proposition)));
|
525 |
$commentId, __FILE__ . ':' . __LINE__));
|
- |
|
526 |
foreach ($listeCommentaires as $ligneProposition) {
|
- |
|
527 |
// ce test sert à exclure les proposition de 1er niveau qui sont elles aussi des commentaires
|
- |
|
528 |
if($ligneProposition['ce_commentaire_parent']) {
|
- |
|
529 |
// TODO/debug: id_commentaire_parent != $commentId ??
|
- |
|
530 |
// reprendre la "logique" du code... moins de boucles, moins de requêtes, ...
|
- |
|
531 |
if($ligneProposition['ce_commentaire_parent'] != $commentId) {
|
491 |
foreach ($listeCommentaires as $ligneProposition) {
|
532 |
// restore_error_handler();
|
- |
|
533 |
error_log(sprintf("possible error: nb_commentaires = %s: comment = %d, parent = %d, %s",
|
492 |
// ce test sert à exclure les proposition de 1er niveau qui sont elles aussi des commentaires
|
534 |
$ligneProposition['nb'], $commentId, $ligneProposition['ce_commentaire_parent'], __FILE__));
|
493 |
if($ligneProposition['ce_commentaire_parent'] != null && $ligneProposition['ce_commentaire_parent'] != 0) {
|
535 |
}
|
494 |
$propositions[$ligneProposition['ce_commentaire_parent']]['nb_commentaires'] = $ligneProposition['nb'];
|
536 |
$proposition_formatee['nb_commentaires'] = $ligneProposition['nb'];
|
495 |
} else {
|
537 |
} else {
|
496 |
$propositions[$ligneProposition['ce_proposition']]['observation']['nb_commentaires'] = $ligneProposition['nb'];
|
538 |
$proposition_formatee['observation']['nb_commentaires'] = $ligneProposition['nb'];
|
497 |
}
|
- |
|
498 |
}
|
- |
|
499 |
}
|
- |
|
500 |
|
- |
|
501 |
/**
|
- |
|
502 |
*
|
- |
|
503 |
* Formate une liste de proposition en fonction du fichier de configuration
|
- |
|
504 |
*/
|
- |
|
505 |
private function formaterDeterminations($proposition) {
|
- |
|
506 |
if(!$proposition) return array();
|
- |
|
Line 507... |
Line -... |
507 |
$propositions_format = array();
|
- |
|
508 |
$ids_proposition[] = $proposition['id_commentaire'];
|
- |
|
509 |
|
- |
|
510 |
$proposition_formatee = array('nb_commentaires' => '0');
|
- |
|
511 |
foreach ($this->mappingCommentaire as $nomOriginal => $nomFinal) {
|
- |
|
512 |
if (isset($proposition[$nomOriginal])) {
|
- |
|
513 |
$proposition_formatee[$nomFinal] = $proposition[$nomOriginal];
|
- |
|
514 |
}
|
- |
|
515 |
}
|
- |
|
516 |
$propositions_format[$proposition['id_commentaire']] = $proposition_formatee;
|
- |
|
517 |
// modifie $propositions_format
|
- |
|
518 |
$this->chargerVotes($ids_proposition, $propositions_format);
|
539 |
}
|
519 |
// modifie $propositions_format
|
540 |
}
|
Line 520... |
Line 541... |
520 |
$this->chargerNombreCommentaire($ids_proposition, $propositions_format);
|
541 |
|
521 |
return $propositions_format;
|
542 |
return $proposition_formatee;
|
522 |
}
|
543 |
}
|
Line 545... |
Line 566... |
545 |
}
|
566 |
}
|
Line 546... |
Line 567... |
546 |
|
567 |
|
547 |
|
568 |
|
548 |
/* filtre et valide les paramètres reconnus.
|
569 |
/* filtre et valide les paramètres reconnus.
|
549 |
Effectue *toute* la sanitization *sauf* l'escape-string */
|
570 |
Effectue *toute* la sanitization *sauf* l'escape-string */
|
Line 550... |
Line 571... |
550 |
static function requestFilterParams(Array $params, Conteneur $c = NULL /* pour la récup des départements */ ) {
|
571 |
static function requestFilterParams(Array $params, $parametres_autorises, Conteneur $c = NULL /* pour la récup des départements */ ) {
|
551 |
$params = array_intersect_key($params, array_flip(self::$parametres_autorises));
|
572 |
$params = array_intersect_key($params, array_flip($parametres_autorises));
|
552 |
|
573 |
|
Line 553... |
Line 574... |
553 |
$p['tri'] = self::unsetIfInvalid($params, 'tri', array('date_observation'));
|
574 |
$p['tri'] = self::unsetIfInvalid($params, 'tri', array('date_observation'));
|
554 |
$p['ordre'] = self::unsetIfInvalid($params, 'ordre', array('asc','desc'));
|
575 |
$p['ordre'] = self::unsetIfInvalid($params, 'ordre', array('asc','desc'));
|
555 |
$p['referentiel'] = self::unsetIfInvalid($params, 'referentiel', array('bdtfx','bdtxa','isfan'));
|
576 |
$p['masque.referentiel'] = self::unsetIfInvalid($params, 'masque.referentiel', array('bdtfx','bdtxa','isfan'));
|
556 |
|
577 |
|
Line 668... |
Line 689... |
668 |
$p = array_merge(self::$default_params, $p);
|
689 |
$p = array_merge(self::$default_params, $p);
|
Line 669... |
Line 690... |
669 |
|
690 |
|
670 |
return $p;
|
691 |
return $p;
|
Line -... |
Line 692... |
- |
|
692 |
}
|
- |
|
693 |
|
- |
|
694 |
static function makeJSONHeader($total, $params, $url_service) {
|
- |
|
695 |
$prev_url = $next_url = NULL;
|
- |
|
696 |
|
- |
|
697 |
$next_offset = $params['navigation.depart'] + $params['navigation.limite'];
|
- |
|
698 |
if($next_offset < $total) {
|
- |
|
699 |
$next_url = sprintf("http://%s?%s", isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $url_service,
|
- |
|
700 |
http_build_query(array_merge($params, array('navigation.depart' => $next_offset))));
|
- |
|
701 |
}
|
- |
|
702 |
|
- |
|
703 |
$prev_offset = $params['navigation.depart'] - $params['navigation.limite'];
|
- |
|
704 |
if($prev_offset > 0) {
|
- |
|
705 |
$prev_url = sprintf("http://%s?%s", isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $url_service,
|
- |
|
706 |
http_build_query(array_merge($params, array('navigation.depart' => $prev_offset))));
|
- |
|
707 |
}
|
- |
|
708 |
|
- |
|
709 |
return array(
|
- |
|
710 |
'masque' => http_build_query(array_diff_key($params, array_flip(array('navigation.depart', 'navigation.limite', 'tri', 'ordre')))),
|
- |
|
711 |
'total' => $total,
|
- |
|
712 |
'depart' => $params['navigation.depart'],
|
- |
|
713 |
'limite' => $params['navigation.limite'],
|
- |
|
714 |
'href.precedent' => $prev_url,
|
- |
|
715 |
'href.suivant' => $next_url
|
671 |
}
|
716 |
);
|