add vide WIP

This commit is contained in:
fredtempez 2022-04-05 13:46:44 +02:00
parent 3da6f8970c
commit da1f293379
6 changed files with 106 additions and 136 deletions

View File

@ -378,52 +378,10 @@ class gallery extends common {
self::$galleriesId[] = $galleryId; self::$galleriesId[] = $galleryId;
} }
} }
// Soumission du formulaire d'ajout d'une galerie
/*
if($this->isPost()) {
if (!$this->getInput('galleryConfigFilterResponse')) {
$galleryId = helper::increment($this->getInput('galleryConfigName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0), 'content']));
// définir une vignette par défaut
$directory = $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true);
$iterator = new DirectoryIterator($directory);
foreach($iterator as $fileInfos) {
if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) {
// Créer la miniature si manquante
if (!file_exists( str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()))) {
$this->makeThumb($fileInfos->getPathname(),
str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()),
self::THUMBS_WIDTH);
}
// Miniatures
$homePicture = strtolower($fileInfos->getFilename());
break;
}
}
$this->setData(['module', $this->getUrl(0), 'content', $galleryId, [
'config' => [
'name' => $this->getInput('galleryConfigName'),
'directory' => $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true),
'homePicture' => $homePicture,
'sort' => $this->getInput('galleryConfigSort'),
'position' => count($this->getData(['module', $this->getUrl(0), 'content'])) + 1,
'fullScreen' => $this->getInput('galleryConfigFullscreen', helper::FILTER_BOOLEAN),
'showPageContent' => $this->getInput('galleryConfigShowPageContent', helper::FILTER_BOOLEAN)
],
'legend' => [],
'positions' => []
]]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(),
'notification' => 'Modifications enregistrées',
'state' => true
]);
}
}
*/
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => 'Configuration du module', 'title' => 'Configuration du module et des galeries',
'view' => 'config', 'view' => 'config',
'vendor' => [ 'vendor' => [
'tablednd' 'tablednd'
@ -437,44 +395,44 @@ class gallery extends common {
public function add() { public function add() {
// Soumission du formulaire d'ajout d'une galerie // Soumission du formulaire d'ajout d'une galerie
if($this->isPost()) { if($this->isPost()) {
if (!$this->getInput('galleryAddFilterResponse')) {
$galleryId = helper::increment($this->getInput('galleryAddName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0), 'content'])); $galleryId = helper::increment($this->getInput('galleryAddName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0), 'content']));
// définir une vignette par défaut $homePicture = '';
$directory = $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true); // définir une vignette par défaut
$iterator = new DirectoryIterator($directory); $directory = $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true);
foreach($iterator as $fileInfos) { $iterator = new DirectoryIterator($directory);
if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) { foreach($iterator as $fileInfos) {
// Créer la miniature si manquante if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) {
if (!file_exists( str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()))) { // Créer la miniature si manquante
$this->makeThumb($fileInfos->getPathname(), if (!file_exists( str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()))) {
str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()), $this->makeThumb($fileInfos->getPathname(),
self::THUMBS_WIDTH); str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()),
} self::THUMBS_WIDTH);
// Miniatures
$homePicture = strtolower($fileInfos->getFilename());
break;
} }
// Miniatures
$homePicture = strtolower($fileInfos->getFilename());
break;
} }
$this->setData(['module', $this->getUrl(0), 'content', $galleryId, [
'config' => [
'name' => $this->getInput('galleryAddName'),
'directory' => $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true),
'homePicture' => $homePicture,
'sort' => $this->getInput('galleryAddSort'),
'position' => count($this->getData(['module', $this->getUrl(0), 'content'])) + 1,
'fullScreen' => $this->getInput('galleryAddFullscreen', helper::FILTER_BOOLEAN),
'showPageContent' => $this->getInput('galleryAddShowPageContent', helper::FILTER_BOOLEAN)
],
'legend' => [],
'positions' => []
]]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', // '#galleryAddForm'*/,
'notification' => 'Modifications enregistrées',
'state' => true
]);
} }
$this->setData(['module', $this->getUrl(0), 'content', $galleryId, [
'config' => [
'name' => $this->getInput('galleryAddName'),
'directory' => $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true),
'homePicture' => $homePicture,
'sort' => $this->getInput('galleryAddSort'),
'position' => count($this->getData(['module', $this->getUrl(0), 'content'])) + 1,
'fullScreen' => $this->getInput('galleryAddFullscreen', helper::FILTER_BOOLEAN),
'showPageContent' => $this->getInput('galleryAddShowPageContent', helper::FILTER_BOOLEAN)
],
'legend' => [],
'positions' => []
]]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', // '#galleryAddForm'*/,
'notification' => 'Modifications enregistrées',
'state' => true
]);
} else { } else {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -540,14 +498,8 @@ class gallery extends common {
} }
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if($this->isPost()) {
// Photo de la page de garde de l'album définie dans form
if (is_array($this->getInput('homePicture', null)) ) {
$d = array_keys($this->getInput('homePicture', null));
$homePicture = $d[0];
}
// légendes // légendes
$legends = [];
$homePicture ='';
foreach((array) $this->getInput('legend', null) as $file => $legend) { foreach((array) $this->getInput('legend', null) as $file => $legend) {
// Image de couverture par défaut si non définie // Image de couverture par défaut si non définie
$homePicture = $file; $homePicture = $file;
@ -555,16 +507,21 @@ class gallery extends common {
$legends[$file] = helper::filter($legend, helper::FILTER_STRING_SHORT); $legends[$file] = helper::filter($legend, helper::FILTER_STRING_SHORT);
} }
// Photo de la page de garde de l'album définie dans form
if (is_array($this->getInput('homePicture', null)) ) {
// Extrait la couverture sélectionnée
$homePicture = array_keys($this->getInput('homePicture', null))[0];
}
// Sauvegarder // Sauvegarder
$this->setData(['module', $this->getUrl(0), 'content', $this->getUrl(2), [ $this->setData(['module', $this->getUrl(0), 'content', $this->getUrl(2), [
'config' => [ 'config' => [
'homePicture' => $homePicture,
// Données mises à jour par les options
'name' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'name']), 'name' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'name']),
'directory' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'directory']), 'directory' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'directory']),
'homePicture' => $homePicture,
// pas de positions, on active le tri alpha
'sort' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2),'config','sort']), 'sort' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2),'config','sort']),
'position' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2),'config', 'position']), 'position' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2),'config', 'position']),
'fullScreen' =>$this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'fullscreen']), 'fullScreen' =>$this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'fullScreen']),
'showPageContent' =>$this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'showPageContent']) 'showPageContent' =>$this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'showPageContent'])
], ],
@ -648,7 +605,7 @@ class gallery extends common {
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'name']), 'title' => 'Configuration de la galerie ' . $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'name']),
'view' => 'edit', 'view' => 'edit',
'vendor' => [ 'vendor' => [
'tablednd' 'tablednd'
@ -733,8 +690,8 @@ class gallery extends common {
'showBarEditButton' => true, 'showBarEditButton' => true,
'title' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'config', 'name']), 'title' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'config', 'name']),
'view' => 'gallery', 'view' => 'gallery',
'style' => file_exists($this->getData(['module', $this->getUrl(0), 'theme', 'style'])) 'style' => file_exists($this->getData(['module', $this->getUrl(0), 'theme', 'style']))
? $this->getData(['module', $this->getUrl(0), 'theme', 'style']) ? $this->getData(['module', $this->getUrl(0), 'theme', 'style'])
: '', : '',
'showPageContent' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'config', 'showPageContent']), 'showPageContent' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'config', 'showPageContent']),
]); ]);
@ -799,8 +756,8 @@ class gallery extends common {
'showBarEditButton' => true, 'showBarEditButton' => true,
'showPageContent' => true, 'showPageContent' => true,
'view' => 'index', 'view' => 'index',
'style' => file_exists($this->getData(['module', $this->getUrl(0), 'theme', 'style'])) 'style' => file_exists($this->getData(['module', $this->getUrl(0), 'theme', 'style']))
? $this->getData(['module', $this->getUrl(0), 'theme', 'style']) ? $this->getData(['module', $this->getUrl(0), 'theme', 'style'])
: '' : ''
]); ]);
} }
@ -883,7 +840,7 @@ class gallery extends common {
*/ */
public function option() { public function option() {
/** /**
* Bifurcation options des galleries ou option d'une galerie * Options applicables à toutes les galeries du module
*/ */
if ($this->getUrl(2) === 'galleries') { if ($this->getUrl(2) === 'galleries') {
// Jeton incorrect // Jeton incorrect
@ -896,17 +853,14 @@ class gallery extends common {
} }
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if($this->isPost()) {
// Dossier de l'instance
if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) { // Sauver la configuration de la galerie
mkdir (self::DATADIRECTORY . $this->getUrl(0), 0755, true);
}
$this->setData(['module', $this->getUrl(0), 'config', [ $this->setData(['module', $this->getUrl(0), 'config', [
'showUniqueGallery' => $this->getinput('galleryOptionShowUniqueGallery', helper::FILTER_BOOLEAN), 'showUniqueGallery' => $this->getinput('galleryOptionShowUniqueGallery', helper::FILTER_BOOLEAN),
'backPosition' => $this->getinput('galleryOptionBackPosition', null), 'backPosition' => $this->getinput('galleryOptionBackPosition', null),
'backAlign' => $this->getinput('galleryOptionBackAlign', null) 'backAlign' => $this->getinput('galleryOptionBackAlign', null)
]]); ]]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl() . '/option', 'redirect' => helper::baseUrl() . $this->getUrl() . '/option',
@ -921,9 +875,10 @@ class gallery extends common {
'title' => "Options des galeries", 'title' => "Options des galeries",
'view' => 'option' 'view' => 'option'
]); ]);
/**
* Enregistre les options de configuration de la galerie d'images sélectionnée
*/
} elseif ($this->getUrl(2) === 'gallery') { } elseif ($this->getUrl(2) === 'gallery') {
// Paramètre d'une galerie
// Jeton incorrect // Jeton incorrect
if ($this->getUrl(4) !== $_SESSION['csrf']) { if ($this->getUrl(4) !== $_SESSION['csrf']) {
// Valeurs en sortie // Valeurs en sortie
@ -934,15 +889,22 @@ class gallery extends common {
} }
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if($this->isPost()) {
// Si l'id a changée
$galleryId = !empty($this->getInput('galleryEditName')) ? $this->getInput('galleryEditName', helper::FILTER_ID, true) : $this->getUrl(2); // Le nom de la galerie est vide c'est le nom dans l'url qui est pris en compte
if($galleryId !== $this->getUrl(2)) { $galleryId = !empty($this->getInput('galleryEditName')) ? $this->getInput('galleryEditName', helper::FILTER_ID, true) : $this->getUrl(3);
// Sauvegarde des Valeurs non affectées par ce formulaire
$homePicture = $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(3), 'config', 'homePicture']);
$position = $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(3),'config','position']);
$legend = $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(3), 'legend']);
$positions = $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(3), 'positions']);
// Le nom de la galerie n'est pas celui dans la BDD
if($galleryId !== $this->getUrl(3)) {
// 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), 'content'])); $galleryId = helper::increment($galleryId, $this->getData(['module', $this->getUrl(0), 'content']));
// 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), 'content', $this->getUrl(2)]); $this->deleteData(['module', $this->getUrl(0), 'content', $this->getUrl(3)]);
} }
// Sauvegarder // Sauvegarder
if ($this->getInput('galleryEditName')) { if ($this->getInput('galleryEditName')) {
@ -950,15 +912,16 @@ class gallery extends common {
'config' => [ 'config' => [
'name' => $this->getInput('galleryEditName', helper::FILTER_STRING_SHORT, true), 'name' => $this->getInput('galleryEditName', helper::FILTER_STRING_SHORT, true),
'directory' => $this->getInput('galleryEditDirectory', helper::FILTER_STRING_SHORT, true), 'directory' => $this->getInput('galleryEditDirectory', helper::FILTER_STRING_SHORT, true),
'homePicture' => $this->getData(['module', $this->getUrl(0), 'content', $galleryId, 'config', 'homePicture']),
'sort' => $this->getInput('galleryEditSort'), 'sort' => $this->getInput('galleryEditSort'),
'position' => $this->getData(['module', $this->getUrl(0), 'content', $galleryId,'config','position']),
'fullScreen' => $this->getInput('galleryEditFullscreen', helper::FILTER_BOOLEAN), 'fullScreen' => $this->getInput('galleryEditFullscreen', helper::FILTER_BOOLEAN),
'showPageContent' => $this->getInput('galleryEditShowPageContent', helper::FILTER_BOOLEAN) 'showPageContent' => $this->getInput('galleryEditShowPageContent', helper::FILTER_BOOLEAN),
// Données lues à partir du formulaire edit de la galerie avec la liste des images
'homePicture' =>$homePicture,
'position' => $position
], ],
'legend' => $this->getData(['module', $this->getUrl(0), 'content', $galleryId, 'config', 'legend']), 'legend' => $legend,
'positions' => empty($oldPositions) ? $this->getData(['module', $this->getUrl(0), 'content', $galleryId, 'positions']) : $oldPositions 'positions' => $positions
]]); ]]);
} }
// Valeurs en sortie // Valeurs en sortie
@ -972,7 +935,7 @@ class gallery extends common {
self::$formOptionSelect = 'gallery'; self::$formOptionSelect = 'gallery';
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => "Options de la galerie", 'title' => "Options",
'view' => 'option' 'view' => 'option'
]); ]);
} else { } else {

View File

@ -8,11 +8,7 @@
]); ?> ]); ?>
</div> </div>
<div class="col2 offset9"> <div class="col2 offset9">
<?php echo template::submit('galleryAddSubmit', [ <?php echo template::submit('galleryAddSubmit'); ?>
'ico' => 'plus',
'value' => ' Ajouter',
'class' => 'gallerySubmit'
]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@ -25,10 +21,12 @@
'label' => 'Nom' 'label' => 'Nom'
]); ?> ]); ?>
</div> </div>
<div class="col5"> <div class="col6">
<?php echo template::hidden('galleryAddDirectoryOld', [ <div class="noDisplay">
'noDirty' => true // Désactivé à cause des modifications en ajax <?php echo template::hidden('galleryAddDirectoryOld', [
]); ?> 'noDirty' => true // Désactivé à cause des modifications en ajax
]); ?>
</div>
<?php echo template::select('galleryAddDirectory', [], [ <?php echo template::select('galleryAddDirectory', [], [
'label' => 'Dossier cible', 'label' => 'Dossier cible',
'noDirty' => true // Désactivé à cause des modifications en ajax 'noDirty' => true // Désactivé à cause des modifications en ajax

View File

@ -22,7 +22,8 @@
<div class="col1"> <div class="col1">
<?php echo template::button('galleryAdd', [ <?php echo template::button('galleryAdd', [
'href' => helper::baseUrl() . $this->getUrl(0) . '/add/', 'href' => helper::baseUrl() . $this->getUrl(0) . '/add/',
'value' => template::ico('plus') 'value' => template::ico('plus'),
'class' => 'buttonGreen'
]); ?> ]); ?>
</div> </div>
</div> </div>

View File

@ -75,3 +75,13 @@ function sortPictures() {
*/ */
}); });
} }
/**
* Checkbox unique
*/
$('.homePicture').click(function(){
$('.homePicture').prop('checked', false);
$(this).prop('checked', true);
});

View File

@ -66,7 +66,3 @@ $("#galleryOptionShowUniqueGallery").click(function() {
directoryOldDOM.val($(this).val()); directoryOldDOM.val($(this).val());
}); });
$('.homePicture').click(function(){
$('.homePicture').prop('checked', false);
$(this).prop('checked', true);
});

View File

@ -67,14 +67,16 @@
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::hidden('galleryEditDirectoryOld', [ <div class="noDisplay">
'value' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(3), 'config', 'directory']), <?php echo template::hidden('galleryEditDirectoryOld', [
'noDirty' => true // Désactivé à cause des modifications en ajax 'value' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(3), 'config', 'directory']),
]); ?> 'noDirty' => true // Désactivé à cause des modifications en ajax
<?php echo template::select('galleryEditDirectory', [], [ ]); ?>
'label' => 'Dossier cible', </div>
'noDirty' => true // Désactivé à cause des modifications en ajax <?php echo template::select('galleryEditDirectory', [], [
]); ?> 'label' => 'Dossier cible',
'noDirty' => true // Désactivé à cause des modifications en ajax
]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">