Merge branch 'gallery_stock_v2' into dev10_gallery_stock_v2

This commit is contained in:
Fred Tempez 2020-04-02 22:11:37 +02:00
commit 779a864761
9 changed files with 153 additions and 28 deletions

View File

@ -475,7 +475,7 @@ class common {
// La clef est une chaine // La clef est une chaine
else { else {
foreach($this->input as $type => $values) { foreach($this->input as $type => $values) {
// Champ obligatoire // Champ obligatoire
if($required) { if($required) {
$this->addRequiredInputNotices($key); $this->addRequiredInputNotices($key);
} }
@ -1111,6 +1111,36 @@ class common {
if (file_exists(self::DATA_DIR.'theme.css') === false) { if (file_exists(self::DATA_DIR.'theme.css') === false) {
unlink (self::DATA_DIR.'theme.css'); unlink (self::DATA_DIR.'theme.css');
} }
// Numérotation des galeries
// Lire toutes les pages et trouver celle avec le module gallery
// Parcourir les galeries du modules
// Verifier la présence des champs : sort et postion
// Tableau avec les pages
$pageList = array();
foreach ($this->getHierarchy(null,null,null) as $parentKey=>$parentValue) {
$pageList [] = $parentKey;
foreach ($parentValue as $childKey) {
$pageList [] = $childKey;
}
}
// Parcourir toutes les pages
foreach ($pageList as $parentKey => $parent) {
//La page a une galerie
if ($this->getData(['page',$parent,'moduleId']) === 'gallery' ) {
// Parcourir les dossiers de la galerie
$tempData = $this->getData(['module', $parent]);
$i = 1;
foreach ($tempData as $galleryKey => $galleryItem) {
if ( $this->getdata(['module',$parent,$galleryKey,'config','sort']) === NULL) {
$this->setdata(['module',$parent,$galleryKey,'config','sort','SORT_ASC']);
}
if ( $this->getdata(['module',$parent,$galleryKey,'config','position']) === NULL) {
$this->setdata(['module',$parent,$galleryKey,'config','position',$i++]);
}
}
}
}
$this->setData(['core', 'dataVersion', 9227]); $this->setData(['core', 'dataVersion', 9227]);
} }
// Version 10.0.00 // Version 10.0.00
@ -1118,6 +1148,7 @@ class common {
$this->setData(['config', 'faviconDark','faviconDark.ico']); $this->setData(['config', 'faviconDark','faviconDark.ico']);
$this->setData(['core', 'dataVersion', 10000]); $this->setData(['core', 'dataVersion', 10000]);
} }
} }
} }
@ -2372,4 +2403,4 @@ class layout extends common {
} }
} }
} }

View File

@ -15,6 +15,7 @@
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/light.css"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/light.css">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false) . self::DATA_DIR; ?>theme.css?<?php echo md5_file(self::DATA_DIR.'theme.css'); ?>"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false) . self::DATA_DIR; ?>theme.css?<?php echo md5_file(self::DATA_DIR.'theme.css'); ?>">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false) . self::DATA_DIR; ?>custom.css?<?php echo md5_file(self::DATA_DIR.'custom.css'); ?>"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false) . self::DATA_DIR; ?>custom.css?<?php echo md5_file(self::DATA_DIR.'custom.css'); ?>">
<?php $layout->showStyle(); ?>
</head> </head>
<body> <body>
<?php $layout->showNotification(); ?> <?php $layout->showNotification(); ?>

View File

@ -0,0 +1 @@
https://github.com/lukasoppermann/html5sortable

View File

@ -19,7 +19,8 @@ class gallery extends common {
'delete' => self::GROUP_MODERATOR, 'delete' => self::GROUP_MODERATOR,
'dirs' => self::GROUP_MODERATOR, 'dirs' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR, 'edit' => self::GROUP_MODERATOR,
'index' => self::GROUP_VISITOR 'filter' => self::GROUP_MODERATOR,
'index' => self::GROUP_VISITOR
]; ];
public static $sort = [ public static $sort = [
@ -34,16 +35,49 @@ class gallery extends common {
public static $galleries = []; public static $galleries = [];
public static $galleriesId = [];
public static $pictures = []; public static $pictures = [];
const GALLERY_VERSION = '1.3'; const GALLERY_VERSION = '2.0';
public function filter() {
// Traitement du tri
$data = explode('&',($this->getInput('galleryConfigFilterResponse')));
$data = str_replace('galleryTable%5B%5D=','',$data);
for($i=0;$i<count($data);$i++) {
$this->setData(['module', $this->getUrl(0), $data[$i], [
'config' => [
'name' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','name']),
'directory' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','directory']),
'homePicture' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','homePicture']),
'sort' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','sort']),
'position' => $i + 1
],
'legend' => $this->getData(['module',$this->getUrl(0),$data[$i],'legend'])
]]);
}
$this->saveData();
// Valeurs en sortie
// Recharge la page
header('Refresh: 0;url='. helper::baseUrl() . $this->getUrl() );
}
/** /**
* Configuration * Configuration
*/ */
public function config() { public function config() {
// Liste des galeries // Tri des galeries
$galleries = $this->getData(['module', $this->getUrl(0)]); $g = $this->getData(['module', $this->getUrl(0)]);
$p = helper::arrayCollumn(helper::arrayCollumn($g,'config'),'position');
asort($p,SORT_NUMERIC);
$galleries = [];
foreach ($p as $positionId => $item) {
$galleries [$positionId] = $g[$positionId];
}
// Traitement de l'affichage
if($galleries) { if($galleries) {
foreach($galleries as $galleryId => $gallery) { foreach($galleries as $galleryId => $gallery) {
// Erreur dossier vide // Erreur dossier vide
@ -57,7 +91,8 @@ class gallery extends common {
$gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . ' (dossier introuvable)</span>'; $gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . ' (dossier introuvable)</span>';
} }
// Met en forme le tableau // Met en forme le tableau
self::$galleries[] = [ self::$galleries[] = [
template::ico('sort'),
$gallery['config']['name'], $gallery['config']['name'],
$gallery['config']['directory'], $gallery['config']['directory'],
//$gallery['config']['order'], //$gallery['config']['order'],
@ -77,31 +112,41 @@ class gallery extends common {
'value' => template::ico('cancel') 'value' => template::ico('cancel')
]) ])
]; ];
// Tableau des id des galleries pour le drag and drop
self::$galleriesId[] = $galleryId;
} }
} }
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if($this->isPost()) {
$galleryId = helper::increment($this->getInput('galleryConfigName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0)])); if ($this->getInput('galleryConfigFilterResponse')) {
$this->setData(['module', $this->getUrl(0), $galleryId, [ self::filter();
'config' => [ } else {
'name' => $this->getInput('galleryConfigName'), $galleryId = helper::increment($this->getInput('galleryConfigName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0)]));
'directory' => $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true), $this->setData(['module', $this->getUrl(0), $galleryId, [
'sort' => $this->getInput('galleryConfigSort'), 'config' => [
'order' => count($this->getData(['module',$this->getUrl(0)])) + 1 'name' => $this->getInput('galleryConfigName'),
], 'directory' => $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true),
'legend' => [] 'sort' => $this->getInput('galleryConfigSort'),
]]); 'order' => count($this->getData(['module',$this->getUrl(0)])) + 1
// Valeurs en sortie ],
$this->addOutput([ 'legend' => []
'redirect' => helper::baseUrl() . $this->getUrl(), ]]);
'notification' => 'Modifications enregistrées', // Valeurs en sortie
'state' => true $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',
'view' => 'config' 'view' => 'config',
'vendor' => [
'tablednd'
]
]); ]);
} }
@ -308,8 +353,16 @@ class gallery extends common {
} }
// Liste des galeries // Liste des galeries
else { else {
foreach((array) $this->getData(['module', $this->getUrl(0)]) as $galleryId => $gallery) { // Tri des galeries
$g = $this->getData(['module', $this->getUrl(0)]);
$p = helper::arrayCollumn(helper::arrayCollumn($g,'config'),'position');
asort($p,SORT_NUMERIC);
$galleries = [];
foreach ($p as $positionId => $item) {
$galleries [$positionId] = $g[$positionId];
}
foreach((array) $galleries 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']);
foreach($iterator as $fileInfos) { foreach($iterator as $fileInfos) {

View File

@ -0,0 +1,3 @@
[
"tablednd.min.js"
]

View File

@ -0,0 +1 @@
https://github.com/isocra/TableDnD

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,24 @@
* @link http://zwiicms.com/ * @link http://zwiicms.com/
*/ */
/**
* Tri dynamique de la galerie
*/
$( document ).ready(function() {
$("#galleryTable").tableDnD({
onDrop: function(table, row) {
$("#galleryConfigFilterResponse").val($.tableDnD.serialize());
},
serializeRegexp: "[^\_]*$"
});
});
// Activer le bouton de tri uniquement après un tri
$("#galleryTable").mouseup(function(e) {
e.preventDefault();
$(":input[type='submit']").prop('disabled', false);
});
/** /**
* Confirmation de suppression * Confirmation de suppression
*/ */
@ -22,6 +40,8 @@ $(".galleryConfigDelete").on("click", function() {
}); });
}); });
/** /**
* Liste des dossiers * Liste des dossiers
*/ */
@ -62,4 +82,3 @@ directoryDOM.on("change", function() {
directoryOldDOM.val($(this).val()); directoryOldDOM.val($(this).val());
}); });

View File

@ -44,11 +44,25 @@
</div> </div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?>
<?php echo template::formOpen('galleryConfigFilterForm'); ?>
<?php if($module::$galleries): ?> <?php if($module::$galleries): ?>
<?php echo template::table([4, 6, 1, 1], $module::$galleries, ['Nom', 'Dossier cible', '', ''], ['id' => 'galleryTable']); ?> <?php echo template::table([1, 4, 5, 1, 1], $module::$galleries, ['','Nom', 'Dossier cible', '', ''], ['id' => 'galleryTable'],$module::$galleriesId); ?>
<?php echo template::hidden('galleryConfigFilterResponse'); ?>
<?php echo template::hidden('galleryConfigFilterSubmit',[
'value' => false
]); ?>
<?php else: ?> <?php else: ?>
<?php echo template::speech('Aucune galerie.'); ?> <?php echo template::speech('Aucune galerie.'); ?>
<?php endif; ?> <?php endif; ?>
<div class="row">
<div class="col2 offset10">
<?php echo template::submit('galleryConfigFilterSubmit', [
'value' => 'Trier',
'disabled' => true
]); ?>
</div>
</div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>
<div class="moduleVersion">Version <div class="moduleVersion">Version
<?php echo $module::GALLERY_VERSION; ?> <?php echo $module::GALLERY_VERSION; ?>