| Line 123... |
Line 123... |
| 123 |
$obsAAjouter['is_public'] = '1';
|
123 |
$obsAAjouter['is_public'] = '1';
|
| 124 |
$obsAAjouter['date_created'] = date('Y-m-d H:i:s');
|
124 |
$obsAAjouter['date_created'] = date('Y-m-d H:i:s');
|
| 125 |
$obsAAjouter['date_updated'] = $obsAAjouter['date_created'];
|
125 |
$obsAAjouter['date_updated'] = $obsAAjouter['date_created'];
|
| 126 |
$obsAAjouter['date_published'] = $obsAAjouter['date_created'];
|
126 |
$obsAAjouter['date_published'] = $obsAAjouter['date_created'];
|
| Line -... |
Line 127... |
| - |
|
127 |
|
| - |
|
128 |
$obsAAjouter['image_nom'] = $obs['image_nom'] ?? null;
|
| - |
|
129 |
$obsAAjouter['image_b64'] = $obs['image_b64'] ?? null;
|
| 127 |
|
130 |
|
| 128 |
$obsAAjouter['certainty'] = '';
|
131 |
$obsAAjouter['certainty'] = '';
|
| 129 |
if (isset($obs['certitude'])) {
|
132 |
if (isset($obs['certitude'])) {
|
| 130 |
switch ($obs['certitude']) {
|
133 |
switch ($obs['certitude']) {
|
| 131 |
case 'certaine':
|
134 |
case 'certaine':
|
| Line 163... |
Line 166... |
| 163 |
$obs_a_taguer_ids = array();
|
166 |
$obs_a_taguer_ids = array();
|
| 164 |
$img_a_taguer_ids_noms = array();
|
167 |
$img_a_taguer_ids_noms = array();
|
| 165 |
$champsEtendusObs = array();
|
168 |
$champsEtendusObs = array();
|
| 166 |
foreach ($observations as $obs) {
|
169 |
foreach ($observations as $obs) {
|
| 167 |
$obs_etendue = $obs['obs_etendue'];
|
170 |
$obs_etendue = $obs['obs_etendue'];
|
| - |
|
171 |
$obs_images['image_nom'] = $obs['image_nom'];
|
| - |
|
172 |
$obs_images['image_b64'] = $obs['image_b64'];
|
| 168 |
unset($obs['obs_etendue']);
|
173 |
unset($obs['obs_etendue']);
|
| - |
|
174 |
unset($obs['image_nom']);
|
| - |
|
175 |
unset($obs['image_b64']);
|
| - |
|
176 |
|
| 169 |
$champs = implode(', ', array_keys($obs));
|
177 |
$champs = implode(', ', array_keys($obs));
|
| 170 |
$valeurs = implode(', ', $obs);
|
178 |
$valeurs = implode(', ', $obs);
|
| 171 |
$requete = "INSERT INTO occurrence ($champs) VALUES ($valeurs) ";
|
179 |
$requete = "INSERT INTO occurrence ($champs) VALUES ($valeurs) ";
|
| Line 172... |
Line 180... |
| 172 |
|
180 |
|
| Line 179... |
Line 187... |
| 179 |
$idNouvelleObs = Cel::db()->obtenirDernierId();
|
187 |
$idNouvelleObs = Cel::db()->obtenirDernierId();
|
| 180 |
$obs_a_taguer_ids[] = $idNouvelleObs;
|
188 |
$obs_a_taguer_ids[] = $idNouvelleObs;
|
| 181 |
$champsEtendusObs[$idNouvelleObs] = $obs_etendue;
|
189 |
$champsEtendusObs[$idNouvelleObs] = $obs_etendue;
|
| Line 182... |
Line 190... |
| 182 |
|
190 |
|
| 183 |
$imgAAjouter = null;
|
191 |
$imgAAjouter = null;
|
| 184 |
if (!empty($obs['image_nom'])) {
|
192 |
if (!empty($obs_images)) {
|
| 185 |
$imgAAjouter = $this->traiterImagesALierAObs($idNouvelleObs, $obs);
|
193 |
$imgAAjouter = $this->traiterImagesALierAObs($idNouvelleObs, $obs_images);
|
| 186 |
if ($imgAAjouter != null) {
|
194 |
if ($imgAAjouter != null) {
|
| 187 |
foreach ($imgAAjouter as $uneImgAAjouter) {
|
195 |
foreach ($imgAAjouter as $uneImgAAjouter) {
|
| 188 |
$nomsOriginauxImagesTemp[] = $uneImgAAjouter['nom'];
|
196 |
$nomsOriginauxImagesTemp[] = $uneImgAAjouter['nom'];
|
| 189 |
}
|
197 |
}
|
| Line 474... |
Line 482... |
| 474 |
if(! $champs_etendus_obs) return TRUE;
|
482 |
if(! $champs_etendus_obs) return TRUE;
|
| Line 475... |
Line 483... |
| 475 |
|
483 |
|
| 476 |
return $gestionChampsEtendus->ajouterParLots($champs_etendus_obs);
|
484 |
return $gestionChampsEtendus->ajouterParLots($champs_etendus_obs);
|
| Line 477... |
Line 485... |
| 477 |
}
|
485 |
}
|
| 478 |
|
486 |
|
| 479 |
private function traiterImagesALierAObs($idObs, $obs) {
|
487 |
private function traiterImagesALierAObs($idObs, $obsImages) {
|
| 480 |
$imgAAjouter = null;
|
488 |
$imgAAjouter = null;
|
| 481 |
if (is_array($obs['image_nom'])) {
|
489 |
if (is_array($obsImages['image_nom'])) {
|
| 482 |
$imgAAjouter = array();
|
490 |
$imgAAjouter = array();
|
| 483 |
foreach ($obs['image_nom'] as $index => $nom_image) {
|
491 |
foreach ($obsImages['image_nom'] as $index => $nom_image) {
|
| 484 |
$image = array();
|
492 |
$image = array();
|
| 485 |
$image['id_utilisateur'] = $this->userId;
|
493 |
$image['id_utilisateur'] = $this->userId;
|
| 486 |
$image['id_obs'] = $idObs;
|
- |
|
| 487 |
$image['nom'] = $nom_image;
|
494 |
$image['id_obs'] = $idObs;
|
| 488 |
$image['tags'] = isset($obs['image_tag'][$index]) ? explode(',',$obs['image_tag'][$index]) : '';
|
495 |
$image['nom'] = $nom_image;
|
| 489 |
// on suppose que les b64 des images sont envoyés dans le même ordre que leurs noms
|
496 |
// on suppose que les b64 des images sont envoyés dans le même ordre que leurs noms
|
| 490 |
// TODO: indexer le tableau avec le nom des images
|
497 |
// TODO: indexer le tableau avec le nom des images
|
| 491 |
$image['b64'] = isset($obs['image_b64'][$index]) ? $obs['image_b64'][$index] : '';
|
498 |
$image['b64'] = isset($obsImages['image_b64'][$index]) ? $obsImages['image_b64'][$index] : '';
|
| 492 |
$this->debug[] = 'Contient B64 : '.(empty($obs['image_b64']) ? 'non' : 'oui');
|
499 |
$this->debug[] = 'Contient B64 : '.(empty($obsImages['image_b64']) ? 'non' : 'oui');
|
| 493 |
$imgAAjouter[] = $image;
|
500 |
$imgAAjouter[] = $image;
|
| 494 |
}
|
501 |
}
|
| 495 |
} else {
|
502 |
} else {
|
| 496 |
if (!empty($obs['image_nom'])) {
|
503 |
if (!empty($obsImages['image_nom'])) {
|
| 497 |
$imgAAjouter = array();
|
504 |
$imgAAjouter = array();
|
| 498 |
$imgAAjouter['id_utilisateur'] = $this->userId;
|
505 |
$imgAAjouter['id_utilisateur'] = $this->userId;
|
| 499 |
$imgAAjouter['id_obs'] = $idObs;
|
- |
|
| 500 |
$imgAAjouter['nom'] = $obs['image_nom'];
|
506 |
$imgAAjouter['id_obs'] = $idObs;
|
| 501 |
//$imgAAjouter['tags'] = isset($obs['image_tag']) ? explode(',',$obs['image_tag']) : '';
|
507 |
$imgAAjouter['nom'] = $obsImages['image_nom'];
|
| 502 |
$imgAAjouter['b64'] = isset($obs['image_b64']) ? $obs['image_b64'] : array();
|
508 |
$imgAAjouter['b64'] = isset($obsImages['image_b64']) ? $obsImages['image_b64'] : array();
|
| 503 |
$this->debug[] = 'Contient B64 : '.(empty($obs['image_b64']) ? 'non' : 'oui');
|
509 |
$this->debug[] = 'Contient B64 : '.(empty($obsImages['image_b64']) ? 'non' : 'oui');
|
| Line 504... |
Line 510... |
| 504 |
}
|
510 |
}
|
| 505 |
}
|
511 |
}
|