diff --git a/module/blog/blog.php b/module/blog/blog.php index a4d68c3d..e9959dfb 100755 --- a/module/blog/blog.php +++ b/module/blog/blog.php @@ -19,7 +19,7 @@ class blog extends common { const REALNAME = 'Blog'; const DELETE = true; const UPDATE = '0.0'; - const DATADIRECTORY = []; // Contenu localisé inclus par défaut (page.json et module.json) + const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json) const EDIT_OWNER = 'owner'; const EDIT_GROUP = 'group'; diff --git a/module/download/download.php b/module/download/download.php index 7dd08a7c..ce14d0d7 100644 --- a/module/download/download.php +++ b/module/download/download.php @@ -18,7 +18,7 @@ class download extends common { const REALNAME = 'Téléchargement'; const DELETE = true; const UPDATE = '0.0'; - const DATADIRECTORY = []; // Contenu localisé inclus par défaut (page.json et module.json) + const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json) // Constantes du module const EDIT_OWNER = 'owner'; diff --git a/module/form/form.php b/module/form/form.php index 77d416d8..ca43f200 100755 --- a/module/form/form.php +++ b/module/form/form.php @@ -20,7 +20,7 @@ class form extends common { const REALNAME = 'Formulaire'; const DELETE = true; const UPDATE = '0.0'; - const DATADIRECTORY = []; // Contenu localisé inclus par défaut (page.json et module.json) + const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json) public static $actions = [ 'config' => self::GROUP_MODERATOR, diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index 3cc13ab6..9583b141 100755 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -21,7 +21,7 @@ class gallery extends common { const REALNAME = 'Galerie'; const DELETE = true; const UPDATE = '0.0'; - const DATADIRECTORY = []; // Contenu localisé inclus par défaut (page.json et module.json) + const DATADIRECTORY = self::DATA_DIR . 'modules/gallery/'; const SORT_ASC = 'SORT_ASC'; const SORT_DSC = 'SORT_DSC'; @@ -149,10 +149,6 @@ class gallery extends common { */ private function update() { - // Variables génériques - $class = get_called_class(); - $moduleId = $this->getUrl(0); - // Mise à jour d'une version inférieure if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '3.0', '<') ) { @@ -183,18 +179,17 @@ class gallery extends common { 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]); - + } + if ( !file_exists(self::DATADIRECTORY . $this->getUrl(0) . '.css')) { // 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); + if (!is_dir(self::DATADIRECTORY )) { + mkdir (self::DATADIRECTORY, 0777, true); } // Nom de la feuille de style - $fileCSS = self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css' ; + $fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '.css' ; $this->setData(['module', $this->getUrl(0), 'config', 'style', $fileCSS]); // Générer la feuille de CSS @@ -217,7 +212,7 @@ class gallery extends common { $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); + file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '.css' , $content . $themeCss); } } @@ -710,14 +705,11 @@ class gallery extends common { // Soumission du formulaire if($this->isPost()) { - // Générer la feuille de CSS - $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); + if (!is_dir(self::DATADIRECTORY )) { + mkdir (self::DATADIRECTORY, 0777, true); } - $fileCSS = self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css' ; + $fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '.css' ; // Fin feuille de style $this->getData(['module', $this->getUrl(0), 'config', [ 'thumbAlign' => $this->getinput('galleryThemeThumbAlign'), diff --git a/module/news/news.php b/module/news/news.php index 888571f8..d26de5ab 100755 --- a/module/news/news.php +++ b/module/news/news.php @@ -19,7 +19,7 @@ class news extends common { const REALNAME = 'Actualités'; const DELETE = true; const UPDATE = '0.0'; - const DATADIRECTORY = []; // Contenu localisé inclus par défaut (page.json et module.json) + const DATADIRECTORY = self::DATA_DIR . 'modules/news/'; public static $actions = [ 'add' => self::GROUP_MODERATOR, @@ -185,15 +185,13 @@ class news extends common { if($this->isPost()) { // Générer la feuille de CSS - $class = get_called_class(); - $moduleId = $this->getUrl(0); $style = '.newsContent {height:' . $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT) . ';}'; // Dossier de l'instance - if (!is_dir(self::DATA_DIR . 'modules/' . $class)) { - mkdir (self::DATA_DIR . 'modules/' . $class, 0777, true); + if (!is_dir(self::DATADIRECTORY)) { + mkdir (self::DATADIRECTORY, 0777, true); } - $success = file_put_contents(self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css' , $style ); + $success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '.css' , $style ); // Fin feuille de style $this->setData(['module', $this->getUrl(0), 'config',[ @@ -203,7 +201,7 @@ class news extends common { 'itemsperCol' => $this->getInput('newsConfigItemsperCol', helper::FILTER_INT,true), 'itemsHeight' => $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT), 'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData']), - 'style' => $success ? self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css' : '' + 'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '.css' : '' ]]); // Valeurs en sortie $this->addOutput([ diff --git a/module/redirection/redirection.php b/module/redirection/redirection.php index 0d1a704d..5ea9d6e5 100755 --- a/module/redirection/redirection.php +++ b/module/redirection/redirection.php @@ -19,7 +19,7 @@ class redirection extends common { const REALNAME = 'Redirection'; const DELETE = true; const UPDATE = '0.0'; - const DATADIRECTORY = []; // Contenu localisé inclus par défaut (page.json et module.json) + const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json) public static $actions = [ 'config' => self::GROUP_MODERATOR, diff --git a/module/search/search.php b/module/search/search.php index 102d7986..6f3f13e7 100755 --- a/module/search/search.php +++ b/module/search/search.php @@ -23,7 +23,7 @@ class search extends common { const REALNAME = 'Recherche'; const DELETE = true; const UPDATE = '0.0'; - const DATADIRECTORY = []; // Contenu localisé inclus par défaut (page.json et module.json) + const DATADIRECTORY = self::DATA_DIR . 'modules/search/'; public static $actions = [ 'index' => self::GROUP_VISITOR, @@ -55,8 +55,6 @@ class search extends common { // Version 2.0 if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '2.0', '<') ) { - $class = get_called_class(); - $moduleId = $this->getUrl(0); // Données de l'instance $data = $this->getData(['module', $this->getUrl(0)]); $this->setData(['module', $this->getUrl(0), 'config', [ @@ -65,7 +63,7 @@ class search extends common { 'resultHideContent' => $this->getData(['module', $this->getUrl(0), 'resultHideContent']), 'previewLength' => $this->getData(['module', $this->getUrl(0), 'previewLength']), 'keywordColor' => $this->getData(['module', $this->getUrl(0), 'keywordColor']), - 'style' => self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css', + 'style' => self::DATADIRECTORY . $this->getUrl(0) . '.css', 'versionData' => '2.0' ]]); $this->deleteData(['module', $this->getUrl(0), 'submitText']); @@ -85,19 +83,17 @@ class search extends common { if ( !is_array($this->getData(['module', $this->getUrl(0), 'config']) ) ) { require_once('module/search/ressource/defaultdata.php'); - $class = get_called_class(); - $moduleId = $this->getUrl(0); // Sauver les données par défaut - init::$defaultData['style'] = self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css'; + init::$defaultData['style'] = self::DATADIRECTORY . $this->getUrl(0) . '.css'; $this->setData(['module', $this->getUrl(0), 'config', init::$defaultData]); $style = '.searchItem {background:' . $this->getData(['module', $this->getUrl(0), 'config', 'keywordColor']). ';}'; // Dossier de l'instance - if (!is_dir(self::DATA_DIR . 'modules/' . $class)) { - mkdir (self::DATA_DIR . 'modules/' . $class, 0777, true); + if (!is_dir(self::DATADIRECTORY )) { + mkdir (self::DATADIRECTORY , 0777, true); } - $success = file_put_contents(self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css' , $style ); + $success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '.css' , $style ); } @@ -116,15 +112,13 @@ class search extends common { if($this->isPost()) { // Générer la feuille de CSS - $class = get_called_class(); - $moduleId = $this->getUrl(0); $style = '.searchItem {background:' . $this->getInput('searchKeywordColor') . ';}'; // Dossier de l'instance - if (!is_dir(self::DATA_DIR . 'modules/' . $class)) { - mkdir (self::DATA_DIR . 'modules/' . $class, 0777, true); + if (!is_dir(self::DATADIRECTORY)) { + mkdir (self::DATADIRECTORY , 0777, true); } - $success = file_put_contents(self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css' , $style ); + $success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '.css' , $style ); // Fin feuille de style // Soumission du formulaire @@ -134,7 +128,7 @@ class search extends common { 'resultHideContent' => $this->getInput('searchResultHideContent',helper::FILTER_BOOLEAN), 'previewLength' => $this->getInput('searchPreviewLength',helper::FILTER_INT), 'keywordColor' => $this->getInput('searchKeywordColor'), - 'style' => $success ? self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css' : '', + 'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '.css' : '', 'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData']) ]]);