Line 164... |
Line 164... |
164 |
private function verifierValeurParametreFormat() {
|
164 |
private function verifierValeurParametreFormat() {
|
165 |
$formats = Outils::recupererTableauConfig('Images.formats');
|
165 |
$formats = Outils::recupererTableauConfig('Images.formats');
|
166 |
$ok = array_key_exists($this->parametres['retour.format'], $formats);
|
166 |
$ok = array_key_exists($this->parametres['retour.format'], $formats);
|
167 |
return $ok;
|
167 |
return $ok;
|
168 |
}
|
168 |
}
|
169 |
|
169 |
|
170 |
private function verifierValeurParametreTri() {
|
170 |
private function verifierValeurParametreTri() {
|
171 |
return in_array($this->parametres['retour.tri'], $this->tris_supportes);
|
171 |
return in_array($this->parametres['retour.tri'], $this->tris_supportes);
|
172 |
}
|
172 |
}
|
Line 173... |
Line 173... |
173 |
|
173 |
|
Line 198... |
Line 198... |
198 |
}
|
198 |
}
|
199 |
}
|
199 |
}
|
200 |
}
|
200 |
}
|
201 |
}
|
201 |
}
|
Line 202... |
Line 202... |
202 |
|
202 |
|
203 |
|
203 |
|
204 |
//+---------------------------------------- REQUETES ---------------------------------------------------------------+
|
204 |
//+---------------------------------------- REQUETES ---------------------------------------------------------------+
|
205 |
private function obtenirIdImageAuHasard() {
|
205 |
private function obtenirIdImageAuHasard() {
|
206 |
$refTax = self::CODE_REFTAX_DEFAUT;
|
206 |
$refTax = self::CODE_REFTAX_DEFAUT;
|
Line 224... |
Line 224... |
224 |
}
|
224 |
}
|
Line 225... |
Line 225... |
225 |
|
225 |
|
226 |
$id_image_hasard = $resultat[array_rand($resultat)]['id_image'];
|
226 |
$id_image_hasard = $resultat[array_rand($resultat)]['id_image'];
|
227 |
return $id_image_hasard;
|
227 |
return $id_image_hasard;
|
228 |
}
|
228 |
}
|
229 |
|
229 |
|
230 |
private function obtenirIdPremiereImage() {
|
230 |
private function obtenirIdPremiereImage() {
|
231 |
$refTax = self::CODE_REFTAX_DEFAUT;
|
231 |
$refTax = self::CODE_REFTAX_DEFAUT;
|
232 |
$numNom = $this->Bdd->proteger($this->ref_tax_demande[$refTax][0]);
|
232 |
$numNom = $this->Bdd->proteger($this->ref_tax_demande[$refTax][0]);
|
233 |
$requete = 'SELECT ci.ci_id_image AS id_image '.
|
233 |
$requete = 'SELECT ci.ci_id_image AS id_image '.
|
Line 237... |
Line 237... |
237 |
' LEFT JOIN cel_inventory AS co '.
|
237 |
' LEFT JOIN cel_inventory AS co '.
|
238 |
' ON (coi.coi_ce_observation = co.ordre AND coi.coi_ce_utilisateur = co.identifiant) '.
|
238 |
' ON (coi.coi_ce_observation = co.ordre AND coi.coi_ce_utilisateur = co.identifiant) '.
|
239 |
'WHERE co.transmission = 1 '.
|
239 |
'WHERE co.transmission = 1 '.
|
240 |
" AND co.num_nom_ret IN ($numNom) ".
|
240 |
" AND co.num_nom_ret IN ($numNom) ".
|
241 |
' AND ci.ci_meta_date != "0000-00-00" ORDER BY ci.ci_meta_date ASC';
|
241 |
' AND ci.ci_meta_date != "0000-00-00" ORDER BY ci.ci_meta_date ASC';
|
242 |
|
242 |
|
243 |
$resultat = $this->Bdd->recupererTous($requete);
|
243 |
$resultat = $this->Bdd->recupererTous($requete);
|
244 |
|
244 |
|
245 |
if (!is_array($resultat) || count($resultat) <= 0) {
|
245 |
if (!is_array($resultat) || count($resultat) <= 0) {
|
246 |
$message = "Aucune image ne correspond au numéro numenclatural $refTax:$numNom";
|
246 |
$message = "Aucune image ne correspond au numéro numenclatural $refTax:$numNom";
|
247 |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
|
247 |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
|
248 |
throw new Exception($message, $code);
|
248 |
throw new Exception($message, $code);
|
249 |
}
|
249 |
}
|
250 |
|
250 |
|
251 |
$id_image_hasard = $resultat[0]['id_image'];
|
251 |
$id_image_hasard = $resultat[0]['id_image'];
|
252 |
return $id_image_hasard;
|
252 |
return $id_image_hasard;
|
253 |
}
|
253 |
}
|
254 |
|
254 |
|
255 |
private function chargerInfosImage() {
|
255 |
private function chargerInfosImage() {
|
256 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS '.
|
256 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS '.
|
257 |
' ci.ci_id_image AS id_img, co.id AS id_obs, '.
|
257 |
' ci.ci_id_image AS id_img, co.id AS id_obs, '.
|
258 |
' identifiant AS utilisateur_courriel, '.
|
258 |
' identifiant AS utilisateur_courriel, '.
|
259 |
' nom_sel, num_nom_sel, '.
|
259 |
' nom_sel, num_nom_sel, '.
|
Line 263... |
Line 263... |
263 |
' LEFT JOIN cel_obs_images AS coi '.
|
263 |
' LEFT JOIN cel_obs_images AS coi '.
|
264 |
' ON (coi.coi_ce_image = ci.ci_id_image) '.
|
264 |
' ON (coi.coi_ce_image = ci.ci_id_image) '.
|
265 |
' LEFT JOIN cel_inventory AS co '.
|
265 |
' LEFT JOIN cel_inventory AS co '.
|
266 |
' ON (coi.coi_ce_observation = co.ordre AND coi.coi_ce_utilisateur = co.identifiant) '.
|
266 |
' ON (coi.coi_ce_observation = co.ordre AND coi.coi_ce_utilisateur = co.identifiant) '.
|
267 |
'WHERE ci.ci_id_image = '.$this->ressources[0];
|
267 |
'WHERE ci.ci_id_image = '.$this->ressources[0];
|
268 |
|
268 |
|
269 |
$this->infosImages = $this->Bdd->recupererTous($requete);
|
269 |
$this->infosImages = $this->Bdd->recupererTous($requete);
|
270 |
}
|
270 |
}
|
Line 271... |
Line 271... |
271 |
|
271 |
|
272 |
private function chargerListeImages() {
|
272 |
private function chargerListeImages() {
|
273 |
$refTax = self::CODE_REFTAX_DEFAUT;
|
273 |
$refTax = self::CODE_REFTAX_DEFAUT;
|
274 |
$numNomListe = implode(',', $this->ref_tax_demande[$refTax]);
|
274 |
$numNomListe = implode(',', $this->ref_tax_demande[$refTax]);
|
275 |
$depart = $this->parametres['navigation.depart'];
|
275 |
$depart = $this->parametres['navigation.depart'];
|
276 |
$limite = $this->parametres['navigation.limite'];
|
276 |
$limite = $this->parametres['navigation.limite'];
|
277 |
|
277 |
|
278 |
//TODO: modifier la requete lors du passage à la nouvelle base de données pour faire quelque chose
|
278 |
//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
|
279 |
// du numéro nomenclatural + modifier les champs appelés pour le nouveau format
|
280 |
$annuaireTable = $this->config['annuaire']['table'];
|
280 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS '.
|
281 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS '.
|
281 |
' ci.ci_id_image AS id_img, co.id AS id_obs, '.
|
282 |
' ci.ci_id_image AS id_img, co.id AS id_obs, '.
|
- |
|
283 |
' identifiant AS utilisateur_courriel, '.
|
282 |
' identifiant AS utilisateur_courriel, '.
|
284 |
' an.u_id AS utilisateur_id, '.
|
283 |
' nom_sel, num_nom_sel, '.
|
285 |
' nom_sel, num_nom_sel, '.
|
284 |
' location, id_location, lieudit, station, milieu, '.
|
286 |
' location, id_location, lieudit, station, milieu, '.
|
285 |
' ci.ci_meta_date AS date '.
|
287 |
' ci.ci_meta_date AS date '.
|
286 |
'FROM cel_images AS ci'.
|
288 |
'FROM cel_images AS ci'.
|
287 |
' LEFT JOIN cel_obs_images AS coi '.
|
289 |
' LEFT JOIN cel_obs_images AS coi '.
|
288 |
' ON (coi.coi_ce_image = ci.ci_id_image) '.
|
290 |
' ON (coi.coi_ce_image = ci.ci_id_image) '.
|
289 |
' LEFT JOIN cel_inventory AS co '.
|
291 |
' LEFT JOIN cel_inventory AS co '.
|
- |
|
292 |
' ON (coi.coi_ce_observation = co.ordre AND coi.coi_ce_utilisateur = co.identifiant) '.
|
- |
|
293 |
" LEFT JOIN $annuaireTable AS an ".
|
290 |
' ON (coi.coi_ce_observation = co.ordre AND coi.coi_ce_utilisateur = co.identifiant) '.
|
294 |
' ON (co.identifiant = an.u_mail) '.
|
291 |
$this->formerRequeteConditions($numNomListe).
|
295 |
$this->formerRequeteConditions($numNomListe).
|
292 |
' GROUP BY id_img '.
|
296 |
' GROUP BY id_img '.
|
293 |
$this->formerRequeteTri().
|
297 |
$this->formerRequeteTri().
|
294 |
"LIMIT $depart,$limite ";
|
298 |
"LIMIT $depart,$limite ";
|
295 |
|
299 |
|
296 |
$this->infosImages = $this->Bdd->recupererTous($requete);
|
300 |
$this->infosImages = $this->Bdd->recupererTous($requete);
|
297 |
}
|
301 |
}
|
298 |
|
302 |
|
299 |
private function formerRequeteConditions($numNomListe) {
|
303 |
private function formerRequeteConditions($numNomListe) {
|
300 |
$where[] = " co.transmission = 1 AND co.num_nom_ret IN ($numNomListe) ";
|
304 |
$where[] = " co.transmission = 1 AND co.num_nom_ret IN ($numNomListe) ";
|
301 |
if (isset($this->parametres['retour.tri']) && $this->parametres['retour.tri'] == 'date') {
|
305 |
if (isset($this->parametres['retour.tri']) && $this->parametres['retour.tri'] == 'date') {
|
302 |
$where[] = ' ci.ci_meta_date != "0000-00-00"';
|
306 |
$where[] = ' ci.ci_meta_date != "0000-00-00"';
|
303 |
}
|
307 |
}
|
304 |
return ' WHERE '.implode(' AND ', $where);
|
308 |
return ' WHERE '.implode(' AND ', $where);
|
305 |
}
|
309 |
}
|
306 |
|
310 |
|
307 |
private function formerRequeteTri() {
|
311 |
private function formerRequeteTri() {
|
308 |
$order = "";
|
312 |
$order = "";
|
309 |
if (isset($this->parametres['retour.tri']) && $this->parametres['retour.tri'] == 'date') {
|
313 |
if (isset($this->parametres['retour.tri']) && $this->parametres['retour.tri'] == 'date') {
|
310 |
$order = ' ORDER BY ci.ci_meta_date ASC ';
|
314 |
$order = ' ORDER BY ci.ci_meta_date ASC ';
|
311 |
}
|
315 |
}
|
312 |
return $order;
|
316 |
return $order;
|
313 |
}
|
317 |
}
|
314 |
|
318 |
|
315 |
|
319 |
|
316 |
private function chargerNbreImagesTotal() {
|
320 |
private function chargerNbreImagesTotal() {
|
317 |
$requete = 'SELECT FOUND_ROWS() AS nbre ';
|
321 |
$requete = 'SELECT FOUND_ROWS() AS nbre ';
|
318 |
$resultats = $this->Bdd->recuperer($requete);
|
322 |
$resultats = $this->Bdd->recuperer($requete);
|
319 |
$this->nbreImages = (int) $resultats['nbre'];
|
323 |
$this->nbreImages = (int) $resultats['nbre'];
|
320 |
}
|
324 |
}
|
Line 321... |
Line 325... |
321 |
|
325 |
|
322 |
|
326 |
|
323 |
//+---------------------------------------CHEMIN ET CONVERSION--------------------------------------------------------+
|
327 |
//+---------------------------------------CHEMIN ET CONVERSION--------------------------------------------------------+
|
324 |
private function recupererImageBinaire($id_image) {
|
328 |
private function recupererImageBinaire($id_image) {
|
Line 357... |
Line 361... |
357 |
$codeImage = wordwrap($codeImage, 3, '_', true);
|
361 |
$codeImage = wordwrap($codeImage, 3, '_', true);
|
358 |
$format = $this->parametres['retour.format'];
|
362 |
$format = $this->parametres['retour.format'];
|
359 |
$codeImage .= '_'.$format;
|
363 |
$codeImage .= '_'.$format;
|
360 |
return $codeImage;
|
364 |
return $codeImage;
|
361 |
}
|
365 |
}
|
362 |
|
366 |
|
363 |
|
367 |
|
364 |
//+------------------------------------FORMATAGE LISTE----------------------------------------------------------------+
|
368 |
//+------------------------------------FORMATAGE LISTE----------------------------------------------------------------+
|
365 |
private function formaterListeImages() {
|
369 |
private function formaterListeImages() {
|
366 |
$entete = $this->construireEntete();
|
370 |
$entete = $this->construireEntete();
|
367 |
$resultats = $this->construireResultats();
|
371 |
$resultats = $this->construireResultats();
|
Line 445... |
Line 449... |
445 |
|
449 |
|
446 |
private function formaterInfosImage($img) {
|
450 |
private function formaterInfosImage($img) {
|
447 |
$info = array();
|
451 |
$info = array();
|
448 |
$info['date'] = $img['date'];
|
452 |
$info['date'] = $img['date'];
|
449 |
$info['mime'] = self::MIME_JPEG;
|
453 |
$info['mime'] = self::MIME_JPEG;
|
- |
|
454 |
$info['auteur.libelle'] = $this->formaterAuteur($img);
|
450 |
$info['auteur'] = $this->formaterAuteur($img);
|
455 |
$info['auteur.id'] = $img['utilisateur_id'];
|
451 |
$info['binaire.href'] = $this->formaterUrlImage($img);
|
456 |
$info['binaire.href'] = $this->formaterUrlImage($img);
|
452 |
$info['determination.libelle'] = $this->formaterDetermination($img);
|
457 |
$info['determination.libelle'] = $this->formaterDetermination($img);
|
453 |
$info['determination.nom_sci'] = $img['nom_sel'];
|
458 |
$info['determination.nom_sci'] = $img['nom_sel'];
|
454 |
$info['determination.nom_sci.code'] = $this->formaterNomSciCode($img);
|
459 |
$info['determination.nom_sci.code'] = $this->formaterNomSciCode($img);
|
455 |
$info = array_merge($info, $this->formaterStation($img));
|
460 |
$info = array_merge($info, $this->formaterStation($img));
|
456 |
return $info;
|
461 |
return $info;
|
457 |
}
|
462 |
}
|
458 |
|
463 |
|
459 |
private function extraireIntitulesAuteurs() {
|
464 |
private function extraireIntitulesAuteurs() {
|
460 |
$courriels = array();
|
465 |
$courriels = array();
|
461 |
foreach ($this->infosImages as $img) {
|
466 |
foreach ($this->infosImages as $img) {
|
462 |
$courriels[] = $img['utilisateur_courriel'];
|
467 |
$courriels[] = $img['utilisateur_courriel'];
|