ajout d'une galerie ok
This commit is contained in:
parent
da1f293379
commit
8c26b42dec
@ -395,44 +395,66 @@ 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()) {
|
||||||
|
$galleryId = $this->getInput('galleryAddName', null, true);
|
||||||
$galleryId = helper::increment($this->getInput('galleryAddName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0), 'content']));
|
$success = false;
|
||||||
$homePicture = '';
|
if ($galleryId ) {
|
||||||
// définir une vignette par défaut
|
$galleryId = helper::increment($this->getInput('galleryAddName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0), 'content']));
|
||||||
$directory = $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true);
|
$homePicture = '';
|
||||||
$iterator = new DirectoryIterator($directory);
|
// définir une vignette par défaut
|
||||||
foreach($iterator as $fileInfos) {
|
$directory = $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true);
|
||||||
if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) {
|
$iterator = new DirectoryIterator($directory);
|
||||||
// Créer la miniature si manquante
|
$i = 0;
|
||||||
if (!file_exists( str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()))) {
|
foreach($iterator as $fileInfos) {
|
||||||
$this->makeThumb($fileInfos->getPathname(),
|
if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) {
|
||||||
str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()),
|
$i += 1;
|
||||||
self::THUMBS_WIDTH);
|
// 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;
|
||||||
}
|
}
|
||||||
// Miniatures
|
}
|
||||||
$homePicture = strtolower($fileInfos->getFilename());
|
// Le dossier de la galerie est vide
|
||||||
break;
|
if ($i > 0) {
|
||||||
|
$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' => []
|
||||||
|
]]);
|
||||||
|
$success = true;
|
||||||
|
} else {
|
||||||
|
self::$inputNotices['galleryAddDirectory'] = "Le dossier sélectionné ne contient aucune image";
|
||||||
|
$success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->setData(['module', $this->getUrl(0), 'content', $galleryId, [
|
|
||||||
'config' => [
|
if ($success) {
|
||||||
'name' => $this->getInput('galleryAddName'),
|
// Valeurs en sortie
|
||||||
'directory' => $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true),
|
$this->addOutput([
|
||||||
'homePicture' => $homePicture,
|
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
|
||||||
'sort' => $this->getInput('galleryAddSort'),
|
'notification' => 'La galerie a été ajoutée',
|
||||||
'position' => count($this->getData(['module', $this->getUrl(0), 'content'])) + 1,
|
'state' => true
|
||||||
'fullScreen' => $this->getInput('galleryAddFullscreen', helper::FILTER_BOOLEAN),
|
]);
|
||||||
'showPageContent' => $this->getInput('galleryAddShowPageContent', helper::FILTER_BOOLEAN)
|
} else {
|
||||||
],
|
// Valeurs en sortie
|
||||||
'legend' => [],
|
$this->addOutput([
|
||||||
'positions' => []
|
'title' => 'Ajout d\'une galerie',
|
||||||
]]);
|
'view' => 'add'
|
||||||
// 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([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user