[9.2.22] Choix photo album

This commit is contained in:
Fred Tempez 2020-02-22 22:18:49 +01:00
parent af371a97e8
commit 1e39da2b65
5 changed files with 39 additions and 11 deletions

View File

@ -4,6 +4,10 @@
- Modifications : - Modifications :
- Aperçu de la police dans les sélecteurs. - Aperçu de la police dans les sélecteurs.
- Gestion du canal de mise à jour selon la version installée - Gestion du canal de mise à jour selon la version installée
- Module Blog : position des boutons d'édition de l'article au-dessus des commentaires.
- Module Gallery :
- choix de la vignette d'album
- Tri ordre naturel de la galerie et des images de la galerie
- Mises à jour : - Mises à jour :
- Configurations Code Mirror pour TinyMCE et standalone - Configurations Code Mirror pour TinyMCE et standalone

View File

@ -39,7 +39,7 @@ class gallery extends common {
// Liste des galeries // Liste des galeries
$galleries = $this->getData(['module', $this->getUrl(0)]); $galleries = $this->getData(['module', $this->getUrl(0)]);
if($galleries) { if($galleries) {
ksort($galleries); ksort($galleries,SORT_NATURAL);
foreach($galleries as $galleryId => $gallery) { foreach($galleries as $galleryId => $gallery) {
// Erreur dossier vide // Erreur dossier vide
if(is_dir($gallery['config']['directory'])) { if(is_dir($gallery['config']['directory'])) {
@ -165,16 +165,25 @@ class gallery extends common {
// 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)]);
} }
// légendes
$legends = []; $legends = [];
foreach((array) $this->getInput('legend', null) as $file => $legend) { foreach((array) $this->getInput('legend', null) as $file => $legend) {
$file = str_replace('.','',$file); $file = str_replace('.','',$file);
$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
$homePictures = [];
foreach((array) $this->getInput('homePicture', null) as $file => $homePicture) {
$homePictures[$file] = $file;
}
// Pas de sélection, retourne NULL plutôt que 0
// Permet de traiter aussi le cas où l'image d'album n'est pas définie.
$homePictures[$file] = $homePictures[$file] === 0 ? NULL : $homePictures[$file];
$this->setData(['module', $this->getUrl(0), $galleryId, [ $this->setData(['module', $this->getUrl(0), $galleryId, [
'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' => $homePictures[$file]
], ],
'legend' => $legends 'legend' => $legends
]]); ]]);
@ -193,6 +202,11 @@ class gallery extends common {
if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) { if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) {
self::$pictures[$fileInfos->getFilename()] = [ self::$pictures[$fileInfos->getFilename()] = [
$fileInfos->getFilename(), $fileInfos->getFilename(),
template::checkbox( 'homePicture[' . $fileInfos->getFilename() . ']', true, '', [
'checked' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2),'config', 'homePicture']) === $fileInfos->getFilename() ? true : false,
'class' => 'homePicture'
]),
template::text('legend[' . $fileInfos->getFilename() . ']', [ template::text('legend[' . $fileInfos->getFilename() . ']', [
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'legend', str_replace('.','',$fileInfos->getFilename())]) 'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'legend', str_replace('.','',$fileInfos->getFilename())])
]) ])
@ -200,7 +214,7 @@ class gallery extends common {
} }
} }
// Tri des images par ordre alphabétique // Tri des images par ordre alphabétique
ksort(self::$pictures); ksort(self::$pictures,SORT_NATURAL);
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -226,7 +240,7 @@ class gallery extends common {
// La galerie existe // La galerie existe
else { else {
// Images de la galerie // Images de la galerie
$directory = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'config', 'directory']); $directory = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'config', 'directory']);
if(is_dir($directory)) { if(is_dir($directory)) {
$iterator = new DirectoryIterator($directory); $iterator = new DirectoryIterator($directory);
foreach($iterator as $fileInfos) { foreach($iterator as $fileInfos) {
@ -235,7 +249,7 @@ class gallery extends common {
} }
} }
// Tri des images par ordre alphabétique // Tri des images par ordre alphabétique
ksort(self::$pictures); ksort(self::$pictures,SORT_NATURAL);
} }
// Affichage du template // Affichage du template
if(self::$pictures) { if(self::$pictures) {
@ -260,7 +274,7 @@ class gallery extends common {
} }
// Liste des galeries // Liste des galeries
else { else {
foreach((array) $this->getData(['module', $this->getUrl(0)]) as $galleryId => $gallery) { foreach((array) $this->getData(['module', $this->getUrl(0)]) as $galleryId => $gallery) {
if(is_dir($gallery['config']['directory'])) { if(is_dir($gallery['config']['directory'])) {
$iterator = new DirectoryIterator($gallery['config']['directory']); $iterator = new DirectoryIterator($gallery['config']['directory']);
@ -271,7 +285,6 @@ class gallery extends common {
continue(2); continue(2);
} }
} }
} }
} }
// Valeurs en sortie // Valeurs en sortie

View File

@ -48,4 +48,9 @@ setInterval(function() {
*/ */
directoryDOM.on("change", function() { directoryDOM.on("change", function() {
directoryOldDOM.val($(this).val()); directoryOldDOM.val($(this).val());
});
$('.homePicture').click(function(){
$('.homePicture').prop('checked', false);
$(this).prop('checked', true);
}); });

View File

@ -38,6 +38,6 @@
</div> </div>
</div> </div>
<?php if($module::$pictures): ?> <?php if($module::$pictures): ?>
<?php echo template::table([4, 8], $module::$pictures, ['Image', 'Légende']); ?> <?php echo template::table([4, 1, 7], $module::$pictures, ['Image', 'Album','Légende']); ?>
<?php endif; ?> <?php endif; ?>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -4,12 +4,18 @@
<?php foreach($module::$galleries as $galleryId => $gallery): ?> <?php foreach($module::$galleries as $galleryId => $gallery): ?>
<?php if($i % 2 === 1): ?> <?php if($i % 2 === 1): ?>
<div class="row"> <div class="row">
<?php endif; ?> <?php endif; ?>
<div class="col6"> <div class="col6">
<a <a
href="<?php echo helper::baseUrl() . $this->getUrl(0); ?>/<?php echo $galleryId; ?>" href="<?php echo helper::baseUrl() . $this->getUrl(0); ?>/<?php echo $galleryId; ?>"
class="galleryPicture" class="galleryPicture"
style="background-image:url('<?php echo helper::baseUrl(false) . $module::$firstPictures[$galleryId]; ?>')" style="background-image:url('<?php
if ($this->getData(['module', $this->getUrl(0), $galleryId, 'config', 'homePicture']) === NULL ) {
echo helper::baseUrl(false) . $module::$firstPictures[$galleryId];
} else {
echo helper::baseUrl(false) . $this->getData(['module', $this->getUrl(0), $galleryId, 'config', 'directory']) . '/' . $this->getData(['module', $this->getUrl(0), $galleryId, 'config', 'homePicture']);
}
?>')"
> >
<div class="galleryName"><?php echo $gallery['config']['name']; ?></div> <div class="galleryName"><?php echo $gallery['config']['name']; ?></div>
</a> </a>