2.24 bug : position manuelles perdues si la galerie change de nom. position devient positions dans json

This commit is contained in:
Fred Tempez 2020-04-30 18:45:42 +02:00
parent a559558f9d
commit da8fadecc3
2 changed files with 16 additions and 14 deletions

View File

@ -572,7 +572,7 @@ class init extends common {
'icebergjpg' => 'Un iceberg', 'icebergjpg' => 'Un iceberg',
'meadowjpg' => 'Une prairie' 'meadowjpg' => 'Une prairie'
], ],
'position' => [ 'positions' => [
'desertjpg' => 3, 'desertjpg' => 3,
'icebergjpg' => 1, 'icebergjpg' => 1,
'meadowjpg' => 2 'meadowjpg' => 2
@ -591,7 +591,7 @@ class init extends common {
'cosmosjpg' => 'Le cosmos', 'cosmosjpg' => 'Le cosmos',
'nebulajpg' => 'Une nébuleuse' 'nebulajpg' => 'Une nébuleuse'
], ],
'position' => [ 'positions' => [
'earthjpg' => 1, 'earthjpg' => 1,
'cosmosjpg' => 3, 'cosmosjpg' => 3,
'nebulajpg' => 2 'nebulajpg' => 2

View File

@ -19,7 +19,7 @@ class gallery extends common {
const SORT_ASC = 'SORT_ASC'; const SORT_ASC = 'SORT_ASC';
const SORT_DSC = 'SORT_DSC'; const SORT_DSC = 'SORT_DSC';
const SORT_HAND = 'SORT_HAND'; const SORT_HAND = 'SORT_HAND';
const GALLERY_VERSION = '2.23'; const GALLERY_VERSION = '2.24';
public static $directories = []; public static $directories = [];
@ -142,12 +142,12 @@ class gallery extends common {
'directory' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','directory']), 'directory' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','directory']),
'homePicture' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','homePicture']), 'homePicture' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','homePicture']),
'sort' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','sort']), 'sort' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','sort']),
'position' => $i, 'position'=> $i,
'fullScreen' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','fullScreen']) 'fullScreen' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','fullScreen'])
], ],
'legend' => $this->getData(['module',$this->getUrl(0),$data[$i],'legend']), 'legend' => $this->getData(['module',$this->getUrl(0),$data[$i],'legend']),
'position' => $this->getData(['module',$this->getUrl(0),$data[$i],'position']) 'positions' => $this->getData(['module',$this->getUrl(0),$data[$i],'positions'])
]]); ]]);
} }
} }
@ -169,12 +169,12 @@ class gallery extends common {
'directory' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','directory']), 'directory' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','directory']),
'homePicture' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','homePicture']), 'homePicture' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','homePicture']),
'sort' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','sort']), 'sort' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','sort']),
'position' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','position']), 'position' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','positions']),
'fullScreen' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','fullScreen']) 'fullScreen' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','fullScreen'])
], ],
'legend' => $this->getData(['module',$this->getUrl(0),$galleryName,'legend']), 'legend' => $this->getData(['module',$this->getUrl(0),$galleryName,'legend']),
'position' => array_flip($data) 'positions' => array_flip($data)
]]); ]]);
} }
} }
@ -254,7 +254,7 @@ class gallery extends common {
'fullScreen' => false 'fullScreen' => false
], ],
'legend' => [], 'legend' => [],
'position' => [] 'positions' => []
]]); ]]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -345,6 +345,8 @@ class gallery extends common {
if($galleryId !== $this->getUrl(2)) { if($galleryId !== $this->getUrl(2)) {
// Incrémente le nouvel id de la galerie // Incrémente le nouvel id de la galerie
$galleryId = helper::increment($galleryId, $this->getData(['module', $this->getUrl(0)])); $galleryId = helper::increment($galleryId, $this->getData(['module', $this->getUrl(0)]));
// Transférer la position des images
$oldPositions = $this->getData(['module',$this->getUrl(0), $this->getUrl(2),'positions']);
// Supprime l'ancienne galerie // Supprime l'ancienne galerie
$this->deleteData(['module', $this->getUrl(0), $this->getUrl(2)]); $this->deleteData(['module', $this->getUrl(0), $this->getUrl(2)]);
} }
@ -370,12 +372,12 @@ class gallery extends common {
'homePicture' => $homePicture, 'homePicture' => $homePicture,
// pas de positions, on active le tri alpha // pas de positions, on active le tri alpha
'sort' => $this->getInput('galleryEditSort'), 'sort' => $this->getInput('galleryEditSort'),
'position' => $this->getData(['module', $this->getUrl(0), $galleryId,'config','position']) === '' ? count($this->getData(['module',$this->getUrl(0)]))-1 : $this->getData(['module', $this->getUrl(0), $galleryId,'config','position']), 'position' => $this->getData(['module', $this->getUrl(0), $galleryId,'config','positions']) === '' ? count($this->getData(['module',$this->getUrl(0)]))-1 : $this->getData(['module', $this->getUrl(0), $galleryId,'config','positions']),
'fullScreen' => $this->getInput('galleryEditFullscreen', helper::FILTER_BOOLEAN) 'fullScreen' => $this->getInput('galleryEditFullscreen', helper::FILTER_BOOLEAN)
], ],
'legend' => $legends, 'legend' => $legends,
'position' => $this->getdata(['module', $this->getUrl(0), $galleryId, 'position']) 'positions' => empty($oldPositions) ? $this->getdata(['module', $this->getUrl(0), $galleryId, 'positions']) : $oldPositions
]]); ]]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -415,7 +417,7 @@ class gallery extends common {
// Tri des images // Tri des images
switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'sort'])) { switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'sort'])) {
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),'positions']);
if ($positions) { if ($positions) {
foreach ($positions as $key => $value) { foreach ($positions as $key => $value) {
if (array_key_exists($key,self::$pictures)) { if (array_key_exists($key,self::$pictures)) {
@ -477,7 +479,7 @@ class gallery extends common {
foreach($iterator as $fileInfos) { foreach($iterator as $fileInfos) {
if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) { if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) {
self::$pictures[$directory . '/' . $fileInfos->getFilename()] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'legend', str_replace('.','',$fileInfos->getFilename())]); self::$pictures[$directory . '/' . $fileInfos->getFilename()] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'legend', str_replace('.','',$fileInfos->getFilename())]);
$picturesSort[$directory . '/' . $fileInfos->getFilename()] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'position', str_replace('.','',$fileInfos->getFilename())]); $picturesSort[$directory . '/' . $fileInfos->getFilename()] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'positions', str_replace('.','',$fileInfos->getFilename())]);
// Créer la miniature si manquante // Créer la miniature si manquante
if (!file_exists( str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()))) { if (!file_exists( str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()))) {
$this->makeThumb($fileInfos->getPathname(), $this->makeThumb($fileInfos->getPathname(),