|
|
|
@ -153,11 +153,41 @@ class gallery extends common {
|
|
|
|
|
$class = get_called_class();
|
|
|
|
|
$moduleId = $this->getUrl(0);
|
|
|
|
|
|
|
|
|
|
// Installation des données de thème par défaut
|
|
|
|
|
|
|
|
|
|
// Mise à jour d'une version inférieure
|
|
|
|
|
if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '3.0', '<') ) {
|
|
|
|
|
// Changement de l'arborescence dans module.json
|
|
|
|
|
$data = $this->getData(['module', $this->getUrl(0)]);
|
|
|
|
|
$this->deleteData(['module', $this->getUrl(0)]);
|
|
|
|
|
$this->setData(['module', $this->getUrl(0), 'content', $data]);
|
|
|
|
|
// Effacer les fichiers CSS de l'ancienne version
|
|
|
|
|
if (file_exists('module/gallery/view/index/index.css')) {
|
|
|
|
|
unlink('module/gallery/view/index/index.css');
|
|
|
|
|
}
|
|
|
|
|
if (file_exists('module/gallery/view/gallery/gallery.css')) {
|
|
|
|
|
unlink('module/gallery/view/gallery/gallery.css');
|
|
|
|
|
}
|
|
|
|
|
// Stockage des données du thème de la gallery
|
|
|
|
|
$data = $this->getData(['theme','gallery']);
|
|
|
|
|
$this->deleteData(['theme','gallery']);
|
|
|
|
|
$this->setData(['module', $this->getUrl(0), 'config', $data]);
|
|
|
|
|
// Nouvelle version
|
|
|
|
|
$this->setData(['module', $this->getUrl(0), 'config', 'versionData', '3.0']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initialisation du thème d'un nouveau module
|
|
|
|
|
*/
|
|
|
|
|
private function initCSS() {
|
|
|
|
|
if ( $this->getData(['module', $this->getUrl(0), 'config']) === null ) {
|
|
|
|
|
require_once('module/gallery/ressource/defaultdata.php');
|
|
|
|
|
$this->setData(['module', $this->getUrl(0), 'config', theme::$defaultData]);
|
|
|
|
|
|
|
|
|
|
// Variables génériques
|
|
|
|
|
$class = get_called_class();
|
|
|
|
|
$moduleId = $this->getUrl(0);
|
|
|
|
|
|
|
|
|
|
// Dossier de l'instance
|
|
|
|
|
if (!is_dir(self::DATA_DIR . 'modules/' . $class)) {
|
|
|
|
|
mkdir (self::DATA_DIR . 'modules/' . $class, 0777, true);
|
|
|
|
@ -167,14 +197,10 @@ class gallery extends common {
|
|
|
|
|
$fileCSS = self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css' ;
|
|
|
|
|
$this->setData(['module', $this->getUrl(0), 'config', 'style', $fileCSS]);
|
|
|
|
|
|
|
|
|
|
// Créer le dossier du module
|
|
|
|
|
if (!is_dir(self::DATA_DIR . 'modules/' . $class)) {
|
|
|
|
|
mkdir (self::DATA_DIR . 'modules/' . $class, 0777, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Générer la feuille de CSS
|
|
|
|
|
$content = file_get_contents('module/gallery/ressource/vartheme.css');
|
|
|
|
|
$themeCss = file_get_contents('module/gallery/ressource/theme.css');
|
|
|
|
|
|
|
|
|
|
// Injection des variables
|
|
|
|
|
$content = str_replace('#thumbAlign#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbAlign']),$content );
|
|
|
|
|
$content = str_replace('#thumbWidth#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbWidth']),$content );
|
|
|
|
@ -193,27 +219,6 @@ class gallery extends common {
|
|
|
|
|
// Ecriture de la feuille de style
|
|
|
|
|
$success = file_put_contents(self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css' , $content . $themeCss);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Mise à jour d'une version inférieure
|
|
|
|
|
if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '3.0', '<') ) {
|
|
|
|
|
// Changement de l'arborescence dans module.json
|
|
|
|
|
$data = $this->getData(['module', $this->getUrl(0)]);
|
|
|
|
|
$this->deleteData(['module', $this->getUrl(0)]);
|
|
|
|
|
$this->setData(['module', $this->getUrl(0), 'content', $data]);
|
|
|
|
|
// Effacer les fichiers CSS de l'ancienne version
|
|
|
|
|
if (file_exists('module/gallery/view/index/index.css')) {
|
|
|
|
|
unlink('module/gallery/view/index/index.css');
|
|
|
|
|
}
|
|
|
|
|
if (file_exists('module/gallery/view/gallery/gallery.css')) {
|
|
|
|
|
unlink('module/gallery/view/gallery/gallery.css');
|
|
|
|
|
}
|
|
|
|
|
// Stockage des données du thème de la gallery
|
|
|
|
|
$data = $this->getData(['theme','gallery']);
|
|
|
|
|
$this->deleteData(['theme','gallery']);
|
|
|
|
|
$this->setData(['module', $this->getUrl(0), 'config', $data]);
|
|
|
|
|
// Nouvelle version
|
|
|
|
|
$this->setData(['module', $this->getUrl(0), 'config', 'versionData', '3.0']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -274,6 +279,10 @@ class gallery extends common {
|
|
|
|
|
* Configuration
|
|
|
|
|
*/
|
|
|
|
|
public function config() {
|
|
|
|
|
|
|
|
|
|
// Initialisation du thème d'un nouveau module
|
|
|
|
|
$this->initCss();
|
|
|
|
|
|
|
|
|
|
// Mise à jour des données de module
|
|
|
|
|
$this->update();
|
|
|
|
|
|
|
|
|
@ -556,6 +565,8 @@ class gallery extends common {
|
|
|
|
|
* Accueil (deux affichages en un pour éviter une url à rallonge)
|
|
|
|
|
*/
|
|
|
|
|
public function index() {
|
|
|
|
|
// Initialisation du thème du nouveau module
|
|
|
|
|
$this->initCss();
|
|
|
|
|
// Mise à jour des données de module
|
|
|
|
|
$this->update();
|
|
|
|
|
// Images d'une galerie
|
|
|
|
|