diff --git a/CHANGES.md b/CHANGES.md
index 28da2a7..e49dcef 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -4,6 +4,7 @@
- Modifications :
- Une troisième langue d'administration est disponible : espagnol / castillan,
- Thème / Menu : le menu en petit écran (burger) dispose maintenant de ses propres paramètres,
+ - Modules du coeur et de page : renforcement de la sécurité,
- Langues : la traduction automatique est supprimée, ce qui parachève la dégooglisation de Deltacms,
- Edition de page / emplacement dans le menu : une page désactivée est signalée par le curseur 'not-allowed' et par une typographie italique en petit écran, son lien est inactif,
- Nouveaux gabarits pour l'éditeur Tinymce : accordéon à 3 et 4 paragraphes,
diff --git a/core/module/addon/addon.php b/core/module/addon/addon.php
index 55bf508..bc46a1f 100644
--- a/core/module/addon/addon.php
+++ b/core/module/addon/addon.php
@@ -48,42 +48,52 @@ class addon extends common {
* Effacement d'un module installé et non utilisé
*/
public function delete() {
- // Lexique
- include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
-
- // Jeton incorrect
- if ($this->getUrl(3) !== $_SESSION['csrf']) {
+ // Autorisation
+ $group = $this->getUser('group');
+ if ($group === false ) $group = 0;
+ if( $group < addon::$actions['delete'] ) {
// Valeurs en sortie
$this->addOutput([
- 'redirect' => helper::baseUrl() . 'addon',
- 'state' => false,
- 'notification' => $text['core_addon']['delete'][0]
- ]);
- }
- else{
- // Suppression des dossiers
- $infoModules = helper::getModules();
- $module = $this->getUrl(2);
- //Liste des dossiers associés au module non effacés
- if( $this->removeDir('./module/'.$module ) === true ){
- $success = true;
- $notification = 'Module '. $module .$text['core_addon']['delete'][1];
- if( is_dir($infoModules[$this->getUrl(2)]['dataDirectory']) ) {
- if (!$this->removeDir($infoModules[$this->getUrl(2)]['dataDirectory'])){
- $notification = 'Module '.$module .$text['core_addon']['delete'][2] . $infoModules[$this->getUrl(2)]['dataDirectory'];
- }
- }
+ 'access' => false
+ ]);
+ } else {
+ // Lexique
+ include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
+
+ // Jeton incorrect
+ if ($this->getUrl(3) !== $_SESSION['csrf']) {
+ // Valeurs en sortie
+ $this->addOutput([
+ 'redirect' => helper::baseUrl() . 'addon',
+ 'state' => false,
+ 'notification' => $text['core_addon']['delete'][0]
+ ]);
}
else{
- $success = false;
- $notification = $text['core_addon']['delete'][3];
+ // Suppression des dossiers
+ $infoModules = helper::getModules();
+ $module = $this->getUrl(2);
+ //Liste des dossiers associés au module non effacés
+ if( $this->removeDir('./module/'.$module ) === true ){
+ $success = true;
+ $notification = 'Module '. $module .$text['core_addon']['delete'][1];
+ if( is_dir($infoModules[$this->getUrl(2)]['dataDirectory']) ) {
+ if (!$this->removeDir($infoModules[$this->getUrl(2)]['dataDirectory'])){
+ $notification = 'Module '.$module .$text['core_addon']['delete'][2] . $infoModules[$this->getUrl(2)]['dataDirectory'];
+ }
+ }
+ }
+ else{
+ $success = false;
+ $notification = $text['core_addon']['delete'][3];
+ }
+ // Valeurs en sortie
+ $this->addOutput([
+ 'redirect' => helper::baseUrl() . 'addon',
+ 'notification' => $notification,
+ 'state' => $success
+ ]);
}
- // Valeurs en sortie
- $this->addOutput([
- 'redirect' => helper::baseUrl() . 'addon',
- 'notification' => $notification,
- 'state' => $success
- ]);
}
}
@@ -206,308 +216,367 @@ class addon extends common {
* Installation d'un module à partir du gestionnaire de fichier
*/
public function upload() {
- // Lexique
- include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
-
- // Soumission du formulaire
- if($this->isPost()) {
- // Installation d'un module
- $checkValidMaj = $this->getInput('configModulesCheck', helper::FILTER_BOOLEAN);
- $zipFilename = $this->getInput('configModulesInstallation', helper::FILTER_STRING_SHORT);
- if( $zipFilename !== ''){
- $success = [
- 'success' => false,
- 'notification'=> ''
- ];
- $state = $this->install(self::FILE_DIR.'source/'.$zipFilename, $checkValidMaj);
- }
+ // Autorisation
+ $group = $this->getUser('group');
+ if ($group === false ) $group = 0;
+ if( $group < addon::$actions['upload'] ) {
+ // Valeurs en sortie
$this->addOutput([
- 'redirect' => helper::baseUrl() . $this->getUrl(),
- 'notification' => $state['notification'],
- 'state' => $state['success']
+ 'access' => false
+ ]);
+ } else {
+ // Lexique
+ include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
+
+ // Soumission du formulaire
+ if($this->isPost()) {
+ // Installation d'un module
+ $checkValidMaj = $this->getInput('configModulesCheck', helper::FILTER_BOOLEAN);
+ $zipFilename = $this->getInput('configModulesInstallation', helper::FILTER_STRING_SHORT);
+ if( $zipFilename !== ''){
+ $success = [
+ 'success' => false,
+ 'notification'=> ''
+ ];
+ $state = $this->install(self::FILE_DIR.'source/'.$zipFilename, $checkValidMaj);
+ }
+ $this->addOutput([
+ 'redirect' => helper::baseUrl() . $this->getUrl(),
+ 'notification' => $state['notification'],
+ 'state' => $state['success']
+ ]);
+ }
+ // Valeurs en sortie
+ $this->addOutput([
+ 'title' => $text['core_addon']['upload'][0],
+ 'view' => 'upload'
]);
}
- // Valeurs en sortie
- $this->addOutput([
- 'title' => $text['core_addon']['upload'][0],
- 'view' => 'upload'
- ]);
}
/***
* Installation d'un module par le catalogue
*/
public function uploadItem() {
- // Jeton incorrect
- if ($this->getUrl(3) !== $_SESSION['csrf']) {
+ // Autorisation
+ $group = $this->getUser('group');
+ if ($group === false ) $group = 0;
+ if( $group < addon::$actions['uploadItem'] ) {
// Valeurs en sortie
$this->addOutput([
- 'redirect' => helper::baseUrl() . 'store',
- 'state' => false,
- 'notification' => 'Action non autorisée'
- ]);
+ 'access' => false
+ ]);
} else {
- // Récupérer le module en ligne
- $moduleName = $this->getUrl(2);
- // Informations sur les module en ligne
- $store = json_decode(helper::urlGetContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
- // Url du module à télécharger
- $moduleFilePath = $store[$moduleName]['file'];
- // Télécharger le fichier
- $moduleData = helper::urlGetContents(self::BASEURL_STORE . self::FILE_DIR . 'source/' . $moduleFilePath);
- // Extraire de l'arborescence
- $d = explode('/',$moduleFilePath);
- $moduleFile = $d[count($d)-1];
- // Créer le dossier modules
- if (!is_dir(self::FILE_DIR . 'source/modules')) {
- mkdir (self::FILE_DIR . 'source/modules', 0755);
+ // Jeton incorrect
+ if ($this->getUrl(3) !== $_SESSION['csrf']) {
+ // Valeurs en sortie
+ $this->addOutput([
+ 'redirect' => helper::baseUrl() . 'store',
+ 'state' => false,
+ 'notification' => 'Action non autorisée'
+ ]);
+ } else {
+ // Récupérer le module en ligne
+ $moduleName = $this->getUrl(2);
+ // Informations sur les module en ligne
+ $store = json_decode(helper::urlGetContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
+ // Url du module à télécharger
+ $moduleFilePath = $store[$moduleName]['file'];
+ // Télécharger le fichier
+ $moduleData = helper::urlGetContents(self::BASEURL_STORE . self::FILE_DIR . 'source/' . $moduleFilePath);
+ // Extraire de l'arborescence
+ $d = explode('/',$moduleFilePath);
+ $moduleFile = $d[count($d)-1];
+ // Créer le dossier modules
+ if (!is_dir(self::FILE_DIR . 'source/modules')) {
+ mkdir (self::FILE_DIR . 'source/modules', 0755);
+ }
+ // Sauver les données du fichiers
+ file_put_contents(self::FILE_DIR . 'source/modules/' . $moduleFile, $moduleData);
+
+ /**
+ * $if( $moduleFile !== ''){
+ * $success = [
+ * 'success' => false,
+ * 'notification'=> ''
+ * ];
+ * $state = $this->install(self::FILE_DIR.'source/modules/'.$moduleFile, false);
+ *}
+ */
+ $this->addOutput([
+ 'redirect' => helper::baseUrl() . 'addon/store',
+ 'notification' => $moduleFile . ' téléchargé dans le dossier modules du gestionnaire de fichiers',
+ 'state' => true
+ ]);
+
}
- // Sauver les données du fichiers
- file_put_contents(self::FILE_DIR . 'source/modules/' . $moduleFile, $moduleData);
-
- /**
- * $if( $moduleFile !== ''){
- * $success = [
- * 'success' => false,
- * 'notification'=> ''
- * ];
- * $state = $this->install(self::FILE_DIR.'source/modules/'.$moduleFile, false);
- *}
- */
+ // Valeurs en sortie
$this->addOutput([
- 'redirect' => helper::baseUrl() . 'addon/store',
- 'notification' => $moduleFile . ' téléchargé dans le dossier modules du gestionnaire de fichiers',
- 'state' => true
+ 'title' => 'Catalogue de modules',
+ 'view' => 'store'
]);
-
}
- // Valeurs en sortie
- $this->addOutput([
- 'title' => 'Catalogue de modules',
- 'view' => 'store'
- ]);
}
/**
* Catalogue des modules sur le site DeltaCMS.fr
*/
public function store() {
- $store = json_decode(helper::urlGetContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
- if ($store) {
- // Modules installés
- $infoModules = helper::getModules();
- // Clés moduleIds dans les pages
- $inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
- foreach( $inPages as $key=>$value){
- $inPagesTitle[ $this->getData(['page', $key, 'title' ]) ] = $value;
- }
- // Parcourir les données des modules
- foreach ($store as $key=>$value) {
- // Module non installé
- $ico = template::ico('download');
- $class = '';
- // Le module est installé
- if (array_key_exists($key,$infoModules) === true) {
- $class = 'buttonGreen';
- $ico = template::ico('update');
+ // Autorisation
+ $group = $this->getUser('group');
+ if ($group === false ) $group = 0;
+ if( $group < addon::$actions['store'] ) {
+ // Valeurs en sortie
+ $this->addOutput([
+ 'access' => false
+ ]);
+ } else {
+ $store = json_decode(helper::urlGetContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
+ if ($store) {
+ // Modules installés
+ $infoModules = helper::getModules();
+ // Clés moduleIds dans les pages
+ $inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
+ foreach( $inPages as $key=>$value){
+ $inPagesTitle[ $this->getData(['page', $key, 'title' ]) ] = $value;
}
- // Le module est installé et utilisé
- if (in_array($key,$inPages) === true) {
- $class = 'buttonRed';
- $ico = template::ico('update');
+ // Parcourir les données des modules
+ foreach ($store as $key=>$value) {
+ // Module non installé
+ $ico = template::ico('download');
+ $class = '';
+ // Le module est installé
+ if (array_key_exists($key,$infoModules) === true) {
+ $class = 'buttonGreen';
+ $ico = template::ico('update');
+ }
+ // Le module est installé et utilisé
+ if (in_array($key,$inPages) === true) {
+ $class = 'buttonRed';
+ $ico = template::ico('update');
+ }
+ self::$storeList [] = [
+ $store[$key]['category'],
+ ''.$store[$key]['title'].'',
+ $store[$key]['version'],
+ mb_detect_encoding(strftime('%d %B %Y', $store[$key]['versionDate']), 'UTF-8', true)
+ ? strftime('%d %B %Y', $store[$key]['versionDate'])
+ : utf8_encode(strftime('%d %B %Y', $store[$key]['versionDate'])),
+ implode(', ', array_keys($inPagesTitle,$key)),
+ template::button('moduleExport' . $key, [
+ 'class' => $class,
+ 'href' => helper::baseUrl(). $this->getUrl(0) . '/uploadItem/' . $key.'/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre
+ 'value' => $ico
+ ])
+ ];
}
- self::$storeList [] = [
- $store[$key]['category'],
- ''.$store[$key]['title'].'',
- $store[$key]['version'],
- mb_detect_encoding(strftime('%d %B %Y', $store[$key]['versionDate']), 'UTF-8', true)
- ? strftime('%d %B %Y', $store[$key]['versionDate'])
- : utf8_encode(strftime('%d %B %Y', $store[$key]['versionDate'])),
- implode(', ', array_keys($inPagesTitle,$key)),
- template::button('moduleExport' . $key, [
- 'class' => $class,
- 'href' => helper::baseUrl(). $this->getUrl(0) . '/uploadItem/' . $key.'/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre
- 'value' => $ico
- ])
- ];
}
+ // Valeurs en sortie
+ $this->addOutput([
+ 'title' => 'Catalogue de modules en ligne',
+ 'view' => 'store'
+ ]);
}
-
- // Valeurs en sortie
- $this->addOutput([
- 'title' => 'Catalogue de modules en ligne',
- 'view' => 'store'
- ]);
}
/**
* Détail d'un objet du catalogue
*/
public function item() {
- $store = json_decode(helper::urlGetContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
- self::$storeItem = $store [$this->getUrl(2)] ;
- self::$storeItem ['fileDate'] = mb_detect_encoding(strftime('%d %B %Y',self::$storeItem ['fileDate']), 'UTF-8', true)
- ? strftime('%d %B %Y', self::$storeItem ['fileDate'])
- : utf8_encode(strftime('%d %B %Y', self::$storeItem ['fileDate']));
- // Valeurs en sortie
- $this->addOutput([
- 'title' =>'Module ' . self::$storeItem['title'],
- 'view' => 'item'
- ]);
+ // Autorisation
+ $group = $this->getUser('group');
+ if ($group === false ) $group = 0;
+ if( $group < addon::$actions['item'] ) {
+ // Valeurs en sortie
+ $this->addOutput([
+ 'access' => false
+ ]);
+ } else {
+ $store = json_decode(helper::urlGetContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
+ self::$storeItem = $store [$this->getUrl(2)] ;
+ self::$storeItem ['fileDate'] = mb_detect_encoding(strftime('%d %B %Y',self::$storeItem ['fileDate']), 'UTF-8', true)
+ ? strftime('%d %B %Y', self::$storeItem ['fileDate'])
+ : utf8_encode(strftime('%d %B %Y', self::$storeItem ['fileDate']));
+ // Valeurs en sortie
+ $this->addOutput([
+ 'title' =>'Module ' . self::$storeItem['title'],
+ 'view' => 'item'
+ ]);
+ }
}
/**
* Gestion des modules
*/
public function index() {
- // Lexique
- include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
+ // Autorisation
+ $group = $this->getUser('group');
+ if ($group === false ) $group = 0;
+ if( $group < addon::$actions['index'] ) {
+ // Valeurs en sortie
+ $this->addOutput([
+ 'access' => false
+ ]);
+ } else {
+ // Lexique
+ include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
- // Lister les modules
- // $infoModules[nom_module]['realName'], ['version'], ['update'], ['delete'], ['dataDirectory']
- $infoModules = helper::getModules();
+ // Lister les modules
+ // $infoModules[nom_module]['realName'], ['version'], ['update'], ['delete'], ['dataDirectory']
+ $infoModules = helper::getModules();
- // Clés moduleIds dans les pages
- $inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
- foreach( $inPages as $key=>$value){
- $inPagesTitle[ $this->getData(['page', $key, 'title' ]) ] = $value;
+ // Clés moduleIds dans les pages
+ $inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
+ foreach( $inPages as $key=>$value){
+ $inPagesTitle[ $this->getData(['page', $key, 'title' ]) ] = $value;
+ }
+
+ // Parcourir les données des modules
+ foreach ($infoModules as $key=>$value) {
+ // Construire le tableau de sortie
+ self::$modInstal[] = [
+ $key,
+ $infoModules[$key]['realName'],
+ $infoModules[$key]['version'],
+ implode(', ', array_keys($inPagesTitle,$key)),
+ //|| ('delete',$infoModules[$key]) && $infoModules[$key]['delete'] === true && implode(', ',array_keys($inPages,$key)) === ''
+ $infoModules[$key]['delete'] === true && implode(', ',array_keys($inPages,$key)) === ''
+ ? template::button('moduleDelete' . $key, [
+ 'class' => 'moduleDelete buttonRed',
+ 'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $key . '/' . $_SESSION['csrf'],
+ 'value' => template::ico('cancel')
+ ])
+ : '',
+ implode(', ',array_keys($inPages,$key)) !== ''
+ ? template::button('moduleExport' . $key, [
+ 'href' => helper::baseUrl(). $this->getUrl(0) . '/export/' . $key . '/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre
+ 'value' => template::ico('download')
+ ])
+ : '',
+ implode(', ',array_keys($inPages,$key)) === ''
+ ? template::button('moduleExport' . $key, [
+ 'href' => helper::baseUrl(). $this->getUrl(0) . '/import/' . $key . '/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre
+ 'value' => template::ico('upload')
+ ])
+ : ''
+ ];
+ }
+
+ // Valeurs en sortie
+ $this->addOutput([
+ 'title' => $text['core_addon']['index'][0],
+ 'view' => 'index'
+ ]);
}
-
- // Parcourir les données des modules
- foreach ($infoModules as $key=>$value) {
- // Construire le tableau de sortie
- self::$modInstal[] = [
- $key,
- $infoModules[$key]['realName'],
- $infoModules[$key]['version'],
- implode(', ', array_keys($inPagesTitle,$key)),
- //|| ('delete',$infoModules[$key]) && $infoModules[$key]['delete'] === true && implode(', ',array_keys($inPages,$key)) === ''
- $infoModules[$key]['delete'] === true && implode(', ',array_keys($inPages,$key)) === ''
- ? template::button('moduleDelete' . $key, [
- 'class' => 'moduleDelete buttonRed',
- 'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $key . '/' . $_SESSION['csrf'],
- 'value' => template::ico('cancel')
- ])
- : '',
- implode(', ',array_keys($inPages,$key)) !== ''
- ? template::button('moduleExport' . $key, [
- 'href' => helper::baseUrl(). $this->getUrl(0) . '/export/' . $key . '/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre
- 'value' => template::ico('download')
- ])
- : '',
- implode(', ',array_keys($inPages,$key)) === ''
- ? template::button('moduleExport' . $key, [
- 'href' => helper::baseUrl(). $this->getUrl(0) . '/import/' . $key . '/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre
- 'value' => template::ico('upload')
- ])
- : ''
- ];
- }
-
- // Valeurs en sortie
- $this->addOutput([
- 'title' => $text['core_addon']['index'][0],
- 'view' => 'index'
- ]);
}
/*
* Export des données d'un module externes ou interne à module.json
*/
public function export(){
- // Lexique
- include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
-
- // Jeton incorrect
- if ($this->getUrl(3) !== $_SESSION['csrf']) {
+ // Autorisation
+ $group = $this->getUser('group');
+ if ($group === false ) $group = 0;
+ if( $group < addon::$actions['export'] ) {
// Valeurs en sortie
$this->addOutput([
- 'redirect' => helper::baseUrl() . 'addon',
- 'state' => false,
- 'notification' => $text['core_addon']['export'][0]
- ]);
- }
- else {
- // Lire les données du module
- $infoModules = helper::getModules();
- // Créer un dossier par défaut
- $tmpFolder = self::TEMP_DIR . uniqid();
- //$tmpFolder = self::TEMP_DIR . 'test';
- if (!is_dir($tmpFolder)) {
- mkdir($tmpFolder, 0755);
- }
- // Clés moduleIds dans les pages
- $inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
- // Parcourir les pages utilisant le module
- foreach (array_keys($inPages,$this->getUrl(2)) as $pageId) {
- // Export des pages hébergeant le module
- $pageParam[$pageId] = $this->getData(['page',$pageId]);
- // Export du contenu de la page
- //$pageContent[$pageId] = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $pageId, 'content']));
- $pageContent[$pageId] = $this->getPage($pageId, self::$i18n);
- // Export de base/module.json
- $moduleId = 'base/module.json';
- $moduleDir = str_replace('site/data/','',$infoModules[$this->getUrl(2)]['dataDirectory']);
- // Création de l'arborescence des langues
- // Pas de nom dossier de langue - dossier par défaut
- $t = explode ('/',$moduleId);
- if ( is_array($t)) {
- $lang = 'base';
- } else {
- $lang = $t[0];
- }
- // Créer le dossier temporaire si inexistant sinon le nettoyer et le créer
- if (!is_dir($tmpFolder . '/' . $lang)) {
- mkdir ($tmpFolder . '/' . $lang, 0755, true);
- } else {
- $this->removeDir($tmpFolder . '/' . $lang);
- mkdir ($tmpFolder . '/' . $lang, 0755, true);
- }
- // Créer le dossier temporaire des données du module
- if ($infoModules[$this->getUrl(2)]['dataDirectory']) {
- if (!is_dir($tmpFolder . '/' . $moduleDir)) {
- mkdir ($tmpFolder . '/' . $moduleDir, 0755, true) ;
- }
- }
- // Sauvegarde si données non vides
- $tmpData [$pageId] = $this->getData(['module',$pageId ]);
- if ($tmpData [$pageId] !== null) {
- file_put_contents($tmpFolder . '/' . $moduleId, json_encode($tmpData));
- }
- // Export des données localisées dans le dossier de données du module
- if ($infoModules[$this->getUrl(2)]['dataDirectory'] &&
- is_dir($infoModules[$this->getUrl(2)]['dataDirectory'])) {
- $this->copyDir ($infoModules[$this->getUrl(2)]['dataDirectory'], $tmpFolder . '/' . $moduleDir);
- }
- }
- // Enregistrement des pages dans le dossier de langue identique à module
- if (!file_exists($tmpFolder . '/' . $lang . '/page.json')) {
- file_put_contents($tmpFolder . '/' . $lang . '/page.json', json_encode($pageParam));
- mkdir ($tmpFolder . '/' . $lang . '/content', 0755);
- file_put_contents($tmpFolder . '/' . $lang . '/content/' . $this->getData(['page', $pageId, 'content']), $pageContent);
- }
- // création du zip
- $fileName = $this->getUrl(2) . '.zip';
- $this->makeZip ($fileName, $tmpFolder, []);
- if (file_exists($fileName)) {
- ob_start();
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename="' . $fileName . '"');
- header('Content-Length: ' . filesize($fileName));
- ob_clean();
- ob_end_flush();
- readfile( $fileName);
- unlink($fileName);
- $this->removeDir($tmpFolder);
- exit();
- } else {
+ 'access' => false
+ ]);
+ } else {
+ // Lexique
+ include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
+
+ // Jeton incorrect
+ if ($this->getUrl(3) !== $_SESSION['csrf']) {
// Valeurs en sortie
$this->addOutput([
- 'redirect' => helper::baseUrl() . 'addon',
- 'notification' => $text['core_addon']['export'][1],
- 'state' => false
+ 'redirect' => helper::baseUrl() . 'addon',
+ 'state' => false,
+ 'notification' => $text['core_addon']['export'][0]
]);
}
+ else {
+ // Lire les données du module
+ $infoModules = helper::getModules();
+ // Créer un dossier par défaut
+ $tmpFolder = self::TEMP_DIR . uniqid();
+ //$tmpFolder = self::TEMP_DIR . 'test';
+ if (!is_dir($tmpFolder)) {
+ mkdir($tmpFolder, 0755);
+ }
+ // Clés moduleIds dans les pages
+ $inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
+ // Parcourir les pages utilisant le module
+ foreach (array_keys($inPages,$this->getUrl(2)) as $pageId) {
+ // Export des pages hébergeant le module
+ $pageParam[$pageId] = $this->getData(['page',$pageId]);
+ // Export du contenu de la page
+ //$pageContent[$pageId] = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $pageId, 'content']));
+ $pageContent[$pageId] = $this->getPage($pageId, self::$i18n);
+ // Export de base/module.json
+ $moduleId = 'base/module.json';
+ $moduleDir = str_replace('site/data/','',$infoModules[$this->getUrl(2)]['dataDirectory']);
+ // Création de l'arborescence des langues
+ // Pas de nom dossier de langue - dossier par défaut
+ $t = explode ('/',$moduleId);
+ if ( is_array($t)) {
+ $lang = 'base';
+ } else {
+ $lang = $t[0];
+ }
+ // Créer le dossier temporaire si inexistant sinon le nettoyer et le créer
+ if (!is_dir($tmpFolder . '/' . $lang)) {
+ mkdir ($tmpFolder . '/' . $lang, 0755, true);
+ } else {
+ $this->removeDir($tmpFolder . '/' . $lang);
+ mkdir ($tmpFolder . '/' . $lang, 0755, true);
+ }
+ // Créer le dossier temporaire des données du module
+ if ($infoModules[$this->getUrl(2)]['dataDirectory']) {
+ if (!is_dir($tmpFolder . '/' . $moduleDir)) {
+ mkdir ($tmpFolder . '/' . $moduleDir, 0755, true) ;
+ }
+ }
+ // Sauvegarde si données non vides
+ $tmpData [$pageId] = $this->getData(['module',$pageId ]);
+ if ($tmpData [$pageId] !== null) {
+ file_put_contents($tmpFolder . '/' . $moduleId, json_encode($tmpData));
+ }
+ // Export des données localisées dans le dossier de données du module
+ if ($infoModules[$this->getUrl(2)]['dataDirectory'] &&
+ is_dir($infoModules[$this->getUrl(2)]['dataDirectory'])) {
+ $this->copyDir ($infoModules[$this->getUrl(2)]['dataDirectory'], $tmpFolder . '/' . $moduleDir);
+ }
+ }
+ // Enregistrement des pages dans le dossier de langue identique à module
+ if (!file_exists($tmpFolder . '/' . $lang . '/page.json')) {
+ file_put_contents($tmpFolder . '/' . $lang . '/page.json', json_encode($pageParam));
+ mkdir ($tmpFolder . '/' . $lang . '/content', 0755);
+ file_put_contents($tmpFolder . '/' . $lang . '/content/' . $this->getData(['page', $pageId, 'content']), $pageContent);
+ }
+ // création du zip
+ $fileName = $this->getUrl(2) . '.zip';
+ $this->makeZip ($fileName, $tmpFolder, []);
+ if (file_exists($fileName)) {
+ ob_start();
+ header('Content-Type: application/octet-stream');
+ header('Content-Disposition: attachment; filename="' . $fileName . '"');
+ header('Content-Length: ' . filesize($fileName));
+ ob_clean();
+ ob_end_flush();
+ readfile( $fileName);
+ unlink($fileName);
+ $this->removeDir($tmpFolder);
+ exit();
+ } else {
+ // Valeurs en sortie
+ $this->addOutput([
+ 'redirect' => helper::baseUrl() . 'addon',
+ 'notification' => $text['core_addon']['export'][1],
+ 'state' => false
+ ]);
+ }
+ }
}
}
@@ -515,94 +584,104 @@ class addon extends common {
* Importer des données d'un module externes ou interne à module.json
*/
public function import(){
- // Lexique
- include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
-
- // Jeton incorrect
- if ($this->getUrl(3) !== $_SESSION['csrf']) {
+ // Autorisation
+ $group = $this->getUser('group');
+ if ($group === false ) $group = 0;
+ if( $group < addon::$actions['import'] ) {
// Valeurs en sortie
$this->addOutput([
- 'redirect' => helper::baseUrl() . 'addon',
- 'state' => false,
- 'notification' => $text['core_addon']['import'][0]
- ]);
- }
- else {
- // Soumission du formulaire
- if($this->isPost()) {
- // Récupérer le fichier et le décompacter
- $zipFilename = $this->getInput('addonImportFile', helper::FILTER_STRING_SHORT, true);
- $tempFolder = uniqid();
- mkdir (self::TEMP_DIR . $tempFolder, 0755);
- $zip = new ZipArchive();
- if ($zip->open(self::FILE_DIR . 'source/' . $zipFilename) === TRUE) {
- $zip->extractTo(self::TEMP_DIR . $tempFolder );
- }
- // Import des données localisées page.json et module.json
- // Pour chaque dossier localisé
- $dataTarget = array();
- $dataSource = array();
- // Liste des pages de même nom dans l'archive et le site
- $list = '';
- // Tableau des langues avec langue originale
- $origin = ['base'=>'Langue originale'];
- $i18nListComplet = array_merge( self::$i18nList, $origin);
- foreach ($i18nListComplet as $key=>$value) {
- // Les Pages et les modules
- foreach (['page','module'] as $fileTarget){
- if (file_exists(self::TEMP_DIR . $tempFolder . '/' .$key . '/' . $fileTarget . '.json')) {
- // Le dossier de langue existe
- // faire la fusion
- $dataSource = json_decode(file_get_contents(self::TEMP_DIR . $tempFolder . '/' .$key . '/' . $fileTarget . '.json'), true);
- // Des pages de même nom que celles de l'archive existent
- if( $fileTarget === 'page' ){
- foreach( $dataSource as $keydataSource=>$valuedataSource ){
- foreach( $this->getData(['page']) as $keypage=>$valuepage ){
- if( $keydataSource === $keypage){
- $list === '' ? $list .= ' '.$this->getData(['page', $keypage, 'title']) : $list .= ', '.$this->getData(['page', $keypage, 'title']);
+ 'access' => false
+ ]);
+ } else {
+ // Lexique
+ include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
+
+ // Jeton incorrect
+ if ($this->getUrl(3) !== $_SESSION['csrf']) {
+ // Valeurs en sortie
+ $this->addOutput([
+ 'redirect' => helper::baseUrl() . 'addon',
+ 'state' => false,
+ 'notification' => $text['core_addon']['import'][0]
+ ]);
+ }
+ else {
+ // Soumission du formulaire
+ if($this->isPost()) {
+ // Récupérer le fichier et le décompacter
+ $zipFilename = $this->getInput('addonImportFile', helper::FILTER_STRING_SHORT, true);
+ $tempFolder = uniqid();
+ mkdir (self::TEMP_DIR . $tempFolder, 0755);
+ $zip = new ZipArchive();
+ if ($zip->open(self::FILE_DIR . 'source/' . $zipFilename) === TRUE) {
+ $zip->extractTo(self::TEMP_DIR . $tempFolder );
+ }
+ // Import des données localisées page.json et module.json
+ // Pour chaque dossier localisé
+ $dataTarget = array();
+ $dataSource = array();
+ // Liste des pages de même nom dans l'archive et le site
+ $list = '';
+ // Tableau des langues avec langue originale
+ $origin = ['base'=>'Langue originale'];
+ $i18nListComplet = array_merge( self::$i18nList, $origin);
+ foreach ($i18nListComplet as $key=>$value) {
+ // Les Pages et les modules
+ foreach (['page','module'] as $fileTarget){
+ if (file_exists(self::TEMP_DIR . $tempFolder . '/' .$key . '/' . $fileTarget . '.json')) {
+ // Le dossier de langue existe
+ // faire la fusion
+ $dataSource = json_decode(file_get_contents(self::TEMP_DIR . $tempFolder . '/' .$key . '/' . $fileTarget . '.json'), true);
+ // Des pages de même nom que celles de l'archive existent
+ if( $fileTarget === 'page' ){
+ foreach( $dataSource as $keydataSource=>$valuedataSource ){
+ foreach( $this->getData(['page']) as $keypage=>$valuepage ){
+ if( $keydataSource === $keypage){
+ $list === '' ? $list .= ' '.$this->getData(['page', $keypage, 'title']) : $list .= ', '.$this->getData(['page', $keypage, 'title']);
+ }
}
}
}
+ $dataTarget = json_decode(file_get_contents(self::DATA_DIR . $key . '/' . $fileTarget . '.json'), true);
+ $data [$fileTarget] = array_merge($dataTarget[$fileTarget], $dataSource);
+ if( $list === ''){
+ file_put_contents(self::DATA_DIR . '/' .$key . '/' . $fileTarget . '.json', json_encode( $data ,JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT|LOCK_EX) );
+ }
+ // copie du contenu de la page
+ $this->copyDir (self::TEMP_DIR . $tempFolder . '/' .$key . '/content', self::DATA_DIR . '/' .$key . '/content');
+ // Supprimer les fichiers importés
+ unlink (self::TEMP_DIR . $tempFolder . '/' .$key . '/' . $fileTarget . '.json');
}
- $dataTarget = json_decode(file_get_contents(self::DATA_DIR . $key . '/' . $fileTarget . '.json'), true);
- $data [$fileTarget] = array_merge($dataTarget[$fileTarget], $dataSource);
- if( $list === ''){
- file_put_contents(self::DATA_DIR . '/' .$key . '/' . $fileTarget . '.json', json_encode( $data ,JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT|LOCK_EX) );
- }
- // copie du contenu de la page
- $this->copyDir (self::TEMP_DIR . $tempFolder . '/' .$key . '/content', self::DATA_DIR . '/' .$key . '/content');
- // Supprimer les fichiers importés
- unlink (self::TEMP_DIR . $tempFolder . '/' .$key . '/' . $fileTarget . '.json');
}
}
- }
- // Import des fichiers placés ailleurs que dans les dossiers localisés.
- $this->copyDir (self::TEMP_DIR . $tempFolder,self::DATA_DIR );
+ // Import des fichiers placés ailleurs que dans les dossiers localisés.
+ $this->copyDir (self::TEMP_DIR . $tempFolder,self::DATA_DIR );
- // Supprimer le dossier temporaire
- $this->removeDir(self::TEMP_DIR . $tempFolder);
- $zip->close();
- if( $list !== '' ){
- $success = false;
- strpos( $list, ',') === false ? $notification = $text['core_addon']['import'][1].$list : $notification = $text['core_addon']['import'][2].$list;
- }
- else{
- $success = true;
- $notification = $text['core_addon']['import'][3];
+ // Supprimer le dossier temporaire
+ $this->removeDir(self::TEMP_DIR . $tempFolder);
+ $zip->close();
+ if( $list !== '' ){
+ $success = false;
+ strpos( $list, ',') === false ? $notification = $text['core_addon']['import'][1].$list : $notification = $text['core_addon']['import'][2].$list;
+ }
+ else{
+ $success = true;
+ $notification = $text['core_addon']['import'][3];
+ }
+ // Valeurs en sortie
+ $this->addOutput([
+ 'redirect' => helper::baseUrl() . 'addon',
+ 'state' => $success,
+ 'notification' => $notification
+ ]);
}
// Valeurs en sortie
$this->addOutput([
- 'redirect' => helper::baseUrl() . 'addon',
- 'state' => $success,
- 'notification' => $notification
+ 'title' => $text['core_addon']['import'][4],
+ 'view' => 'import'
]);
}
- // Valeurs en sortie
- $this->addOutput([
- 'title' => $text['core_addon']['import'][4],
- 'view' => 'import'
- ]);
}
}
diff --git a/core/module/config/config.php b/core/module/config/config.php
index f522673..49fdafd 100644
--- a/core/module/config/config.php
+++ b/core/module/config/config.php
@@ -167,20 +167,30 @@ class config extends common {
* Robots.txt
*/
public function generateFiles() {
- // Lexique
- include('./core/module/config/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_config.php');
+ // Autorisation
+ $group = $this->getUser('group');
+ if ($group === false ) $group = 0;
+ if( $group < config::$actions['generateFiles'] ) {
+ // Valeurs en sortie
+ $this->addOutput([
+ 'access' => false
+ ]);
+ } else {
+ // Lexique
+ include('./core/module/config/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_config.php');
- // Mettre à jour le site map
- $successSitemap=$this->createSitemap();
+ // Mettre à jour le site map
+ $successSitemap=$this->createSitemap();
- // Valeurs en sortie
- $this->addOutput([
- /*'title' => 'Configuration',
- 'view' => 'index',*/
- 'redirect' => helper::baseUrl() . 'config',
- 'notification' => $successSitemap ? $text['core_config']['generateFiles'][0] : $text['core_config']['generateFiles'][1],
- 'state' => $successSitemap
- ]);
+ // Valeurs en sortie
+ $this->addOutput([
+ /*'title' => 'Configuration',
+ 'view' => 'index',*/
+ 'redirect' => helper::baseUrl() . 'config',
+ 'notification' => $successSitemap ? $text['core_config']['generateFiles'][0] : $text['core_config']['generateFiles'][1],
+ 'state' => $successSitemap
+ ]);
+ }
}
@@ -188,33 +198,43 @@ class config extends common {
* Sauvegarde des données
*/
public function backup() {
- // Lexique
- include('./core/module/config/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_config.php');
-
- // Soumission du formulaire
- if($this->isPost()) {
- // Creation du ZIP
- $filter = $this->getInput('configBackupOption',helper::FILTER_BOOLEAN) === true ? ['backup','tmp'] : ['backup','tmp','file'];
- $fileName = helper::autoBackup(self::TEMP_DIR,$filter);
- // Créer le répertoire manquant
- if (!is_dir(self::FILE_DIR.'source/backup')) {
- mkdir(self::FILE_DIR.'source/backup', 0755);
- }
- // Copie dans les fichiers
- $success = copy (self::TEMP_DIR . $fileName , self::FILE_DIR.'source/backup/' . $fileName);
- // Détruire le temporaire
- unlink(self::TEMP_DIR . $fileName);
+ // Autorisation
+ $group = $this->getUser('group');
+ if ($group === false ) $group = 0;
+ if( $group < config::$actions['backup'] ) {
// Valeurs en sortie
$this->addOutput([
- 'display' => self::DISPLAY_JSON,
- 'content' => json_encode($success)
- ]);
+ 'access' => false
+ ]);
} else {
- // Valeurs en sortie
- $this->addOutput([
- 'title' => $text['core_config']['backup'][0],
- 'view' => 'backup'
- ]);
+ // Lexique
+ include('./core/module/config/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_config.php');
+
+ // Soumission du formulaire
+ if($this->isPost()) {
+ // Creation du ZIP
+ $filter = $this->getInput('configBackupOption',helper::FILTER_BOOLEAN) === true ? ['backup','tmp'] : ['backup','tmp','file'];
+ $fileName = helper::autoBackup(self::TEMP_DIR,$filter);
+ // Créer le répertoire manquant
+ if (!is_dir(self::FILE_DIR.'source/backup')) {
+ mkdir(self::FILE_DIR.'source/backup', 0755);
+ }
+ // Copie dans les fichiers
+ $success = copy (self::TEMP_DIR . $fileName , self::FILE_DIR.'source/backup/' . $fileName);
+ // Détruire le temporaire
+ unlink(self::TEMP_DIR . $fileName);
+ // Valeurs en sortie
+ $this->addOutput([
+ 'display' => self::DISPLAY_JSON,
+ 'content' => json_encode($success)
+ ]);
+ } else {
+ // Valeurs en sortie
+ $this->addOutput([
+ 'title' => $text['core_config']['backup'][0],
+ 'view' => 'backup'
+ ]);
+ }
}
}
@@ -222,100 +242,120 @@ class config extends common {
* Active ou désactive le mode Open Graph
*/
public function configOpenGraph() {
- // Lexique
- include('./core/module/config/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_config.php');
+ // Autorisation
+ $group = $this->getUser('group');
+ if ($group === false ) $group = 0;
+ if( $group < config::$actions['configOpenGraph'] ) {
+ // Valeurs en sortie
+ $this->addOutput([
+ 'access' => false
+ ]);
+ } else {
+ // Lexique
+ include('./core/module/config/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_config.php');
- $texte='';
- if( isset($_SESSION['screenshot']) && $_SESSION['screenshot'] === 'on'){
- $_SESSION['screenshot'] = 'off';
- $texte = $text['core_config']['configOpenGraph'][0];
+ $texte='';
+ if( isset($_SESSION['screenshot']) && $_SESSION['screenshot'] === 'on'){
+ $_SESSION['screenshot'] = 'off';
+ $texte = $text['core_config']['configOpenGraph'][0];
+ }
+ else{
+ $_SESSION['screenshot'] = 'on';
+ $texte = $text['core_config']['configOpenGraph'][1];
+ }
+ // Valeurs en sortie
+ $this->addOutput([
+ 'redirect' => helper::baseUrl() . 'config',
+ 'notification' => $texte,
+ 'state' => true
+ ]);
}
- else{
- $_SESSION['screenshot'] = 'on';
- $texte = $text['core_config']['configOpenGraph'][1];
- }
- // Valeurs en sortie
- $this->addOutput([
- 'redirect' => helper::baseUrl() . 'config',
- 'notification' => $texte,
- 'state' => true
- ]);
}
/**
* Procédure d'importation
*/
public function restore() {
- // Lexique
- include('./core/module/config/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_config.php');
-
- // Soumission du formulaire
- if($this->isPost() ) {
-
- $success = false;
-
- if ($this->getInput('configRestoreImportFile', null, true) ) {
-
- $fileZip = $this->getInput('configRestoreImportFile');
- $file_parts = pathinfo($fileZip);
- $folder = date('Y-m-d-h-i-s', time());
- $zip = new ZipArchive();
- if ($file_parts['extension'] !== 'zip') {
- // Valeurs en sortie erreur
- $this->addOutput([
- 'title' => $text['core_config']['restore'][0],
- 'view' => 'restore',
- 'notification' => $text['core_config']['restore'][1],
- 'state' => false
- ]);
- }
- $successOpen = $zip->open(self::FILE_DIR . 'source/' . $fileZip);
- if ($successOpen === FALSE) {
- // Valeurs en sortie erreur
- $this->addOutput([
- 'title' => $text['core_config']['restore'][0],
- 'view' => 'restore',
- 'notification' => $text['core_config']['restore'][2],
- 'state' => false
- ]);
- }
- // Lire le contenu de l'archive dans le tableau files
- for( $i = 0; $i < $zip->numFiles; $i++ ){
- $stat = $zip->statIndex( $i );
- $files [] = ( basename( $stat['name'] ));
- }
-
- // Option active, les users sont stockées
- if ($this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true ) $users = $this->getData(['user']);
-
- // Extraire le zip ou 'site/'
- $this->removeDir(self::DATA_DIR);
- $success = $zip->extractTo( 'site/' );
- // Fermer l'archive
- $zip->close();
-
- // Restaurer les users originaux d'une v10 si option cochée
- if (!empty($users) && $this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true) $this->setData(['user',$users]);
- }
-
- // Message de notification
- $notification = $success === true ? $text['core_config']['restore'][4] : $text['core_config']['restore'][5] ;
- $redirect = $this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true ? helper::baseUrl() . 'config/restore' : helper::baseUrl() . 'user/login/';
- // Valeurs en sortie erreur
+ // Autorisation
+ $group = $this->getUser('group');
+ if ($group === false ) $group = 0;
+ if( $group < config::$actions['restore'] ) {
+ // Valeurs en sortie
$this->addOutput([
- /*'title' => $text['core_config']['restore'][0],
- 'view' => 'restore',*/
- 'redirect' => $redirect,
- 'notification' => $notification,
- 'state' => $success
+ 'access' => false
+ ]);
+ } else {
+ // Lexique
+ include('./core/module/config/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_config.php');
+
+ // Soumission du formulaire
+ if($this->isPost() ) {
+
+ $success = false;
+
+ if ($this->getInput('configRestoreImportFile', null, true) ) {
+
+ $fileZip = $this->getInput('configRestoreImportFile');
+ $file_parts = pathinfo($fileZip);
+ $folder = date('Y-m-d-h-i-s', time());
+ $zip = new ZipArchive();
+ if ($file_parts['extension'] !== 'zip') {
+ // Valeurs en sortie erreur
+ $this->addOutput([
+ 'title' => $text['core_config']['restore'][0],
+ 'view' => 'restore',
+ 'notification' => $text['core_config']['restore'][1],
+ 'state' => false
+ ]);
+ }
+ $successOpen = $zip->open(self::FILE_DIR . 'source/' . $fileZip);
+ if ($successOpen === FALSE) {
+ // Valeurs en sortie erreur
+ $this->addOutput([
+ 'title' => $text['core_config']['restore'][0],
+ 'view' => 'restore',
+ 'notification' => $text['core_config']['restore'][2],
+ 'state' => false
+ ]);
+ }
+ // Lire le contenu de l'archive dans le tableau files
+ for( $i = 0; $i < $zip->numFiles; $i++ ){
+ $stat = $zip->statIndex( $i );
+ $files [] = ( basename( $stat['name'] ));
+ }
+
+ // Option active, les users sont stockées
+ if ($this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true ) $users = $this->getData(['user']);
+
+ // Extraire le zip ou 'site/'
+ $this->removeDir(self::DATA_DIR);
+ $success = $zip->extractTo( 'site/' );
+ // Fermer l'archive
+ $zip->close();
+
+ // Restaurer les users originaux d'une v10 si option cochée
+ if (!empty($users) && $this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true) $this->setData(['user',$users]);
+ }
+
+ // Message de notification
+ $notification = $success === true ? $text['core_config']['restore'][4] : $text['core_config']['restore'][5] ;
+ $redirect = $this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true ? helper::baseUrl() . 'config/restore' : helper::baseUrl() . 'user/login/';
+ // Valeurs en sortie erreur
+ $this->addOutput([
+ /*'title' => $text['core_config']['restore'][0],
+ 'view' => 'restore',*/
+ 'redirect' => $redirect,
+ 'notification' => $notification,
+ 'state' => $success
+ ]);
+ }
+
+ // Valeurs en sortie
+ $this->addOutput([
+ 'title' => $text['core_config']['restore'][0],
+ 'view' => 'restore'
]);
}
-
- // Valeurs en sortie
- $this->addOutput([
- 'title' => $text['core_config']['restore'][0],
- 'view' => 'restore'
- ]);
}
@@ -323,249 +363,278 @@ class config extends common {
* Configuration
*/
public function index() {
- // Lexique
- include('./core/module/config/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_config.php');
-
- // Soumission du formulaire
- if($this->isPost()) {
+ // Autorisation
+ $group = $this->getUser('group');
+ if ($group === false ) $group = 0;
+ if( $group < config::$actions['index'] ) {
+ // Valeurs en sortie
+ $this->addOutput([
+ 'access' => false
+ ]);
+ } else {
+ // Lexique
+ include('./core/module/config/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_config.php');
+
+ // Soumission du formulaire
+ if($this->isPost()) {
- // Basculement en mise à jour auto, remise à 0 du compteur
- if ($this->getData(['config','autoUpdate']) === false &&
- $this->getInput('configAutoUpdate', helper::FILTER_BOOLEAN) === true) {
- $this->setData(['core','lastAutoUpdate',0]);
- }
-
- // Eviter déconnexion automatique après son activation
- if ( $this->getData(['config','connect', 'autoDisconnect']) === false
- AND $this->getInput('configAutoDisconnect',helper::FILTER_BOOLEAN) === true ) {
- $this->setData(['user',$this->getuser('id'),'accessCsrf',$_SESSION['csrf']]);
- }
- // Répercuter la suppression de la page dans la configuration du footer
- if ( $this->getData(['theme','footer','displaySearch']) === true
- AND $this->getInput('configSearchPageId') === 'none'
- ){
- $this->setData(['theme', 'footer', 'displaySearch', false]);
- }
- if ( $this->getData(['theme','footer','displayLegal']) === true
- AND $this->getInput('configLegalPageId') === 'none'
- ){
- $this->setData(['theme', 'footer', 'displayLegal', false]);
- }
-
- // Sauvegarder les locales
- $this->setData([
- 'locale',
- [
- 'homePageId' => $this->getInput('localeHomePageId', helper::FILTER_ID, true),
- 'page404' => $this->getInput('localePage404'),
- 'page403' => $this->getInput('localePage403'),
- 'page302' => $this->getInput('localePage302'),
- 'legalPageId' => $this->getInput('localeLegalPageId'),
- 'searchPageId' => $this->getInput('localeSearchPageId'),
- 'searchPageLabel' => empty($this->getInput('localeSearchPageLabel', helper::FILTER_STRING_SHORT)) ? 'Rechercher' : $this->getInput('localeSearchPageLabel', helper::FILTER_STRING_SHORT),
- 'legalPageLabel' => empty($this->getInput('localeLegalPageLabel', helper::FILTER_STRING_SHORT)) ? 'Mentions légales' : $this->getInput('localeLegalPageLabel', helper::FILTER_STRING_SHORT),
- 'sitemapPageLabel' => empty($this->getInput('localeSitemapPageLabel', helper::FILTER_STRING_SHORT)) ? 'Plan du site' : $this->getInput('localeSitemapPageLabel', helper::FILTER_STRING_SHORT),
- 'visitorLabel' => $this->getInput('localeVisitorLabel', helper::FILTER_STRING_SHORT),
- 'memberLabel' => $this->getInput('localeMemberLabel', helper::FILTER_STRING_SHORT),
- 'editorLabel' => $this->getInput('localeEditorLabel', helper::FILTER_STRING_SHORT),
- 'moderatorLabel' => $this->getInput('localeModeratorLabel', helper::FILTER_STRING_SHORT),
- 'administratorLabel' => $this->getInput('localeAdministratorLabel', helper::FILTER_STRING_SHORT),
- 'metaDescription' => $this->getInput('localeMetaDescription', helper::FILTER_STRING_LONG, true),
- 'title' => $this->getInput('localeTitle', helper::FILTER_STRING_SHORT, true),
- 'captchaSimpleText' => $this->getInput('localeCaptchaSimpleText', helper::FILTER_STRING_LONG),
- 'captchaSimpleHelp' => $this->getInput('localeCaptchaSimpleHelp', helper::FILTER_STRING_LONG),
- 'cookies' => [
- // Les champs sont obligatoires si l'option consentement des cookies est active
- 'cookiesDeltaText' => $this->getInput('localeCookiesDeltaText', helper::FILTER_STRING_LONG, $this->getData(['config', 'cookieConsent'])),
- 'cookiesExtText' => $this->getInput('localeCookiesExtText', helper::FILTER_STRING_LONG),
- 'cookiesTitleText' => $this->getInput('localeCookiesTitleText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])),
- 'cookiesLinkMlText' => $this->getInput('localeCookiesLinkMlText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])),
- 'cookiesCheckboxExtText' => $this->getInput('localeCookiesCheckboxExtText', helper::FILTER_STRING_SHORT),
- 'cookiesFooterText' => $this->getInput('localeCookiesFooterText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])),
- 'cookiesButtonText' =>$this->getInput('localeCookiesButtonText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent']))
- ]
- ]
- ]);
-
- // Sauvegarder la configuration
- $this->setData([
- 'config',
- [
- 'favicon' => $this->getInput('configFavicon'),
- 'faviconDark' => $this->getInput('configFaviconDark'),
- 'timezone' => $this->getInput('configTimezone', helper::FILTER_STRING_SHORT, true),
- 'autoUpdate' => $this->getInput('configAutoUpdate', helper::FILTER_BOOLEAN),
- 'autoUpdateHtaccess' => $this->getInput('configAutoUpdateHtaccess', helper::FILTER_BOOLEAN),
- 'autoBackup' => $this->getInput('configAutoBackup', helper::FILTER_BOOLEAN),
- 'maintenance' => $this->getInput('configMaintenance', helper::FILTER_BOOLEAN),
- 'cookieConsent' => $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN),
- 'proxyType' => $this->getInput('configProxyType'),
- 'proxyUrl' => $this->getInput('configProxyUrl'),
- 'proxyPort' => $this->getInput('configProxyPort',helper::FILTER_INT),
- 'social' => [
- 'facebookId' => $this->getInput('socialFacebookId'),
- 'linkedinId' => $this->getInput('socialLinkedinId'),
- 'instagramId' => $this->getInput('socialInstagramId'),
- 'pinterestId' => $this->getInput('socialPinterestId'),
- 'twitterId' => $this->getInput('socialTwitterId'),
- 'youtubeId' => $this->getInput('socialYoutubeId'),
- 'youtubeUserId' => $this->getInput('socialYoutubeUserId'),
- 'githubId' => $this->getInput('socialGithubId'),
- 'headFacebook' => $this->getInput('socialHeadFacebook', helper::FILTER_BOOLEAN)
- ],
- 'smtp' => [
- 'enable' => $this->getInput('smtpEnable',helper::FILTER_BOOLEAN),
- 'host' => $this->getInput('smtpHost',helper::FILTER_STRING_SHORT,$this->getInput('smtpEnable',helper::FILTER_BOOLEAN)),
- 'port' => $this->getInput('smtpPort',helper::FILTER_INT,$this->getInput('smtpEnable',helper::FILTER_BOOLEAN)),
- 'auth' => $this->getInput('smtpAuth',helper::FILTER_BOOLEAN),
- 'secure' => $this->getInput('smtpSecure',helper::FILTER_BOOLEAN),
- 'username' => $this->getInput('smtpUsername',helper::FILTER_STRING_SHORT,$this->getInput('smtpAuth',helper::FILTER_BOOLEAN)),
- 'password' =>helper::encrypt($this->getData(['config','smtp','username']),$this->getInput('smtpPassword',null,$this->getInput('smtpAuth',helper::FILTER_BOOLEAN))),
- 'sender' => $this->getInput('smtpSender',helper::FILTER_MAIL)
- ],
- 'seo' => [
- 'robots' => $this->getInput('seoRobots',helper::FILTER_BOOLEAN),
- 'analyticsId' => $this->getInput('seoAnalyticsId')
- ],
- 'connect' => [
- 'attempt' => $this->getInput('connectAttempt',helper::FILTER_INT),
- 'timeout' => $this->getInput('connectTimeout',helper::FILTER_INT),
- 'log' => $this->getInput('connectLog',helper::FILTER_BOOLEAN),
- 'anonymousIp' => $this->getInput('connectAnonymousIp',helper::FILTER_INT),
- 'captcha' => $this->getInput('connectCaptcha',helper::FILTER_BOOLEAN),
- 'captchaBot' => $this->getInput('connectCaptchaBot',helper::FILTER_BOOLEAN),
- 'autoDisconnect' => $this->getInput('connectAutoDisconnect',helper::FILTER_BOOLEAN),
- 'passwordVisibility' => $this->getInput('connectPasswordVisibility',helper::FILTER_BOOLEAN)
- ],
- 'i18n' => [
- 'enable' => $this->getInput('localei18n',helper::FILTER_BOOLEAN),
- 'scriptGoogle' => $this->getData(['config', 'i18n', 'scriptGoogle']),
- 'showCredits' => $this->getData(['config', 'i18n', 'showCredits']),
- 'autoDetect' => $this->getData(['config', 'i18n', 'autoDetect']),
- //'admin' => $this->getData(['config', 'i18n', 'admin']),
- 'langAdmin' => $this->getData(['config', 'i18n', 'langAdmin']),
- 'langBase' => $this->getData(['config', 'i18n', 'langBase']),
- 'fr' => $this->getData(['config', 'i18n', 'fr']),
- 'de' => $this->getData(['config', 'i18n', 'de']),
- 'en' => $this->getData(['config', 'i18n', 'en']),
- 'es' => $this->getData(['config', 'i18n', 'es']),
- 'it' => $this->getData(['config', 'i18n', 'it']),
- 'nl' => $this->getData(['config', 'i18n', 'nl']),
- 'pt' => $this->getData(['config', 'i18n', 'pt']),
- 'el' => $this->getData(['config', 'i18n', 'el']),
- 'da' => $this->getData(['config', 'i18n', 'da']),
- 'fi' => $this->getData(['config', 'i18n', 'fi']),
- 'ga' => $this->getData(['config', 'i18n', 'ga']),
- 'sv' => $this->getData(['config', 'i18n', 'sv']),
- 'br' => $this->getData(['config', 'i18n', 'br']),
- 'ca' => $this->getData(['config', 'i18n', 'ca']),
- 'co' => $this->getData(['config', 'i18n', 'co']),
- 'eu' => $this->getData(['config', 'i18n', 'eu'])
- ],
- 'statislite' => [
- 'enable' => $this->getData(['config', 'statislite', 'enable'])
- ]
- ]
- ]);
-
- // Efface les fichiers de backup lorsque l'option est désactivée
- if ($this->getInput('configFileBackup', helper::FILTER_BOOLEAN) === false) {
- $path = realpath('site/data');
- foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $filename)
- {
- if (strpos($filename,'backup.json')) {
- unlink($filename);
+ // Basculement en mise à jour auto, remise à 0 du compteur
+ if ($this->getData(['config','autoUpdate']) === false &&
+ $this->getInput('configAutoUpdate', helper::FILTER_BOOLEAN) === true) {
+ $this->setData(['core','lastAutoUpdate',0]);
}
+
+ // Eviter déconnexion automatique après son activation
+ if ( $this->getData(['config','connect', 'autoDisconnect']) === false
+ AND $this->getInput('configAutoDisconnect',helper::FILTER_BOOLEAN) === true ) {
+ $this->setData(['user',$this->getuser('id'),'accessCsrf',$_SESSION['csrf']]);
}
- if (file_exists('site/data/.backup')) unlink('site/data/.backup');
- } else {
- touch('site/data/.backup');
+ // Répercuter la suppression de la page dans la configuration du footer
+ if ( $this->getData(['theme','footer','displaySearch']) === true
+ AND $this->getInput('configSearchPageId') === 'none'
+ ){
+ $this->setData(['theme', 'footer', 'displaySearch', false]);
+ }
+ if ( $this->getData(['theme','footer','displayLegal']) === true
+ AND $this->getInput('configLegalPageId') === 'none'
+ ){
+ $this->setData(['theme', 'footer', 'displayLegal', false]);
+ }
+
+ // Sauvegarder les locales
+ $this->setData([
+ 'locale',
+ [
+ 'homePageId' => $this->getInput('localeHomePageId', helper::FILTER_ID, true),
+ 'page404' => $this->getInput('localePage404'),
+ 'page403' => $this->getInput('localePage403'),
+ 'page302' => $this->getInput('localePage302'),
+ 'legalPageId' => $this->getInput('localeLegalPageId'),
+ 'searchPageId' => $this->getInput('localeSearchPageId'),
+ 'searchPageLabel' => empty($this->getInput('localeSearchPageLabel', helper::FILTER_STRING_SHORT)) ? 'Rechercher' : $this->getInput('localeSearchPageLabel', helper::FILTER_STRING_SHORT),
+ 'legalPageLabel' => empty($this->getInput('localeLegalPageLabel', helper::FILTER_STRING_SHORT)) ? 'Mentions légales' : $this->getInput('localeLegalPageLabel', helper::FILTER_STRING_SHORT),
+ 'sitemapPageLabel' => empty($this->getInput('localeSitemapPageLabel', helper::FILTER_STRING_SHORT)) ? 'Plan du site' : $this->getInput('localeSitemapPageLabel', helper::FILTER_STRING_SHORT),
+ 'visitorLabel' => $this->getInput('localeVisitorLabel', helper::FILTER_STRING_SHORT),
+ 'memberLabel' => $this->getInput('localeMemberLabel', helper::FILTER_STRING_SHORT),
+ 'editorLabel' => $this->getInput('localeEditorLabel', helper::FILTER_STRING_SHORT),
+ 'moderatorLabel' => $this->getInput('localeModeratorLabel', helper::FILTER_STRING_SHORT),
+ 'administratorLabel' => $this->getInput('localeAdministratorLabel', helper::FILTER_STRING_SHORT),
+ 'metaDescription' => $this->getInput('localeMetaDescription', helper::FILTER_STRING_LONG, true),
+ 'title' => $this->getInput('localeTitle', helper::FILTER_STRING_SHORT, true),
+ 'captchaSimpleText' => $this->getInput('localeCaptchaSimpleText', helper::FILTER_STRING_LONG),
+ 'captchaSimpleHelp' => $this->getInput('localeCaptchaSimpleHelp', helper::FILTER_STRING_LONG),
+ 'cookies' => [
+ // Les champs sont obligatoires si l'option consentement des cookies est active
+ 'cookiesDeltaText' => $this->getInput('localeCookiesDeltaText', helper::FILTER_STRING_LONG, $this->getData(['config', 'cookieConsent'])),
+ 'cookiesExtText' => $this->getInput('localeCookiesExtText', helper::FILTER_STRING_LONG),
+ 'cookiesTitleText' => $this->getInput('localeCookiesTitleText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])),
+ 'cookiesLinkMlText' => $this->getInput('localeCookiesLinkMlText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])),
+ 'cookiesCheckboxExtText' => $this->getInput('localeCookiesCheckboxExtText', helper::FILTER_STRING_SHORT),
+ 'cookiesFooterText' => $this->getInput('localeCookiesFooterText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])),
+ 'cookiesButtonText' =>$this->getInput('localeCookiesButtonText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent']))
+ ]
+ ]
+ ]);
+
+ // Sauvegarder la configuration
+ $this->setData([
+ 'config',
+ [
+ 'favicon' => $this->getInput('configFavicon'),
+ 'faviconDark' => $this->getInput('configFaviconDark'),
+ 'timezone' => $this->getInput('configTimezone', helper::FILTER_STRING_SHORT, true),
+ 'autoUpdate' => $this->getInput('configAutoUpdate', helper::FILTER_BOOLEAN),
+ 'autoUpdateHtaccess' => $this->getInput('configAutoUpdateHtaccess', helper::FILTER_BOOLEAN),
+ 'autoBackup' => $this->getInput('configAutoBackup', helper::FILTER_BOOLEAN),
+ 'maintenance' => $this->getInput('configMaintenance', helper::FILTER_BOOLEAN),
+ 'cookieConsent' => $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN),
+ 'proxyType' => $this->getInput('configProxyType'),
+ 'proxyUrl' => $this->getInput('configProxyUrl'),
+ 'proxyPort' => $this->getInput('configProxyPort',helper::FILTER_INT),
+ 'social' => [
+ 'facebookId' => $this->getInput('socialFacebookId'),
+ 'linkedinId' => $this->getInput('socialLinkedinId'),
+ 'instagramId' => $this->getInput('socialInstagramId'),
+ 'pinterestId' => $this->getInput('socialPinterestId'),
+ 'twitterId' => $this->getInput('socialTwitterId'),
+ 'youtubeId' => $this->getInput('socialYoutubeId'),
+ 'youtubeUserId' => $this->getInput('socialYoutubeUserId'),
+ 'githubId' => $this->getInput('socialGithubId'),
+ 'headFacebook' => $this->getInput('socialHeadFacebook', helper::FILTER_BOOLEAN)
+ ],
+ 'smtp' => [
+ 'enable' => $this->getInput('smtpEnable',helper::FILTER_BOOLEAN),
+ 'host' => $this->getInput('smtpHost',helper::FILTER_STRING_SHORT,$this->getInput('smtpEnable',helper::FILTER_BOOLEAN)),
+ 'port' => $this->getInput('smtpPort',helper::FILTER_INT,$this->getInput('smtpEnable',helper::FILTER_BOOLEAN)),
+ 'auth' => $this->getInput('smtpAuth',helper::FILTER_BOOLEAN),
+ 'secure' => $this->getInput('smtpSecure',helper::FILTER_BOOLEAN),
+ 'username' => $this->getInput('smtpUsername',helper::FILTER_STRING_SHORT,$this->getInput('smtpAuth',helper::FILTER_BOOLEAN)),
+ 'password' =>helper::encrypt($this->getData(['config','smtp','username']),$this->getInput('smtpPassword',null,$this->getInput('smtpAuth',helper::FILTER_BOOLEAN))),
+ 'sender' => $this->getInput('smtpSender',helper::FILTER_MAIL)
+ ],
+ 'seo' => [
+ 'robots' => $this->getInput('seoRobots',helper::FILTER_BOOLEAN),
+ 'analyticsId' => $this->getInput('seoAnalyticsId')
+ ],
+ 'connect' => [
+ 'attempt' => $this->getInput('connectAttempt',helper::FILTER_INT),
+ 'timeout' => $this->getInput('connectTimeout',helper::FILTER_INT),
+ 'log' => $this->getInput('connectLog',helper::FILTER_BOOLEAN),
+ 'anonymousIp' => $this->getInput('connectAnonymousIp',helper::FILTER_INT),
+ 'captcha' => $this->getInput('connectCaptcha',helper::FILTER_BOOLEAN),
+ 'captchaBot' => $this->getInput('connectCaptchaBot',helper::FILTER_BOOLEAN),
+ 'autoDisconnect' => $this->getInput('connectAutoDisconnect',helper::FILTER_BOOLEAN),
+ 'passwordVisibility' => $this->getInput('connectPasswordVisibility',helper::FILTER_BOOLEAN)
+ ],
+ 'i18n' => [
+ 'enable' => $this->getInput('localei18n',helper::FILTER_BOOLEAN),
+ 'scriptGoogle' => $this->getData(['config', 'i18n', 'scriptGoogle']),
+ 'showCredits' => $this->getData(['config', 'i18n', 'showCredits']),
+ 'autoDetect' => $this->getData(['config', 'i18n', 'autoDetect']),
+ //'admin' => $this->getData(['config', 'i18n', 'admin']),
+ 'langAdmin' => $this->getData(['config', 'i18n', 'langAdmin']),
+ 'langBase' => $this->getData(['config', 'i18n', 'langBase']),
+ 'fr' => $this->getData(['config', 'i18n', 'fr']),
+ 'de' => $this->getData(['config', 'i18n', 'de']),
+ 'en' => $this->getData(['config', 'i18n', 'en']),
+ 'es' => $this->getData(['config', 'i18n', 'es']),
+ 'it' => $this->getData(['config', 'i18n', 'it']),
+ 'nl' => $this->getData(['config', 'i18n', 'nl']),
+ 'pt' => $this->getData(['config', 'i18n', 'pt']),
+ 'el' => $this->getData(['config', 'i18n', 'el']),
+ 'da' => $this->getData(['config', 'i18n', 'da']),
+ 'fi' => $this->getData(['config', 'i18n', 'fi']),
+ 'ga' => $this->getData(['config', 'i18n', 'ga']),
+ 'sv' => $this->getData(['config', 'i18n', 'sv']),
+ 'br' => $this->getData(['config', 'i18n', 'br']),
+ 'ca' => $this->getData(['config', 'i18n', 'ca']),
+ 'co' => $this->getData(['config', 'i18n', 'co']),
+ 'eu' => $this->getData(['config', 'i18n', 'eu'])
+ ],
+ 'statislite' => [
+ 'enable' => $this->getData(['config', 'statislite', 'enable'])
+ ]
+ ]
+ ]);
+
+ // Efface les fichiers de backup lorsque l'option est désactivée
+ if ($this->getInput('configFileBackup', helper::FILTER_BOOLEAN) === false) {
+ $path = realpath('site/data');
+ foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $filename)
+ {
+ if (strpos($filename,'backup.json')) {
+ unlink($filename);
+ }
+ }
+ if (file_exists('site/data/.backup')) unlink('site/data/.backup');
+ } else {
+ touch('site/data/.backup');
+ }
+ // Notice
+ if(self::$inputNotices === []) {
+ // Active la réécriture d'URL
+ $rewrite = $this->getInput('configRewrite', helper::FILTER_BOOLEAN);
+ if(
+ $rewrite
+ AND helper::checkRewrite() === false
+ ) {
+ // Ajout des lignes dans le .htaccess
+ file_put_contents(
+ '.htaccess',
+ PHP_EOL .
+ '
'.$text['core_page']['add'][1].'
', self::$i18n); + // Met à jour le site map + // $this->createSitemap('all'); + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $pageId, + 'notification' => $text['core_page']['add'][2], + 'state' => true + ]); } - $this->setPage($pageId, ''.$text['core_page']['add'][1].'
', self::$i18n); - // Met à jour le site map - // $this->createSitemap('all'); - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . $pageId, - 'notification' => $text['core_page']['add'][2], - 'state' => true - ]); } /** * Suppression */ public function delete() { - // Lexique - include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php'); - // $url prend l'adresse sans le token - $url = explode('&',$this->getUrl(2)); - // La page n'existe pas - if($this->getData(['page', $url[0]]) === null) { + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < page::$actions['delete'] ) { // Valeurs en sortie $this->addOutput([ 'access' => false - ]); - } // Jeton incorrect - elseif(!isset($_GET['csrf'])) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], - 'notification' => $text['core_page']['delete'][0] - ]); - } - elseif ($_GET['csrf'] !== $_SESSION['csrf']) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], - 'notification' => $text['core_page']['delete'][1] - ]); - } - // Impossible de supprimer la page d'accueil - elseif($url[0] === $this->getData(['locale', 'homePageId'])) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'config', - 'notification' => $text['core_page']['delete'][2] - ]); - } - // Impossible de supprimer la page de recherche affectée - elseif($url[0] === $this->getData(['locale', 'searchPageId'])) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'config', - 'notification' => $text['core_page']['delete'][2] - ]); - } - // Impossible de supprimer la page des mentions légales affectée - elseif($url[0] === $this->getData(['locale', 'legalPageId'])) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'config', - 'notification' => $text['core_page']['delete'][2] - ]); - } - // Impossible de supprimer la page des mentions légales affectée - elseif($url[0] === $this->getData(['locale', 'page404'])) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'config', - 'notification' => $text['core_page']['delete'][2] - ]); - } - // Impossible de supprimer la page des mentions légales affectée - elseif($url[0] === $this->getData(['locale', 'page403'])) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'config', - 'notification' => $text['core_page']['delete'][2] - ]); - } - // Impossible de supprimer la page des mentions légales affectée - elseif($url[0] === $this->getData(['locale', 'page302'])) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'config', - 'notification' => $text['core_page']['delete'][2] - ]); - } - // Jeton incorrect - elseif(!isset($_GET['csrf'])) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], - 'notification' => $text['core_page']['delete'][0] - ]); - } - elseif ($_GET['csrf'] !== $_SESSION['csrf']) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], - 'notification' => $text['core_page']['delete'][1] - ]); - } - // Impossible de supprimer une page contenant des enfants - elseif($this->getHierarchy($url[0],null)) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], - 'notification' => $text['core_page']['delete'][3] - ]); - } - // Suppression - else { + ]); + } else { + // Lexique + include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php'); + // $url prend l'adresse sans le token + $url = explode('&',$this->getUrl(2)); + // La page n'existe pas + if($this->getData(['page', $url[0]]) === null) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } // Jeton incorrect + elseif(!isset($_GET['csrf'])) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], + 'notification' => $text['core_page']['delete'][0] + ]); + } + elseif ($_GET['csrf'] !== $_SESSION['csrf']) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], + 'notification' => $text['core_page']['delete'][1] + ]); + } + // Impossible de supprimer la page d'accueil + elseif($url[0] === $this->getData(['locale', 'homePageId'])) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'config', + 'notification' => $text['core_page']['delete'][2] + ]); + } + // Impossible de supprimer la page de recherche affectée + elseif($url[0] === $this->getData(['locale', 'searchPageId'])) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'config', + 'notification' => $text['core_page']['delete'][2] + ]); + } + // Impossible de supprimer la page des mentions légales affectée + elseif($url[0] === $this->getData(['locale', 'legalPageId'])) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'config', + 'notification' => $text['core_page']['delete'][2] + ]); + } + // Impossible de supprimer la page des mentions légales affectée + elseif($url[0] === $this->getData(['locale', 'page404'])) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'config', + 'notification' => $text['core_page']['delete'][2] + ]); + } + // Impossible de supprimer la page des mentions légales affectée + elseif($url[0] === $this->getData(['locale', 'page403'])) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'config', + 'notification' => $text['core_page']['delete'][2] + ]); + } + // Impossible de supprimer la page des mentions légales affectée + elseif($url[0] === $this->getData(['locale', 'page302'])) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'config', + 'notification' => $text['core_page']['delete'][2] + ]); + } + // Jeton incorrect + elseif(!isset($_GET['csrf'])) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], + 'notification' => $text['core_page']['delete'][0] + ]); + } + elseif ($_GET['csrf'] !== $_SESSION['csrf']) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], + 'notification' => $text['core_page']['delete'][1] + ]); + } + // Impossible de supprimer une page contenant des enfants + elseif($this->getHierarchy($url[0],null)) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], + 'notification' => $text['core_page']['delete'][3] + ]); + } + // Suppression + else { - // Effacer le dossier du module - $moduleId = $this->getData(['page',$url[0],'moduleId']); - $modulesData = helper::getModules(); - if (is_dir($modulesData[$moduleId]['dataDirectory']. $url[0])) { - $this->removeDir( $modulesData[$moduleId]['dataDirectory']. $url[0] ); + // Effacer le dossier du module + $moduleId = $this->getData(['page',$url[0],'moduleId']); + $modulesData = helper::getModules(); + if (is_dir($modulesData[$moduleId]['dataDirectory']. $url[0])) { + $this->removeDir( $modulesData[$moduleId]['dataDirectory']. $url[0] ); + } + // Effacer la page + $this->deleteData(['page', $url[0]]); + if (file_exists(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html')) { + unlink(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html'); + } + $this->deleteData(['module', $url[0]]); + // Met à jour le site map + // $this->createSitemap('all'); + // Met à jour 'config', 'statislite', 'enable' si aucume page utilise le module Statislite + $inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC'); + $statislite = 'off'; + foreach($inPages as $key=>$value){ + if( $value === 'statislite') $statislite = 'on'; + } + if( $statislite === 'off') $this->setData(['config', 'statislite', 'enable', false ]); + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl(false), + 'notification' => $text['core_page']['delete'][4], + 'state' => true + ]); } - // Effacer la page - $this->deleteData(['page', $url[0]]); - if (file_exists(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html')) { - unlink(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html'); - } - $this->deleteData(['module', $url[0]]); - // Met à jour le site map - // $this->createSitemap('all'); - // Met à jour 'config', 'statislite', 'enable' si aucume page utilise le module Statislite - $inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC'); - $statislite = 'off'; - foreach($inPages as $key=>$value){ - if( $value === 'statislite') $statislite = 'on'; - } - if( $statislite === 'off') $this->setData(['config', 'statislite', 'enable', false ]); - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl(false), - 'notification' => $text['core_page']['delete'][4], - 'state' => true - ]); } } @@ -279,221 +310,231 @@ class page extends common { * Édition */ public function edit() { - // Lexique - include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php'); - // La page n'existe pas - if($this->getData(['page', $this->getUrl(2)]) === null) { + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < page::$actions['edit'] ) { // Valeurs en sortie $this->addOutput([ 'access' => false - ]); - } - // La page existe - else { - // Soumission du formulaire - if($this->isPost()) { - // Si le Title n'est pas vide, premier test pour positionner la notification du champ obligatoire - if( $this->getInput('pageEditTitle', helper::FILTER_ID, true) !== null && $this->getInput('pageEditTitle') !== '' ){ - // Génére l'ID si le titre de la page a changé - if ( $this->getInput('pageEditTitle') !== $this->getData(['page',$this->getUrl(2),'title']) ) { - $pageId = $this->getInput('pageEditTitle', helper::FILTER_ID, true); - } else { - $pageId = $this->getUrl(2); - } - // un dossier existe du même nom (erreur en cas de redirection) - if (file_exists($pageId)) { - $pageId = uniqid($pageId); - } - // Si l'id a changée - if ($pageId !== $this->getUrl(2)) { - // Incrémente le nouvel id de la page - $pageId = helper::increment($pageId, $this->getData(['page'])); - $pageId = helper::increment($pageId, self::$coreModuleIds); - $pageId = helper::increment($pageId, self::$moduleIds); - // Met à jour les enfants - foreach($this->getHierarchy($this->getUrl(2),null) as $childrenPageId) { - $this->setData(['page', $childrenPageId, 'parentPageId', $pageId]); + ]); + } else { + // Lexique + include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php'); + // La page n'existe pas + if($this->getData(['page', $this->getUrl(2)]) === null) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } + // La page existe + else { + // Soumission du formulaire + if($this->isPost()) { + // Si le Title n'est pas vide, premier test pour positionner la notification du champ obligatoire + if( $this->getInput('pageEditTitle', helper::FILTER_ID, true) !== null && $this->getInput('pageEditTitle') !== '' ){ + // Génére l'ID si le titre de la page a changé + if ( $this->getInput('pageEditTitle') !== $this->getData(['page',$this->getUrl(2),'title']) ) { + $pageId = $this->getInput('pageEditTitle', helper::FILTER_ID, true); + } else { + $pageId = $this->getUrl(2); } - // Change l'id de page dans les données des modules - 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']. $this->getUrl(2))) { - // Placer la feuille de style dans un dossier au nom de la nouvelle instance - mkdir( $modulesData[$moduleId]['dataDirectory']. $pageId, 0755 ); - copy( $modulesData[$moduleId]['dataDirectory']. $this->getUrl(2), $modulesData[$moduleId]['dataDirectory']. $pageId); - $this->removeDir($modulesData[$moduleId]['dataDirectory']. $this->getUrl(2)); - // Mettre à jour le nom de la feuille de style - $this->setData(['module',$pageId,'theme','style', $modulesData[$moduleId]['dataDirectory']. $pageId]); + // un dossier existe du même nom (erreur en cas de redirection) + if (file_exists($pageId)) { + $pageId = uniqid($pageId); + } + // Si l'id a changée + if ($pageId !== $this->getUrl(2)) { + // Incrémente le nouvel id de la page + $pageId = helper::increment($pageId, $this->getData(['page'])); + $pageId = helper::increment($pageId, self::$coreModuleIds); + $pageId = helper::increment($pageId, self::$moduleIds); + // Met à jour les enfants + foreach($this->getHierarchy($this->getUrl(2),null) as $childrenPageId) { + $this->setData(['page', $childrenPageId, 'parentPageId', $pageId]); + } + // Change l'id de page dans les données des modules + 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']. $this->getUrl(2))) { + // Placer la feuille de style dans un dossier au nom de la nouvelle instance + mkdir( $modulesData[$moduleId]['dataDirectory']. $pageId, 0755 ); + copy( $modulesData[$moduleId]['dataDirectory']. $this->getUrl(2), $modulesData[$moduleId]['dataDirectory']. $pageId); + $this->removeDir($modulesData[$moduleId]['dataDirectory']. $this->getUrl(2)); + // Mettre à jour le nom de la feuille de style + $this->setData(['module',$pageId,'theme','style', $modulesData[$moduleId]['dataDirectory']. $pageId]); + } + } + // Si la page correspond à la page d'accueil, change l'id dans la configuration du site + if($this->getData(['locale', 'homePageId']) === $this->getUrl(2)) { + $this->setData(['locale', 'homePageId', $pageId]); } } - // Si la page correspond à la page d'accueil, change l'id dans la configuration du site - if($this->getData(['locale', 'homePageId']) === $this->getUrl(2)) { - $this->setData(['locale', 'homePageId', $pageId]); + // Supprime les données du module en cas de changement de module + if($this->getInput('pageEditModuleId') !== $this->getData(['page', $this->getUrl(2), 'moduleId'])) { + $this->deleteData(['module', $pageId]); } - } - // Supprime les données du module en cas de changement de module - if($this->getInput('pageEditModuleId') !== $this->getData(['page', $this->getUrl(2), 'moduleId'])) { - $this->deleteData(['module', $pageId]); - } - // Supprime l'ancienne page si l'id a changée - if($pageId !== $this->getUrl(2)) { - $this->deleteData(['page', $this->getUrl(2)]); - unlink (self::DATA_DIR . self::$i18n . '/content/' . $this->getUrl(2) . '.html'); - } - // Traitement des pages spéciales affectées dans la config : - if ($this->getUrl(2) === $this->getData(['locale', 'legalPageId']) ) { - $this->setData(['locale','legalPageId', $pageId]); - } - if ($this->getUrl(2) === $this->getData(['locale', 'searchPageId']) ) { - $this->setData(['locale','searchPageId', $pageId]); - } - if ($this->getUrl(2) === $this->getData(['locale', 'page404']) ) { - $this->setData(['locale','page404', $pageId]); - } - if ($this->getUrl(2) === $this->getData(['locale', 'page403']) ) { - $this->setData(['locale','page403', $pageId]); - } - if ($this->getUrl(2) === $this->getData(['locale', 'page302']) ) { - $this->setData(['locale','page302', $pageId]); - } - // Si la page est une page enfant, actualise les positions des autres enfants du parent, sinon actualise les pages sans parents - $lastPosition = 1; - $hierarchy = $this->getInput('pageEditParentPageId') ? $this->getHierarchy($this->getInput('pageEditParentPageId')) : array_keys($this->getHierarchy()); - $position = $this->getInput('pageEditPosition', helper::FILTER_INT); - foreach($hierarchy as $hierarchyPageId) { - // Ignore la page en cours de modification - if($hierarchyPageId === $this->getUrl(2)) { - continue; + // Supprime l'ancienne page si l'id a changée + if($pageId !== $this->getUrl(2)) { + $this->deleteData(['page', $this->getUrl(2)]); + unlink (self::DATA_DIR . self::$i18n . '/content/' . $this->getUrl(2) . '.html'); } - // Incrémente de +1 pour laisser la place à la position de la page en cours de modification - if($lastPosition === $position) { + // Traitement des pages spéciales affectées dans la config : + if ($this->getUrl(2) === $this->getData(['locale', 'legalPageId']) ) { + $this->setData(['locale','legalPageId', $pageId]); + } + if ($this->getUrl(2) === $this->getData(['locale', 'searchPageId']) ) { + $this->setData(['locale','searchPageId', $pageId]); + } + if ($this->getUrl(2) === $this->getData(['locale', 'page404']) ) { + $this->setData(['locale','page404', $pageId]); + } + if ($this->getUrl(2) === $this->getData(['locale', 'page403']) ) { + $this->setData(['locale','page403', $pageId]); + } + if ($this->getUrl(2) === $this->getData(['locale', 'page302']) ) { + $this->setData(['locale','page302', $pageId]); + } + // Si la page est une page enfant, actualise les positions des autres enfants du parent, sinon actualise les pages sans parents + $lastPosition = 1; + $hierarchy = $this->getInput('pageEditParentPageId') ? $this->getHierarchy($this->getInput('pageEditParentPageId')) : array_keys($this->getHierarchy()); + $position = $this->getInput('pageEditPosition', helper::FILTER_INT); + foreach($hierarchy as $hierarchyPageId) { + // Ignore la page en cours de modification + if($hierarchyPageId === $this->getUrl(2)) { + continue; + } + // Incrémente de +1 pour laisser la place à la position de la page en cours de modification + if($lastPosition === $position) { + $lastPosition++; + } + // Change la position + $this->setData(['page', $hierarchyPageId, 'position', $lastPosition]); + // Incrémente pour la prochaine position $lastPosition++; } - // Change la position - $this->setData(['page', $hierarchyPageId, 'position', $lastPosition]); - // Incrémente pour la prochaine position - $lastPosition++; - } - if ($this->getinput('pageEditBlock') !== 'bar') { - $barLeft = $this->getinput('pageEditBarLeft'); - $barRight = $this->getinput('pageEditBarRight'); - $hideTitle = $this->getInput('pageEditHideTitle', helper::FILTER_BOOLEAN); + if ($this->getinput('pageEditBlock') !== 'bar') { + $barLeft = $this->getinput('pageEditBarLeft'); + $barRight = $this->getinput('pageEditBarRight'); + $hideTitle = $this->getInput('pageEditHideTitle', helper::FILTER_BOOLEAN); - } else { - // Une barre ne peut pas avoir de barres - $barLeft = ""; - $barRight = ""; - // Une barre est masquée - $position = 0; - $hideTitle = true; - } - // Modifie la page ou en crée une nouvelle si l'id a changé - $this->setData([ - 'page', - $pageId, - [ - 'typeMenu' => $this->getinput('pageTypeMenu'), - 'iconUrl' => $this->getinput('pageIconUrl'), - 'disable'=> $this->getinput('pageEditDisable', helper::FILTER_BOOLEAN), - 'content' => $pageId . '.html', - 'hideTitle' => $hideTitle, - 'breadCrumb' => $this->getInput('pageEditbreadCrumb', helper::FILTER_BOOLEAN), - 'metaDescription' => $this->getInput('pageEditMetaDescription', helper::FILTER_STRING_LONG), - 'metaTitle' => $this->getInput('pageEditMetaTitle'), - 'moduleId' => $this->getInput('pageEditModuleId'), - 'modulePosition' => $this->getInput('configModulePosition'), - 'parentPageId' => $this->getInput('pageEditParentPageId'), - 'position' => $position, - 'group' => $this->getinput('pageEditBlock') !== 'bar' ? $this->getInput('pageEditGroup', helper::FILTER_INT) : 0, - 'groupEdit' => $this->getInput('pageEditGroupEdit', helper::FILTER_INT), - 'targetBlank' => $this->getInput('pageEditTargetBlank', helper::FILTER_BOOLEAN), - 'title' => $this->getInput('pageEditTitle', helper::FILTER_STRING_SHORT), - 'shortTitle' => $this->getInput('pageEditShortTitle', helper::FILTER_STRING_SHORT, true), - 'block' => $this->getinput('pageEditBlock'), - 'barLeft' => $barLeft, - 'barRight' => $barRight, - 'displayMenu' => $this->getinput('pageEditDisplayMenu'), - 'hideMenuSide' => $this->getinput('pageEditHideMenuSide', helper::FILTER_BOOLEAN), - 'hideMenuHead' => $this->getinput('pageEditHideMenuHead', helper::FILTER_BOOLEAN), - 'hideMenuChildren' => $this->getinput('pageEditHideMenuChildren', helper::FILTER_BOOLEAN), - ] - ]); - // Creation du contenu de la page - if (!is_dir(self::DATA_DIR . self::$i18n . '/content')) { - mkdir(self::DATA_DIR . self::$i18n . '/content', 0755); - } - $content = empty($this->getInput('pageEditContent', null)) ? '' : str_replace('', '', $this->getInput('pageEditContent', null)); - //file_put_contents( self::DATA_DIR . self::$i18n . '/content/' . $pageId . '.html' , $content ); - $this->setPage($pageId , $content, self::$i18n); - // Barre renommée : changement le nom de la barre dans les pages mères - if ($this->getinput('pageEditBlock') === 'bar') { - foreach ($this->getHierarchy() as $eachPageId=>$parentId) { - if ($this->getData(['page',$eachPageId,'barRight']) === $this->getUrl(2)) { - $this->setData(['page',$eachPageId,'barRight',$pageId]); - } - if ($this->getData(['page',$eachPageId,'barLeft']) === $this->getUrl(2)) { - $this->setData(['page',$eachPageId,'barLeft',$pageId]); - } - foreach ($parentId as $childId) { - if ($this->getData(['page',$childId,'barRight']) === $this->getUrl(2)) { - $this->setData(['page',$childId,'barRight',$pageId]); + } else { + // Une barre ne peut pas avoir de barres + $barLeft = ""; + $barRight = ""; + // Une barre est masquée + $position = 0; + $hideTitle = true; + } + // Modifie la page ou en crée une nouvelle si l'id a changé + $this->setData([ + 'page', + $pageId, + [ + 'typeMenu' => $this->getinput('pageTypeMenu'), + 'iconUrl' => $this->getinput('pageIconUrl'), + 'disable'=> $this->getinput('pageEditDisable', helper::FILTER_BOOLEAN), + 'content' => $pageId . '.html', + 'hideTitle' => $hideTitle, + 'breadCrumb' => $this->getInput('pageEditbreadCrumb', helper::FILTER_BOOLEAN), + 'metaDescription' => $this->getInput('pageEditMetaDescription', helper::FILTER_STRING_LONG), + 'metaTitle' => $this->getInput('pageEditMetaTitle'), + 'moduleId' => $this->getInput('pageEditModuleId'), + 'modulePosition' => $this->getInput('configModulePosition'), + 'parentPageId' => $this->getInput('pageEditParentPageId'), + 'position' => $position, + 'group' => $this->getinput('pageEditBlock') !== 'bar' ? $this->getInput('pageEditGroup', helper::FILTER_INT) : 0, + 'groupEdit' => $this->getInput('pageEditGroupEdit', helper::FILTER_INT), + 'targetBlank' => $this->getInput('pageEditTargetBlank', helper::FILTER_BOOLEAN), + 'title' => $this->getInput('pageEditTitle', helper::FILTER_STRING_SHORT), + 'shortTitle' => $this->getInput('pageEditShortTitle', helper::FILTER_STRING_SHORT, true), + 'block' => $this->getinput('pageEditBlock'), + 'barLeft' => $barLeft, + 'barRight' => $barRight, + 'displayMenu' => $this->getinput('pageEditDisplayMenu'), + 'hideMenuSide' => $this->getinput('pageEditHideMenuSide', helper::FILTER_BOOLEAN), + 'hideMenuHead' => $this->getinput('pageEditHideMenuHead', helper::FILTER_BOOLEAN), + 'hideMenuChildren' => $this->getinput('pageEditHideMenuChildren', helper::FILTER_BOOLEAN), + ] + ]); + // Creation du contenu de la page + if (!is_dir(self::DATA_DIR . self::$i18n . '/content')) { + mkdir(self::DATA_DIR . self::$i18n . '/content', 0755); + } + $content = empty($this->getInput('pageEditContent', null)) ? '' : str_replace('', '
', $this->getInput('pageEditContent', null)); + //file_put_contents( self::DATA_DIR . self::$i18n . '/content/' . $pageId . '.html' , $content ); + $this->setPage($pageId , $content, self::$i18n); + // Barre renommée : changement le nom de la barre dans les pages mères + if ($this->getinput('pageEditBlock') === 'bar') { + foreach ($this->getHierarchy() as $eachPageId=>$parentId) { + if ($this->getData(['page',$eachPageId,'barRight']) === $this->getUrl(2)) { + $this->setData(['page',$eachPageId,'barRight',$pageId]); } - if ($this->getData(['page',$childId,'barLeft']) === $this->getUrl(2)) { - $this->setData(['page',$childId,'barLeft',$pageId]); + if ($this->getData(['page',$eachPageId,'barLeft']) === $this->getUrl(2)) { + $this->setData(['page',$eachPageId,'barLeft',$pageId]); + } + foreach ($parentId as $childId) { + if ($this->getData(['page',$childId,'barRight']) === $this->getUrl(2)) { + $this->setData(['page',$childId,'barRight',$pageId]); + } + if ($this->getData(['page',$childId,'barLeft']) === $this->getUrl(2)) { + $this->setData(['page',$childId,'barLeft',$pageId]); + } } } } - } - // Met à jour le site map - // $this->createSitemap('all'); - // Redirection vers la configuration - if($this->getInput('pageEditModuleRedirect', helper::FILTER_BOOLEAN)) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . $pageId . '/config', - 'state' => true - ]); - } - // Redirection vers la page - else { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . $pageId, - 'notification' => $text['core_page']['edit'][0], - 'state' => true - ]); + // Met à jour le site map + // $this->createSitemap('all'); + // Redirection vers la configuration + if($this->getInput('pageEditModuleRedirect', helper::FILTER_BOOLEAN)) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $pageId . '/config', + 'state' => true + ]); + } + // Redirection vers la page + else { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $pageId, + 'notification' => $text['core_page']['edit'][0], + 'state' => true + ]); + } } } - } - self::$moduleIds = array_merge( ['' => $text['core_page']['edit'][1]] , helper::arrayCollumn(helper::getModules(),'realName','SORT_ASC')); // Pages sans parent - self::$pagesNoParentId = $pagesNoParentId; - foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) { - if($parentPageId !== $this->getUrl(2)) { - self::$pagesNoParentId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']); - //self::$pagesNoParentId_en[$parentPageId] = $this->getData(['page', $parentPageId, 'title']); - } - } - // Pages barre latérales - self::$pagesBarId = $pagesBarId; - foreach($this->getHierarchy(null,false,true) as $parentPageId => $childrenPageIds) { - if($parentPageId !== $this->getUrl(2) && - $this->getData(['page', $parentPageId, 'block']) === 'bar') { - self::$pagesBarId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']); - //self::$pagesBarId_en[$parentPageId] = $this->getData(['page', $parentPageId, 'title']); + self::$moduleIds = array_merge( ['' => $text['core_page']['edit'][1]] , helper::arrayCollumn(helper::getModules(),'realName','SORT_ASC')); // Pages sans parent + self::$pagesNoParentId = $pagesNoParentId; + foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) { + if($parentPageId !== $this->getUrl(2)) { + self::$pagesNoParentId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']); + //self::$pagesNoParentId_en[$parentPageId] = $this->getData(['page', $parentPageId, 'title']); } + } + // Pages barre latérales + self::$pagesBarId = $pagesBarId; + foreach($this->getHierarchy(null,false,true) as $parentPageId => $childrenPageIds) { + if($parentPageId !== $this->getUrl(2) && + $this->getData(['page', $parentPageId, 'block']) === 'bar') { + self::$pagesBarId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']); + //self::$pagesBarId_en[$parentPageId] = $this->getData(['page', $parentPageId, 'title']); + } + } + // Mise à jour de la liste des pages pour TinyMCE + $this->pages2Json(); + // Valeurs en sortie + $this->addOutput([ + 'title' => $this->getData(['page', $this->getUrl(2), 'title']), + 'vendor' => ['tinymce'], + 'view' => 'edit' + ]); } - // Mise à jour de la liste des pages pour TinyMCE - $this->pages2Json(); - // Valeurs en sortie - $this->addOutput([ - 'title' => $this->getData(['page', $this->getUrl(2), 'title']), - 'vendor' => ['tinymce'], - 'view' => 'edit' - ]); } } } diff --git a/core/module/theme/theme.php b/core/module/theme/theme.php index 4d22a53..7900af5 100644 --- a/core/module/theme/theme.php +++ b/core/module/theme/theme.php @@ -65,247 +65,307 @@ class theme extends common { * Thème des écrans d'administration */ public function admin() { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - // Soumission du formulaire - if($this->isPost()) { - $this->setData(['admin', [ - 'backgroundColor' => $this->getInput('adminBackgroundColor'), - 'colorTitle' => $this->getInput('adminColorTitle'), - 'colorText' => $this->getInput('adminColorText'), - 'colorButtonText' => $this->getInput('adminColorButtonText'), - 'backgroundColorButton' => $this->getInput('adminColorButton'), - 'backgroundColorButtonGrey' => $this->getInput('adminColorGrey'), - 'backgroundColorButtonRed' => $this->getInput('adminColorRed'), - 'backgroundColorButtonGreen'=> $this->getInput('adminColorGreen'), - 'backgroundColorButtonHelp'=> $this->getInput('adminColorHelp'), - 'fontText' => $this->getInput('adminFontText'), - 'fontSize' => $this->getInput('adminFontTextSize'), - 'fontTitle' => $this->getInput('adminFontTitle'), - 'backgroundBlockColor' => $this->getInput('adminBackGroundBlockColor'), - 'borderBlockColor' => $this->getInput('adminBorderBlockColor'), - 'maj' => true - ]]); + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['admin'] ) { // Valeurs en sortie $this->addOutput([ - 'notification' => $text['core_theme']['admin'][0], - 'redirect' => helper::baseUrl() . 'theme/admin', - 'state' => true + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // Soumission du formulaire + if($this->isPost()) { + $this->setData(['admin', [ + 'backgroundColor' => $this->getInput('adminBackgroundColor'), + 'colorTitle' => $this->getInput('adminColorTitle'), + 'colorText' => $this->getInput('adminColorText'), + 'colorButtonText' => $this->getInput('adminColorButtonText'), + 'backgroundColorButton' => $this->getInput('adminColorButton'), + 'backgroundColorButtonGrey' => $this->getInput('adminColorGrey'), + 'backgroundColorButtonRed' => $this->getInput('adminColorRed'), + 'backgroundColorButtonGreen'=> $this->getInput('adminColorGreen'), + 'backgroundColorButtonHelp'=> $this->getInput('adminColorHelp'), + 'fontText' => $this->getInput('adminFontText'), + 'fontSize' => $this->getInput('adminFontTextSize'), + 'fontTitle' => $this->getInput('adminFontTitle'), + 'backgroundBlockColor' => $this->getInput('adminBackGroundBlockColor'), + 'borderBlockColor' => $this->getInput('adminBorderBlockColor'), + 'maj' => true + ]]); + // Valeurs en sortie + $this->addOutput([ + 'notification' => $text['core_theme']['admin'][0], + 'redirect' => helper::baseUrl() . 'theme/admin', + 'state' => true + ]); + } + self::$fonts = $this->extract('./site/data/fonts.json'); + // Valeurs en sortie + $this->addOutput([ + 'title' => $text['core_theme']['admin'][1], + 'view' => 'admin', + 'vendor' => [ + 'tinycolorpicker' + ], ]); } - self::$fonts = $this->extract('./site/data/fonts.json'); - // Valeurs en sortie - $this->addOutput([ - 'title' => $text['core_theme']['admin'][1], - 'view' => 'admin', - 'vendor' => [ - 'tinycolorpicker' - ], - ]); } /** * Mode avancé */ public function advanced() { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - // Soumission du formulaire - if($this->isPost()) { - // Enregistre le CSS - file_put_contents(self::DATA_DIR.'custom.css', $this->getInput('themeAdvancedCss', null)); + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['advanced'] ) { // Valeurs en sortie $this->addOutput([ - 'notification' => $text['core_theme']['advanced'][0], - 'redirect' => helper::baseUrl() . 'theme/advanced', - 'state' => true + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // Soumission du formulaire + if($this->isPost()) { + // Enregistre le CSS + file_put_contents(self::DATA_DIR.'custom.css', $this->getInput('themeAdvancedCss', null)); + // Valeurs en sortie + $this->addOutput([ + 'notification' => $text['core_theme']['advanced'][0], + 'redirect' => helper::baseUrl() . 'theme/advanced', + 'state' => true + ]); + } + // Valeurs en sortie + $this->addOutput([ + 'title' => $text['core_theme']['advanced'][1], + 'vendor' => [ + 'tinymce/plugins/codemirror/codemirror' + ], + 'view' => 'advanced' ]); } - // Valeurs en sortie - $this->addOutput([ - 'title' => $text['core_theme']['advanced'][1], - 'vendor' => [ - 'tinymce/plugins/codemirror/codemirror' - ], - 'view' => 'advanced' - ]); } /** * Gestion des polices / affichage principal */ public function fonts() { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - // Préparation du tableau d'affichage des polices - $fontsName = helper::arrayCollumn($this->getData(['fonts']), 'name'); - ksort($fontsName); - foreach($fontsName as $fontsId => $value) { - - self::$fonts[] = [ - ''.$fontsId.'', - ''.$this->getData(['fonts', $fontsId, 'name']).'', - ''.$this->getData(['fonts', $fontsId, 'file']).'', - 'TPQtpq741àéèôüç', - template::button('fontsEdit' . $fontsId, [ - 'href' => helper::baseUrl() . 'theme/editFonts/' . $fontsId, - 'value' => template::ico('pencil') - ]), - template::button('fontsDelete' . $fontsId, [ - 'class' => 'fontDelete buttonRed', - 'href' => helper::baseUrl() . 'theme/deleteFonts/' . $fontsId, - 'value' => template::ico('cancel') - ]) - ]; - + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['fonts'] ) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // Préparation du tableau d'affichage des polices + $fontsName = helper::arrayCollumn($this->getData(['fonts']), 'name'); + ksort($fontsName); + foreach($fontsName as $fontsId => $value) { + + self::$fonts[] = [ + ''.$fontsId.'', + ''.$this->getData(['fonts', $fontsId, 'name']).'', + ''.$this->getData(['fonts', $fontsId, 'file']).'', + 'TPQtpq741àéèôüç', + template::button('fontsEdit' . $fontsId, [ + 'href' => helper::baseUrl() . 'theme/editFonts/' . $fontsId, + 'value' => template::ico('pencil') + ]), + template::button('fontsDelete' . $fontsId, [ + 'class' => 'fontDelete buttonRed', + 'href' => helper::baseUrl() . 'theme/deleteFonts/' . $fontsId, + 'value' => template::ico('cancel') + ]) + ]; + + } + + // Valeurs en sortie + $this->addOutput([ + 'title' => $text['core_theme']['fonts'][0], + 'view' => 'fonts' + ]); } - - // Valeurs en sortie - $this->addOutput([ - 'title' => $text['core_theme']['fonts'][0], - 'view' => 'fonts' - ]); } /** * Gestion des polices / édition */ public function editfonts() { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - // Retour du formulaire - if($this->isPost()) { - if( $this->getInput('typeEditFont') === 'file' && $this->getInput('fileEditFont') === $text['core_theme']['editFonts'][0]){ - // Valeurs en sortie - $this->addOutput([ - 'notification' => $text['core_theme']['editFonts'][1], - 'redirect' => helper::baseUrl() . 'theme/fonts', - 'state' => false - ]); + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['editfonts'] ) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // Retour du formulaire + if($this->isPost()) { + if( $this->getInput('typeEditFont') === 'file' && $this->getInput('fileEditFont') === $text['core_theme']['editFonts'][0]){ + // Valeurs en sortie + $this->addOutput([ + 'notification' => $text['core_theme']['editFonts'][1], + 'redirect' => helper::baseUrl() . 'theme/fonts', + 'state' => false + ]); + } + else{ + $file = $this->getInput('typeEditFont') === 'none' ? '' : $this->getInput('fileEditFont'); + $key = strtolower(str_replace(' ','-',$this->getInput('nameEditFont'))); + $this->setData(['fonts', $key, [ + 'name' => $this->getInput('nameEditFont'), + 'type' => $this->getInput('typeEditFont'), + 'file' => $file, + 'link' => '', + 'license' => $this->getInput('licenseEditFont') + ]]); + // Force une maj de admin.css + $this-> setData(['admin', 'maj', true]); + // Valeurs en sortie + $this->addOutput([ + 'notification' => $text['core_theme']['editFonts'][2], + 'redirect' => helper::baseUrl() . 'theme/fonts', + 'state' => true + ]); + } } - else{ - $file = $this->getInput('typeEditFont') === 'none' ? '' : $this->getInput('fileEditFont'); - $key = strtolower(str_replace(' ','-',$this->getInput('nameEditFont'))); - $this->setData(['fonts', $key, [ - 'name' => $this->getInput('nameEditFont'), - 'type' => $this->getInput('typeEditFont'), - 'file' => $file, - 'link' => '', - 'license' => $this->getInput('licenseEditFont') - ]]); - // Force une maj de admin.css - $this-> setData(['admin', 'maj', true]); - // Valeurs en sortie - $this->addOutput([ - 'notification' => $text['core_theme']['editFonts'][2], - 'redirect' => helper::baseUrl() . 'theme/fonts', - 'state' => true - ]); + + // Fichiers site/file/fonts/ + if(is_dir(self::FILE_DIR.'source/fonts')) { + $dir=self::FILE_DIR.'source/fonts'; + $values = scandir($dir); + $values[0] = $text['core_theme']['editFonts'][0]; + unset($values[array_search('..', $values)]); + if (count($values) <= 1){ + self::$icsFiles = array(0 => $text['core_theme']['editFonts'][3].self::FILE_DIR.'source/fonts'); + } + else{ + //Modifier les clefs (qui sont les valeurs de retour du formulaire avec clef = valeur + self::$fontFiles = array_combine($values,$values); + } } + else { + self::$fontFiles = array(0 => $text['core_theme']['editFonts'][4].self::FILE_DIR.'source/fonts '.$text['core_theme']['editFonts'][5]); + } + + // Valeurs en sortie + $this->addOutput([ + 'title' => $text['core_theme']['editFonts'][6], + 'view' => 'editFonts' + ]); } - - // Fichiers site/file/fonts/ - if(is_dir(self::FILE_DIR.'source/fonts')) { - $dir=self::FILE_DIR.'source/fonts'; - $values = scandir($dir); - $values[0] = $text['core_theme']['editFonts'][0]; - unset($values[array_search('..', $values)]); - if (count($values) <= 1){ - self::$icsFiles = array(0 => $text['core_theme']['editFonts'][3].self::FILE_DIR.'source/fonts'); - } - else{ - //Modifier les clefs (qui sont les valeurs de retour du formulaire avec clef = valeur - self::$fontFiles = array_combine($values,$values); - } - } - else { - self::$fontFiles = array(0 => $text['core_theme']['editFonts'][4].self::FILE_DIR.'source/fonts '.$text['core_theme']['editFonts'][5]); - } - - // Valeurs en sortie - $this->addOutput([ - 'title' => $text['core_theme']['editFonts'][6], - 'view' => 'editFonts' - ]); } /** * Gestion des polices / suppression */ public function deleteFonts() { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - //Suppression de la police passée en paramètre - $this->deleteData(['fonts', $this->getUrl(2)]); - // Force une maj de admin.css - $this-> setData(['admin', 'maj', true]); - // Valeurs en sortie - $this->addOutput([ - 'notification' => $text['core_theme']['deleteFonts'][0], - 'redirect' => helper::baseUrl() . 'theme/fonts', - 'state' => true + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['deleteFonts'] ) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + //Suppression de la police passée en paramètre + $this->deleteData(['fonts', $this->getUrl(2)]); + // Force une maj de admin.css + $this-> setData(['admin', 'maj', true]); + // Valeurs en sortie + $this->addOutput([ + 'notification' => $text['core_theme']['deleteFonts'][0], + 'redirect' => helper::baseUrl() . 'theme/fonts', + 'state' => true ]); + } } /** * Gestion des polices / ajout */ public function addFonts() { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - // Retour du formulaire - if($this->isPost()) { - if( $this->getInput('typeAddFont') === 'file' && $this->getInput('fileAddFont') === $text['core_theme']['addFonts'][0]){ - // Valeurs en sortie - $this->addOutput([ - 'notification' => $text['core_theme']['addFonts'][1], - 'redirect' => helper::baseUrl() . 'theme/addFonts', - 'state' => false - ]); + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['addFonts'] ) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // Retour du formulaire + if($this->isPost()) { + if( $this->getInput('typeAddFont') === 'file' && $this->getInput('fileAddFont') === $text['core_theme']['addFonts'][0]){ + // Valeurs en sortie + $this->addOutput([ + 'notification' => $text['core_theme']['addFonts'][1], + 'redirect' => helper::baseUrl() . 'theme/addFonts', + 'state' => false + ]); + } + else{ + $file = $this->getInput('typeAddFont') === 'none' ? '' : $this->getInput('fileAddFont'); + $key = strtolower(str_replace(' ','-',$this->getInput('nameAddFont'))); + $this->setData(['fonts', $key, [ + 'name' => $this->getInput('nameAddFont'), + 'type' => $this->getInput('typeAddFont'), + 'file' => $file, + 'link' => '', + 'license' => $this->getInput('licenseAddFont') + ]]); + // Force une maj de admin.css + $this-> setData(['admin', 'maj', true]); + // Valeurs en sortie + $this->addOutput([ + 'notification' => $text['core_theme']['addFonts'][2], + 'redirect' => helper::baseUrl() . 'theme/fonts', + 'state' => true + ]); + } } - else{ - $file = $this->getInput('typeAddFont') === 'none' ? '' : $this->getInput('fileAddFont'); - $key = strtolower(str_replace(' ','-',$this->getInput('nameAddFont'))); - $this->setData(['fonts', $key, [ - 'name' => $this->getInput('nameAddFont'), - 'type' => $this->getInput('typeAddFont'), - 'file' => $file, - 'link' => '', - 'license' => $this->getInput('licenseAddFont') - ]]); - // Force une maj de admin.css - $this-> setData(['admin', 'maj', true]); - // Valeurs en sortie - $this->addOutput([ - 'notification' => $text['core_theme']['addFonts'][2], - 'redirect' => helper::baseUrl() . 'theme/fonts', - 'state' => true - ]); + // Fichiers site/file/fonts/ + if(is_dir(self::FILE_DIR.'source/fonts')) { + $dir=self::FILE_DIR.'source/fonts'; + $values = scandir($dir); + $values[0] = $text['core_theme']['addFonts'][0]; + unset($values[array_search('..', $values)]); + if (count($values) <= 1){ + self::$icsFiles = array(0 => $text['core_theme']['addFonts'][3].self::FILE_DIR.'source/fonts'); + } + else{ + //Modifier les clefs (qui sont les valeurs de retour du formulaire avec clef = valeur + self::$fontFiles = array_combine($values,$values); + } } - } - // Fichiers site/file/fonts/ - if(is_dir(self::FILE_DIR.'source/fonts')) { - $dir=self::FILE_DIR.'source/fonts'; - $values = scandir($dir); - $values[0] = $text['core_theme']['addFonts'][0]; - unset($values[array_search('..', $values)]); - if (count($values) <= 1){ - self::$icsFiles = array(0 => $text['core_theme']['addFonts'][3].self::FILE_DIR.'source/fonts'); + else { + self::$fontFiles = array(0 => $text['core_theme']['addFonts'][4].self::FILE_DIR.'source/fonts '.$text['core_theme']['addFonts'][5]); } - else{ - //Modifier les clefs (qui sont les valeurs de retour du formulaire avec clef = valeur - self::$fontFiles = array_combine($values,$values); - } - } - else { - self::$fontFiles = array(0 => $text['core_theme']['addFonts'][4].self::FILE_DIR.'source/fonts '.$text['core_theme']['addFonts'][5]); - } - // Valeurs en sortie - $this->addOutput([ - 'title' => $text['core_theme']['addFonts'][6], - 'view' => 'addFonts' - ]); + // Valeurs en sortie + $this->addOutput([ + 'title' => $text['core_theme']['addFonts'][6], + 'view' => 'addFonts' + ]); + } } @@ -313,371 +373,431 @@ class theme extends common { * Options de l'arrière plan */ public function body() { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - // Soumission du formulaire - if($this->isPost()) { - $this->setData([ 'theme', 'update', true]); - $this->setData(['theme', 'body', [ - 'backgroundColor' => $this->getInput('themeBodyBackgroundColor'), - 'image' => $this->getInput('themeBodyImage'), - 'imageAttachment' => $this->getInput('themeBodyImageAttachment'), - 'imagePosition' => $this->getInput('themeBodyImagePosition'), - 'imageRepeat' => $this->getInput('themeBodyImageRepeat'), - 'imageSize' => $this->getInput('themeBodyImageSize'), - 'toTopbackgroundColor' => $this->getInput('themeBodyToTopBackground'), - 'toTopColor' => $this->getInput('themeBodyToTopColor') - ]]); + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['body'] ) { // Valeurs en sortie $this->addOutput([ - 'notification' => $text['core_theme']['body'][0], - 'redirect' => helper::baseUrl() . 'theme', - 'state' => true + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // Soumission du formulaire + if($this->isPost()) { + $this->setData([ 'theme', 'update', true]); + $this->setData(['theme', 'body', [ + 'backgroundColor' => $this->getInput('themeBodyBackgroundColor'), + 'image' => $this->getInput('themeBodyImage'), + 'imageAttachment' => $this->getInput('themeBodyImageAttachment'), + 'imagePosition' => $this->getInput('themeBodyImagePosition'), + 'imageRepeat' => $this->getInput('themeBodyImageRepeat'), + 'imageSize' => $this->getInput('themeBodyImageSize'), + 'toTopbackgroundColor' => $this->getInput('themeBodyToTopBackground'), + 'toTopColor' => $this->getInput('themeBodyToTopColor') + ]]); + // Valeurs en sortie + $this->addOutput([ + 'notification' => $text['core_theme']['body'][0], + 'redirect' => helper::baseUrl() . 'theme', + 'state' => true + ]); + } + // Valeurs en sortie + $this->addOutput([ + 'title' => $text['core_theme']['body'][1], + 'vendor' => [ + 'tinycolorpicker' + ], + 'view' => 'body' ]); } - // Valeurs en sortie - $this->addOutput([ - 'title' => $text['core_theme']['body'][1], - 'vendor' => [ - 'tinycolorpicker' - ], - 'view' => 'body' - ]); } /** * Options du pied de page */ public function footer() { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - // Soumission du formulaire - if($this->isPost()) { - $this->setData([ 'theme', 'update', true]); - if ( $this->getInput('themeFooterCopyrightPosition') === 'hide' && - $this->getInput('themeFooterSocialsPosition') === 'hide' && - $this->getInput('themeFooterTextPosition') === 'hide' ) { - // Valeurs en sortie - $this->addOutput([ - 'notification' => $text['core_theme']['footer'][0], - 'redirect' => helper::baseUrl() . 'theme/footer', - 'state' => false - ]); - } else { - $this->setData(['theme', 'footer', [ - 'backgroundColor' => $this->getInput('themeFooterBackgroundColor'), - 'copyrightAlign' => $this->getInput('themeFooterCopyrightAlign'), - 'height' => $this->getInput('themeFooterHeight'), - 'loginLink' => $this->getInput('themeFooterLoginLink'), - 'margin' => $this->getInput('themeFooterMargin', helper::FILTER_BOOLEAN), - 'position' => $this->getInput('themeFooterPosition'), - 'fixed' => $this->getInput('themeFooterFixed', helper::FILTER_BOOLEAN), - 'socialsAlign' => $this->getInput('themeFooterSocialsAlign'), - 'text' => $this->getInput('themeFooterText', null), - 'textAlign' => $this->getInput('themeFooterTextAlign'), - 'textColor' => $this->getInput('themeFooterTextColor'), - 'copyrightPosition' => $this->getInput('themeFooterCopyrightPosition'), - 'textPosition' => $this->getInput('themeFooterTextPosition'), - 'socialsPosition' => $this->getInput('themeFooterSocialsPosition'), - 'textTransform' => $this->getInput('themeFooterTextTransform'), - 'font' => $this->getInput('themeFooterFont'), - 'fontSize' => $this->getInput('themeFooterFontSize'), - 'fontWeight' => $this->getInput('themeFooterFontWeight'), - 'displayVersion' => $this->getInput('themefooterDisplayVersion', helper::FILTER_BOOLEAN), - 'displaySiteMap' => $this->getInput('themefooterDisplaySiteMap', helper::FILTER_BOOLEAN), - 'displayCopyright' => $this->getInput('themefooterDisplayCopyright', helper::FILTER_BOOLEAN), - 'displayCookie' => $this->getInput('themefooterDisplayCookie', helper::FILTER_BOOLEAN), - 'displayLegal' => $this->getInput('themeFooterDisplayLegal', helper::FILTER_BOOLEAN), - 'displaySearch' => $this->getInput('themeFooterDisplaySearch', helper::FILTER_BOOLEAN), - 'displayMemberBar'=> $this->getInput('themeFooterDisplayMemberBar', helper::FILTER_BOOLEAN), - 'template' => $this->getInput('themeFooterTemplate'), - 'displayWhois' => $this->getInput('themeFooterDisplayWhois', helper::FILTER_BOOLEAN) - ]]); + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['footer'] ) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // Soumission du formulaire + if($this->isPost()) { + $this->setData([ 'theme', 'update', true]); + if ( $this->getInput('themeFooterCopyrightPosition') === 'hide' && + $this->getInput('themeFooterSocialsPosition') === 'hide' && + $this->getInput('themeFooterTextPosition') === 'hide' ) { + // Valeurs en sortie + $this->addOutput([ + 'notification' => $text['core_theme']['footer'][0], + 'redirect' => helper::baseUrl() . 'theme/footer', + 'state' => false + ]); + } else { + $this->setData(['theme', 'footer', [ + 'backgroundColor' => $this->getInput('themeFooterBackgroundColor'), + 'copyrightAlign' => $this->getInput('themeFooterCopyrightAlign'), + 'height' => $this->getInput('themeFooterHeight'), + 'loginLink' => $this->getInput('themeFooterLoginLink'), + 'margin' => $this->getInput('themeFooterMargin', helper::FILTER_BOOLEAN), + 'position' => $this->getInput('themeFooterPosition'), + 'fixed' => $this->getInput('themeFooterFixed', helper::FILTER_BOOLEAN), + 'socialsAlign' => $this->getInput('themeFooterSocialsAlign'), + 'text' => $this->getInput('themeFooterText', null), + 'textAlign' => $this->getInput('themeFooterTextAlign'), + 'textColor' => $this->getInput('themeFooterTextColor'), + 'copyrightPosition' => $this->getInput('themeFooterCopyrightPosition'), + 'textPosition' => $this->getInput('themeFooterTextPosition'), + 'socialsPosition' => $this->getInput('themeFooterSocialsPosition'), + 'textTransform' => $this->getInput('themeFooterTextTransform'), + 'font' => $this->getInput('themeFooterFont'), + 'fontSize' => $this->getInput('themeFooterFontSize'), + 'fontWeight' => $this->getInput('themeFooterFontWeight'), + 'displayVersion' => $this->getInput('themefooterDisplayVersion', helper::FILTER_BOOLEAN), + 'displaySiteMap' => $this->getInput('themefooterDisplaySiteMap', helper::FILTER_BOOLEAN), + 'displayCopyright' => $this->getInput('themefooterDisplayCopyright', helper::FILTER_BOOLEAN), + 'displayCookie' => $this->getInput('themefooterDisplayCookie', helper::FILTER_BOOLEAN), + 'displayLegal' => $this->getInput('themeFooterDisplayLegal', helper::FILTER_BOOLEAN), + 'displaySearch' => $this->getInput('themeFooterDisplaySearch', helper::FILTER_BOOLEAN), + 'displayMemberBar'=> $this->getInput('themeFooterDisplayMemberBar', helper::FILTER_BOOLEAN), + 'template' => $this->getInput('themeFooterTemplate'), + 'displayWhois' => $this->getInput('themeFooterDisplayWhois', helper::FILTER_BOOLEAN) + ]]); - // Sauvegarder la configuration localisée - $this->setData(['locale','legalPageId', $this->getInput('configLegalPageId')]); - $this->setData(['locale','searchPageId', $this->getInput('configSearchPageId')]); - - // Valeurs en sortie - $this->addOutput([ - 'notification' => $text['core_theme']['footer'][1], - 'redirect' => helper::baseUrl() . 'theme', - 'state' => true - ]); + // Sauvegarder la configuration localisée + $this->setData(['locale','legalPageId', $this->getInput('configLegalPageId')]); + $this->setData(['locale','searchPageId', $this->getInput('configSearchPageId')]); + + // Valeurs en sortie + $this->addOutput([ + 'notification' => $text['core_theme']['footer'][1], + 'redirect' => helper::baseUrl() . 'theme', + 'state' => true + ]); + } } - } - // Liste des pages - self::$pagesList = $this->getData(['page']); - foreach(self::$pagesList as $page => $pageId) { - if ($this->getData(['page',$page,'block']) === 'bar' || - $this->getData(['page',$page,'disable']) === true) { - unset(self::$pagesList[$page]); + // Liste des pages + self::$pagesList = $this->getData(['page']); + foreach(self::$pagesList as $page => $pageId) { + if ($this->getData(['page',$page,'block']) === 'bar' || + $this->getData(['page',$page,'disable']) === true) { + unset(self::$pagesList[$page]); + } } + self::$fonts = $this->extract('./site/data/fonts.json'); + // Valeurs en sortie + $this->addOutput([ + 'title' => $text['core_theme']['footer'][2], + 'vendor' => [ + 'tinycolorpicker' + ], + 'view' => 'footer' + ]); } - self::$fonts = $this->extract('./site/data/fonts.json'); - // Valeurs en sortie - $this->addOutput([ - 'title' => $text['core_theme']['footer'][2], - 'vendor' => [ - 'tinycolorpicker' - ], - 'view' => 'footer' - ]); } /** * Options de la bannière */ public function header() { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - // Liste des dossiers dans site/file/source triés et non vides - $filter = ['jpg', 'jpeg', 'png', 'gif', 'tiff', 'ico', 'webp']; - self::$listDirs = helper::scanDir(self::FILE_DIR.'source', $filter); - sort(self::$listDirs); - // Soumission du formulaire - if($this->isPost()) { - $this->setData([ 'theme', 'update', true]); - // Modification des URL des images dans la bannière perso - $featureContent = $this->getInput('themeHeaderText', null); - // Bannière animée avec swiper - if( $this->getInput('themeHeaderFeature') === 'swiper' ){ - $swiperContent = $this->swiperContent('header'); - $headerHeight = 'unset'; - } else { - $headerHeight = $this->getInput('themeHeaderHeight'); - } - // $featureContent = str_replace(helper::baseUrl(false,false), './', $featureContent); - // Si une image est positionnée, l'arrière en transparent. - $this->setData(['theme', 'header', [ - 'backgroundColor' => $this->getInput('themeHeaderBackgroundColor'), - 'font' => $this->getInput('themeHeaderFont'), - 'fontSize' => $this->getInput('themeHeaderFontSize'), - 'fontWeight' => $this->getInput('themeHeaderFontWeight'), - 'heightSelect' => $headerHeight, - 'wide' => $this->getInput('themeHeaderWide'), - 'image' => $this->getInput('themeHeaderImage'), - 'imagePosition' => $this->getInput('themeHeaderImagePosition'), - 'imageRepeat' => $this->getInput('themeHeaderImageRepeat'), - 'margin' => $this->getInput('themeHeaderMargin', helper::FILTER_BOOLEAN), - 'position' => $this->getInput('themeHeaderPosition'), - 'textAlign' => $this->getInput('themeHeaderTextAlign'), - 'textColor' => $this->getInput('themeHeaderTextColor'), - 'textHide' => $this->getInput('themeHeaderTextHide', helper::FILTER_BOOLEAN), - 'textTransform' => $this->getInput('themeHeaderTextTransform'), - 'linkHomePage' => $this->getInput('themeHeaderlinkHomePage',helper::FILTER_BOOLEAN), - 'imageContainer' => $this->getInput('themeHeaderImageContainer'), - 'tinyHidden' => $this->getInput('themeHeaderTinyHidden', helper::FILTER_BOOLEAN), - 'feature' => $this->getInput('themeHeaderFeature'), - 'featureContent' => $featureContent, - 'homePageOnly' => $this->getInput('themeHeaderHomePageOnly', helper::FILTER_BOOLEAN), - 'swiperImagesDir' => self::$listDirs[$this->getInput('themeHeaderDirectory')], - 'swiperContent' => $swiperContent, - 'swiperEffects' => $this->getInput('themeHeaderSwiperEffects'), - 'swiperDirection' => $this->getInput('themeHeaderSwiperDirection', helper::FILTER_BOOLEAN), - 'swiperTime' => $this->getInput('themeHeaderSwiperTime'), - 'swiperTransition' => $this->getInput('themeHeaderSwiperTransition') - ]]); - // Modification de la position du menu selon la position de la bannière - if ( $this->getData(['theme','header','position']) == 'site' ) - { - $this->setData(['theme', 'menu', 'position',str_replace ('body-','site-',$this->getData(['theme','menu','position']))]); - } - if ( $this->getData(['theme','header','position']) == 'body') - { - $this->setData(['theme', 'menu', 'position',str_replace ('site-','body-',$this->getData(['theme','menu','position']))]); - } - // Menu accroché à la bannière qui devient cachée - if ( $this->getData(['theme','header','position']) == 'hide' && - in_array( $this->getData(['theme','menu','position']) , ['body-first', 'site-first', 'body-first' , 'site-second']) - ) { - $this->setData(['theme', 'menu', 'position','site']); - } - // Suppression de l'image en contenu personnalisé - if( $this->getData(['theme','header','feature']) == 'feature'){ - $this->setData(['theme','header', 'image',""]); - } - // Application de la hauteur de l'image sélectionnée si hauteur de l'image sur hauteur du contenu - if( $this->getData(['theme', 'header', 'feature']) ==='wallpaper' && - $this->getData(['theme', 'header', 'image']) !== '' && - $this->getData(['theme', 'header', 'heightSelect']) === 'unset' ){ - $infoImage = getimagesize( self::FILE_DIR.'source/'. $this->getData(['theme', 'header', 'image']) ); - $this->setData(['theme', 'header', 'height', $infoImage[1]."px"]); - } else { - // Si pas d'image ou bannière personnalisée - $this->setData(['theme', 'header', 'height', $this->getData(['theme', 'header', 'heightSelect']) ]); - } + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['header'] ) { // Valeurs en sortie - if (isset($_POST['themeHeaderSubmit'])){ - $this->addOutput([ - 'notification' => $text['core_theme']['header'][0], - 'redirect' => helper::baseUrl() . 'theme', - 'state' => true - ]); - } else { //Preview - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'theme/header' - ]); + $this->addOutput([ + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // Liste des dossiers dans site/file/source triés et non vides + $filter = ['jpg', 'jpeg', 'png', 'gif', 'tiff', 'ico', 'webp']; + self::$listDirs = helper::scanDir(self::FILE_DIR.'source', $filter); + sort(self::$listDirs); + // Soumission du formulaire + if($this->isPost()) { + $this->setData([ 'theme', 'update', true]); + // Modification des URL des images dans la bannière perso + $featureContent = $this->getInput('themeHeaderText', null); + // Bannière animée avec swiper + if( $this->getInput('themeHeaderFeature') === 'swiper' ){ + $swiperContent = $this->swiperContent('header'); + $headerHeight = 'unset'; + } else { + $headerHeight = $this->getInput('themeHeaderHeight'); + } + // $featureContent = str_replace(helper::baseUrl(false,false), './', $featureContent); + // Si une image est positionnée, l'arrière en transparent. + $this->setData(['theme', 'header', [ + 'backgroundColor' => $this->getInput('themeHeaderBackgroundColor'), + 'font' => $this->getInput('themeHeaderFont'), + 'fontSize' => $this->getInput('themeHeaderFontSize'), + 'fontWeight' => $this->getInput('themeHeaderFontWeight'), + 'heightSelect' => $headerHeight, + 'wide' => $this->getInput('themeHeaderWide'), + 'image' => $this->getInput('themeHeaderImage'), + 'imagePosition' => $this->getInput('themeHeaderImagePosition'), + 'imageRepeat' => $this->getInput('themeHeaderImageRepeat'), + 'margin' => $this->getInput('themeHeaderMargin', helper::FILTER_BOOLEAN), + 'position' => $this->getInput('themeHeaderPosition'), + 'textAlign' => $this->getInput('themeHeaderTextAlign'), + 'textColor' => $this->getInput('themeHeaderTextColor'), + 'textHide' => $this->getInput('themeHeaderTextHide', helper::FILTER_BOOLEAN), + 'textTransform' => $this->getInput('themeHeaderTextTransform'), + 'linkHomePage' => $this->getInput('themeHeaderlinkHomePage',helper::FILTER_BOOLEAN), + 'imageContainer' => $this->getInput('themeHeaderImageContainer'), + 'tinyHidden' => $this->getInput('themeHeaderTinyHidden', helper::FILTER_BOOLEAN), + 'feature' => $this->getInput('themeHeaderFeature'), + 'featureContent' => $featureContent, + 'homePageOnly' => $this->getInput('themeHeaderHomePageOnly', helper::FILTER_BOOLEAN), + 'swiperImagesDir' => self::$listDirs[$this->getInput('themeHeaderDirectory')], + 'swiperContent' => $swiperContent, + 'swiperEffects' => $this->getInput('themeHeaderSwiperEffects'), + 'swiperDirection' => $this->getInput('themeHeaderSwiperDirection', helper::FILTER_BOOLEAN), + 'swiperTime' => $this->getInput('themeHeaderSwiperTime'), + 'swiperTransition' => $this->getInput('themeHeaderSwiperTransition') + ]]); + // Modification de la position du menu selon la position de la bannière + if ( $this->getData(['theme','header','position']) == 'site' ) + { + $this->setData(['theme', 'menu', 'position',str_replace ('body-','site-',$this->getData(['theme','menu','position']))]); + } + if ( $this->getData(['theme','header','position']) == 'body') + { + $this->setData(['theme', 'menu', 'position',str_replace ('site-','body-',$this->getData(['theme','menu','position']))]); + } + // Menu accroché à la bannière qui devient cachée + if ( $this->getData(['theme','header','position']) == 'hide' && + in_array( $this->getData(['theme','menu','position']) , ['body-first', 'site-first', 'body-first' , 'site-second']) + ) { + $this->setData(['theme', 'menu', 'position','site']); + } + // Suppression de l'image en contenu personnalisé + if( $this->getData(['theme','header','feature']) == 'feature'){ + $this->setData(['theme','header', 'image',""]); + } + // Application de la hauteur de l'image sélectionnée si hauteur de l'image sur hauteur du contenu + if( $this->getData(['theme', 'header', 'feature']) ==='wallpaper' && + $this->getData(['theme', 'header', 'image']) !== '' && + $this->getData(['theme', 'header', 'heightSelect']) === 'unset' ){ + $infoImage = getimagesize( self::FILE_DIR.'source/'. $this->getData(['theme', 'header', 'image']) ); + $this->setData(['theme', 'header', 'height', $infoImage[1]."px"]); + } else { + // Si pas d'image ou bannière personnalisée + $this->setData(['theme', 'header', 'height', $this->getData(['theme', 'header', 'heightSelect']) ]); + } + // Valeurs en sortie + if (isset($_POST['themeHeaderSubmit'])){ + $this->addOutput([ + 'notification' => $text['core_theme']['header'][0], + 'redirect' => helper::baseUrl() . 'theme', + 'state' => true + ]); + } else { //Preview + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'theme/header' + ]); + } } + self::$fonts = $this->extract('./site/data/fonts.json'); + // Valeurs en sortie + $this->addOutput([ + 'title' => $text['core_theme']['header'][1], + 'vendor' => [ + 'tinycolorpicker', + 'tinymce' + ], + 'view' => 'header' + ]); } - self::$fonts = $this->extract('./site/data/fonts.json'); - // Valeurs en sortie - $this->addOutput([ - 'title' => $text['core_theme']['header'][1], - 'vendor' => [ - 'tinycolorpicker', - 'tinymce' - ], - 'view' => 'header' - ]); } /** * Accueil de la personnalisation */ public function index() { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - // Valeurs en sortie - $this->addOutput([ - 'title' => $text['core_theme']['index'][0], - 'view' => 'index' - ]); + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['index'] ) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // Valeurs en sortie + $this->addOutput([ + 'title' => $text['core_theme']['index'][0], + 'view' => 'index' + ]); + } } /** * Options du menu */ public function menu() { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - // Soumission du formulaire - if($this->isPost()) { - $this->setData([ 'theme', 'update', true]); - $this->setData(['theme', 'menu', [ - 'backgroundColor' => $this->getInput('themeMenuBackgroundColor'), - 'backgroundColorSub' => $this->getInput('themeMenuBackgroundColorSub'), - 'font' => $this->getInput('themeMenuFont'), - 'fontSize' => $this->getInput('themeMenuFontSize'), - 'fontWeight' => $this->getInput('themeMenuFontWeight'), - 'height' => $this->getInput('themeMenuHeight'), - 'wide' => $this->getInput('themeMenuWide'), - 'loginLink' => $this->getInput('themeMenuLoginLink', helper::FILTER_BOOLEAN), - 'margin' => $this->getInput('themeMenuMargin', helper::FILTER_BOOLEAN), - 'position' => $this->getInput('themeMenuPosition'), - 'textAlign' => $this->getInput('themeMenuTextAlign'), - 'textColor' => $this->getInput('themeMenuTextColor'), - 'textTransform' => $this->getInput('themeMenuTextTransform'), - 'fixed' => $this->getInput('themeMenuFixed', helper::FILTER_BOOLEAN), - 'activeColorAuto' => $this->getInput('themeMenuActiveColorAuto', helper::FILTER_BOOLEAN), - 'activeColor' => $this->getInput('themeMenuActiveColor'), - 'activeTextColor' => $this->getInput('themeMenuActiveTextColor'), - 'radius' => $this->getInput('themeMenuRadius'), - 'burgerTitle' => $this->getInput('themeMenuBurgerTitle', helper::FILTER_BOOLEAN), - 'memberBar' => $this->getInput('themeMenuMemberBar', helper::FILTER_BOOLEAN), - 'burgerIcon1' => $this->getInput('themeMenuBurgerIcon1'), - 'burgerIcon2' => $this->getInput('themeMenuBurgerIcon2'), - 'burgerContent' => $this->getInput('themeMenuBurgerContent'), - 'burgerTextColor' => $this->getInput('themeMenuBurgerTextColor'), - 'burgerFontSize' => $this->getInput('themeMenuBurgerFontSize'), - 'minWidthTab' => $this->getInput('themeMenuMinWidthTab'), - 'minWidthParentOrAll' => $this->getInput('themeMenuMinWidthParentOrAll', helper::FILTER_BOOLEAN), - 'burgerFixed' => $this->getInput('themeMenuBurgerFixed', helper::FILTER_BOOLEAN), - 'burgerIconColor' => $this->getInput('themeMenuBurgerIconColor'), - 'burgerIconBgColor' => $this->getInput('themeMenuBurgerIconBgColor'), - 'burgerBannerColor' => $this->getInput('themeMenuBurgerBannerColor'), - 'burgerTextMenuColor' => $this->getInput('themeMenuBurgerTextMenuColor'), - 'burgerActiveTextColor' => $this->getInput('themeMenuBurgerActiveTextColor'), - 'burgerBackgroundColor' => $this->getInput('themeMenuBurgerBackgroundColor'), - 'burgerActiveColorAuto' => $this->getInput('themeMenuBurgerActiveColorAuto', helper::FILTER_BOOLEAN), - 'burgerActiveColor' => $this->getInput('themeMenuBurgerActiveColor'), - 'burgerBackgroundColorSub' => $this->getInput('themeMenuBurgerBackgroundColorSub'), - 'burgerIconLink1' => $this->getInput('themeMenuBurgerIconLink1'), - 'burgerIconLink2' => $this->getInput('themeMenuBurgerIconLink2'), - 'burgerOverlay' => $this->getInput('themeMenuBurgerOverlay', helper::FILTER_BOOLEAN) - ]]); - + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['menu'] ) { // Valeurs en sortie - if (isset($_POST['themeMenuSubmit'])){ - $this->addOutput([ - 'notification' => $text['core_theme']['menu'][0], - 'redirect' => helper::baseUrl() . 'theme', - 'state' => true - ]); - } else { // Preview - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'theme/menu' - ]); + $this->addOutput([ + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // Soumission du formulaire + if($this->isPost()) { + $this->setData([ 'theme', 'update', true]); + $this->setData(['theme', 'menu', [ + 'backgroundColor' => $this->getInput('themeMenuBackgroundColor'), + 'backgroundColorSub' => $this->getInput('themeMenuBackgroundColorSub'), + 'font' => $this->getInput('themeMenuFont'), + 'fontSize' => $this->getInput('themeMenuFontSize'), + 'fontWeight' => $this->getInput('themeMenuFontWeight'), + 'height' => $this->getInput('themeMenuHeight'), + 'wide' => $this->getInput('themeMenuWide'), + 'loginLink' => $this->getInput('themeMenuLoginLink', helper::FILTER_BOOLEAN), + 'margin' => $this->getInput('themeMenuMargin', helper::FILTER_BOOLEAN), + 'position' => $this->getInput('themeMenuPosition'), + 'textAlign' => $this->getInput('themeMenuTextAlign'), + 'textColor' => $this->getInput('themeMenuTextColor'), + 'textTransform' => $this->getInput('themeMenuTextTransform'), + 'fixed' => $this->getInput('themeMenuFixed', helper::FILTER_BOOLEAN), + 'activeColorAuto' => $this->getInput('themeMenuActiveColorAuto', helper::FILTER_BOOLEAN), + 'activeColor' => $this->getInput('themeMenuActiveColor'), + 'activeTextColor' => $this->getInput('themeMenuActiveTextColor'), + 'radius' => $this->getInput('themeMenuRadius'), + 'burgerTitle' => $this->getInput('themeMenuBurgerTitle', helper::FILTER_BOOLEAN), + 'memberBar' => $this->getInput('themeMenuMemberBar', helper::FILTER_BOOLEAN), + 'burgerIcon1' => $this->getInput('themeMenuBurgerIcon1'), + 'burgerIcon2' => $this->getInput('themeMenuBurgerIcon2'), + 'burgerContent' => $this->getInput('themeMenuBurgerContent'), + 'burgerTextColor' => $this->getInput('themeMenuBurgerTextColor'), + 'burgerFontSize' => $this->getInput('themeMenuBurgerFontSize'), + 'minWidthTab' => $this->getInput('themeMenuMinWidthTab'), + 'minWidthParentOrAll' => $this->getInput('themeMenuMinWidthParentOrAll', helper::FILTER_BOOLEAN), + 'burgerFixed' => $this->getInput('themeMenuBurgerFixed', helper::FILTER_BOOLEAN), + 'burgerIconColor' => $this->getInput('themeMenuBurgerIconColor'), + 'burgerIconBgColor' => $this->getInput('themeMenuBurgerIconBgColor'), + 'burgerBannerColor' => $this->getInput('themeMenuBurgerBannerColor'), + 'burgerTextMenuColor' => $this->getInput('themeMenuBurgerTextMenuColor'), + 'burgerActiveTextColor' => $this->getInput('themeMenuBurgerActiveTextColor'), + 'burgerBackgroundColor' => $this->getInput('themeMenuBurgerBackgroundColor'), + 'burgerActiveColorAuto' => $this->getInput('themeMenuBurgerActiveColorAuto', helper::FILTER_BOOLEAN), + 'burgerActiveColor' => $this->getInput('themeMenuBurgerActiveColor'), + 'burgerBackgroundColorSub' => $this->getInput('themeMenuBurgerBackgroundColorSub'), + 'burgerIconLink1' => $this->getInput('themeMenuBurgerIconLink1'), + 'burgerIconLink2' => $this->getInput('themeMenuBurgerIconLink2'), + 'burgerOverlay' => $this->getInput('themeMenuBurgerOverlay', helper::FILTER_BOOLEAN) + ]]); + + // Valeurs en sortie + if (isset($_POST['themeMenuSubmit'])){ + $this->addOutput([ + 'notification' => $text['core_theme']['menu'][0], + 'redirect' => helper::baseUrl() . 'theme', + 'state' => true + ]); + } else { // Preview + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'theme/menu' + ]); + } } + // Liste des pages pour les liens sur icônes + foreach ($this->getHierarchy(null,null,null) as $parentKey=>$parentValue) { + // Exclusions les barres, les pages masquées ou non publiques + if ($this->getData(['page',$parentKey,'group']) !== 0 || + $this->getData(['page', $parentKey, 'block']) === 'bar' ) { + continue; + } + self::$pageList [$parentKey] = $parentKey; + foreach ($parentValue as $childKey) { + self::$pageList [$childKey] = $childKey; + } + } + + + self::$fonts = $this->extract('./site/data/fonts.json'); + // Valeurs en sortie + $this->addOutput([ + 'title' => $text['core_theme']['menu'][1], + 'vendor' => [ + 'tinycolorpicker' + ], + 'view' => 'menu' + ]); } - // Liste des pages pour les liens sur icônes - foreach ($this->getHierarchy(null,null,null) as $parentKey=>$parentValue) { - // Exclusions les barres, les pages masquées ou non publiques - if ($this->getData(['page',$parentKey,'group']) !== 0 || - $this->getData(['page', $parentKey, 'block']) === 'bar' ) { - continue; - } - self::$pageList [$parentKey] = $parentKey; - foreach ($parentValue as $childKey) { - self::$pageList [$childKey] = $childKey; - } - } - - - self::$fonts = $this->extract('./site/data/fonts.json'); - // Valeurs en sortie - $this->addOutput([ - 'title' => $text['core_theme']['menu'][1], - 'vendor' => [ - 'tinycolorpicker' - ], - 'view' => 'menu' - ]); } /** * Réinitialisation de la personnalisation avancée */ public function reset() { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - // $url prend l'adresse sans le token - $url = explode('&',$this->getUrl(2)); - - if ( isset($_GET['csrf']) - AND $_GET['csrf'] === $_SESSION['csrf'] - ) { - // Réinitialisation - $redirect =''; - switch ($url[0]) { - case 'admin': - $this->initData('admin'); - $redirect = helper::baseUrl() . 'theme/admin'; - break; - case 'manage': - $this->initData('theme'); - $redirect = helper::baseUrl() . 'theme/manage'; - break; - case 'custom': - unlink(self::DATA_DIR.'custom.css'); - $redirect = helper::baseUrl() . 'theme/advanced'; - break; - default : - $redirect = helper::baseUrl() . 'theme'; - } - + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['reset'] ) { // Valeurs en sortie $this->addOutput([ - 'notification' => $text['core_theme']['reset'][0], - 'redirect' => $redirect, - 'state' => true - ]); + 'access' => false + ]); } else { - // Valeurs en sortie - $this->addOutput([ - 'notification' => $text['core_theme']['reset'][1] - ]); + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // $url prend l'adresse sans le token + $url = explode('&',$this->getUrl(2)); + + if ( isset($_GET['csrf']) + AND $_GET['csrf'] === $_SESSION['csrf'] + ) { + // Réinitialisation + $redirect =''; + switch ($url[0]) { + case 'admin': + $this->initData('admin'); + $redirect = helper::baseUrl() . 'theme/admin'; + break; + case 'manage': + $this->initData('theme'); + $redirect = helper::baseUrl() . 'theme/manage'; + break; + case 'custom': + unlink(self::DATA_DIR.'custom.css'); + $redirect = helper::baseUrl() . 'theme/advanced'; + break; + default : + $redirect = helper::baseUrl() . 'theme'; + } + + // Valeurs en sortie + $this->addOutput([ + 'notification' => $text['core_theme']['reset'][0], + 'redirect' => $redirect, + 'state' => true + ]); + } else { + // Valeurs en sortie + $this->addOutput([ + 'notification' => $text['core_theme']['reset'][1] + ]); + } } } @@ -686,103 +806,123 @@ class theme extends common { * Options du site */ public function site() { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - // Soumission du formulaire - if($this->isPost()) { - $this->setData([ 'theme', 'update', true]); - $this->setData(['theme', 'title', [ - 'font' => $this->getInput('themeTitleFont'), - 'textColor' => $this->getInput('themeTitleTextColor'), - 'fontWeight' => $this->getInput('themeTitleFontWeight'), - 'textTransform' => $this->getInput('themeTitleTextTransform') - ]]); - $this->setData(['theme', 'text', [ - 'font' => $this->getInput('themeTextFont'), - 'fontSize' => $this->getInput('themeTextFontSize'), - 'textColor' => $this->getInput('themeTextTextColor'), - 'linkColor'=> $this->getInput('themeTextLinkColor') - ]]); - $this->setData(['theme', 'site', [ - 'backgroundColor' => $this->getInput('themeSiteBackgroundColor'), - 'radius' => $this->getInput('themeSiteRadius'), - 'shadow' => $this->getInput('themeSiteShadow'), - 'width' => $this->getInput('themeSiteWidth'), - 'margin' => $this->getInput('themeSiteMargin',helper::FILTER_BOOLEAN) - ]]); - $this->setData(['theme', 'button', [ - 'backgroundColor' => $this->getInput('themeButtonBackgroundColor') - ]]); - $this->setData(['theme', 'block', [ - 'backgroundColor' => $this->getInput('themeBlockBackgroundColor'), - 'borderColor' => $this->getInput('themeBlockBorderColor'), - 'backgroundTitleColor' => $this->getInput('themeBlockBackgroundTitleColor'), - 'blockBorderRadius' => $this->getInput('themeBlockBorderRadius'), - 'blockBorderShadow' => $this->getInput('themeBlockBorderShadow') - ]]); - // Si barrière animée nouveau swiperContent - if($this->getData(['theme', 'header', 'feature']) === 'swiper' ) $this->swiperContent('site'); + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['site'] ) { // Valeurs en sortie $this->addOutput([ - 'notification' => $text['core_theme']['site'][0], - 'redirect' => helper::baseUrl() . 'theme', - 'state' => true + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // Soumission du formulaire + if($this->isPost()) { + $this->setData([ 'theme', 'update', true]); + $this->setData(['theme', 'title', [ + 'font' => $this->getInput('themeTitleFont'), + 'textColor' => $this->getInput('themeTitleTextColor'), + 'fontWeight' => $this->getInput('themeTitleFontWeight'), + 'textTransform' => $this->getInput('themeTitleTextTransform') + ]]); + $this->setData(['theme', 'text', [ + 'font' => $this->getInput('themeTextFont'), + 'fontSize' => $this->getInput('themeTextFontSize'), + 'textColor' => $this->getInput('themeTextTextColor'), + 'linkColor'=> $this->getInput('themeTextLinkColor') + ]]); + $this->setData(['theme', 'site', [ + 'backgroundColor' => $this->getInput('themeSiteBackgroundColor'), + 'radius' => $this->getInput('themeSiteRadius'), + 'shadow' => $this->getInput('themeSiteShadow'), + 'width' => $this->getInput('themeSiteWidth'), + 'margin' => $this->getInput('themeSiteMargin',helper::FILTER_BOOLEAN) + ]]); + $this->setData(['theme', 'button', [ + 'backgroundColor' => $this->getInput('themeButtonBackgroundColor') + ]]); + $this->setData(['theme', 'block', [ + 'backgroundColor' => $this->getInput('themeBlockBackgroundColor'), + 'borderColor' => $this->getInput('themeBlockBorderColor'), + 'backgroundTitleColor' => $this->getInput('themeBlockBackgroundTitleColor'), + 'blockBorderRadius' => $this->getInput('themeBlockBorderRadius'), + 'blockBorderShadow' => $this->getInput('themeBlockBorderShadow') + ]]); + // Si barrière animée nouveau swiperContent + if($this->getData(['theme', 'header', 'feature']) === 'swiper' ) $this->swiperContent('site'); + // Valeurs en sortie + $this->addOutput([ + 'notification' => $text['core_theme']['site'][0], + 'redirect' => helper::baseUrl() . 'theme', + 'state' => true + ]); + } + self::$fonts = $this->extract('./site/data/fonts.json'); + // Valeurs en sortie + $this->addOutput([ + 'title' => $text['core_theme']['site'][1], + 'vendor' => [ + 'tinycolorpicker' + ], + 'view' => 'site' ]); } - self::$fonts = $this->extract('./site/data/fonts.json'); - // Valeurs en sortie - $this->addOutput([ - 'title' => $text['core_theme']['site'][1], - 'vendor' => [ - 'tinycolorpicker' - ], - 'view' => 'site' - ]); } /** * Import du thème */ public function manage() { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['manage'] ) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - if($this->isPost() ) { - if( isset( $_POST['themeSaveTheme'])){ - $this->save('theme',$this->getInput('themeSaveName')); - } elseif( isset( $_POST['themeSaveAdmin'])){ - $this->save('admin',$this->getInput('themeSaveName')); - } elseif( isset( $_POST['themeExportTheme'])){ - $this->export('theme',$this->getInput('themeExportName')); - } elseif( isset( $_POST['themeExportAdmin'])){ - $this->export('admin',$this->getInput('themeExportName')); - }else { - $zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true); - $data = $this->import(self::FILE_DIR.'source/' . $zipFilename); - if ($data['success']) { - // Refresh: 0 bien contenu dans la réponse envoyée au navigateur mais sans l'effet attendu - header("Refresh: 0"); - $this->addOutput([ - 'notification' => $data['notification'], - 'redirect' => helper::baseUrl() . 'theme', - 'state' => $data['success'] - ]); - } else { - // Valeurs en sortie - $this->addOutput([ - 'notification' => $data['notification'], - 'state' => $data['success'], - 'title' => $text['core_theme']['manage'][0], - 'view' => 'manage' - ]);; + if($this->isPost() ) { + if( isset( $_POST['themeSaveTheme'])){ + $this->save('theme',$this->getInput('themeSaveName')); + } elseif( isset( $_POST['themeSaveAdmin'])){ + $this->save('admin',$this->getInput('themeSaveName')); + } elseif( isset( $_POST['themeExportTheme'])){ + $this->export('theme',$this->getInput('themeExportName')); + } elseif( isset( $_POST['themeExportAdmin'])){ + $this->export('admin',$this->getInput('themeExportName')); + }else { + $zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true); + $data = $this->import(self::FILE_DIR.'source/' . $zipFilename); + if ($data['success']) { + // Refresh: 0 bien contenu dans la réponse envoyée au navigateur mais sans l'effet attendu + header("Refresh: 0"); + $this->addOutput([ + 'notification' => $data['notification'], + 'redirect' => helper::baseUrl() . 'theme', + 'state' => $data['success'] + ]); + } else { + // Valeurs en sortie + $this->addOutput([ + 'notification' => $data['notification'], + 'state' => $data['success'], + 'title' => $text['core_theme']['manage'][0], + 'view' => 'manage' + ]);; + } } } + // Valeurs en sortie + $this->addOutput([ + 'title' => $text['core_theme']['manage'][0], + 'view' => 'manage' + ]); } - // Valeurs en sortie - $this->addOutput([ - 'title' => $text['core_theme']['manage'][0], - 'view' => 'manage' - ]); } /** @@ -792,70 +932,80 @@ class theme extends common { */ public function import($zipName = '') { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['import'] ) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - if ($zipName !== '' && - file_exists($zipName)) { - // Init variables de retour - $success = false; - $notification = ''; - // Dossier temporaire - $tempFolder = uniqid(); - // Ouvrir le zip - $zip = new ZipArchive(); - if ($zip->open($zipName) === TRUE) { - mkdir (self::TEMP_DIR . $tempFolder, 0755); - $zip->extractTo(self::TEMP_DIR . $tempFolder ); - $modele = ''; - // Archive de thème ? - if ( - file_exists(self::TEMP_DIR . $tempFolder . '/site/data/custom.css') - AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.css') - AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.json') - ) { - $modele = 'theme'; - $this->sauve( $modele ); - } - if( - file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.json') - AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.css') - ) { - $modele = 'admin'; - $this->sauve( $modele ); - } - if (!empty($modele) - ) { - // traiter l'archive - $importFolder = './site/file/import'; - mkdir ($importFolder, 0755); - $success = $zip->extractTo($importFolder); - // $path = $importFolder.'/site/file/source/'; - // Modifie le nom de tous les fichiers de $path et leur nom dans theme.json - // $this->changeName($path); - $this->copyDir( $importFolder, './'); - $this->removeDir($importFolder); - // traitement de l'erreur - $notification = $success ? $text['core_theme']['import'][0] : $text['core_theme']['import'][1]; - - - } else { - // pas une archive de thème - $success = false; - $notification = $text['core_theme']['import'][2]; - } - // Supprimer le dossier temporaire même si le thème est invalide - $this->removeDir(self::TEMP_DIR . $tempFolder); - $zip->close(); - } else { - // erreur à l'ouverture + if ($zipName !== '' && + file_exists($zipName)) { + // Init variables de retour $success = false; - $notification = $text['core_theme']['import'][3]; - } - return (['success' => $success, 'notification' => $notification]); - } + $notification = ''; + // Dossier temporaire + $tempFolder = uniqid(); + // Ouvrir le zip + $zip = new ZipArchive(); + if ($zip->open($zipName) === TRUE) { + mkdir (self::TEMP_DIR . $tempFolder, 0755); + $zip->extractTo(self::TEMP_DIR . $tempFolder ); + $modele = ''; + // Archive de thème ? + if ( + file_exists(self::TEMP_DIR . $tempFolder . '/site/data/custom.css') + AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.css') + AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.json') + ) { + $modele = 'theme'; + $this->sauve( $modele ); + } + if( + file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.json') + AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.css') + ) { + $modele = 'admin'; + $this->sauve( $modele ); + } + if (!empty($modele) + ) { + // traiter l'archive + $importFolder = './site/file/import'; + mkdir ($importFolder, 0755); + $success = $zip->extractTo($importFolder); + // $path = $importFolder.'/site/file/source/'; + // Modifie le nom de tous les fichiers de $path et leur nom dans theme.json + // $this->changeName($path); + $this->copyDir( $importFolder, './'); + $this->removeDir($importFolder); + // traitement de l'erreur + $notification = $success ? $text['core_theme']['import'][0] : $text['core_theme']['import'][1]; - return (['success' => false, 'notification' => $text['core_theme']['import'][4]]); + + } else { + // pas une archive de thème + $success = false; + $notification = $text['core_theme']['import'][2]; + } + // Supprimer le dossier temporaire même si le thème est invalide + $this->removeDir(self::TEMP_DIR . $tempFolder); + $zip->close(); + } else { + // erreur à l'ouverture + $success = false; + $notification = $text['core_theme']['import'][3]; + } + return (['success' => $success, 'notification' => $notification]); + } + + return (['success' => false, 'notification' => $text['core_theme']['import'][4]]); + } } @@ -864,7 +1014,16 @@ class theme extends common { * Export du thème */ public function export($modele, $name) { - // Make zip + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['export'] ) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } else { + // Make zip $zipFilename = $this->zipTheme($modele, $name); // Téléchargement du ZIP header('Content-Description: File Transfer'); @@ -876,29 +1035,40 @@ class theme extends common { // Nettoyage du dossier unlink (self::TEMP_DIR . $zipFilename); exit(); + } } /** * Export du thème */ public function save($modele, $name) { - // Lexique - include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); - // Make zip - $zipFilename = $this->zipTheme($modele, $name); - // Téléchargement du ZIP - if (!is_dir(self::FILE_DIR.'source/theme')) { - mkdir(self::FILE_DIR.'source/theme', 0755); + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < theme::$actions['save'] ) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } else { + // Lexique + include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php'); + // Make zip + $zipFilename = $this->zipTheme($modele, $name); + // Téléchargement du ZIP + if (!is_dir(self::FILE_DIR.'source/theme')) { + mkdir(self::FILE_DIR.'source/theme', 0755); + } + copy (self::TEMP_DIR . $zipFilename , self::FILE_DIR.'source/theme/' . $zipFilename); + // Nettoyage du dossier + unlink (self::TEMP_DIR . $zipFilename); + // Valeurs en sortie + $this->addOutput([ + 'notification' => $text['core_theme']['save'][0].''.$zipFilename.''. $text['core_theme']['save'][1], + 'redirect' => helper::baseUrl() . 'theme/manage', + 'state' => true + ]); } - copy (self::TEMP_DIR . $zipFilename , self::FILE_DIR.'source/theme/' . $zipFilename); - // Nettoyage du dossier - unlink (self::TEMP_DIR . $zipFilename); - // Valeurs en sortie - $this->addOutput([ - 'notification' => $text['core_theme']['save'][0].''.$zipFilename.''. $text['core_theme']['save'][1], - 'redirect' => helper::baseUrl() . 'theme/manage', - 'state' => true - ]); } /** diff --git a/core/module/translate/translate.php b/core/module/translate/translate.php index 4dbde5d..f39e555 100644 --- a/core/module/translate/translate.php +++ b/core/module/translate/translate.php @@ -37,155 +37,175 @@ class translate extends common { * Configuration avancée des langues */ public function copy() { - // Lexique - include('./core/module/translate/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_translate.php'); - - // Soumission du formulaire - if ($this->isPost()) { - // Initialisation - $success = false; - $copyFrom = $this->getInput('translateFormCopySource'); - $toCreate = $this->getInput('translateFormCopyTarget'); - if ($copyFrom !== $toCreate) { - // Création du dossier - if (is_dir(self::DATA_DIR . $toCreate) === false ) { // Si le dossier est déjà créé - $success = mkdir (self::DATA_DIR . $toCreate, 0755); - $success = mkdir (self::DATA_DIR . $toCreate.'/content', 0755); - } else { - $success = true; - } - // Copier les données par défaut avec gestion des erreurs - $success = (copy (self::DATA_DIR . $copyFrom . '/locale.json', self::DATA_DIR . $toCreate . '/locale.json') === true && $success === true) ? true : false; - $success = (copy (self::DATA_DIR . $copyFrom . '/module.json', self::DATA_DIR . $toCreate . '/module.json') === true && $success === true) ? true : false; - $success = (copy (self::DATA_DIR . $copyFrom . '/page.json', self::DATA_DIR . $toCreate . '/page.json') === true && $success === true) ? true : false; - $success = ($this->copyDir (self::DATA_DIR . $copyFrom . '/content', self::DATA_DIR . $toCreate . '/content') === true && $success === true) ? true : false; - // Enregistrer la langue - if ($success) { - $this->setData(['config', 'i18n', $toCreate, 'site' ]); - $i18nListBase = array_merge(['base' => $text['core_translate']['copy'][5] ],self::$i18nList); - $notification = $text['core_translate']['copy'][3] . $i18nListBase[$copyFrom] . $text['core_translate']['copy'][4] . self::$i18nList[$toCreate]; - } else { - $notification = $text['core_translate']['copy'][0]; - } - } else { - $success = false; - $notification = $text['core_translate']['copy'][1]; - } + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < translate::$actions['copy'] ) { // Valeurs en sortie $this->addOutput([ - 'notification' => $notification, - 'title' => $text['core_translate']['copy'][2], - 'view' => 'index', - 'state' => $success + 'access' => false + ]); + } else { + // Lexique + include('./core/module/translate/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_translate.php'); + + // Soumission du formulaire + if ($this->isPost()) { + // Initialisation + $success = false; + $copyFrom = $this->getInput('translateFormCopySource'); + $toCreate = $this->getInput('translateFormCopyTarget'); + if ($copyFrom !== $toCreate) { + // Création du dossier + if (is_dir(self::DATA_DIR . $toCreate) === false ) { // Si le dossier est déjà créé + $success = mkdir (self::DATA_DIR . $toCreate, 0755); + $success = mkdir (self::DATA_DIR . $toCreate.'/content', 0755); + } else { + $success = true; + } + // Copier les données par défaut avec gestion des erreurs + $success = (copy (self::DATA_DIR . $copyFrom . '/locale.json', self::DATA_DIR . $toCreate . '/locale.json') === true && $success === true) ? true : false; + $success = (copy (self::DATA_DIR . $copyFrom . '/module.json', self::DATA_DIR . $toCreate . '/module.json') === true && $success === true) ? true : false; + $success = (copy (self::DATA_DIR . $copyFrom . '/page.json', self::DATA_DIR . $toCreate . '/page.json') === true && $success === true) ? true : false; + $success = ($this->copyDir (self::DATA_DIR . $copyFrom . '/content', self::DATA_DIR . $toCreate . '/content') === true && $success === true) ? true : false; + // Enregistrer la langue + if ($success) { + $this->setData(['config', 'i18n', $toCreate, 'site' ]); + $i18nListBase = array_merge(['base' => $text['core_translate']['copy'][5] ],self::$i18nList); + $notification = $text['core_translate']['copy'][3] . $i18nListBase[$copyFrom] . $text['core_translate']['copy'][4] . self::$i18nList[$toCreate]; + } else { + $notification = $text['core_translate']['copy'][0]; + } + } else { + $success = false; + $notification = $text['core_translate']['copy'][1]; + } + // Valeurs en sortie + $this->addOutput([ + 'notification' => $notification, + 'title' => $text['core_translate']['copy'][2], + 'view' => 'index', + 'state' => $success + ]); + } + // Tableau des langues installées + foreach ($i18nList as $key => $value) { + if ($this->getData(['config','i18n', $key]) === 'site') { + self::$languagesTarget[$key] = $value; + } + } + + // Langues cibles base en plus + self::$languagesInstalled = array_merge(['base' => $text['core_translate']['copy'][5] ],self::$languagesTarget); + + // Valeurs en sortie + $this->addOutput([ + 'title' => $text['core_translate']['copy'][2], + 'view' => 'copy' ]); } - // Tableau des langues installées - foreach ($i18nList as $key => $value) { - if ($this->getData(['config','i18n', $key]) === 'site') { - self::$languagesTarget[$key] = $value; - } - } - - // Langues cibles base en plus - self::$languagesInstalled = array_merge(['base' => $text['core_translate']['copy'][5] ],self::$languagesTarget); - - // Valeurs en sortie - $this->addOutput([ - 'title' => $text['core_translate']['copy'][2], - 'view' => 'copy' - ]); } /** * Configuration */ public function index() { - // Lexique - include('./core/module/translate/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_translate.php'); - - // Soumission du formulaire - if($this->isPost()) { - // Edition des langues - foreach (self::$i18nList as $keyi18n => $value) { - if ($keyi18n === 'base') continue; - - // Effacement d'une langue installée - if ( is_dir( self::DATA_DIR . $keyi18n ) === true - AND $this->getInput('translate' . strtoupper($keyi18n)) === 'delete') - { - $this->removeDir( self::DATA_DIR . $keyi18n); - // Au cas ou la langue est sélectionnée - helper::deleteCookie('DELTA_I18N_SITE'); - } - } - // 'langBase' mémorise le code ISO de la langue sélectionnée ou de la valeur saisie si la langue sélectionnée est Autre langue - $requiredOtherLang = false; - $langBase = $this->getInput('translateLangBase'); - if( $langBase === 'none'){ - $langBase = $this->getInput('translateOtherBase'); - $requiredOtherLang = true; - } - - // Enregistrement des données - $this->setData(['config','i18n', [ - 'enable' => $this->getData(['config', 'i18n', 'enable']), - 'langAdmin' => $this->getInput('translateLangAdmin'), - 'langBase' => $langBase, - 'otherLangBase' => $this->getInput('translateOtherBase', helper::FILTER_STRING_SHORT,$requiredOtherLang), - 'fr' => $this->getInput('translateFR'), - 'de' => $this->getInput('translateDE'), - 'en' => $this->getInput('translateEN'), - 'es' => $this->getInput('translateES'), - 'it' => $this->getInput('translateIT'), - 'nl' => $this->getInput('translateNL'), - 'pt' => $this->getInput('translatePT'), - 'el' => $this->getInput('translateEL'), - 'da' => $this->getInput('translateDA'), - 'fi' => $this->getInput('translateFI'), - 'ga' => $this->getInput('translateGA'), - 'sv' => $this->getInput('translateSV'), - 'br' => $this->getInput('translateBR'), - 'ca' => $this->getInput('translateCA'), - 'co' => $this->getInput('translateCO'), - 'eu' => $this->getInput('translateEU') - - ]]); - + // Autorisation + $group = $this->getUser('group'); + if ($group === false ) $group = 0; + if( $group < translate::$actions['index'] ) { // Valeurs en sortie $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl(), - 'notification' => $text['core_translate']['index'][0], - 'state' => true + 'access' => false + ]); + } else { + // Lexique + include('./core/module/translate/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_translate.php'); + + // Soumission du formulaire + if($this->isPost()) { + // Edition des langues + foreach (self::$i18nList as $keyi18n => $value) { + if ($keyi18n === 'base') continue; + + // Effacement d'une langue installée + if ( is_dir( self::DATA_DIR . $keyi18n ) === true + AND $this->getInput('translate' . strtoupper($keyi18n)) === 'delete') + { + $this->removeDir( self::DATA_DIR . $keyi18n); + // Au cas ou la langue est sélectionnée + helper::deleteCookie('DELTA_I18N_SITE'); + } + } + // 'langBase' mémorise le code ISO de la langue sélectionnée ou de la valeur saisie si la langue sélectionnée est Autre langue + $requiredOtherLang = false; + $langBase = $this->getInput('translateLangBase'); + if( $langBase === 'none'){ + $langBase = $this->getInput('translateOtherBase'); + $requiredOtherLang = true; + } + + // Enregistrement des données + $this->setData(['config','i18n', [ + 'enable' => $this->getData(['config', 'i18n', 'enable']), + 'langAdmin' => $this->getInput('translateLangAdmin'), + 'langBase' => $langBase, + 'otherLangBase' => $this->getInput('translateOtherBase', helper::FILTER_STRING_SHORT,$requiredOtherLang), + 'fr' => $this->getInput('translateFR'), + 'de' => $this->getInput('translateDE'), + 'en' => $this->getInput('translateEN'), + 'es' => $this->getInput('translateES'), + 'it' => $this->getInput('translateIT'), + 'nl' => $this->getInput('translateNL'), + 'pt' => $this->getInput('translatePT'), + 'el' => $this->getInput('translateEL'), + 'da' => $this->getInput('translateDA'), + 'fi' => $this->getInput('translateFI'), + 'ga' => $this->getInput('translateGA'), + 'sv' => $this->getInput('translateSV'), + 'br' => $this->getInput('translateBR'), + 'ca' => $this->getInput('translateCA'), + 'co' => $this->getInput('translateCO'), + 'eu' => $this->getInput('translateEU') + + ]]); + + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(), + 'notification' => $text['core_translate']['index'][0], + 'state' => true + ]); + } + // Modification des options de suppression de la langue installée. + foreach (self::$i18nList as $key => $value) { + if ($this->getData(['config','i18n',$key]) === 'site') { + self::$translateOptions [$key] = [ + 'none' => $text['core_translate']['index'][1], + 'site' => $text['core_translate']['index'][3], + 'delete' => $text['core_translate']['index'][4] + ]; + self::$siteTranslate = $key !== $this->getData(['config', 'i18n', 'langBase']) ? false : true; + } else { + self::$translateOptions [$key] = [ + 'none' => $text['core_translate']['index'][1], + 'site' => $text['core_translate']['index'][3] + ]; + } + // Limitation du choix pour la langue d'origine + if ( $key === $this->getData(['config', 'i18n', 'langBase'])){ + self::$translateOptions [$key] = [ + 'none' => $text['core_translate']['index'][1], + 'site' => $text['core_translate']['index'][5] + ]; + } + } + // Valeurs en sortie + $this->addOutput([ + 'title' => $text['core_translate']['index'][6], + 'view' => 'index' ]); } - // Modification des options de suppression de la langue installée. - foreach (self::$i18nList as $key => $value) { - if ($this->getData(['config','i18n',$key]) === 'site') { - self::$translateOptions [$key] = [ - 'none' => $text['core_translate']['index'][1], - 'site' => $text['core_translate']['index'][3], - 'delete' => $text['core_translate']['index'][4] - ]; - self::$siteTranslate = $key !== $this->getData(['config', 'i18n', 'langBase']) ? false : true; - } else { - self::$translateOptions [$key] = [ - 'none' => $text['core_translate']['index'][1], - 'site' => $text['core_translate']['index'][3] - ]; - } - // Limitation du choix pour la langue d'origine - if ( $key === $this->getData(['config', 'i18n', 'langBase'])){ - self::$translateOptions [$key] = [ - 'none' => $text['core_translate']['index'][1], - 'site' => $text['core_translate']['index'][5] - ]; - } - } - // Valeurs en sortie - $this->addOutput([ - 'title' => $text['core_translate']['index'][6], - 'view' => 'index' - ]); } diff --git a/core/module/user/user.php b/core/module/user/user.php index 665a802..b93f041 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -47,257 +47,81 @@ class user extends common { * Ajout */ public function add() { - // Lexique - include('./core/module/user/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_user.php'); - // Soumission du formulaire - if($this->isPost()) { - $check=true; - // L'identifiant d'utilisateur est indisponible - $userId = $this->getInput('userAddId', helper::FILTER_ID, true); - if($this->getData(['user', $userId])) { - self::$inputNotices['userAddId'] = $text['core_user']['add'][0]; - $check=false; - } - // Double vérification pour le mot de passe - if($this->getInput('userAddPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('userAddConfirmPassword', helper::FILTER_STRING_SHORT, true)) { - self::$inputNotices['userAddConfirmPassword'] = $text['core_user']['add'][1]; - $check = false; - } - // Crée l'utilisateur - $userFirstname = $this->getInput('userAddFirstname', helper::FILTER_STRING_SHORT, true); - $userLastname = $this->getInput('userAddLastname', helper::FILTER_STRING_SHORT, true); - $userMail = $this->getInput('userAddMail', helper::FILTER_MAIL, true); - - // Stockage des données - $this->setData([ - 'user', - $userId, - [ - 'firstname' => $userFirstname, - 'forgot' => 0, - 'group' => $this->getInput('userAddGroup', helper::FILTER_INT, true), - 'lastname' => $userLastname, - 'pseudo' => $this->getInput('userAddPseudo', helper::FILTER_STRING_SHORT, true), - 'signature' => $this->getInput('userAddSignature', helper::FILTER_INT, true), - 'mail' => $userMail, - 'password' => $this->getInput('userAddPassword', helper::FILTER_PASSWORD, true), - "connectFail" => null, - "connectTimeout" => null, - "accessUrl" => null, - "accessTimer" => null, - "accessCsrf" => null, - "files" => $this->getInput('userAddFiles', helper::FILTER_BOOLEAN), - "redirectPageId" => $this->getInput('userRedirectPageId', helper::FILTER_STRING_SHORT) - ] - ]); - - // Envoie le mail - $sent = true; - if($this->getInput('userAddSendMail', helper::FILTER_BOOLEAN) && $check === true) { - $sent = $this->sendMail( - $userMail, - $text['core_user']['add'][2] . $this->getData(['locale', 'title']), - $text['core_user']['add'][3].'' . $userFirstname . ' ' . $userLastname . ',