| Line 30... |
Line 30... |
| 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' => 'nom_sel_nn',
|
33 |
private $retour_champs = array('determination.nom_sci' => 'nom_sel', 'determination.nom_sci.code' => 'nom_sel_nn',
|
| 34 |
'station.lieudit' => 'lieudit', 'station', 'milieu');
|
34 |
'station.lieudit' => 'lieudit', 'station', 'milieu');
|
| - |
|
35 |
private $code_ref_tax_demande = null;
|
| 35 |
private $ref_tax_demande = array();
|
36 |
private $ref_tax_demande = array();
|
| 36 |
private $infosImages = array();
|
37 |
private $infosImages = array();
|
| 37 |
private $nbreImages = 0;
|
38 |
private $nbreImages = 0;
|
| 38 |
private $Utilisateurs = null;
|
39 |
private $Utilisateurs = null;
|
| 39 |
private $UrlNavigation = null;
|
40 |
private $UrlNavigation = null;
|
| Line 89... |
Line 90... |
| 89 |
$this->parametres['navigation.depart'] = 0;
|
90 |
$this->parametres['navigation.depart'] = 0;
|
| 90 |
}
|
91 |
}
|
| 91 |
if (isset($this->parametres['navigation.limite']) == false) {
|
92 |
if (isset($this->parametres['navigation.limite']) == false) {
|
| 92 |
$this->parametres['navigation.limite'] = 100;
|
93 |
$this->parametres['navigation.limite'] = 100;
|
| 93 |
}
|
94 |
}
|
| - |
|
95 |
if (isset($this->parametres['referentiel']) == false) {
|
| - |
|
96 |
$this->parametres['referentiel'] = self::CODE_REFTAX_DEFAUT;
|
| - |
|
97 |
}
|
| 94 |
}
|
98 |
}
|
| Line 95... |
Line 99... |
| 95 |
|
99 |
|
| 96 |
private function verifierParametres() {
|
100 |
private function verifierParametres() {
|
| Line 201... |
Line 205... |
| 201 |
}
|
205 |
}
|
| Line 202... |
Line 206... |
| 202 |
|
206 |
|
| 203 |
private function analyserMasqueNn() {
|
207 |
private function analyserMasqueNn() {
|
| 204 |
$nn = $this->parametres['masque.nn'];
|
208 |
$nn = $this->parametres['masque.nn'];
|
| 205 |
if (preg_match('/^[0-9]+$/', $nn)) {
|
209 |
if (preg_match('/^[0-9]+$/', $nn)) {
|
| 206 |
$this->ref_tax_demande[self::CODE_REFTAX_DEFAUT][] = $nn;
|
210 |
$this->ref_tax_demande[$this->parametres['referentiel']][] = $nn;
|
| 207 |
} else {
|
211 |
} else {
|
| 208 |
// ceci contient potentiellement des formes ref_tax1:nn1,nn2;ref_tax2:nn3,nn4
|
212 |
// ceci contient potentiellement des formes ref_tax1:nn1,nn2;ref_tax2:nn3,nn4
|
| 209 |
$projetsListeEtNumNoms = explode(';', $nn);
|
213 |
$projetsListeEtNumNoms = explode(';', $nn);
|
| 210 |
if (count($projetsListeEtNumNoms) > 0) {
|
214 |
if (count($projetsListeEtNumNoms) > 0) {
|
| 211 |
foreach ($projetsListeEtNumNoms as $projetEtNumNoms) {
|
215 |
foreach ($projetsListeEtNumNoms as $projetEtNumNoms) {
|
| 212 |
$projetEtNumNoms = (strpos($projetEtNumNoms, ':')) ? $projetEtNumNoms : self::CODE_REFTAX_DEFAUT.':'.$projetEtNumNoms;
|
216 |
$projetEtNumNoms = (strpos($projetEtNumNoms, ':')) ? $projetEtNumNoms : $this->parametres['referentiel'].':'.$projetEtNumNoms;
|
| 213 |
list($projet, $numNoms) = explode(':', $projetEtNumNoms);
|
217 |
list($projet, $numNoms) = explode(':', $projetEtNumNoms);
|
| 214 |
$this->ref_tax_demande[$projet] = explode(',', $numNoms);
|
218 |
$this->ref_tax_demande[$projet] = explode(',', $numNoms);
|
| 215 |
}
|
219 |
}
|
| 216 |
}
|
220 |
}
|
| 217 |
}
|
221 |
}
|
| Line 218... |
Line 222... |
| 218 |
}
|
222 |
}
|
| 219 |
|
223 |
|
| 220 |
|
224 |
|
| 221 |
//+---------------------------------------- REQUETES ---------------------------------------------------------------+
|
225 |
//+---------------------------------------- REQUETES ---------------------------------------------------------------+
|
| Line 222... |
Line -... |
| 222 |
private function obtenirIdImageAuHasard() {
|
- |
|
| 223 |
$refTax = self::CODE_REFTAX_DEFAUT;
|
- |
|
| 224 |
$numNom = $this->Bdd->proteger($this->ref_tax_demande[$refTax][0]);
|
226 |
private function obtenirIdImageAuHasard() {
|
| 225 |
|
227 |
$refTax = $this->parametres['referentiel'];
|
| 226 |
//TODO: modifier la requete lors du passage à la nouvelle base de données pour faire quelque chose
|
228 |
$numNom = $this->Bdd->proteger($this->ref_tax_demande[$refTax][0]);
|
| 227 |
// du numéro nomenclatural + modifier les champs appelés pour le nouveau format
|
229 |
|
| 228 |
$requete = 'SELECT coi.id_image AS id_image '.
|
230 |
$requete = 'SELECT coi.id_image AS id_image '.
|
| 229 |
'FROM cel_obs_images AS coi '.
|
231 |
'FROM cel_obs_images AS coi '.
|
| - |
|
232 |
' LEFT JOIN cel_obs AS co '.
|
| Line 230... |
Line 233... |
| 230 |
' LEFT JOIN cel_obs AS co '.
|
233 |
'ON (coi.id_observation = co.id_observation) '.
|
| Line 231... |
Line 234... |
| 231 |
'ON (coi.id_observation = co.id_observation) '.
|
234 |
'WHERE ci.transmission = 1 '.
|
| 232 |
'WHERE ci.transmission = 1 '.
|
235 |
" AND ci.nom_ret_nn IN ($numNom)";
|
| Line 243... |
Line 246... |
| 243 |
$id_image_hasard = $resultat[array_rand($resultat)]['id_image'];
|
246 |
$id_image_hasard = $resultat[array_rand($resultat)]['id_image'];
|
| 244 |
return $id_image_hasard;
|
247 |
return $id_image_hasard;
|
| 245 |
}
|
248 |
}
|
| Line 246... |
Line 249... |
| 246 |
|
249 |
|
| 247 |
private function obtenirIdPremiereImage() {
|
250 |
private function obtenirIdPremiereImage() {
|
| 248 |
$refTax = self::CODE_REFTAX_DEFAUT;
|
251 |
$refTax = $this->parametres['referentiel'];
|
| 249 |
$numNom = $this->Bdd->proteger($this->ref_tax_demande[$refTax][0]);
|
252 |
$numNom = $this->Bdd->proteger($this->ref_tax_demande[$refTax][0]);
|
| 250 |
$requete = 'SELECT ci.id_image AS id_image '.
|
253 |
$requete = 'SELECT ci.id_image AS id_image '.
|
| 251 |
'FROM cel_images AS ci'.
|
254 |
'FROM cel_images AS ci'.
|
| 252 |
' LEFT JOIN cel_obs_images AS coi '.
|
255 |
' LEFT JOIN cel_obs_images AS coi '.
|
| 253 |
' ON (coi.id_image = ci.id_image) '.
|
256 |
' ON (coi.id_image = ci.id_image) '.
|
| 254 |
' LEFT JOIN cel_obs AS co '.
|
257 |
' LEFT JOIN cel_obs AS co '.
|
| 255 |
' ON (coi.id_observation = co.id_observation) '.
|
258 |
' ON (coi.id_observation = co.id_observation) '.
|
| 256 |
'WHERE co.transmission = 1 '.
|
259 |
'WHERE co.transmission = 1 '.
|
| 257 |
" AND co.nom_ret_nn IN ($numNom) ".
|
260 |
" AND co.nom_ret_nn IN ($numNom) ".
|
| - |
|
261 |
' AND ci.date_prise_de_vue != "0000-00-00" ORDER BY ci.date_prise_de_vue ASC '.
|
| 258 |
' AND ci.date_prise_de_vue != "0000-00-00" ORDER BY ci.date_prise_de_vue ASC '.
|
262 |
' AND co.nom_referentiel LIKE '.$this->proteger($refTax.'%').' '.
|
| Line 259... |
Line 263... |
| 259 |
'LIMIT 1';
|
263 |
'LIMIT 1';
|
| Line 260... |
Line 264... |
| 260 |
|
264 |
|
| Line 270... |
Line 274... |
| 270 |
return $id_image_hasard;
|
274 |
return $id_image_hasard;
|
| 271 |
}
|
275 |
}
|
| Line 272... |
Line 276... |
| 272 |
|
276 |
|
| 273 |
private function chargerInfosImage() {
|
277 |
private function chargerInfosImage() {
|
| 274 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS '.
|
278 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS '.
|
| 275 |
' ci.id_image AS id_img, ci.date_creation AS date, '.
|
279 |
' ci.id_image AS id_img, co.date_observation AS date, '.
|
| 276 |
' co.id_observation AS id_obs, '.
|
280 |
' co.id_observation AS id_obs, '.
|
| 277 |
' ci.courriel_utilisateur AS utilisateur_courriel, '.
|
281 |
' ci.courriel_utilisateur AS utilisateur_courriel, '.
|
| 278 |
' nom_sel, nom_sel_nn, '.
|
282 |
' nom_sel, nom_sel_nn, '.
|
| 279 |
' zone_geo, ce_zone_geo, lieudit, station, milieu '.
|
283 |
' zone_geo, ce_zone_geo, lieudit, station, milieu '.
|
| Line 286... |
Line 290... |
| 286 |
|
290 |
|
| 287 |
$this->infosImages = $this->Bdd->recupererTous($requete);
|
291 |
$this->infosImages = $this->Bdd->recupererTous($requete);
|
| Line 288... |
Line 292... |
| 288 |
}
|
292 |
}
|
| 289 |
|
293 |
|
| 290 |
private function chargerListeImages() {
|
294 |
private function chargerListeImages() {
|
| 291 |
$refTax = self::CODE_REFTAX_DEFAUT;
|
295 |
$refTax = $this->parametres['referentiel'];
|
| 292 |
$numNomListe = implode(',', $this->ref_tax_demande[$refTax]);
|
296 |
$numNomListe = implode(',', $this->ref_tax_demande[$refTax]);
|
| Line 293... |
Line 297... |
| 293 |
$depart = $this->parametres['navigation.depart'];
|
297 |
$depart = $this->parametres['navigation.depart'];
|
| 294 |
$limite = $this->parametres['navigation.limite'];
|
298 |
$limite = $this->parametres['navigation.limite'];
|
| 295 |
|
299 |
|
| 296 |
//TODO: modifier la requete lors du passage à la nouvelle base de données pour faire quelque chose
|
300 |
//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
|
301 |
// du numéro nomenclatural + modifier les champs appelés pour le nouveau format
|
| 298 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS '.
|
302 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS '.
|
| 299 |
' co.id_observation AS id_obs, co.courriel_utilisateur AS utilisateur_courriel, co.zone_geo, co.ce_zone_geo, '.
|
303 |
' co.id_observation AS id_obs, co.courriel_utilisateur AS utilisateur_courriel, co.zone_geo, co.ce_zone_geo, '.
|
| 300 |
' co.nom_sel, co.nom_sel_nn, '.
|
304 |
' co.nom_sel, co.nom_sel_nn, '.
|
| 301 |
' ci.id_image AS id_img, ci.date_prise_de_vue AS date '.
|
305 |
' ci.id_image AS id_img, co.date_observation AS date '.
|
| 302 |
(isset($this->parametres['retour.champs']) ? ', '.$this->parametres['retour.champs'] : '').
|
306 |
(isset($this->parametres['retour.champs']) ? ', '.$this->parametres['retour.champs'] : '').
|
| 303 |
'FROM cel_images AS ci'.
|
307 |
'FROM cel_images AS ci'.
|
| Line 312... |
Line 316... |
| 312 |
|
316 |
|
| 313 |
$this->infosImages = $this->Bdd->recupererTous($requete);
|
317 |
$this->infosImages = $this->Bdd->recupererTous($requete);
|
| Line 314... |
Line 318... |
| 314 |
}
|
318 |
}
|
| - |
|
319 |
|
| 315 |
|
320 |
private function formerRequeteConditions($numNomListe) {
|
| 316 |
private function formerRequeteConditions($numNomListe) {
|
- |
|
| 317 |
$where[] = " co.transmission = 1 AND co.nom_ret_nn IN ($numNomListe) ";
|
321 |
$refTax = $this->parametres['referentiel'];
|
| 318 |
if (isset($this->parametres['retour.tri']) && $this->parametres['retour.tri'] == 'date') {
|
322 |
$where[] = " co.transmission = 1 AND co.nom_ret_nn IN ($numNomListe) ";
|
| 319 |
$where[] = ' ci.date_prise_de_vue != "0000-00-00"';
|
323 |
$where[] = " co.nom_referentiel LIKE ".$this->Bdd->proteger($refTax."%").' ';
|
| 320 |
}
|
324 |
|
| Line 321... |
Line 325... |
| 321 |
return ' WHERE '.implode(' AND ', $where);
|
325 |
return ' WHERE '.implode(' AND ', $where);
|
| 322 |
}
|
326 |
}
|
| 323 |
|
327 |
|
| 324 |
private function formerRequeteTri() {
|
328 |
private function formerRequeteTri() {
|
| 325 |
$order = '';
|
329 |
$order = '';
|
| 326 |
if (isset($this->parametres['retour.tri']) && $this->parametres['retour.tri'] == 'date') {
|
330 |
if (isset($this->parametres['retour.tri']) && $this->parametres['retour.tri'] == 'date') {
|
| 327 |
$order = ' ORDER BY ci.date_prise_de_vue ASC ';
|
331 |
$order = ' ORDER BY co.date_observation ASC ';
|
| Line 328... |
Line 332... |
| 328 |
}
|
332 |
}
|
| Line 495... |
Line 499... |
| 495 |
$auteur = $this->Utilisateurs->getIntitule($infos['utilisateur_courriel']);
|
499 |
$auteur = $this->Utilisateurs->getIntitule($infos['utilisateur_courriel']);
|
| 496 |
return $infos['nom_sel']."[Dét. : $auteur]";
|
500 |
return $infos['nom_sel']."[Dét. : $auteur]";
|
| 497 |
}
|
501 |
}
|
| Line 498... |
Line 502... |
| 498 |
|
502 |
|
| 499 |
private function formaterNomSciCode($infos) {
|
503 |
private function formaterNomSciCode($infos) {
|
| 500 |
return self::CODE_REFTAX_DEFAUT.'.'.$infos['nom_sel_nn'];
|
504 |
return $this->parametres['referentiel'].'.'.$infos['nom_sel_nn'];
|
| Line 501... |
Line 505... |
| 501 |
}
|
505 |
}
|
| 502 |
|
506 |
|
| 503 |
private function formaterStation($infos) {
|
507 |
private function formaterStation($infos) {
|
| Line 524... |
Line 528... |
| 524 |
private function formaterCommune($infos) {
|
528 |
private function formaterCommune($infos) {
|
| 525 |
$commune = array();
|
529 |
$commune = array();
|
| 526 |
if ($this->avoirContenu($infos['zone_geo'])) {
|
530 |
if ($this->avoirContenu($infos['zone_geo'])) {
|
| 527 |
$commune[] = $infos['zone_geo'];
|
531 |
$commune[] = $infos['zone_geo'];
|
| 528 |
}
|
532 |
}
|
| 529 |
if (isset($infos['ce_zone_geo']) && $this->avoirContenu($infos['ce_zone_geo'])) {
|
533 |
if (isset($infos['ce_zone_geo']) && $this->avoirContenu($infos['ce_zone_geo']) && $infos['ce_zone_geo'] != 'INSEE-C:') {
|
| 530 |
$commune[] = '('.substr(str_replace('INSEE-C:','',$infos['ce_zone_geo']), 0, 2).')';
|
534 |
$commune[] = '('.substr(str_replace('INSEE-C:','',$infos['ce_zone_geo']), 0, 2).')';
|
| 531 |
}
|
535 |
}
|
| 532 |
return implode(' ', $commune);
|
536 |
return implode(' ', $commune);
|
| 533 |
}
|
537 |
}
|
| Line 534... |
Line 538... |
| 534 |
|
538 |
|
| 535 |
private function avoirContenu($info) {
|
- |
|
| 536 |
$vide = true;
|
539 |
private function avoirContenu($info) {
|
| 537 |
if ($info == null || $info == '' || $info == '000null') {
|
- |
|
| 538 |
$vide = false;
|
- |
|
| 539 |
}
|
- |
|
| 540 |
return $vide;
|
540 |
return !($info == null || $info == '' || $info == '000null');
|
| 541 |
}
|
541 |
}
|
| 542 |
}
|
542 |
}
|
| 543 |
?>
|
543 |
?>
|