album photo V4

This commit is contained in:
Deltacms 2023-11-01 11:17:08 +01:00
parent 70a38dc753
commit 0ac2431c45
1 changed files with 65 additions and 46 deletions

View File

@ -5,7 +5,7 @@
*/
setlocale(LC_NUMERIC,'English','en_US','en_US.UTF-8');
class album extends common {
const VERSION = '4.3.2';
const VERSION = '4.4';
const REALNAME = 'Album Photo';
const DELETE = true;
const UPDATE = '0.0';
@ -30,6 +30,20 @@ class album extends common {
'edit' => self::GROUP_EDITOR,
'index' => self::GROUP_VISITOR
];
/**
* Mise à jour du module
* Appelée par la fonction index
*/
private function update() {
// Versions < 4.4 : versionData absent
if( null === $this->getData(['module', $this->getUrl(0), 'config', 'versionData']) ) $this->setData(['module', $this->getUrl(0), 'config', 'versionData', '4.3']);
// Version 4.4
if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '4.4', '<') ) {
$this->setData(['module', $this->getUrl(0), 'config', 'versionData','4.4']);
}
}
/**
* Tri de la liste des galeries sans bouton
@ -128,58 +142,61 @@ class album extends common {
// Traitement de l'affichage
if($galleries) {
foreach($galleries as $galleryId => $gallery) {
// Erreur dossier vide
if(is_dir($gallery['config']['directory'])) {
if(count(scandir($gallery['config']['directory'])) === 2) {
$gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . $text['gallery']['config'][0].'</span>';
// pour ne pas prendre en compte la fausse galerie 'config'
if(isset($gallery['config']['directory'])){
// Erreur dossier vide
if(is_dir($gallery['config']['directory'])) {
if(count(scandir($gallery['config']['directory'])) === 2) {
$gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . $text['gallery']['config'][0].'</span>';
}
}
// Erreur dossier supprimé
else {
$gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . $text['gallery']['config'][1].'</span>';
}
// Met en forme le tableau
self::$galleries[] = [
template::ico('sort'),
$gallery['config']['name'],
str_replace('site/file/source/','',$gallery['config']['directory']),
template::button('galleryConfigEdit' . $galleryId , [
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $galleryId . '/' . $_SESSION['csrf'],
'value' => template::ico('pencil')
]),
template::button('galleryConfigDelete' . $galleryId, [
'class' => 'galleryConfigDelete buttonRed',
'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $galleryId . '/' . $_SESSION['csrf'],
'value' => template::ico('cancel'),
'disabled' => $this->getUser('group') >= self::GROUP_MODERATOR ? false : true
])
];
// Tableau des id des galleries pour le drag and drop
self::$galleriesId[] = $galleryId;
}
// Erreur dossier supprimé
else {
$gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . $text['gallery']['config'][1].'</span>';
}
// Met en forme le tableau
self::$galleries[] = [
template::ico('sort'),
$gallery['config']['name'],
str_replace('site/file/source/','',$gallery['config']['directory']),
template::button('galleryConfigEdit' . $galleryId , [
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $galleryId . '/' . $_SESSION['csrf'],
'value' => template::ico('pencil')
]),
template::button('galleryConfigDelete' . $galleryId, [
'class' => 'galleryConfigDelete buttonRed',
'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $galleryId . '/' . $_SESSION['csrf'],
'value' => template::ico('cancel'),
'disabled' => $this->getUser('group') >= self::GROUP_MODERATOR ? false : true
])
];
// Tableau des id des galleries pour le drag and drop
self::$galleriesId[] = $galleryId;
}
}
// Soumission du formulaire d'ajout d'un album
if($this->isPost()) {
if (!$this->getInput('galleryConfigFilterResponse')) {
$galleryId = helper::increment($this->getInput('galleryConfigName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0)]));
$this->setData(['module', $this->getUrl(0), $galleryId, [
'config' => [
'name' => $this->getInput('galleryConfigName'),
'directory' => $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true),
'homePicture' => NULL, // homePicture non préalablement définie
'sort' => self::SORT_ASC,
'position' => $this->getData(['module',$this->getUrl(0)]) !== null ? count($this->getData(['module',$this->getUrl(0)])) + 1 : 0
],
'legend' => [],
'order' => []
]]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(),
'notification' => $text['gallery']['config'][2],
'state' => true
]);
}
$galleryId = helper::increment($this->getInput('galleryConfigName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0)]));
$this->setData(['module', $this->getUrl(0), $galleryId, [
'config' => [
'name' => $this->getInput('galleryConfigName'),
'directory' => $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true),
'homePicture' => NULL, // homePicture non préalablement définie
'sort' => self::SORT_ASC,
'position' => $this->getData(['module',$this->getUrl(0)]) !== null ? count($this->getData(['module',$this->getUrl(0)])) + 1 : 0
],
'legend' => [],
'order' => []
]]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(),
'notification' => $text['gallery']['config'][2],
'state' => true
]);
}
}
// Valeurs en sortie
$this->addOutput([
@ -410,6 +427,8 @@ class album extends common {
* Accueil (deux affichages en un pour éviter une url à rallonge)
*/
public function index() {
// Mise à jour des données de module
$this->update();
// Images d'une galerie
if($this->getUrl(1)) {
// La galerie n'existe pas