[9.2.10] Gallery module 1.3 structure modifiée pour la v10

This commit is contained in:
fredtempez 2019-11-04 12:22:26 +01:00
parent 757c15fc48
commit 68ac511781
1 changed files with 16 additions and 3 deletions

View File

@ -30,7 +30,7 @@ class gallery extends common {
public static $pictures = [];
const GALLERY_VERSION = '1.2';
const GALLERY_VERSION = '1.3';
/**
* Configuration
@ -167,6 +167,7 @@ class gallery extends common {
}
$legends = [];
foreach((array) $this->getInput('legend', null) as $file => $legend) {
$file = str_replace('.','',$file);
$legends[$file] = helper::filter($legend, helper::FILTER_STRING_SHORT);
}
@ -193,7 +194,7 @@ class gallery extends common {
self::$pictures[$fileInfos->getFilename()] = [
$fileInfos->getFilename(),
template::text('legend[' . $fileInfos->getFilename() . ']', [
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'legend', $fileInfos->getFilename()])
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'legend', str_replace('.','',$fileInfos->getFilename())])
])
];
}
@ -229,8 +230,20 @@ class gallery extends common {
if(is_dir($directory)) {
$iterator = new DirectoryIterator($directory);
foreach($iterator as $fileInfos) {
// Préparation des clés de légendes pour la v10
$data = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'legend']);
foreach ($data as $itemKey=>$itemValue) {
// Ancien nom avec un point devant l'extension ?
if (strpos($itemKey,'.') > 0) {
// Créer une nouvelle clé
$this->setData(['module', $this->getUrl(0), $this->getUrl(1), 'legend',str_replace('.','',$itemKey),$itemValue]);
// Supprimer la valeur
$this->deleteData(['module', $this->getUrl(0), $this->getUrl(1), 'legend',$itemKey]);
}
$this->saveData();
}
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', $fileInfos->getFilename()]);
self::$pictures[$directory . '/' . $fileInfos->getFilename()] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'legend', str_replace('.','',$fileInfos->getFilename())]);
}
}
// Tri des images par ordre alphabétique