Modules : datadirectory type string

This commit is contained in:
fredtempez 2021-04-06 11:20:04 +02:00
parent ba1d5bbf1f
commit e90da78bad
7 changed files with 24 additions and 32 deletions

View File

@ -19,7 +19,7 @@ class blog extends common {
const REALNAME = 'Blog'; const REALNAME = 'Blog';
const DELETE = true; const DELETE = true;
const UPDATE = '0.0'; 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_OWNER = 'owner';
const EDIT_GROUP = 'group'; const EDIT_GROUP = 'group';

View File

@ -18,7 +18,7 @@ class download extends common {
const REALNAME = 'Téléchargement'; const REALNAME = 'Téléchargement';
const DELETE = true; const DELETE = true;
const UPDATE = '0.0'; 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 // Constantes du module
const EDIT_OWNER = 'owner'; const EDIT_OWNER = 'owner';

View File

@ -20,7 +20,7 @@ class form extends common {
const REALNAME = 'Formulaire'; const REALNAME = 'Formulaire';
const DELETE = true; const DELETE = true;
const UPDATE = '0.0'; 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 = [ public static $actions = [
'config' => self::GROUP_MODERATOR, 'config' => self::GROUP_MODERATOR,

View File

@ -21,7 +21,7 @@ class gallery extends common {
const REALNAME = 'Galerie'; const REALNAME = 'Galerie';
const DELETE = true; const DELETE = true;
const UPDATE = '0.0'; const UPDATE = '0.0';
const DATADIRECTORY = self::DATA_DIR . 'modules/gallery'; const DATADIRECTORY = self::DATA_DIR . 'modules/gallery/';
const SORT_ASC = 'SORT_ASC'; const SORT_ASC = 'SORT_ASC';
const SORT_DSC = 'SORT_DSC'; const SORT_DSC = 'SORT_DSC';
@ -180,7 +180,7 @@ class gallery extends common {
require_once('module/gallery/ressource/defaultdata.php'); require_once('module/gallery/ressource/defaultdata.php');
$this->setData(['module', $this->getUrl(0), 'config', theme::$defaultData]); $this->setData(['module', $this->getUrl(0), 'config', theme::$defaultData]);
} }
if ( !file_exists(self::DATADIRECTORY . '/' . $this->getUrl(0) . '.css')) { if ( !file_exists(self::DATADIRECTORY . $this->getUrl(0) . '.css')) {
// Variables génériques // Variables génériques
// Dossier de l'instance // Dossier de l'instance
@ -189,7 +189,7 @@ class gallery extends common {
} }
// Nom de la feuille de style // Nom de la feuille de style
$fileCSS = self::DATADIRECTORY . '/' . $this->getUrl(0) . '.css' ; $fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '.css' ;
$this->setData(['module', $this->getUrl(0), 'config', 'style', $fileCSS]); $this->setData(['module', $this->getUrl(0), 'config', 'style', $fileCSS]);
// Générer la feuille de CSS // Générer la feuille de CSS
@ -212,7 +212,7 @@ class gallery extends common {
$content = str_replace('#legendTextColor#',$this->getData(['module', $this->getUrl(0), 'config', 'legendTextColor']),$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 ); $content = str_replace('#legendBgColor#',$this->getData(['module', $this->getUrl(0), 'config', 'legendBgColor']),$content );
// Ecriture de la feuille de style // Ecriture de la feuille de style
file_put_contents(self::DATADIRECTORY . '/' . $this->getUrl(0) . '.css' , $content . $themeCss); file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '.css' , $content . $themeCss);
} }
} }
@ -709,7 +709,7 @@ class gallery extends common {
if (!is_dir(self::DATADIRECTORY )) { if (!is_dir(self::DATADIRECTORY )) {
mkdir (self::DATADIRECTORY, 0777, true); mkdir (self::DATADIRECTORY, 0777, true);
} }
$fileCSS = self::DATADIRECTORY . '/' . $this->getUrl(0) . '.css' ; $fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '.css' ;
// Fin feuille de style // Fin feuille de style
$this->getData(['module', $this->getUrl(0), 'config', [ $this->getData(['module', $this->getUrl(0), 'config', [
'thumbAlign' => $this->getinput('galleryThemeThumbAlign'), 'thumbAlign' => $this->getinput('galleryThemeThumbAlign'),

View File

@ -19,7 +19,7 @@ class news extends common {
const REALNAME = 'Actualités'; const REALNAME = 'Actualités';
const DELETE = true; const DELETE = true;
const UPDATE = '0.0'; 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 = [ public static $actions = [
'add' => self::GROUP_MODERATOR, 'add' => self::GROUP_MODERATOR,
@ -185,15 +185,13 @@ class news extends common {
if($this->isPost()) { if($this->isPost()) {
// Générer la feuille de CSS // 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) . ';}'; $style = '.newsContent {height:' . $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT) . ';}';
// Dossier de l'instance // Dossier de l'instance
if (!is_dir(self::DATA_DIR . 'modules/' . $class)) { if (!is_dir(self::DATADIRECTORY)) {
mkdir (self::DATA_DIR . 'modules/' . $class, 0777, true); 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 // Fin feuille de style
$this->setData(['module', $this->getUrl(0), 'config',[ $this->setData(['module', $this->getUrl(0), 'config',[
@ -203,7 +201,7 @@ class news extends common {
'itemsperCol' => $this->getInput('newsConfigItemsperCol', helper::FILTER_INT,true), 'itemsperCol' => $this->getInput('newsConfigItemsperCol', helper::FILTER_INT,true),
'itemsHeight' => $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT), 'itemsHeight' => $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT),
'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '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 // Valeurs en sortie
$this->addOutput([ $this->addOutput([

View File

@ -19,7 +19,7 @@ class redirection extends common {
const REALNAME = 'Redirection'; const REALNAME = 'Redirection';
const DELETE = true; const DELETE = true;
const UPDATE = '0.0'; 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 = [ public static $actions = [
'config' => self::GROUP_MODERATOR, 'config' => self::GROUP_MODERATOR,

View File

@ -23,7 +23,7 @@ class search extends common {
const REALNAME = 'Recherche'; const REALNAME = 'Recherche';
const DELETE = true; const DELETE = true;
const UPDATE = '0.0'; 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 = [ public static $actions = [
'index' => self::GROUP_VISITOR, 'index' => self::GROUP_VISITOR,
@ -55,8 +55,6 @@ class search extends common {
// Version 2.0 // Version 2.0
if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '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 // Données de l'instance
$data = $this->getData(['module', $this->getUrl(0)]); $data = $this->getData(['module', $this->getUrl(0)]);
$this->setData(['module', $this->getUrl(0), 'config', [ $this->setData(['module', $this->getUrl(0), 'config', [
@ -65,7 +63,7 @@ class search extends common {
'resultHideContent' => $this->getData(['module', $this->getUrl(0), 'resultHideContent']), 'resultHideContent' => $this->getData(['module', $this->getUrl(0), 'resultHideContent']),
'previewLength' => $this->getData(['module', $this->getUrl(0), 'previewLength']), 'previewLength' => $this->getData(['module', $this->getUrl(0), 'previewLength']),
'keywordColor' => $this->getData(['module', $this->getUrl(0), 'keywordColor']), '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' 'versionData' => '2.0'
]]); ]]);
$this->deleteData(['module', $this->getUrl(0), 'submitText']); $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']) ) ) { if ( !is_array($this->getData(['module', $this->getUrl(0), 'config']) ) ) {
require_once('module/search/ressource/defaultdata.php'); require_once('module/search/ressource/defaultdata.php');
$class = get_called_class();
$moduleId = $this->getUrl(0);
// Sauver les données par défaut // 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]); $this->setData(['module', $this->getUrl(0), 'config', init::$defaultData]);
$style = '.searchItem {background:' . $this->getData(['module', $this->getUrl(0), 'config', 'keywordColor']). ';}'; $style = '.searchItem {background:' . $this->getData(['module', $this->getUrl(0), 'config', 'keywordColor']). ';}';
// Dossier de l'instance // Dossier de l'instance
if (!is_dir(self::DATA_DIR . 'modules/' . $class)) { if (!is_dir(self::DATADIRECTORY )) {
mkdir (self::DATA_DIR . 'modules/' . $class, 0777, true); 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()) { if($this->isPost()) {
// Générer la feuille de CSS // Générer la feuille de CSS
$class = get_called_class();
$moduleId = $this->getUrl(0);
$style = '.searchItem {background:' . $this->getInput('searchKeywordColor') . ';}'; $style = '.searchItem {background:' . $this->getInput('searchKeywordColor') . ';}';
// Dossier de l'instance // Dossier de l'instance
if (!is_dir(self::DATA_DIR . 'modules/' . $class)) { if (!is_dir(self::DATADIRECTORY)) {
mkdir (self::DATA_DIR . 'modules/' . $class, 0777, true); 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 // Fin feuille de style
// Soumission du formulaire // Soumission du formulaire
@ -134,7 +128,7 @@ class search extends common {
'resultHideContent' => $this->getInput('searchResultHideContent',helper::FILTER_BOOLEAN), 'resultHideContent' => $this->getInput('searchResultHideContent',helper::FILTER_BOOLEAN),
'previewLength' => $this->getInput('searchPreviewLength',helper::FILTER_INT), 'previewLength' => $this->getInput('searchPreviewLength',helper::FILTER_INT),
'keywordColor' => $this->getInput('searchKeywordColor'), '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']) 'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData'])
]]); ]]);