Browse Source

Modules : datadirectory type string

10600
fredtempez 2 months ago
parent
commit
e90da78bad
  1. 2
      module/blog/blog.php
  2. 2
      module/download/download.php
  3. 2
      module/form/form.php
  4. 10
      module/gallery/gallery.php
  5. 12
      module/news/news.php
  6. 2
      module/redirection/redirection.php
  7. 26
      module/search/search.php

2
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';

2
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';

2
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,

10
module/gallery/gallery.php

@ -21,7 +21,7 @@ class gallery extends common {
const REALNAME = 'Galerie';
const DELETE = true;
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_DSC = 'SORT_DSC';
@ -180,7 +180,7 @@ class gallery extends common {
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')) {
if ( !file_exists(self::DATADIRECTORY . $this->getUrl(0) . '.css')) {
// Variables génériques
// Dossier de l'instance
@ -189,7 +189,7 @@ class gallery extends common {
}
// 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]);
// 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('#legendBgColor#',$this->getData(['module', $this->getUrl(0), 'config', 'legendBgColor']),$content );
// 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 )) {
mkdir (self::DATADIRECTORY, 0777, true);
}
$fileCSS = self::DATADIRECTORY . '/' . $this->getUrl(0) . '.css' ;
$fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '.css' ;
// Fin feuille de style
$this->getData(['module', $this->getUrl(0), 'config', [
'thumbAlign' => $this->getinput('galleryThemeThumbAlign'),

12
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([

2
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,

26
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'])
]]);

Loading…
Cancel
Save