diff --git a/CHANGES.md b/CHANGES.md index 2329c986..6e8b3b5b 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,7 +5,8 @@ Cette version apporte aux modules une autonomie complète par rapport au noyau. - mise à jour interne (fonction update) - feuille de style propres aux instances (fonction init) - Modifications : - - Module Search : en l'absence de texte dans le bouton Rechercher, une loupe est affichée. + - Module search : en l'absence de texte dans le bouton Rechercher, une loupe est affichée. + - Modules search, news et gallery, chaque module de page dispose de réglages de thème stockés dans des feuilles de style séparés. Nouvelle structure de données distinguant configuration, données et thème. ## version 10.5.02 - Corrections : diff --git a/README.md b/README.md index 02f45c9a..e678297a 100755 --- a/README.md +++ b/README.md @@ -60,22 +60,23 @@ Pour revenir à la version 8, renommez ce fichier "data.json". [R] vendor Librairies extérieures [F] core.js.php Cœur javascript [F] core.php Cœur PHP - + [R] module Modules de page [R] blog Blog [R] form Gestionnaire de formulaires [R] gallery Galerie [R] news Nouvelles [R] redirection Redirection - + [R] site Contenu du site [R] backup Sauvegardes automatiques [R] data Répertoire des données [R] fr Dossier localisé [F] page.json Données des pages [F] module.json Données des modules de pages + [R] modules Personnalisation des modules ou données propres [F] admin.css Thème des pages d'administration - [F] admin.json Données de thème des pages d'administration + [F] admin.json Données de thème des pages d'administration [F] blacklist.json Journalisation des tentatives de connexion avec des comptes inconnus [F] config.json Configuration du site [F] core.json Configuration du noyau @@ -89,7 +90,7 @@ Pour revenir à la version 8, renommez ce fichier "data.json". [R] source Ressources diverses [R] thumb Miniatures des images [R] tmp Répertoire temporaire - + [F] index.php Fichier d'initialisation de ZwiiCMS [F] robots.txt Filtrage des répertoires accessibles aux robots des moteurs de recherche [F] sitemap.xml Plan du site diff --git a/core/module/page/page.php b/core/module/page/page.php index f842e3da..744e5eda 100755 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -258,6 +258,13 @@ class page extends common { } // Suppression else { + + // Effacer le dossier du module + $moduleId = $this->getData(['page',$url[0],'moduleId']); + $modulesData = helper::getModules(); + if (is_dir($modulesData[$moduleId]['dataDirectory'])) { + $this->removeDir( $modulesData[$moduleId]['dataDirectory'] ); + } // Effacer la page $this->deleteData(['page', $url[0]]); $this->deleteData(['module', $url[0]]); @@ -312,6 +319,16 @@ class page extends common { if ($this->getData(['module', $this->getUrl(2)]) !== null ) { $this->setData(['module', $pageId, $this->getData(['module', $this->getUrl(2)])]); $this->deleteData(['module', $this->getUrl(2)]); + // Renommer le dossier du module + $moduleId = $this->getData(['page',$this->getUrl(2),'moduleId']); + $modulesData = helper::getModules(); + if (is_dir($modulesData[$moduleId]['dataDirectory'])) { + // Renommer la feuille de style + rename( $modulesData[$moduleId]['dataDirectory'],str_replace($this->geturl(2),$pageId, $modulesData[$moduleId]['dataDirectory'])); + $this->removeDir($modulesData[$moduleId]['dataDirectory']); + // Mettre à jour le nom de la feuille de site + $this->setData(['module',$pageId,'theme','style',str_replace($this->geturl(2),$pageId, $modulesData[$moduleId]['dataDirectory'])]); + } } // Si la page correspond à la page d'accueil, change l'id dans la configuration du site if($this->getData(['locale', 'homePageId']) === $this->getUrl(2)) { diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index 69f55f5b..7e0d406d 100755 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -149,7 +149,6 @@ class gallery extends common { */ private function update() { - // Mise à jour d'une version inférieure, la gallery existe mais pas content if ($this->getData(['module', $this->getUrl(0)]) && $this->getData(['module', $this->getUrl(0), 'content']) === NULL ) { @@ -172,7 +171,7 @@ class gallery extends common { $this->deleteData(['theme','gallery']); $this->setData(['module', $this->getUrl(0), 'theme', $data]); // Nom de la feuille de style - $this->setData(['module', $this->getUrl(0), 'theme', 'style', self::DATADIRECTORY . $moduleId . '.css']); + $this->setData(['module', $this->getUrl(0), 'theme', 'style', self::DATADIRECTORY . $this->getUrl(0) . '/theme.css']); } // Nouvelle version $this->setData(['module', $this->getUrl(0), 'config', 'versionData', '3.0']); @@ -185,49 +184,50 @@ class gallery extends common { * Config * Content */ - private function init($moduleId) { + private function init() { // Variable commune - $fileCSS = self::DATADIRECTORY . $moduleId . '.css' ; + $fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' ; // Check la présence du thème - if ( $this->getData(['module', $moduleId, 'theme']) === null ) { + if ( $this->getData(['module', $this->getUrl(0), 'theme']) === null ) { require_once('module/gallery/ressource/defaultdata.php'); - $this->setData(['module', $moduleId, 'theme', theme::$defaultTheme]); + $this->setData(['module', $this->getUrl(0), 'theme', theme::$defaultTheme]); + // Nom de la feuille de style + $this->setData(['module', $this->getUrl(0), 'theme', 'style', $fileCSS]); } // Check la présence de la feuille de style - if ( !file_exists(self::DATADIRECTORY . $moduleId . '.css')) { + if ( !file_exists(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css')) { // Dossier de l'instance - if (!is_dir(self::DATADIRECTORY )) { - mkdir (self::DATADIRECTORY, 0777, true); + if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) { + mkdir (self::DATADIRECTORY . $this->getUrl(0), 0777, true); } - // Nom de la feuille de style - $this->setData(['module', $moduleId, 'theme', 'style', $fileCSS]); - // 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', $moduleId, 'theme', 'thumbAlign']),$content ); - $content = str_replace('#thumbWidth#',$this->getData(['module', $moduleId, 'theme', 'thumbWidth']),$content ); - $content = str_replace('#thumbHeight#',$this->getData(['module', $moduleId, 'theme', 'thumbHeight']),$content ); - $content = str_replace('#thumbMargin#',$this->getData(['module', $moduleId, 'theme', 'thumbMargin']),$content ); - $content = str_replace('#thumbBorder#',$this->getData(['module', $moduleId, 'theme', 'thumbBorder']),$content ); - $content = str_replace('#thumbBorderColor#',$this->getData(['module', $moduleId, 'theme', 'thumbBorderColor']),$content ); - $content = str_replace('#thumbOpacity#',$this->getData(['module', $moduleId, 'theme', 'thumbOpacity']),$content ); - $content = str_replace('#thumbShadows#',$this->getData(['module', $moduleId, 'theme', 'thumbShadows']),$content ); - $content = str_replace('#thumbShadowsColor#',$this->getData(['module', $moduleId, 'theme', 'thumbShadowsColor']),$content ); - $content = str_replace('#thumbRadius#',$this->getData(['module', $moduleId, 'theme', 'thumbRadius']),$content ); - $content = str_replace('#legendAlign#',$this->getData(['module', $moduleId, 'theme', 'legendAlign']),$content ); - $content = str_replace('#legendHeight#',$this->getData(['module', $moduleId, 'theme', 'legendHeight']),$content ); - $content = str_replace('#legendTextColor#',$this->getData(['module', $moduleId, 'theme', 'legendTextColor']),$content ); - $content = str_replace('#legendBgColor#',$this->getData(['module', $moduleId, 'theme', 'legendBgColor']),$content ); + $content = str_replace('#thumbAlign#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbAlign']),$content ); + $content = str_replace('#thumbWidth#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbWidth']),$content ); + $content = str_replace('#thumbHeight#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbHeight']),$content ); + $content = str_replace('#thumbMargin#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbMargin']),$content ); + $content = str_replace('#thumbBorder#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbBorder']),$content ); + $content = str_replace('#thumbBorderColor#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbBorderColor']),$content ); + $content = str_replace('#thumbOpacity#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbOpacity']),$content ); + $content = str_replace('#thumbShadows#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbShadows']),$content ); + $content = str_replace('#thumbShadowsColor#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbShadowsColor']),$content ); + $content = str_replace('#thumbRadius#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbRadius']),$content ); + $content = str_replace('#legendAlign#',$this->getData(['module', $this->getUrl(0), 'theme', 'legendAlign']),$content ); + $content = str_replace('#legendHeight#',$this->getData(['module', $this->getUrl(0), 'theme', 'legendHeight']),$content ); + $content = str_replace('#legendTextColor#',$this->getData(['module', $this->getUrl(0), 'theme', 'legendTextColor']),$content ); + $content = str_replace('#legendBgColor#',$this->getData(['module', $this->getUrl(0), 'theme', 'legendBgColor']),$content ); // Ecriture de la feuille de style - file_put_contents(self::DATADIRECTORY . $moduleId . '.css' , $content . $themeCss); + file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' , $content . $themeCss); + // Nom de la feuille de style + $this->setData(['module', $this->getUrl(0), 'theme', 'style', $fileCSS]); } // Check Config - if ( $this->getData(['module', $moduleId, 'config']) === null ) { + if ( $this->getData(['module', $this->getUrl(0), 'config']) === null ) { require_once('module/gallery/ressource/defaultdata.php'); - $this->setData(['module', $moduleId, 'config', theme::$defaultData]); + $this->setData(['module', $this->getUrl(0), 'config', theme::$defaultData]); } // Contenu vide de la galerie @@ -299,7 +299,7 @@ class gallery extends common { $this->update(); // Initialisation d'un nouveau module - $this->init($this->getUrl(0)); + $this->init(); //Affichage de la galerie triée $g = $this->getData(['module', $this->getUrl(0), 'content']); @@ -585,7 +585,7 @@ class gallery extends common { $this->update(); // Initialisation d'un nouveau module - $this->init($this->getUrl(0)); + $this->init(); // Images d'une galerie if($this->getUrl(1)) { @@ -727,29 +727,26 @@ class gallery extends common { } // Soumission du formulaire if($this->isPost()) { - // Dossier de l'instance - if (!is_dir(self::DATADIRECTORY )) { - mkdir (self::DATADIRECTORY, 0777, true); + if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) { + mkdir (self::DATADIRECTORY . $this->getUrl(0), 0777, true); } - $fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '.css' ; - // Fin feuille de style - $this->getData(['module', $this->getUrl(0), 'theme', [ - 'thumbAlign' => $this->getinput('galleryThemeThumbAlign'), - 'thumbWidth' => $this->getinput('galleryThemeThumbWidth'), - 'thumbHeight' => $this->getinput('galleryThemeThumbHeight'), - 'thumbMargin' => $this->getinput('galleryThemeThumbMargin'), - 'thumbBorder' => $this->getinput('galleryThemeThumbBorder'), - 'thumbBorderColor' => $this->getinput('galleryThemeThumbBorderColor'), - 'thumbOpacity' => $this->getinput('galleryThemeThumbOpacity'), - 'thumbShadows' => $this->getinput('galleryThemeThumbShadows'), - 'thumbShadowsColor' => $this->getinput('galleryThemeThumbShadowsColor'), - 'thumbRadius' => $this->getinput('galleryThemeThumbRadius'), - 'legendHeight' => $this->getinput('galleryThemeLegendHeight'), - 'legendAlign' => $this->getinput('galleryThemeLegendAlign'), - 'legendTextColor' => $this->getinput('galleryThemeLegendTextColor'), - 'legendBgColor' => $this->getinput('galleryThemeLegendBgColor'), - 'style' => $fileCSS, + $this->setData(['module', $this->getUrl(0), 'theme', [ + 'thumbAlign' => $this->getinput('galleryThemeThumbAlign', helper::FILTER_STRING_SHORT), + 'thumbWidth' => $this->getinput('galleryThemeThumbWidth', helper::FILTER_STRING_SHORT), + 'thumbHeight' => $this->getinput('galleryThemeThumbHeight', helper::FILTER_STRING_SHORT), + 'thumbMargin' => $this->getinput('galleryThemeThumbMargin', helper::FILTER_STRING_SHORT), + 'thumbBorder' => $this->getinput('galleryThemeThumbBorder', helper::FILTER_STRING_SHORT), + 'thumbBorderColor' => $this->getinput('galleryThemeThumbBorderColor', helper::FILTER_STRING_SHORT), + 'thumbOpacity' => $this->getinput('galleryThemeThumbOpacity', helper::FILTER_STRING_SHORT), + 'thumbShadows' => $this->getinput('galleryThemeThumbShadows', helper::FILTER_STRING_SHORT), + 'thumbShadowsColor' => $this->getinput('galleryThemeThumbShadowsColor', helper::FILTER_STRING_SHORT), + 'thumbRadius' => $this->getinput('galleryThemeThumbRadius', helper::FILTER_STRING_SHORT), + 'legendHeight' => $this->getinput('galleryThemeLegendHeight', helper::FILTER_STRING_SHORT), + 'legendAlign' => $this->getinput('galleryThemeLegendAlign', helper::FILTER_STRING_SHORT), + 'legendTextColor' => $this->getinput('galleryThemeLegendTextColor', helper::FILTER_STRING_SHORT), + 'legendBgColor' => $this->getinput('galleryThemeLegendBgColor', helper::FILTER_STRING_SHORT), + 'style' => self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' ]]); // Création des fichiers CSS $content = file_get_contents('module/gallery/ressource/vartheme.css'); @@ -769,7 +766,7 @@ class gallery extends common { $content = str_replace('#legendHeight#',$this->getinput('galleryThemeLegendHeight'),$content ); $content = str_replace('#legendTextColor#',$this->getinput('galleryThemeLegendTextColor'),$content ); $content = str_replace('#legendBgColor#',$this->getinput('galleryThemeLegendBgColor'),$content ); - $success = file_put_contents($fileCSS, $content . $themeCss); + $success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css', $content . $themeCss); // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . $this->getUrl() . '/theme', diff --git a/module/news/news.php b/module/news/news.php index 4af1cb48..cdd91409 100755 --- a/module/news/news.php +++ b/module/news/news.php @@ -177,29 +177,27 @@ class news extends common { $this->update(); // Initialisation d'un nouveau module - if ($this->getData(['module', $this->getUrl(0)]) === null) { - $this->init($this->getUrl(0)); - } + $this->init(); // Soumission du formulaire if($this->isPost()) { - // Générer la feuille de CSS + // Générer la feuille de CSS $style = '.newsContent {height:' . $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT) . ';}'; $style .= '.newsBlur {background: linear-gradient(#333 ' . $this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT) . ',#FFF );'; $style .= ' background-clip: text;-webkit-background-clip: text;-webkit-text-fill-color: transparent;}'; - + // Dossier de l'instance - if (!is_dir(self::DATADIRECTORY)) { - mkdir (self::DATADIRECTORY, 0777, true); + if (!is_dir(self::DATADIRECTORY . $this->getUrl(0))) { + mkdir (self::DATADIRECTORY . $this->getUrl(0) . '/theme.css', 0777, true); } - $success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '.css' , $style ); + $success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css', $style ); // Fin feuille de style $this->setData(['module', $this->getUrl(0), 'theme',[ - 'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '.css' : '', + 'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' : '', 'itemsHeight' => $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT), 'itemsBlur' => $this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT) ]]); @@ -360,10 +358,7 @@ class news extends common { $this->update(); // Initialisation d'un nouveau module - if ($this->getData(['module', $this->getUrl(0)]) === null) { - $this->init($this->getUrl(0)); - } - + $this->init(); // Affichage d'un article if( @@ -454,37 +449,41 @@ class news extends common { // Version 3.0 if ($this->getData(['module', $this->getUrl(0), 'config']) === NULL ) { // Données config et theme absentes du précédent module - $this->init($this->getUrl(0)); + $this->init(); } } /** * Initialisation du thème d'un nouveau module */ - private function init($moduleId) { - // Variable commune - $fileCSS = self::DATADIRECTORY . $moduleId . '.css' ; + private function init() { - // Données du module - require_once('module/news/ressource/defaultdata.php'); - $this->setData(['module', $moduleId, 'config',init::$defaultData ]); - // Données de thème - $this->setData(['module', $moduleId, 'theme',init::$defaultTheme ]); + $fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '/theme.css'; - // Générer la feuille de CSS - $style = '.newsContent {height: ' . $this->getData([ 'module', $moduleId, 'theme', 'itemsHeight' ]) .';}'; - $style .= '.newsBlur {background: linear-gradient(#333 ' . $this->getData([ 'module', $moduleId, 'theme', 'itemsBlur' ]) . ',#FFF );'; - $style .= ' background-clip: text;-webkit-background-clip: text;-webkit-text-fill-color: transparent;}'; - - // Dossier de l'instance - if (!is_dir(self::DATADIRECTORY)) { - mkdir (self::DATADIRECTORY, 0777, true); + // Données du module + if ($this->getData(['module', $this->getUrl(0) ]) === null) { + require_once('module/news/ressource/defaultdata.php'); + $this->setData(['module', $this->getUrl(0), 'config', init::$defaultData]); + // Données de thème + $this->setData(['module', $this->getUrl(0), 'theme', init::$defaultTheme]); + $this->setData(['module', $this->getUrl(0), 'theme', 'style', self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' ]); } - // Sauver la feuille de style - file_put_contents(self::DATADIRECTORY .$moduleId . '.css' , $style ); + // Dossier de l'instance + if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) { + mkdir (self::DATADIRECTORY . $this->getUrl(0) , 0777, true); + } - // Stocker le nom de la feuille de style - $this->setData(['module', $moduleId, 'theme', 'style', self::DATADIRECTORY . $moduleId . '.css']); + // Check la présence de la feuille de style + if ( !file_exists(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css')) { + // Générer la feuille de CSS + $style = '.newsContent {height: ' . $this->getData([ 'module', $this->getUrl(0), 'theme', 'itemsHeight' ]) .';}'; + $style .= '.newsBlur {background: linear-gradient(#333 ' . $this->getData([ 'module', $this->getUrl(0), 'theme', 'itemsBlur' ]) . ',#FFF );'; + $style .= ' background-clip: text;-webkit-background-clip: text;-webkit-text-fill-color: transparent;}'; + // Sauver la feuille de style + file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' , $style ); + // Stocker le nom de la feuille de style + $this->setData(['module', $this->getUrl(0), 'theme', 'style', self::DATADIRECTORY . $this->getUrl(0) . '/theme.css']); + } } } diff --git a/module/search/ressource/defaultdata.php b/module/search/ressource/defaultdata.php index 74f7a636..a4980e6e 100755 --- a/module/search/ressource/defaultdata.php +++ b/module/search/ressource/defaultdata.php @@ -1,6 +1,6 @@ 100, 'resultHideContent' => false, 'placeHolder' => 'Un ou plusieurs mots-clés séparés par un espace ou par +', diff --git a/module/search/search.php b/module/search/search.php index 9a5fad73..15a8a690 100755 --- a/module/search/search.php +++ b/module/search/search.php @@ -56,7 +56,7 @@ class search extends common { if ($this->getData(['module', $this->getUrl(0), 'previewLength']) ) { $data = $this->getData(['module', $this->getUrl(0)]); // Feuille de style - $fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '.css' ; + $fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' ; $this->setData(['module', $this->getUrl(0), 'config', [ 'submitText' => $this->getData(['module', $this->getUrl(0), 'submitText']), 'placeHolder' => $this->getData(['module', $this->getUrl(0), 'placeHolder']), @@ -70,8 +70,8 @@ class search extends common { ]]); // Dossier de l'instance - if (!is_dir(self::DATADIRECTORY)) { - mkdir (self::DATADIRECTORY, 0777, true); + if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) { + mkdir (self::DATADIRECTORY . $this->getUrl(0), 0777, true); } // Générer la feuille de CSS $style = '.keywordColor {background: ' . $this->getData(['module', $this->getUrl(0), 'theme', 'keywordColor']) . ';}'; @@ -91,29 +91,34 @@ class search extends common { /** * Initialisation du module */ - private function init($moduleId){ - // Variable commune - $fileCSS = self::DATADIRECTORY . $moduleId . '.css' ; + private function init(){ - // Données du module - require_once('module/search/ressource/defaultdata.php'); - $this->setData(['module', $moduleId, 'config',init::$defaultData ]); - // Données de thème - $this->setData(['module', $moduleId, 'theme',init::$defaultTheme ]); - // Générer la feuille de CSS - $style = '.keywordColor {background: ' . $this->getData([ 'module', $moduleId, 'theme', 'keywordColor' ]) . ';}'; + $fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' ; - // Dossier de l'instance - if (!is_dir(self::DATADIRECTORY)) { - mkdir (self::DATADIRECTORY, 0777, true); + if ($this->getData(['module', $this->getUrl(0)]) === null) { + // Données du module + require_once('module/search/ressource/defaultdata.php'); + $this->setData(['module', $this->getUrl(0), 'config',init::$defaultConfig ]); + // Données de thème + $this->setData(['module', $this->getUrl(0), 'theme',init::$defaultTheme ]); + $this->setData(['module', $this->getUrl(0), 'theme', 'style', self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' ]); } - // Sauver la feuille de style - file_put_contents(self::DATADIRECTORY .$moduleId . '.css' , $style ); + // Dossier de l'instance + if (!is_dir(self::DATADIRECTORY . $this->getUrl(0))) { + mkdir (self::DATADIRECTORY . $this->getUrl(0), 0777, true); + } - // Stocker le nom de la feuille de style - $this->setData(['module', $moduleId, 'theme', 'style', self::DATADIRECTORY . $moduleId . '.css']); + // Check la présence de la feuille de style + if ( !file_exists(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css')) { + // Générer la feuille de CSS + $style = '.keywordColor {background: ' . $this->getData([ 'module', $this->getUrl(0), 'theme', 'keywordColor' ]) . ';}'; + // Sauver la feuille de style + file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css', $style ); + // Stocker le nom de la feuille de style + $this->setData(['module', $this->getUrl(0) , 'theme', 'style', $fileCSS]); + } } @@ -124,20 +129,15 @@ class search extends common { $this->update(); // Initialisation d'un nouveau module - if ($this->getData(['module', $this->getUrl(0)]) === null) { - $this->init($this->getUrl(0)); - } + $this->init(); + if($this->isPost()) { // Générer la feuille de CSS $style = '.keywordColor {background:' . $this->getInput('searchKeywordColor') . ';}'; - // Dossier de l'instance - if (!is_dir(self::DATADIRECTORY)) { - mkdir (self::DATADIRECTORY , 0777, true); - } - $success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '.css' , $style ); + $success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' , $style ); // Fin feuille de style // Soumission du formulaire @@ -150,7 +150,7 @@ class search extends common { ]]); $this->setData(['module', $this->getUrl(0), 'theme',[ 'keywordColor' => $this->getInput('searchKeywordColor'), - 'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '.css' : '', + 'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' : '', ]]); @@ -178,9 +178,8 @@ class search extends common { $this->update(); // Initialisation d'un nouveau module - if ($this->getData(['module', $this->getUrl(0)]) === null) { - $this->init($this->getUrl(0)); - } + $this->init(); + if($this->isPost()) { //Initialisations variables