2.11 gestion des images supprimées ou ajoutées au dossier

This commit is contained in:
Fred Tempez 2020-04-16 14:15:49 +02:00
parent e02c2fd52f
commit 229ef395db

View File

@ -47,7 +47,7 @@ class gallery extends common {
public static $thumbs = []; public static $thumbs = [];
const GALLERY_VERSION = '2.10'; const GALLERY_VERSION = '2.11';
/** /**
@ -233,7 +233,7 @@ class gallery extends common {
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if($this->isPost()) {
/** /**
* $picturesPosition contien un tableau avec les images triées * $picturesPosition contient un tableau avec les images triées
*/ */
$picturesPosition = []; $picturesPosition = [];
if ($this->getInput('galleryEditFormResponse') && if ($this->getInput('galleryEditFormResponse') &&
@ -324,9 +324,18 @@ class gallery extends common {
case self::SORT_HAND: case self::SORT_HAND:
$positions = $this->getdata(['module',$this->getUrl(0), $this->getUrl(2),'position']); $positions = $this->getdata(['module',$this->getUrl(0), $this->getUrl(2),'position']);
if ($positions) { if ($positions) {
foreach ($positions as $position => $name) { foreach ($positions as $key => $value) {
$tempPictures [] = self::$pictures[$position]; if (array_key_exists($key,self::$pictures)) {
$tempPicturesId [] = $position; $tempPictures[$key] = self::$pictures[$key];
$tempPicturesId [] = $key;
}
}
// Images ayant été ajoutées dans le dossier mais non triées
foreach (self::$pictures as $key => $value) {
if (!array_key_exists($key,$tempPictures)) {
$tempPictures[$key] = self::$pictures[$key];
$tempPicturesId [] = $key;
}
} }
self::$pictures = $tempPictures; self::$pictures = $tempPictures;
self::$picturesId = $tempPicturesId; self::$picturesId = $tempPicturesId;