From 55c921025a4b78acf7f9925c293a5eaddb50026b Mon Sep 17 00:00:00 2001 From: F Tempez Date: Wed, 7 Apr 2021 14:26:12 +0200 Subject: [PATCH] News : initCss --- module/news/news.php | 64 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/module/news/news.php b/module/news/news.php index d26de5ab..b87ee9c5 100755 --- a/module/news/news.php +++ b/module/news/news.php @@ -70,20 +70,6 @@ class news extends common { public static $articleSignature = ''; - /** - * Mise à jour du module - * Appelée par les fonctions index et config - */ - private function update() { - // Version 3.0 - if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '3.0', '<') ) { - $this->setData(['module', $this->getUrl(0), 'config', 'itemsperPage', 16]); - $this->setData(['module', $this->getUrl(0), 'config', 'itemsperCol', 6]); - $this->setData(['module', $this->getUrl(0), 'config', 'versionData','3.0']); - } - } - - /** * Flux RSS */ @@ -178,6 +164,10 @@ class news extends common { * Configuration */ public function config() { + + // Initialisation du thème du nouveau module + $this->initCss($this->getUrl(0)); + // Mise à jour des données de module $this->update(); @@ -347,6 +337,10 @@ class news extends common { * Accueil */ public function index() { + + // Initialisation du thème du nouveau module + $this->initCss($this->getUrl(0)); + // Mise à jour des données de module $this->update(); // Affichage d'un article @@ -428,4 +422,46 @@ class news extends common { return $this->getData(['user', $userId, 'firstname']); } } + + /** + * Mise à jour du module + * Appelée par les fonctions index et config + */ + private function update() { + // Version 3.0 + if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '3.0', '<') ) { + $this->setData(['module', $this->getUrl(0), 'config', 'itemsperPage', 16]); + $this->setData(['module', $this->getUrl(0), 'config', 'itemsperCol', 6]); + $this->setData(['module', $this->getUrl(0), 'config', 'versionData','3.0']); + } + } + + /** + * Initialisation du thème d'un nouveau module + */ + private function initCSS($moduleId) { + // Variable commune + $fileCSS = self::DATADIRECTORY . $moduleId . '.css' ; + + if ( $this->getData(['module', $moduleId, 'config', 'itemsHeight']) === null ) { + + $this->setData(['module', $moduleId, 'config', 'itemsHeight', '200px']); + + // Générer la feuille de CSS + $style = '.newsContent {height: 200px;}'; + + // Dossier de l'instance + if (!is_dir(self::DATADIRECTORY)) { + mkdir (self::DATADIRECTORY, 0777, true); + } + + // Sauver la feuille de style + $success = file_put_contents(self::DATADIRECTORY .$moduleId . '.css' , $style ); + + // Nom de la feuille de style + $this->setData(['module', $moduleId, 'config', 'style', self::DATADIRECTORY .$moduleId]); + // Fin feuille de style + + } + } }