Rafraichissement forcé

This commit is contained in:
Fred Tempez 2020-04-08 22:22:40 +02:00
parent 193843ae14
commit b44ef817e8
3 changed files with 51 additions and 39 deletions

View File

@ -49,7 +49,37 @@ class gallery extends common {
* Configuration * Configuration
*/ */
public function config() { public function config() {
// Tri des galeries
/*
* Le traitement du tri s'effectue en début de fonction
*/
// Soumission du formulaire
if($this->isPost()) {
if ($this->getInput('galleryConfigFilterResponse')) {
$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
],
'legend' => $this->getData(['module',$this->getUrl(0),$data[$i],'legend'])
]]);
}
}
// Valeurs en sortie
//header('Refresh: 0;url='. helper::baseUrl() . $this->getUrl() . '#galleryConfigFilterForm' );
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl() . '#galleryConfigFilterForm',
'notification' => 'Modifications enregistrées',
'state' => true
]);
}
// Tri pour l'affichage de la galerie
$g = $this->getData(['module', $this->getUrl(0)]); $g = $this->getData(['module', $this->getUrl(0)]);
$p = helper::arrayCollumn(helper::arrayCollumn($g,'config'),'position'); $p = helper::arrayCollumn(helper::arrayCollumn($g,'config'),'position');
asort($p,SORT_NUMERIC); asort($p,SORT_NUMERIC);
@ -89,36 +119,10 @@ class gallery extends common {
self::$galleriesId[] = $galleryId; self::$galleriesId[] = $galleryId;
} }
} }
// Soumission du formulaire // Soumission du formulaire d'ajouter d'une galerie
if($this->isPost()) { if($this->isPost()) {
// Tri de la galerie if (!$this->getInput('galleryConfigFilterResponse')) {
if ($this->getInput('galleryConfigFilterResponse')) {
$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
],
'legend' => $this->getData(['module',$this->getUrl(0),$data[$i],'legend'])
]]);
}
$this->saveData();
// Valeurs en sortie
$this->addOutput([
'title' => 'Configuration du module',
'view' => 'config',
'vendor' => [
'tablednd'
]
]);
} else {
$galleryId = helper::increment($this->getInput('galleryConfigName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0)])); $galleryId = helper::increment($this->getInput('galleryConfigName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0)]));
// La première image est celle de la couverture de l'album
$directory = $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true); $directory = $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true);
$iterator = new DirectoryIterator($directory); $iterator = new DirectoryIterator($directory);
foreach($iterator as $fileInfos) { foreach($iterator as $fileInfos) {
@ -149,7 +153,7 @@ class gallery extends common {
]]); ]]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(), 'redirect' => helper::baseUrl() . $this->getUrl(). '#galleryConfigForm',
'notification' => 'Modifications enregistrées', 'notification' => 'Modifications enregistrées',
'state' => true 'state' => true
]); ]);
@ -269,8 +273,7 @@ class gallery extends common {
]]); ]]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
//'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $this->getUrl(2) . '/' . $_SESSION['csrf'] ,
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $this->getUrl(2) . '/' . $_SESSION['csrf'],
'notification' => 'Modifications enregistrées', 'notification' => 'Modifications enregistrées',
'state' => true 'state' => true
]); ]);
@ -304,8 +307,7 @@ class gallery extends common {
self::$picturesId [] = str_replace('.','',$fileInfos->getFilename()); self::$picturesId [] = str_replace('.','',$fileInfos->getFilename());
} }
} }
// Tri des images par ordre alphabétique // Tri des images
switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'sort'])) { switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'sort'])) {
case 'SORT_HAND': case 'SORT_HAND':
$positions = $this->getdata(['module',$this->getUrl(0), $this->getUrl(2),'position']); $positions = $this->getdata(['module',$this->getUrl(0), $this->getUrl(2),'position']);
@ -326,7 +328,6 @@ class gallery extends common {
krsort(self::$pictures,SORT_NATURAL); krsort(self::$pictures,SORT_NATURAL);
rsort(self::$picturesId,SORT_NATURAL); rsort(self::$picturesId,SORT_NATURAL);
break; break;
} }
} }
// Valeurs en sortie // Valeurs en sortie

View File

@ -22,8 +22,17 @@ $( document ).ready(function() {
}, },
serializeRegexp: "[^\_]*$" serializeRegexp: "[^\_]*$"
}); });
/*
var href = window.location.href;
if(href.indexOf("#") > 0){
href = href.split("#")[0] + href.split("#")[1];
window.location.href = href;
}*/
}); });
// Activer le bouton de tri uniquement après un tri // Activer le bouton de tri uniquement après un tri
$("#galleryTable").click(function() { $("#galleryTable").click(function() {
if ($("#galleryConfigFilterResponse").val() != "") { if ($("#galleryConfigFilterResponse").val() != "") {
@ -82,4 +91,3 @@ setInterval(function() {
directoryDOM.on("change", function() { directoryDOM.on("change", function() {
directoryOldDOM.val($(this).val()); directoryOldDOM.val($(this).val());
}); });

View File

@ -37,7 +37,8 @@
<div class="col1 verticalAlignBottom"> <div class="col1 verticalAlignBottom">
<?php echo template::submit('galleryConfigSubmit', [ <?php echo template::submit('galleryConfigSubmit', [
'ico' => '', 'ico' => '',
'value' => template::ico('plus') 'value' => template::ico('plus'),
'class' => 'gallerySubmit'
]); ?> ]); ?>
</div> </div>
</div> </div>
@ -52,7 +53,9 @@
<h4>Galeries installées</h4> <h4>Galeries installées</h4>
<div class="col2 offset10"> <div class="col2 offset10">
<?php echo template::submit('galleryConfigFilterSubmit', [ <?php echo template::submit('galleryConfigFilterSubmit', [
'disabled' => true 'value' => 'Trier',
'disabled' => true,
'class' => 'gallerySubmit'
]); ?> ]); ?>
</div> </div>
<?php if($module::$galleries): ?> <?php if($module::$galleries): ?>