album photo V4
This commit is contained in:
parent
70a38dc753
commit
0ac2431c45
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
setlocale(LC_NUMERIC,'English','en_US','en_US.UTF-8');
|
setlocale(LC_NUMERIC,'English','en_US','en_US.UTF-8');
|
||||||
class album extends common {
|
class album extends common {
|
||||||
const VERSION = '4.3.2';
|
const VERSION = '4.4';
|
||||||
const REALNAME = 'Album Photo';
|
const REALNAME = 'Album Photo';
|
||||||
const DELETE = true;
|
const DELETE = true;
|
||||||
const UPDATE = '0.0';
|
const UPDATE = '0.0';
|
||||||
|
@ -30,6 +30,20 @@ class album extends common {
|
||||||
'edit' => self::GROUP_EDITOR,
|
'edit' => self::GROUP_EDITOR,
|
||||||
'index' => self::GROUP_VISITOR
|
'index' => self::GROUP_VISITOR
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mise à jour du module
|
||||||
|
* Appelée par la fonction index
|
||||||
|
*/
|
||||||
|
private function update() {
|
||||||
|
// Versions < 4.4 : versionData absent
|
||||||
|
if( null === $this->getData(['module', $this->getUrl(0), 'config', 'versionData']) ) $this->setData(['module', $this->getUrl(0), 'config', 'versionData', '4.3']);
|
||||||
|
|
||||||
|
// Version 4.4
|
||||||
|
if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '4.4', '<') ) {
|
||||||
|
$this->setData(['module', $this->getUrl(0), 'config', 'versionData','4.4']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tri de la liste des galeries sans bouton
|
* Tri de la liste des galeries sans bouton
|
||||||
|
@ -128,58 +142,61 @@ class album extends common {
|
||||||
// Traitement de l'affichage
|
// Traitement de l'affichage
|
||||||
if($galleries) {
|
if($galleries) {
|
||||||
foreach($galleries as $galleryId => $gallery) {
|
foreach($galleries as $galleryId => $gallery) {
|
||||||
// Erreur dossier vide
|
// pour ne pas prendre en compte la fausse galerie 'config'
|
||||||
if(is_dir($gallery['config']['directory'])) {
|
if(isset($gallery['config']['directory'])){
|
||||||
if(count(scandir($gallery['config']['directory'])) === 2) {
|
// Erreur dossier vide
|
||||||
$gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . $text['gallery']['config'][0].'</span>';
|
if(is_dir($gallery['config']['directory'])) {
|
||||||
|
if(count(scandir($gallery['config']['directory'])) === 2) {
|
||||||
|
$gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . $text['gallery']['config'][0].'</span>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// Erreur dossier supprimé
|
||||||
|
else {
|
||||||
|
$gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . $text['gallery']['config'][1].'</span>';
|
||||||
|
}
|
||||||
|
// Met en forme le tableau
|
||||||
|
self::$galleries[] = [
|
||||||
|
template::ico('sort'),
|
||||||
|
$gallery['config']['name'],
|
||||||
|
str_replace('site/file/source/','',$gallery['config']['directory']),
|
||||||
|
template::button('galleryConfigEdit' . $galleryId , [
|
||||||
|
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $galleryId . '/' . $_SESSION['csrf'],
|
||||||
|
'value' => template::ico('pencil')
|
||||||
|
]),
|
||||||
|
template::button('galleryConfigDelete' . $galleryId, [
|
||||||
|
'class' => 'galleryConfigDelete buttonRed',
|
||||||
|
'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $galleryId . '/' . $_SESSION['csrf'],
|
||||||
|
'value' => template::ico('cancel'),
|
||||||
|
'disabled' => $this->getUser('group') >= self::GROUP_MODERATOR ? false : true
|
||||||
|
])
|
||||||
|
];
|
||||||
|
// Tableau des id des galleries pour le drag and drop
|
||||||
|
self::$galleriesId[] = $galleryId;
|
||||||
}
|
}
|
||||||
// Erreur dossier supprimé
|
|
||||||
else {
|
|
||||||
$gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . $text['gallery']['config'][1].'</span>';
|
|
||||||
}
|
|
||||||
// Met en forme le tableau
|
|
||||||
self::$galleries[] = [
|
|
||||||
template::ico('sort'),
|
|
||||||
$gallery['config']['name'],
|
|
||||||
str_replace('site/file/source/','',$gallery['config']['directory']),
|
|
||||||
template::button('galleryConfigEdit' . $galleryId , [
|
|
||||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $galleryId . '/' . $_SESSION['csrf'],
|
|
||||||
'value' => template::ico('pencil')
|
|
||||||
]),
|
|
||||||
template::button('galleryConfigDelete' . $galleryId, [
|
|
||||||
'class' => 'galleryConfigDelete buttonRed',
|
|
||||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $galleryId . '/' . $_SESSION['csrf'],
|
|
||||||
'value' => template::ico('cancel'),
|
|
||||||
'disabled' => $this->getUser('group') >= self::GROUP_MODERATOR ? false : true
|
|
||||||
])
|
|
||||||
];
|
|
||||||
// Tableau des id des galleries pour le drag and drop
|
|
||||||
self::$galleriesId[] = $galleryId;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Soumission du formulaire d'ajout d'un album
|
// Soumission du formulaire d'ajout d'un album
|
||||||
if($this->isPost()) {
|
if($this->isPost()) {
|
||||||
if (!$this->getInput('galleryConfigFilterResponse')) {
|
if (!$this->getInput('galleryConfigFilterResponse')) {
|
||||||
$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)]));
|
||||||
$this->setData(['module', $this->getUrl(0), $galleryId, [
|
$this->setData(['module', $this->getUrl(0), $galleryId, [
|
||||||
'config' => [
|
'config' => [
|
||||||
'name' => $this->getInput('galleryConfigName'),
|
'name' => $this->getInput('galleryConfigName'),
|
||||||
'directory' => $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true),
|
'directory' => $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true),
|
||||||
'homePicture' => NULL, // homePicture non préalablement définie
|
'homePicture' => NULL, // homePicture non préalablement définie
|
||||||
'sort' => self::SORT_ASC,
|
'sort' => self::SORT_ASC,
|
||||||
'position' => $this->getData(['module',$this->getUrl(0)]) !== null ? count($this->getData(['module',$this->getUrl(0)])) + 1 : 0
|
'position' => $this->getData(['module',$this->getUrl(0)]) !== null ? count($this->getData(['module',$this->getUrl(0)])) + 1 : 0
|
||||||
],
|
],
|
||||||
'legend' => [],
|
'legend' => [],
|
||||||
'order' => []
|
'order' => []
|
||||||
]]);
|
]]);
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . $this->getUrl(),
|
'redirect' => helper::baseUrl() . $this->getUrl(),
|
||||||
'notification' => $text['gallery']['config'][2],
|
'notification' => $text['gallery']['config'][2],
|
||||||
'state' => true
|
'state' => true
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
|
@ -410,6 +427,8 @@ class album extends common {
|
||||||
* Accueil (deux affichages en un pour éviter une url à rallonge)
|
* Accueil (deux affichages en un pour éviter une url à rallonge)
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
|
// Mise à jour des données de module
|
||||||
|
$this->update();
|
||||||
// Images d'une galerie
|
// Images d'une galerie
|
||||||
if($this->getUrl(1)) {
|
if($this->getUrl(1)) {
|
||||||
// La galerie n'existe pas
|
// La galerie n'existe pas
|
||||||
|
|
Loading…
Reference in New Issue