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');
|
32 |
private $tris_supportes = array('date');
|
33 |
private $retour_champs = array('determination.nom_sci' => 'nom_sel', 'determination.nom_sci.code' => 'num_nom_sel',
|
33 |
private $retour_champs = array('determination.nom_sci' => 'nom_sel', 'determination.nom_sci.code' => 'num_nom_sel',
|
34 |
'station.lieudit' => 'lieudit', 'station', 'milieu');
|
34 |
'station.lieudit' => 'lieudit', 'station', 'milieu');
|
35 |
private $ref_tax_demande = array();
|
35 |
private $ref_tax_demande = array();
|
36 |
private $infosImages = array();
|
36 |
private $infosImages = array();
|
37 |
private $nbreImages = 0;
|
37 |
private $nbreImages = 0;
|
38 |
private $Utilisateurs = null;
|
- |
|
39 |
private $intitulesAuteurs = array();
|
38 |
private $Utilisateurs = null;
|
Line 40... |
Line 39... |
40 |
private $UrlNavigation = null;
|
39 |
private $UrlNavigation = null;
|
41 |
|
40 |
|
42 |
public function __construct(Bdd $bdd = null, Array $config = null, Utilisateurs $utilisateurs = null, Url $url = null) {
|
41 |
public function __construct(Bdd $bdd = null, Array $config = null, Utilisateurs $utilisateurs = null, Url $url = null) {
|
Line 64... |
Line 63... |
64 |
}
|
63 |
}
|
65 |
$resultat->corps = $this->recupererImageBinaire($id_image_a_renvoyer);
|
64 |
$resultat->corps = $this->recupererImageBinaire($id_image_a_renvoyer);
|
66 |
} else if ($this->parametres['retour'] == self::MIME_JSON) {
|
65 |
} else if ($this->parametres['retour'] == self::MIME_JSON) {
|
67 |
if (isset($this->ressources[0])) {
|
66 |
if (isset($this->ressources[0])) {
|
68 |
$this->chargerInfosImage();
|
67 |
$this->chargerInfosImage();
|
69 |
$this->extraireIntitulesAuteurs();
|
68 |
$this->extraireIdentitesAuteurs();
|
70 |
$resultat->corps = $this->formaterInfosImage($this->infosImages[0]);
|
69 |
$resultat->corps = $this->formaterInfosImage($this->infosImages[0]);
|
71 |
} else {
|
70 |
} else {
|
72 |
$this->chargerListeImages();
|
71 |
$this->chargerListeImages();
|
73 |
$this->chargerNbreImagesTotal();
|
72 |
$this->chargerNbreImagesTotal();
|
74 |
$resultat->corps = $this->formaterListeImages();
|
73 |
$resultat->corps = $this->formaterListeImages();
|
Line 124... |
Line 123... |
124 |
if (isset($this->parametres['retour.tri'])){
|
123 |
if (isset($this->parametres['retour.tri'])){
|
125 |
if ($this->verifierValeurParametreTri() == false) {
|
124 |
if ($this->verifierValeurParametreTri() == false) {
|
126 |
$erreurs[] = "Le type de tri '{$this->parametres['retour.tri']}' n'est pas supporté";
|
125 |
$erreurs[] = "Le type de tri '{$this->parametres['retour.tri']}' n'est pas supporté";
|
127 |
}
|
126 |
}
|
128 |
}
|
127 |
}
|
129 |
|
128 |
|
130 |
if (isset($this->parametres['retour.champs'])){
|
129 |
if (isset($this->parametres['retour.champs'])){
|
131 |
if ($this->verifierValeurParametreRetourChamps() == false) {
|
130 |
if ($this->verifierValeurParametreRetourChamps() == false) {
|
132 |
$erreurs[] = "Le champs '{$this->parametres['retour.champs']}' n'existe pas";
|
131 |
$erreurs[] = "Le champs '{$this->parametres['retour.champs']}' n'existe pas";
|
133 |
}
|
132 |
}
|
134 |
}
|
133 |
}
|
135 |
|
134 |
|
136 |
if ($this->verifierValeurParametreNavigationDepart() == false) {
|
135 |
if ($this->verifierValeurParametreNavigationDepart() == false) {
|
137 |
$erreurs[] = "Le paramètre 'navigation.depart' doit possèder un valeur numérique.";
|
136 |
$erreurs[] = "Le paramètre 'navigation.depart' doit possèder un valeur numérique.";
|
138 |
}
|
137 |
}
|
139 |
if ($this->verifierValeurParametreNavigationLimite() == false) {
|
138 |
if ($this->verifierValeurParametreNavigationLimite() == false) {
|
140 |
$erreurs[] = "Le paramètre 'navigation.limite' doit possèder un valeur numérique supérieure à 0.";
|
139 |
$erreurs[] = "Le paramètre 'navigation.limite' doit possèder un valeur numérique supérieure à 0.";
|
Line 177... |
Line 176... |
177 |
}
|
176 |
}
|
Line 178... |
Line 177... |
178 |
|
177 |
|
179 |
private function verifierValeurParametreTri() {
|
178 |
private function verifierValeurParametreTri() {
|
180 |
return in_array($this->parametres['retour.tri'], $this->tris_supportes);
|
179 |
return in_array($this->parametres['retour.tri'], $this->tris_supportes);
|
181 |
}
|
180 |
}
|
182 |
|
181 |
|
183 |
private function verifierValeurParametreRetourChamps() {
|
182 |
private function verifierValeurParametreRetourChamps() {
|
184 |
$ok = false;
|
183 |
$ok = false;
|
185 |
$liste_champs = preg_split(',', $this->parametres['retour.champs']);
|
184 |
$liste_champs = preg_split(',', $this->parametres['retour.champs']);
|
186 |
foreach ($liste_champs as $champs) {
|
185 |
foreach ($liste_champs as $champs) {
|
Line 292... |
Line 291... |
292 |
$numNomListe = implode(',', $this->ref_tax_demande[$refTax]);
|
291 |
$numNomListe = implode(',', $this->ref_tax_demande[$refTax]);
|
293 |
$depart = $this->parametres['navigation.depart'];
|
292 |
$depart = $this->parametres['navigation.depart'];
|
294 |
$limite = $this->parametres['navigation.limite'];
|
293 |
$limite = $this->parametres['navigation.limite'];
|
Line 295... |
Line 294... |
295 |
|
294 |
|
296 |
//TODO: modifier la requete lors du passage à la nouvelle base de données pour faire quelque chose
|
295 |
//TODO: modifier la requete lors du passage à la nouvelle base de données pour faire quelque chose
|
297 |
// du numéro nomenclatural + modifier les champs appelés pour le nouveau format + supprimer table annuaire
|
- |
|
298 |
$annuaireTable = $this->config['annuaire']['table'];
|
296 |
// du numéro nomenclatural + modifier les champs appelés pour le nouveau format
|
- |
|
297 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS '.
|
299 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS '.
|
298 |
' co.id AS id_obs, co.identifiant AS utilisateur_courriel, co.location, co.id_location, '.
|
- |
|
299 |
' co.nom_sel, co.num_nom_sel, '.
|
- |
|
300 |
' ci.ci_id_image AS id_img, ci.ci_meta_date AS date '.
|
300 |
$this->formerRequeteChamps().
|
301 |
(isset($this->parametres['retour.champs']) ? ', '.$this->parametres['retour.champs'] : '').
|
301 |
'FROM cel_images AS ci'.
|
302 |
'FROM cel_images AS ci'.
|
302 |
' LEFT JOIN cel_obs_images AS coi '.
|
303 |
' LEFT JOIN cel_obs_images AS coi '.
|
303 |
' ON (coi.coi_ce_image = ci.ci_id_image) '.
|
304 |
' ON (coi.coi_ce_image = ci.ci_id_image) '.
|
304 |
' LEFT JOIN cel_inventory AS co '.
|
305 |
' LEFT JOIN cel_inventory AS co '.
|
305 |
' ON (coi.coi_ce_observation = co.ordre AND coi.coi_ce_utilisateur = co.identifiant) '.
|
- |
|
306 |
" LEFT JOIN $annuaireTable AS an ".
|
- |
|
307 |
' ON (co.identifiant = an.u_mail) '.
|
306 |
' ON (coi.coi_ce_observation = co.ordre AND coi.coi_ce_utilisateur = co.identifiant) '.
|
308 |
$this->formerRequeteConditions($numNomListe).
|
307 |
$this->formerRequeteConditions($numNomListe).' '.
|
309 |
' GROUP BY id_img '.
|
308 |
'GROUP BY id_img '.
|
310 |
$this->formerRequeteTri().
|
309 |
$this->formerRequeteTri().
|
Line 311... |
Line 310... |
311 |
"LIMIT $depart,$limite ";
|
310 |
"LIMIT $depart,$limite ";
|
312 |
|
311 |
|
313 |
$this->infosImages = $this->Bdd->recupererTous($requete);
|
312 |
$this->infosImages = $this->Bdd->recupererTous($requete);
|
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 |
}
|
313 |
}
|
324 |
|
314 |
|
325 |
private function formerRequeteConditions($numNomListe) {
|
315 |
private function formerRequeteConditions($numNomListe) {
|
326 |
$where[] = " co.transmission = 1 AND co.num_nom_ret IN ($numNomListe) ";
|
316 |
$where[] = " co.transmission = 1 AND co.num_nom_ret IN ($numNomListe) ";
|
327 |
if (isset($this->parametres['retour.tri']) && $this->parametres['retour.tri'] == 'date') {
|
317 |
if (isset($this->parametres['retour.tri']) && $this->parametres['retour.tri'] == 'date') {
|
328 |
$where[] = ' ci.ci_meta_date != "0000-00-00"';
|
318 |
$where[] = ' ci.ci_meta_date != "0000-00-00"';
|
329 |
}
|
319 |
}
|
Line 330... |
Line 320... |
330 |
return ' WHERE '.implode(' AND ', $where);
|
320 |
return ' WHERE '.implode(' AND ', $where);
|
331 |
}
|
321 |
}
|
332 |
|
322 |
|
333 |
private function formerRequeteTri() {
|
323 |
private function formerRequeteTri() {
|
334 |
$order = "";
|
324 |
$order = '';
|
335 |
if (isset($this->parametres['retour.tri']) && $this->parametres['retour.tri'] == 'date') {
|
325 |
if (isset($this->parametres['retour.tri']) && $this->parametres['retour.tri'] == 'date') {
|
336 |
$order = ' ORDER BY ci.ci_meta_date ASC ';
|
326 |
$order = ' ORDER BY ci.ci_meta_date ASC ';
|
Line 337... |
Line -... |
337 |
}
|
- |
|
338 |
return $order;
|
327 |
}
|
339 |
}
|
328 |
return $order;
|
340 |
|
329 |
}
|
341 |
|
330 |
|
342 |
private function chargerNbreImagesTotal() {
|
331 |
private function chargerNbreImagesTotal() {
|
Line 343... |
Line -... |
343 |
$requete = 'SELECT FOUND_ROWS() AS nbre ';
|
- |
|
344 |
$resultats = $this->Bdd->recuperer($requete);
|
332 |
$requete = 'SELECT FOUND_ROWS() AS nbre ';
|
345 |
$this->nbreImages = (int) $resultats['nbre'];
|
333 |
$resultats = $this->Bdd->recuperer($requete);
|
346 |
}
|
334 |
$this->nbreImages = (int) $resultats['nbre'];
|
347 |
|
335 |
}
|
348 |
|
336 |
|
Line 384... |
Line 372... |
384 |
$format = $this->parametres['retour.format'];
|
372 |
$format = $this->parametres['retour.format'];
|
385 |
$codeImage .= '_'.$format;
|
373 |
$codeImage .= '_'.$format;
|
386 |
return $codeImage;
|
374 |
return $codeImage;
|
387 |
}
|
375 |
}
|
Line 388... |
Line -... |
388 |
|
- |
|
389 |
|
376 |
|
390 |
//+------------------------------------FORMATAGE LISTE----------------------------------------------------------------+
|
377 |
//+------------------------------------FORMATAGE LISTE----------------------------------------------------------------+
|
391 |
private function formaterListeImages() {
|
378 |
private function formaterListeImages() {
|
392 |
$entete = $this->construireEntete();
|
379 |
$entete = $this->construireEntete();
|
Line 454... |
Line 441... |
454 |
return $url;
|
441 |
return $url;
|
455 |
}
|
442 |
}
|
Line 456... |
Line 443... |
456 |
|
443 |
|
457 |
private function construireResultats() {
|
444 |
private function construireResultats() {
|
458 |
$resultats = array();
|
445 |
$resultats = array();
|
459 |
$this->extraireIntitulesAuteurs();
|
446 |
$this->extraireIdentitesAuteurs();
|
460 |
foreach ($this->infosImages as $img) {
|
447 |
foreach ($this->infosImages as $img) {
|
461 |
$info = $this->formaterInfosImage($img);
|
448 |
$info = $this->formaterInfosImage($img);
|
462 |
$id = $img['id_img'];
|
449 |
$id = $img['id_img'];
|
463 |
$info['href'] = $this->config['urlService'].'/'.$id;
|
450 |
$info['href'] = $this->config['urlService'].'/'.$id;
|
Line 472... |
Line 459... |
472 |
|
459 |
|
473 |
private function formaterInfosImage($img) {
|
460 |
private function formaterInfosImage($img) {
|
474 |
$info = array();
|
461 |
$info = array();
|
475 |
$info['date'] = $img['date'];
|
462 |
$info['date'] = $img['date'];
|
476 |
$info['mime'] = self::MIME_JPEG;
|
463 |
$info['mime'] = self::MIME_JPEG;
|
477 |
$info['auteur'] = $this->formaterAuteur($img);
|
464 |
$info['auteur.libelle'] = $this->Utilisateurs->getIntitule($img['utilisateur_courriel']);
|
478 |
$info['auteur.id'] = $img['utilisateur_id'];
|
465 |
$info['auteur.id'] = $this->Utilisateurs->getId($img['utilisateur_courriel']);
|
479 |
$info['binaire.href'] = $this->formaterUrlImage($img);
|
466 |
$info['binaire.href'] = $this->formaterUrlImage($img);
|
480 |
if (isset($img['nom_sel'])) {
|
467 |
if (isset($img['nom_sel'])) {
|
481 |
$info['determination.libelle'] = $this->formaterDetermination($img);
|
468 |
$info['determination.libelle'] = $this->formaterDetermination($img);
|
482 |
$info['determination.nom_sci'] = $img['nom_sel'];
|
469 |
$info['determination.nom_sci'] = $img['nom_sel'];
|
483 |
$info['determination.nom_sci.code'] = $this->formaterNomSciCode($img);
|
470 |
$info['determination.nom_sci.code'] = $this->formaterNomSciCode($img);
|
484 |
}
|
471 |
}
|
485 |
$info = array_merge($info, $this->formaterStation($img));
|
472 |
$info = array_merge($info, $this->formaterStation($img));
|
486 |
return $info;
|
473 |
return $info;
|
Line 487... |
Line 474... |
487 |
}
|
474 |
}
|
488 |
|
475 |
|
489 |
private function extraireIntitulesAuteurs() {
|
476 |
private function extraireIdentitesAuteurs() {
|
490 |
$courriels = array();
|
477 |
$courriels = array();
|
491 |
foreach ($this->infosImages as $img) {
|
478 |
foreach ($this->infosImages as $img) {
|
492 |
$courriels[] = $img['utilisateur_courriel'];
|
479 |
$courriels[] = $img['utilisateur_courriel'];
|
493 |
}
|
480 |
}
|
494 |
$utilisateurs = new Utilisateurs($courriels);
|
481 |
$this->Utilisateurs->setCourriels($courriels);
|
Line 495... |
Line 482... |
495 |
$this->intitulesAuteurs = $utilisateurs->getIntitules();
|
482 |
$this->Utilisateurs->chargerIdentites();
|
496 |
}
|
483 |
}
|
497 |
|
484 |
|
498 |
private function formaterUrlImage($infos) {
|
485 |
private function formaterUrlImage($infos) {
|
499 |
$format = $this->parametres['retour.format'];
|
486 |
$format = $this->parametres['retour.format'];
|
500 |
$id = sprintf('%09s', $infos['id_img']).$format;
|
487 |
$id = sprintf('%09s', $infos['id_img']).$format;
|
Line 501... |
Line 488... |
501 |
$url = sprintf(self::TPL_URL_IMG, $id);
|
488 |
$url = sprintf(self::TPL_URL_IMG, $id);
|
502 |
return $url;
|
489 |
return $url;
|
- |
|
490 |
}
|
503 |
}
|
491 |
|
Line 504... |
Line 492... |
504 |
|
492 |
private function formaterDetermination($infos) {
|
505 |
private function formaterDetermination($infos) {
|
493 |
$auteur = $this->Utilisateurs->getIntitule($infos['utilisateur_courriel']);
|
506 |
return $infos['nom_sel'].'[Dét. : '.$this->intitulesAuteurs[$infos['utilisateur_courriel']].']';
|
494 |
return $infos['nom_sel']."[Dét. : $auteur]";
|
Line 540... |
Line 528... |
540 |
$commune[] = '('.$infos['id_location'].')';
|
528 |
$commune[] = '('.$infos['id_location'].')';
|
541 |
}
|
529 |
}
|
542 |
return implode(' ', $commune);
|
530 |
return implode(' ', $commune);
|
543 |
}
|
531 |
}
|
Line 544... |
Line -... |
544 |
|
- |
|
545 |
private function formaterAuteur($infos) {
|
- |
|
546 |
$auteur = $this->intitulesAuteurs[$infos['utilisateur_courriel']];
|
- |
|
547 |
return $auteur;
|
- |
|
548 |
}
|
- |
|
549 |
|
532 |
|
550 |
private function avoirContenu($info) {
|
533 |
private function avoirContenu($info) {
|
551 |
$vide = true;
|
534 |
$vide = true;
|
552 |
if ($info == null || $info == '' || $info == '000null') {
|
535 |
if ($info == null || $info == '' || $info == '000null') {
|
553 |
$vide = false;
|
536 |
$vide = false;
|