Line 28... |
Line 28... |
28 |
|
28 |
|
29 |
private $config = array();
|
29 |
private $config = array();
|
30 |
private $cheminImagesBase = '';
|
30 |
private $cheminImagesBase = '';
|
31 |
private $formats_supportes = array(self::MIME_JPEG, self::MIME_JSON);
|
31 |
private $formats_supportes = array(self::MIME_JPEG, self::MIME_JSON);
|
- |
|
32 |
private $tris_supportes = array('date');
|
- |
|
33 |
private $retour_champs = array('determination.nom_sci' => 'nom_sel', 'determination.nom_sci.code' => 'num_nom_sel',
|
32 |
private $tris_supportes = array('date');
|
34 |
'station.lieudit' => 'lieudit', 'station', 'milieu');
|
33 |
private $ref_tax_demande = array();
|
35 |
private $ref_tax_demande = array();
|
34 |
private $infosImages = array();
|
36 |
private $infosImages = array();
|
35 |
private $nbreImages = 0;
|
37 |
private $nbreImages = 0;
|
36 |
private $Utilisateurs = null;
|
38 |
private $Utilisateurs = null;
|
Line 53... |
Line 55... |
53 |
$this->definirValeurParDefautDesParametres();
|
55 |
$this->definirValeurParDefautDesParametres();
|
54 |
$this->verifierParametres();
|
56 |
$this->verifierParametres();
|
Line 55... |
Line 57... |
55 |
|
57 |
|
56 |
$resultat = new ResultatService();
|
58 |
$resultat = new ResultatService();
|
57 |
if ($this->parametres['retour'] == self::MIME_JPEG) {
|
59 |
if ($this->parametres['retour'] == self::MIME_JPEG) {
|
58 |
if ($this->parametres['retour.tri'] == 'date') {
|
60 |
if ($this->parametres['retour.tri'] == 'date') { // recherche la plus vieille image du CEL
|
59 |
$id_image_a_renvoyer = $this->obtenirIdPremiereImage();
|
61 |
$id_image_a_renvoyer = $this->obtenirIdPremiereImage();
|
60 |
} else {
|
62 |
} else {
|
61 |
$id_image_a_renvoyer = $this->obtenirIdImageAuHasard();
|
63 |
$id_image_a_renvoyer = $this->obtenirIdImageAuHasard();
|
62 |
}
|
64 |
}
|
Line 122... |
Line 124... |
122 |
if (isset($this->parametres['retour.tri'])){
|
124 |
if (isset($this->parametres['retour.tri'])){
|
123 |
if ($this->verifierValeurParametreTri() == false) {
|
125 |
if ($this->verifierValeurParametreTri() == false) {
|
124 |
$erreurs[] = "Le type de tri '{$this->parametres['retour.tri']}' n'est pas supporté";
|
126 |
$erreurs[] = "Le type de tri '{$this->parametres['retour.tri']}' n'est pas supporté";
|
125 |
}
|
127 |
}
|
126 |
}
|
128 |
}
|
- |
|
129 |
|
- |
|
130 |
if (isset($this->parametres['retour.champs'])){
|
- |
|
131 |
if ($this->verifierValeurParametreRetourChamps() == false) {
|
- |
|
132 |
$erreurs[] = "Le champs '{$this->parametres['retour.champs']}' n'existe pas";
|
- |
|
133 |
}
|
- |
|
134 |
}
|
- |
|
135 |
|
127 |
if ($this->verifierValeurParametreNavigationDepart() == false) {
|
136 |
if ($this->verifierValeurParametreNavigationDepart() == false) {
|
128 |
$erreurs[] = "Le paramètre 'navigation.depart' doit possèder un valeur numérique.";
|
137 |
$erreurs[] = "Le paramètre 'navigation.depart' doit possèder un valeur numérique.";
|
129 |
}
|
138 |
}
|
130 |
if ($this->verifierValeurParametreNavigationLimite() == false) {
|
139 |
if ($this->verifierValeurParametreNavigationLimite() == false) {
|
131 |
$erreurs[] = "Le paramètre 'navigation.limite' doit possèder un valeur numérique supérieure à 0.";
|
140 |
$erreurs[] = "Le paramètre 'navigation.limite' doit possèder un valeur numérique supérieure à 0.";
|
Line 168... |
Line 177... |
168 |
}
|
177 |
}
|
Line 169... |
Line 178... |
169 |
|
178 |
|
170 |
private function verifierValeurParametreTri() {
|
179 |
private function verifierValeurParametreTri() {
|
171 |
return in_array($this->parametres['retour.tri'], $this->tris_supportes);
|
180 |
return in_array($this->parametres['retour.tri'], $this->tris_supportes);
|
- |
|
181 |
}
|
- |
|
182 |
|
- |
|
183 |
private function verifierValeurParametreRetourChamps() {
|
- |
|
184 |
$ok = false;
|
- |
|
185 |
$liste_champs = preg_split(',', $this->parametres['retour.champs']);
|
- |
|
186 |
foreach ($liste_champs as $champs) {
|
- |
|
187 |
$ok[$champs] = array_key_exists($champs, $this->retour_champs);
|
- |
|
188 |
}
|
- |
|
189 |
return $ok;
|
Line 172... |
Line 190... |
172 |
}
|
190 |
}
|
173 |
|
191 |
|
174 |
private function verifierValeurParametreNavigationDepart() {
|
192 |
private function verifierValeurParametreNavigationDepart() {
|
175 |
$depart = $this->parametres['navigation.depart'];
|
193 |
$depart = $this->parametres['navigation.depart'];
|
Line 277... |
Line 295... |
277 |
|
295 |
|
278 |
//TODO: modifier la requete lors du passage à la nouvelle base de données pour faire quelque chose
|
296 |
//TODO: modifier la requete lors du passage à la nouvelle base de données pour faire quelque chose
|
279 |
// du numéro nomenclatural + modifier les champs appelés pour le nouveau format + supprimer table annuaire
|
297 |
// du numéro nomenclatural + modifier les champs appelés pour le nouveau format + supprimer table annuaire
|
280 |
$annuaireTable = $this->config['annuaire']['table'];
|
298 |
$annuaireTable = $this->config['annuaire']['table'];
|
281 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS '.
|
- |
|
282 |
' ci.ci_id_image AS id_img, co.id AS id_obs, '.
|
- |
|
283 |
' identifiant AS utilisateur_courriel, '.
|
- |
|
284 |
' an.u_id AS utilisateur_id, '.
|
- |
|
285 |
' nom_sel, num_nom_sel, '.
|
- |
|
286 |
' location, id_location, lieudit, station, milieu, '.
|
299 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS '.
|
287 |
' ci.ci_meta_date AS date '.
|
300 |
$this->formerRequeteChamps().
|
288 |
'FROM cel_images AS ci'.
|
301 |
'FROM cel_images AS ci'.
|
289 |
' LEFT JOIN cel_obs_images AS coi '.
|
302 |
' LEFT JOIN cel_obs_images AS coi '.
|
290 |
' ON (coi.coi_ce_image = ci.ci_id_image) '.
|
303 |
' ON (coi.coi_ce_image = ci.ci_id_image) '.
|
291 |
' LEFT JOIN cel_inventory AS co '.
|
304 |
' LEFT JOIN cel_inventory AS co '.
|
Line 297... |
Line 310... |
297 |
$this->formerRequeteTri().
|
310 |
$this->formerRequeteTri().
|
298 |
"LIMIT $depart,$limite ";
|
311 |
"LIMIT $depart,$limite ";
|
Line 299... |
Line 312... |
299 |
|
312 |
|
300 |
$this->infosImages = $this->Bdd->recupererTous($requete);
|
313 |
$this->infosImages = $this->Bdd->recupererTous($requete);
|
301 |
}
|
314 |
}
|
- |
|
315 |
|
- |
|
316 |
private function formerRequeteChamps() {
|
- |
|
317 |
$champs[] = " ci.ci_id_image AS id_img, co.id AS id_obs, identifiant AS utilisateur_courriel, location, ".
|
- |
|
318 |
"id_location, ci.ci_meta_date AS date, an.u_id AS utilisateur_id ";
|
- |
|
319 |
if (isset($this->parametres['retour.champs'])) {
|
- |
|
320 |
$champs[] = $this->parametres['retour.champs'];
|
- |
|
321 |
}
|
- |
|
322 |
return implode(' , ', $champs);
|
- |
|
323 |
}
|
302 |
|
324 |
|
303 |
private function formerRequeteConditions($numNomListe) {
|
325 |
private function formerRequeteConditions($numNomListe) {
|
304 |
$where[] = " co.transmission = 1 AND co.num_nom_ret IN ($numNomListe) ";
|
326 |
$where[] = " co.transmission = 1 AND co.num_nom_ret IN ($numNomListe) ";
|
305 |
if (isset($this->parametres['retour.tri']) && $this->parametres['retour.tri'] == 'date') {
|
327 |
if (isset($this->parametres['retour.tri']) && $this->parametres['retour.tri'] == 'date') {
|
306 |
$where[] = ' ci.ci_meta_date != "0000-00-00"';
|
328 |
$where[] = ' ci.ci_meta_date != "0000-00-00"';
|
Line 436... |
Line 458... |
436 |
$resultats = array();
|
458 |
$resultats = array();
|
437 |
$this->extraireIntitulesAuteurs();
|
459 |
$this->extraireIntitulesAuteurs();
|
438 |
foreach ($this->infosImages as $img) {
|
460 |
foreach ($this->infosImages as $img) {
|
439 |
$info = $this->formaterInfosImage($img);
|
461 |
$info = $this->formaterInfosImage($img);
|
440 |
$id = $img['id_img'];
|
462 |
$id = $img['id_img'];
|
- |
|
463 |
$info['href'] = $this->config['urlService'].'/'.$id;
|
441 |
if (!isset($resultats[$id])) {
|
464 |
if (!isset($resultats[$id])) {
|
442 |
$resultats[$id] = $info;
|
465 |
$resultats[$id] = $info;
|
443 |
} else {
|
466 |
} else {
|
444 |
throw new Exception("Double : $id");
|
467 |
throw new Exception("Double : $id");
|
445 |
}
|
468 |
}
|
Line 449... |
Line 472... |
449 |
|
472 |
|
450 |
private function formaterInfosImage($img) {
|
473 |
private function formaterInfosImage($img) {
|
451 |
$info = array();
|
474 |
$info = array();
|
452 |
$info['date'] = $img['date'];
|
475 |
$info['date'] = $img['date'];
|
453 |
$info['mime'] = self::MIME_JPEG;
|
476 |
$info['mime'] = self::MIME_JPEG;
|
454 |
$info['auteur.libelle'] = $this->formaterAuteur($img);
|
477 |
$info['auteur'] = $this->formaterAuteur($img);
|
455 |
$info['auteur.id'] = $img['utilisateur_id'];
|
478 |
$info['auteur.id'] = $img['utilisateur_id'];
|
- |
|
479 |
$info['binaire.href'] = $this->formaterUrlImage($img);
|
456 |
$info['binaire.href'] = $this->formaterUrlImage($img);
|
480 |
if (isset($img['nom_sel'])) {
|
457 |
$info['determination.libelle'] = $this->formaterDetermination($img);
|
481 |
$info['determination.libelle'] = $this->formaterDetermination($img);
|
458 |
$info['determination.nom_sci'] = $img['nom_sel'];
|
482 |
$info['determination.nom_sci'] = $img['nom_sel'];
|
- |
|
483 |
$info['determination.nom_sci.code'] = $this->formaterNomSciCode($img);
|
459 |
$info['determination.nom_sci.code'] = $this->formaterNomSciCode($img);
|
484 |
}
|
460 |
$info = array_merge($info, $this->formaterStation($img));
|
485 |
$info = array_merge($info, $this->formaterStation($img));
|
461 |
return $info;
|
486 |
return $info;
|
Line 462... |
Line 487... |
462 |
}
|
487 |
}
|
Line 485... |
Line 510... |
485 |
return self::CODE_REFTAX_DEFAUT.'.'.$infos['num_nom_sel'];
|
510 |
return self::CODE_REFTAX_DEFAUT.'.'.$infos['num_nom_sel'];
|
486 |
}
|
511 |
}
|
Line 487... |
Line 512... |
487 |
|
512 |
|
488 |
private function formaterStation($infos) {
|
513 |
private function formaterStation($infos) {
|
489 |
$station = array();
|
514 |
$station = array();
|
490 |
if ($commune = $this->formaterCommune($infos)) {
|
515 |
if (isset($infos['location']) && $commune = $this->formaterCommune($infos)) {
|
491 |
$station['station.commune'] = $commune;
|
516 |
$station['station.commune'] = $commune;
|
492 |
}
|
517 |
}
|
493 |
if ($this->avoirContenu($infos['lieudit'])) {
|
518 |
if (isset($infos['lieudit']) && $this->avoirContenu($infos['lieudit'])) {
|
494 |
$station['station.lieudit'] = $infos['lieudit'];
|
519 |
$station['station.lieudit'] = $infos['lieudit'];
|
495 |
}
|
520 |
}
|
496 |
if ($this->avoirContenu($infos['station'])) {
|
521 |
if (isset($infos['station']) && $this->avoirContenu($infos['station'])) {
|
497 |
$station['station.station'] = $infos['station'];
|
522 |
$station['station.station'] = $infos['station'];
|
Line 498... |
Line 523... |
498 |
}
|
523 |
}
|
499 |
|
524 |
|
500 |
if ($this->avoirContenu($infos['milieu'])) {
|
525 |
if (isset($infos['milieu']) && $this->avoirContenu($infos['milieu'])) {
|
- |
|
526 |
$station['station.milieu'] = $infos['milieu'];
|
501 |
$station['station.milieu'] = $infos['milieu'];
|
527 |
}
|
- |
|
528 |
if (count($station) > 1) {
|
502 |
}
|
529 |
$station['station.libelle'] = implode(' > ', $station);
|
503 |
$station['station.libelle'] = implode(' > ', $station);
|
530 |
}
|
Line 504... |
Line 531... |
504 |
return $station;
|
531 |
return $station;
|
505 |
}
|
532 |
}
|
506 |
|
533 |
|
507 |
private function formaterCommune($infos) {
|
534 |
private function formaterCommune($infos) {
|
508 |
$commune = array();
|
535 |
$commune = array();
|
509 |
if ($this->avoirContenu($infos['location'])) {
|
536 |
if ($this->avoirContenu($infos['location'])) {
|
510 |
$commune[] = $infos['location'];
|
537 |
$commune[] = $infos['location'];
|
511 |
}
|
538 |
}
|
512 |
if ($this->avoirContenu($infos['id_location'])) {
|
539 |
if (isset($infos['id_location']) && $this->avoirContenu($infos['id_location'])) {
|
513 |
$commune[] = '('.$infos['id_location'].')';
|
540 |
$commune[] = '('.$infos['id_location'].')';
|