From 650ae755be090b912feb12bff37a96706b75d40e Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sun, 4 Apr 2021 19:11:41 +0200 Subject: [PATCH] bug modif theme + init feuille de style --- module/gallery/gallery.php | 56 ++++++++++++++--------------- module/gallery/view/theme/theme.php | 28 +++++++-------- 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index 13231097..1da334b0 100755 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -149,15 +149,13 @@ class gallery extends common { */ private function update() { - // Installation des données de la galerie d'exemple + // Installation des données par défaut + $class = get_called_class(); + $moduleId = $this->getUrl(0); 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]); - // Générer la feuille de CSS du modèle par défaut - $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); @@ -166,31 +164,31 @@ class gallery extends common { // Nom de la feuille de style $fileCSS = self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css' ; $this->setData(['module', $this->getUrl(0), 'config', 'style', $fileCSS]); - - if (!file_exists(self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css' )) { - // Générer la feuille de CSS - // Création des fichiers 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 ); - $content = str_replace('#thumbHeight#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbHeight']),$content ); - $content = str_replace('#thumbMargin#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbMargin']),$content ); - $content = str_replace('#thumbBorder#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbBorder']),$content ); - $content = str_replace('#thumbBorderColor#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbBorderColor']),$content ); - $content = str_replace('#thumbOpacity#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbOpacity']),$content ); - $content = str_replace('#thumbShadows#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbShadows']),$content ); - $content = str_replace('#thumbShadowsColor#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbShadowsColor']),$content ); - $content = str_replace('#thumbRadius#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbRadius']),$content ); - $content = str_replace('#legendAlign#',$this->getData(['module', $this->getUrl(0), 'config', 'legendAlign']),$content ); - $content = str_replace('#legendHeight#',$this->getData(['module', $this->getUrl(0), 'config', 'legendHeight']),$content ); - $content = str_replace('#legendTextColor#',$this->getData(['module', $this->getUrl(0), 'config', 'legendTextColor']),$content ); - $content = str_replace('#legendBgColor#',$this->getData(['module', $this->getUrl(0), 'config', 'legendBgColor']),$content ); - // Ecriture de la feuille de style - $success = file_put_contents(self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css' , $content . $themeCss); - } } + + // Générer la feuille de CSS + if (!file_exists(self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.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 ); + $content = str_replace('#thumbHeight#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbHeight']),$content ); + $content = str_replace('#thumbMargin#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbMargin']),$content ); + $content = str_replace('#thumbBorder#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbBorder']),$content ); + $content = str_replace('#thumbBorderColor#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbBorderColor']),$content ); + $content = str_replace('#thumbOpacity#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbOpacity']),$content ); + $content = str_replace('#thumbShadows#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbShadows']),$content ); + $content = str_replace('#thumbShadowsColor#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbShadowsColor']),$content ); + $content = str_replace('#thumbRadius#',$this->getData(['module', $this->getUrl(0), 'config', 'thumbRadius']),$content ); + $content = str_replace('#legendAlign#',$this->getData(['module', $this->getUrl(0), 'config', 'legendAlign']),$content ); + $content = str_replace('#legendHeight#',$this->getData(['module', $this->getUrl(0), 'config', 'legendHeight']),$content ); + $content = str_replace('#legendTextColor#',$this->getData(['module', $this->getUrl(0), 'config', 'legendTextColor']),$content ); + $content = str_replace('#legendBgColor#',$this->getData(['module', $this->getUrl(0), 'config', 'legendBgColor']),$content ); + // 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 diff --git a/module/gallery/view/theme/theme.php b/module/gallery/view/theme/theme.php index 694ecaf9..5110b148 100755 --- a/module/gallery/view/theme/theme.php +++ b/module/gallery/view/theme/theme.php @@ -25,25 +25,25 @@
'Largeur', - 'selected' => $this->getData(['theme', 'gallery','thumbWidth']) + 'selected' => $this->getData(['module', $this->getUrl(0), 'config','thumbWidth']) ]); ?>
'Hauteur', - 'selected' => $this->getData(['theme', 'gallery','thumbHeight']) + 'selected' => $this->getData(['module', $this->getUrl(0), 'config','thumbHeight']) ]); ?>
'Alignement', - 'selected' => $this->getData(['theme', 'gallery','thumbAlign']) + 'selected' => $this->getData(['module', $this->getUrl(0), 'config','thumbAlign']) ]); ?>
'Marge', - 'selected' => $this->getData(['theme', 'gallery','thumbMargin']) + 'selected' => $this->getData(['module', $this->getUrl(0), 'config','thumbMargin']) ]); ?>
@@ -51,7 +51,7 @@
'Bordure', - 'selected' => $this->getData(['theme', 'gallery','thumbBorder']) + 'selected' => $this->getData(['module', $this->getUrl(0), 'config','thumbBorder']) ]); ?>
@@ -59,13 +59,13 @@ 'class' => 'colorPicker', 'help' => 'Le curseur horizontal règle le niveau de transparence.', 'label' => 'Couleur de la bordure', - 'value' => $this->getData(['theme', 'gallery','thumbBorderColor']) + 'value' => $this->getData(['module', $this->getUrl(0), 'config','thumbBorderColor']) ]); ?>
'Arrondi des angles', - 'selected' => $this->getData(['theme', 'gallery','thumbRadius']) + 'selected' => $this->getData(['module', $this->getUrl(0), 'config','thumbRadius']) ]); ?>
@@ -73,7 +73,7 @@
'Ombre', - 'selected' => $this->getData(['theme', 'gallery','thumbShadows']) + 'selected' => $this->getData(['module', $this->getUrl(0), 'config','thumbShadows']) ]); ?>
@@ -81,13 +81,13 @@ 'class' => 'colorPicker', 'help' => 'Le curseur horizontal règle le niveau de transparence.', 'label' => 'Couleur de l\'ombre', - 'value' => $this->getData(['theme', 'gallery','thumbShadowsColor']) + 'value' => $this->getData(['module', $this->getUrl(0), 'config','thumbShadowsColor']) ]); ?>
'Opacité au survol', - 'selected' => $this->getData(['theme', 'gallery','thumbOpacity']) + 'selected' => $this->getData(['module', $this->getUrl(0), 'config','thumbOpacity']) ]); ?>
@@ -108,7 +108,7 @@ 'class' => 'colorPicker', 'help' => 'Le curseur horizontal règle le niveau de transparence.', 'label' => 'Texte', - 'value' => $this->getData(['theme', 'gallery','legendTextColor']) + 'value' => $this->getData(['module', $this->getUrl(0), 'config','legendTextColor']) ]); ?>
@@ -116,19 +116,19 @@ 'class' => 'colorPicker', 'help' => 'Le curseur horizontal règle le niveau de transparence.', 'label' => 'Fond', - 'value' => $this->getData(['theme', 'gallery','legendBgColor']) + 'value' => $this->getData(['module', $this->getUrl(0), 'config','legendBgColor']) ]); ?>
'Hauteur', - 'selected' => $this->getData(['theme', 'gallery','legendHeight']) + 'selected' => $this->getData(['module', $this->getUrl(0), 'config','legendHeight']) ]); ?>
'Alignement', - 'selected' => $this->getData(['theme', 'gallery','legendAlign']) + 'selected' => $this->getData(['module', $this->getUrl(0), 'config','legendAlign']) ]); ?>