bug edit galeri nom vide

This commit is contained in:
Fred Tempez 2020-09-22 19:20:35 +02:00
parent b8d464fea4
commit 027e75dd7e

View File

@ -253,7 +253,7 @@ class gallery extends common {
break; break;
} }
} }
if ( $this->getInput('galleryEditName') ) { if ( $this->getInput('galleryConfigName') ) {
$this->setData(['module', $this->getUrl(0), $galleryId, [ $this->setData(['module', $this->getUrl(0), $galleryId, [
'config' => [ 'config' => [
'name' => $this->getInput('galleryConfigName'), 'name' => $this->getInput('galleryConfigName'),
@ -352,7 +352,7 @@ class gallery extends common {
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if($this->isPost()) {
// Si l'id a changée // Si l'id a changée
$galleryId = $this->getInput('galleryEditName', helper::FILTER_ID, true); $galleryId = !empty($this->getInput('galleryEditName')) ? $this->getInput('galleryEditName', helper::FILTER_ID, true) : $this->getUrl(2);
if($galleryId !== $this->getUrl(2)) { if($galleryId !== $this->getUrl(2)) {
// 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)])); $galleryId = helper::increment($galleryId, $this->getData(['module', $this->getUrl(0)]));
@ -376,20 +376,22 @@ class gallery extends common {
$homePicture = $d[0]; $homePicture = $d[0];
} }
// Sauvegarder // Sauvegarder
$this->setData(['module', $this->getUrl(0), $galleryId, [ if ($this->getInput('galleryEditName')) {
'config' => [ $this->setData(['module', $this->getUrl(0), $galleryId, [
'name' => $this->getInput('galleryEditName', helper::FILTER_STRING_SHORT, true), 'config' => [
'directory' => $this->getInput('galleryEditDirectory', helper::FILTER_STRING_SHORT, true), 'name' => $this->getInput('galleryEditName', helper::FILTER_STRING_SHORT, true),
'homePicture' => $homePicture, 'directory' => $this->getInput('galleryEditDirectory', helper::FILTER_STRING_SHORT, true),
// pas de positions, on active le tri alpha 'homePicture' => $homePicture,
'sort' => $this->getInput('galleryEditSort'), // pas de positions, on active le tri alpha
'position' => $this->getData(['module', $this->getUrl(0), $galleryId,'config','positions']) === null ? count($this->getData(['module',$this->getUrl(0)]))-1 : $this->getData(['module', $this->getUrl(0), $galleryId,'config','positions']), 'sort' => $this->getInput('galleryEditSort'),
'fullScreen' => $this->getInput('galleryEditFullscreen', helper::FILTER_BOOLEAN) 'position' => $this->getData(['module', $this->getUrl(0), $galleryId,'config','positions']) === null ? count($this->getData(['module',$this->getUrl(0)]))-1 : $this->getData(['module', $this->getUrl(0), $galleryId,'config','positions']),
'fullScreen' => $this->getInput('galleryEditFullscreen', helper::FILTER_BOOLEAN)
], ],
'legend' => $legends, 'legend' => $legends,
'positions' => empty($oldPositions) ? $this->getdata(['module', $this->getUrl(0), $galleryId, 'positions']) : $oldPositions 'positions' => empty($oldPositions) ? $this->getdata(['module', $this->getUrl(0), $galleryId, 'positions']) : $oldPositions
]]); ]]);
}
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $galleryId . '/' . $_SESSION['csrf'] , 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $galleryId . '/' . $_SESSION['csrf'] ,