From b77bdbd08a0a0a79082ee83bf17e4e04e0cc07f3 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Tue, 12 May 2020 16:28:10 +0200 Subject: [PATCH] =?UTF-8?q?092=20Edition=20des=20scripts=20dans=20une=20fe?= =?UTF-8?q?n=C3=AAtre=20d=C3=A9di=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 4 +- core/class/template.class.php | 2 +- core/module/config/config.php | 34 +- core/module/config/view/index/index.php | 809 +++++++++---------- core/module/config/view/manage/manage.php | 10 +- core/module/config/view/script/script.js.php | 1 + core/module/config/view/script/script.php | 38 + core/module/theme/view/advanced/advanced.php | 2 +- core/vendor/codemirror/init.js | 2 +- 9 files changed, 476 insertions(+), 426 deletions(-) create mode 100644 core/module/config/view/script/script.js.php create mode 100644 core/module/config/view/script/script.php diff --git a/CHANGES.md b/CHANGES.md index c9f6a280..7aa7aa6d 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,7 +3,9 @@ ## version 10.0.092 - Nouveautés : - - Masque de configuration : options de réglage d'un serveur SMTP + - Configuration : + - Options de réglage d'un serveur SMTP + - Edition des scripts dans une fenêtre dédiée - Modification : - Masque de configuration : changement de libellés. - Scripts externes: diff --git a/core/class/template.class.php b/core/class/template.class.php index 0cb422bc..d3cc78bf 100755 --- a/core/class/template.class.php +++ b/core/class/template.class.php @@ -719,7 +719,7 @@ class template { // Attributs par défaut $attributes = array_merge([ 'before' => true, - 'class' => '', // editorWysiwyg et editorCss possible pour utiliser le éditeurs (il faut également instancier les librairies) + 'class' => '', // editorWysiwyg et editor possible pour utiliser un éditeur (il faut également instancier les librairies) 'classWrapper' => '', 'disabled' => false, 'noDirty' => false, diff --git a/core/module/config/config.php b/core/module/config/config.php index 5b9a4f6f..222d1ef8 100755 --- a/core/module/config/config.php +++ b/core/module/config/config.php @@ -23,7 +23,8 @@ class config extends common { 'updateRobots' => self::GROUP_ADMIN, 'index' => self::GROUP_ADMIN, 'manage' => self::GROUP_ADMIN, - 'updateBaseUrl' => self::GROUP_ADMIN + 'updateBaseUrl' => self::GROUP_ADMIN, + 'script' => self::GROUP_ADMIN ]; public static $timezones = [ @@ -165,7 +166,6 @@ class config extends common { 'ssl' => 'SSL/TLS' ]; - public function generateFiles() { // Mettre à jour le site map $successSitemap=$this->createSitemap(); @@ -445,9 +445,6 @@ class config extends common { ]); if(self::$inputNotices === []) { - // Ecrire les fichiers de script - file_put_contents(self::DATA_DIR . 'head.inc.html',$this->getInput('configScriptHead',null)); - file_put_contents(self::DATA_DIR . 'body.inc.html',$this->getInput('configScriptBody',null)); // Active la réécriture d'URL $rewrite = $this->getInput('rewrite', helper::FILTER_BOOLEAN); if( @@ -504,6 +501,33 @@ class config extends common { ]); } + public function script() { + // Soumission du formulaire + if($this->isPost()) { + // Ecrire les fichiers de script + if ($this->getInput('configScriptHead')) { + file_put_contents(self::DATA_DIR . 'head.inc.html',$this->getInput('configScriptHead',null)); + } + if ($this->getInput('configScriptBody')) { + file_put_contents(self::DATA_DIR . 'body.inc.html',$this->getInput('configScriptBody',null)); + } + // Valeurs en sortie + $this->addOutput([ + 'notification' => 'Modifications enregistrées', + 'redirect' => helper::baseUrl() . 'config/script/'. $this->geturl(2), + 'state' => true + ]); + } + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Éditeur de script dans ' . ucfirst($this->geturl(2)) , + 'vendor' => [ + 'codemirror' + ], + 'view' => 'script' + ]); + } + /** * Met à jour les données de site avec l'adresse trannsmise */ diff --git a/core/module/config/view/index/index.php b/core/module/config/view/index/index.php index 4f8b07c2..c892849f 100755 --- a/core/module/config/view/index/index.php +++ b/core/module/config/view/index/index.php @@ -1,439 +1,424 @@ -
-
-
- 'buttonGrey', - 'href' => helper::baseUrl(false), - 'ico' => 'home', - 'value' => 'Accueil' - ]); ?> -
-
- helper::baseUrl() . 'config/backup', - 'value' => 'Sauvegarder', - 'ico' => 'download' - ]); ?> -
-
- helper::baseUrl() . 'config/manage', - 'value' => 'Restaurer', - 'ico' => 'upload' - ]); ?> -
-
- -
+
+
+ 'buttonGrey', + 'href' => helper::baseUrl(false), + 'ico' => 'home', + 'value' => 'Accueil' + ]); ?>
-
-
-
-

Informations générales

-
-
- getData(['page']); - foreach($pages as $page => $pageId) { - if ($this->getData(['page',$page,'block']) === 'bar' || - $this->getData(['page',$page,'disable']) === true) { - unset($pages[$page]); - } - } - echo template::select('configHomePageId', helper::arrayCollumn($pages, 'title', 'SORT_ASC'), [ - 'label' => 'Page d\'accueil', - 'selected' =>$this->getData(['config', 'homePageId']) - ]); ?> -
-
- 'Titre du site', - 'value' => $this->getData(['config', 'title']), - 'help' => 'Il apparaît dans la barre de titre et les partages sur les réseaux sociaux.' - ]); ?> -
-
- 'Description du site', - 'value' => $this->getData(['config', 'metaDescription']), - 'help' => 'Elle apparaît dans les partages sur les réseaux sociaux.' - ]); ?> +
+ helper::baseUrl() . 'config/backup', + 'value' => 'Sauvegarder', + 'ico' => 'download' + ]); ?>
-
+
+ helper::baseUrl() . 'config/manage', + 'value' => 'Restaurer', + 'ico' => 'upload' + ]); ?> +
+
+
-
-
-
-

Paramètres

- - - - -
-
- 1, - 'help' => 'Pensez à supprimer le cache de votre navigateur si la favicon ne change pas.', - 'label' => 'Favicon', - 'value' => $this->getData(['config', 'favicon']) - ]); ?> -
-
- 1, - 'help' => 'Sélectionnez une icône adaptée à un thème sombre.
Pensez à supprimer le cache de votre navigateur si la favicon ne change pas.', - 'label' => 'Favicon thème sombre', - 'value' => $this->getData(['config', 'faviconDark']) +
+
+
+
+

Informations générales

+
+
+ getData(['page']); + foreach($pages as $page => $pageId) { + if ($this->getData(['page',$page,'block']) === 'bar' || + $this->getData(['page',$page,'disable']) === true) { + unset($pages[$page]); + } + } + echo template::select('configHomePageId', helper::arrayCollumn($pages, 'title', 'SORT_ASC'), [ + 'label' => 'Page d\'accueil', + 'selected' =>$this->getData(['config', 'homePageId']) ]); ?>
-
- 'Articles par page', - 'selected' => $this->getData(['config', 'itemsperPage']), - 'help' => 'Modules Blog et News' - ]); ?> -
+
+ 'Titre du site', + 'value' => $this->getData(['config', 'title']), + 'help' => 'Il apparaît dans la barre de titre et les partages sur les réseaux sociaux.' + ]); ?> +
+
+ 'Description du site', + 'value' => $this->getData(['config', 'metaDescription']), + 'help' => 'Elle apparaît dans les partages sur les réseaux sociaux.' + ]); ?> +
+
+
+
+
+
+

Paramètres

+ + + + +
+
+ 1, + 'help' => 'Pensez à supprimer le cache de votre navigateur si la favicon ne change pas.', + 'label' => 'Favicon', + 'value' => $this->getData(['config', 'favicon']) + ]); ?>
-
-
- 'Fuseau horaire', - 'selected' => $this->getData(['config', 'timezone']), - 'help' => 'Le fuseau horaire est utile au bon référencement' - ]); ?> -
-
- 'Sélectionner'] , helper::arrayCollumn($this->getData(['page']), 'title', 'SORT_ASC') ); - ?> - 'Mentions légales', - 'selected' => $this->getData(['config', 'legalPageId']), - 'help' => 'Les mentions légales sont obligatoires en France' - ]); ?> -
+
+ 1, + 'help' => 'Sélectionnez une icône adaptée à un thème sombre.
Pensez à supprimer le cache de votre navigateur si la favicon ne change pas.', + 'label' => 'Favicon thème sombre', + 'value' => $this->getData(['config', 'faviconDark']) + ]); ?> +
+
+ 'Articles par page', + 'selected' => $this->getData(['config', 'itemsperPage']), + 'help' => 'Modules Blog et News' + ]); ?> +
+
+
+
+ 'Fuseau horaire', + 'selected' => $this->getData(['config', 'timezone']), + 'help' => 'Le fuseau horaire est utile au bon référencement' + ]); ?> +
+
+ 'Sélectionner'] , helper::arrayCollumn($this->getData(['page']), 'title', 'SORT_ASC') ); + ?> + 'Mentions légales', + 'selected' => $this->getData(['config', 'legalPageId']), + 'help' => 'Les mentions légales sont obligatoires en France' + ]); ?>
-
-
- $this->getData(['config', 'cookieConsent']) - ]); ?> -
-
- helper::checkRewrite(), - 'help' => 'Vérifiez d\'abord que votre serveur l\'autorise : ce n\'est pas le cas chez Free.' - ]); ?> -
-
-
-
- $this->getData(['config', 'autoBackup']), - 'help' => '

Une archive contenant le dossier /site/data est copiée dans le dossier \'site/backup\'. La sauvegarde est conservée pendant 30 jours.

Les fichiers du site ne sont pas sauvegardés automatiquement.

' - ]); ?> -
-
- $this->getData(['config', 'maintenance']) +
+
+
+ $this->getData(['config', 'cookieConsent']) + ]); ?> +
+
+ helper::checkRewrite(), + 'help' => 'Vérifiez d\'abord que votre serveur l\'autorise : ce n\'est pas le cas chez Free.' + ]); ?> +
+
+
+
+ $this->getData(['config', 'autoBackup']), + 'help' => '

Une archive contenant le dossier /site/data est copiée dans le dossier \'site/backup\'. La sauvegarde est conservée pendant 30 jours.

Les fichiers du site ne sont pas sauvegardés automatiquement.

' ]); ?> -
+
+
+ $this->getData(['config', 'maintenance']) + ]); ?>
-
-
- $this->getData(['config', 'autoUpdate']), - 'help' => 'Vérifie une fois par jour l\'existence d\'une mise à jour.' - ]); ?> -
-
- helper::baseUrl() . 'install/update', - 'value' => 'Mise à jour manuelle', - 'disabled' => !$error +
+
+
+ $this->getData(['config', 'autoUpdate']), + 'help' => 'Vérifie une fois par jour l\'existence d\'une mise à jour.' ]); ?> -
+
+
+ helper::baseUrl() . 'install/update', + 'value' => 'Mise à jour manuelle', + 'disabled' => !$error + ]); ?>
-
+
+
+
+
+
+
+
+

Réseaux sociaux

+
+
+ 'Saisissez votre ID : https://www.facebook.com/[ID].', + 'label' => 'Facebook', + 'value' => $this->getData(['config', 'social', 'facebookId']) + ]); ?> +
+
+ 'Saisissez votre ID : https://www.instagram.com/[ID].', + 'label' => 'Instagram', + 'value' => $this->getData(['config', 'social', 'instagramId']) + ]); ?> +
+
+
+
+ 'ID de la chaîne : https://www.youtube.com/channel/[ID].', + 'label' => 'Chaîne Youtube', + 'value' => $this->getData(['config', 'social', 'youtubeId']) + ]); ?> +
+
+ 'Saisissez votre ID Utilisateur : https://www.youtube.com/user/[ID].', + 'label' => 'Youtube', + 'value' => $this->getData(['config', 'social', 'youtubeUserId']) + ]); ?> +
+
+
+
+ 'Saisissez votre ID : https://twitter.com/[ID].', + 'label' => 'Twitter', + 'value' => $this->getData(['config', 'social', 'twitterId']) + ]); ?> +
+
+ 'Saisissez votre ID : https://pinterest.com/[ID].', + 'label' => 'Pinterest', + 'value' => $this->getData(['config', 'social', 'pinterestId']) + ]); ?> +
+
+ 'Saisissez votre ID Linkedin : https://fr.linkedin.com/in/[ID].', + 'label' => 'Linkedin', + 'value' => $this->getData(['config', 'social', 'linkedinId']) + ]); ?> +
+
+ 'Saisissez votre ID Github : https://github.com/[ID].', + 'label' => 'Github', + 'value' => $this->getData(['config', 'social', 'githubId']) + ]); ?> +
+
-
-
-
-

Réseaux sociaux

-
-
- 'Saisissez votre ID : https://www.facebook.com/[ID].', - 'label' => 'Facebook', - 'value' => $this->getData(['config', 'social', 'facebookId']) - ]); ?> -
-
- 'Saisissez votre ID : https://www.instagram.com/[ID].', - 'label' => 'Instagram', - 'value' => $this->getData(['config', 'social', 'instagramId']) - ]); ?> -
-
-
-
- 'ID de la chaîne : https://www.youtube.com/channel/[ID].', - 'label' => 'Chaîne Youtube', - 'value' => $this->getData(['config', 'social', 'youtubeId']) - ]); ?> -
-
- 'Saisissez votre ID Utilisateur : https://www.youtube.com/user/[ID].', - 'label' => 'Youtube', - 'value' => $this->getData(['config', 'social', 'youtubeUserId']) - ]); ?> -
+ +
+
+

Référencement

+
+
+ helper::baseUrl() . 'config/configMetaImage', + 'value' => 'Rafraîchir la capture d\'écran Open Graph' + ]); ?>
-
-
- 'Saisissez votre ID : https://twitter.com/[ID].', - 'label' => 'Twitter', - 'value' => $this->getData(['config', 'social', 'twitterId']) +
+ helper::baseUrl() . 'config/generateFiles', + 'value' => 'Générer sitemap.xml et robots.txt' + ]); ?> +
+
+
+
+ +
+
+
+
+
+
+
+
+

Options avancées

+
+
+ 'Saisissez l\'ID de suivi.', + 'label' => 'Google Analytics', + 'placeholder' => 'UA-XXXXXXXX-X', + 'value' => $this->getData(['config', 'analyticsId']) + ]); ?> +
+
+ helper::baseUrl() . 'config/script/head', + 'value' => 'Editer script dans head' + ]); ?> +
+
+ helper::baseUrl() . 'config/script/body', + 'value' => 'Editer script dans body' + ]); ?> +
+
+
+
+
+
+
+
+

Paramètres réseaux

+
+
+ 'Type de proxy', + 'selected' => $this->getData(['config', 'proxyType']) + ]); ?> +
+
+ 'Adresse du proxy', + 'placeholder' => 'cache.proxy.fr', + 'value' => $this->getData(['config', 'proxyUrl']) + ]); ?> +
+
+ 'Port du proxy', + 'placeholder' => '6060', + 'value' => $this->getData(['config', 'proxyPort']) + ]); ?> +
+
+
+
+
+
+
+
+

Paramètres de messagerie SMTP

+
+
+ $this->getData(['config', 'smtp','enable']), + 'help' => 'Paramètres à utiliser lorsque votre hébergeur ne propose pas la fonctionnalité d\'envoi de mail.' ]); ?> +
+
+
+
+
+ 'Adresse SMTP', + 'placeholder' => 'smtp.fr', + 'value' => $this->getData(['config', 'smtp','host']) + ]); ?> +
+
+ 'Port SMTP', + 'placeholder' => '589', + 'value' => $this->getData(['config', 'smtp','port']) + ]); ?>
-
- 'Saisissez votre ID : https://pinterest.com/[ID].', - 'label' => 'Pinterest', - 'value' => $this->getData(['config', 'social', 'pinterestId']) - ]); ?> -
-
- 'Saisissez votre ID Linkedin : https://fr.linkedin.com/in/[ID].', - 'label' => 'Linkedin', - 'value' => $this->getData(['config', 'social', 'linkedinId']) - ]); ?> -
-
- 'Saisissez votre ID Github : https://github.com/[ID].', - 'label' => 'Github', - 'value' => $this->getData(['config', 'social', 'githubId']) - ]); ?> +
+ 'Authentification', + 'selected' => $this->getData(['config', 'smtp','auth']) + ]); ?>
-
-
- -
-
-

Référencement

-
-
- helper::baseUrl() . 'config/configMetaImage', - 'value' => 'Rafraîchir la capture d\'écran Open Graph' - ]); ?> -
-
- helper::baseUrl() . 'config/generateFiles', - 'value' => 'Générer sitemap.xml et robots.txt' - ]); ?> -
-
-
-
- -
-
-
-
-
-
-
- -
-

Options avancées

-
-
- 'Saisissez l\'ID de suivi.', - 'label' => 'Google Analytics', - 'placeholder' => 'UA-XXXXXXXX-X', - 'value' => $this->getData(['config', 'analyticsId']) - ]); ?> -
-
-
-
- 'Insérer un script dans "Head"', - 'value' => $headerFile - ]); ?> -
-
- 'Insérer un script dans "Body"', - 'value' => $bodyFile - ]); ?> -
-
-
-
-
-
-
-
-

Paramètres réseaux

-
-
- 'Type de proxy', - 'selected' => $this->getData(['config', 'proxyType']) - ]); ?> -
-
- 'Adresse du proxy', - 'placeholder' => 'cache.proxy.fr', - 'value' => $this->getData(['config', 'proxyUrl']) - ]); ?> -
-
- 'Port du proxy', - 'placeholder' => '6060', - 'value' => $this->getData(['config', 'proxyPort']) - ]); ?> -
-
-
-
-
-
-
-
-

Paramètres de messagerie SMTP

-
-
- $this->getData(['config', 'smtp','enable']), - 'help' => 'Paramètres à utiliser lorsque votre hébergeur ne propose pas la fonctionnalité d\'envoi de mail.' - ]); ?> -
-
-
+
-
- 'Adresse SMTP', - 'placeholder' => 'smtp.fr', - 'value' => $this->getData(['config', 'smtp','host']) - ]); ?> -
-
- 'Port SMTP', - 'placeholder' => '589', - 'value' => $this->getData(['config', 'smtp','port']) - ]); ?> +
+ 'Nom utilisateur', + 'value' => $this->getData(['config', 'smtp','username' ]) + ]); ?> +
+
+ 'Mot de passe', + 'autocomplete' => 'off', + 'value' => $this->getData(['config','smtp','password']) + ]); ?>
- 'Authentification', - 'selected' => $this->getData(['config', 'smtp','auth']) - ]); ?> -
-
-
-
-
- 'Nom utilisateur', - 'value' => $this->getData(['config', 'smtp','username' ]) - ]); ?> -
-
- 'Mot de passe', - 'autocomplete' => 'off', - 'value' => $this->getData(['config','smtp','password']) - ]); ?> -
-
- 'Sécurité', - 'selected' => $this->getData(['config', 'smtp','secure']) - ]); ?> -
-
-
-
-
+ 'Sécurité', + 'selected' => $this->getData(['config', 'smtp','secure']) + ]); ?> +
+
+
+
-
-
-
-
-

Versions système

-
-
- 'ZwiiCMS', +
+
+
+
+
+

Versions système

+
+
+ 'ZwiiCMS', + 'readonly' => true, + 'value' => common::ZWII_VERSION + ]); ?> +
+
+ 'Blog', 'readonly' => true, - 'value' => common::ZWII_VERSION - ]); ?> -
-
- 'Blog', - 'readonly' => true, - 'value' => blog::BLOG_VERSION - ]); ?> -
-
- 'Form', - 'readonly' => true, - 'value' => form::FORM_VERSION - ]); ?> -
-
- 'Gallery', - 'readonly' => true, - 'value' => gallery::GALLERY_VERSION - ]); ?> -
-
- 'News', - 'readonly' => true, - 'value' => news::NEWS_VERSION - ]); ?> -
-
- 'Redirection', - 'readonly' => true, - 'value' => redirection::REDIRECTION_VERSION - ]); ?> -
-
-
+ 'value' => blog::BLOG_VERSION + ]); ?> +
+
+ 'Form', + 'readonly' => true, + 'value' => form::FORM_VERSION + ]); ?> +
+
+ 'Gallery', + 'readonly' => true, + 'value' => gallery::GALLERY_VERSION + ]); ?> +
+
+ 'News', + 'readonly' => true, + 'value' => news::NEWS_VERSION + ]); ?> +
+
+ 'Redirection', + 'readonly' => true, + 'value' => redirection::REDIRECTION_VERSION + ]); ?> +
+
diff --git a/core/module/config/view/manage/manage.php b/core/module/config/view/manage/manage.php index a7c7ef4e..38f27347 100755 --- a/core/module/config/view/manage/manage.php +++ b/core/module/config/view/manage/manage.php @@ -9,11 +9,11 @@ ]); ?>
- 'valider', - 'ico' => 'check' - ]); ?> -
+ 'valider', + 'ico' => 'check' + ]); ?> +
diff --git a/core/module/config/view/script/script.js.php b/core/module/config/view/script/script.js.php new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/core/module/config/view/script/script.js.php @@ -0,0 +1 @@ + diff --git a/core/module/config/view/script/script.php b/core/module/config/view/script/script.php new file mode 100644 index 00000000..34473285 --- /dev/null +++ b/core/module/config/view/script/script.php @@ -0,0 +1,38 @@ + +
+
+ 'buttonGrey', + 'href' => helper::baseUrl() . 'config', + 'ico' => 'left', + 'value' => 'Retour' + ]); ?> +
+
+ 'valider', + 'ico' => 'check' + ]); ?> +
+
+ geturl(2) === 'head'): ?> +
+
+ file_exists( self::DATA_DIR . 'head.inc.html') ? file_get_contents (self::DATA_DIR . 'head.inc.html') : '' , + 'class' => 'editor' + ]); ?> +
+
+ + geturl(2) === 'body'): ?> +
+
+ file_exists( self::DATA_DIR . 'body.inc.html') ? file_get_contents (self::DATA_DIR . 'body.inc.html') : '' , + 'class' => 'editor' + ]); ?> +
+
+ + \ No newline at end of file diff --git a/core/module/theme/view/advanced/advanced.php b/core/module/theme/view/advanced/advanced.php index 613164cb..b3a82d33 100755 --- a/core/module/theme/view/advanced/advanced.php +++ b/core/module/theme/view/advanced/advanced.php @@ -24,7 +24,7 @@
file_get_contents(self::DATA_DIR.'custom.css'), - 'class' => 'editorCss' + 'class' => 'editor' ]); ?>
diff --git a/core/vendor/codemirror/init.js b/core/vendor/codemirror/init.js index 26819e53..07bd0f5e 100755 --- a/core/vendor/codemirror/init.js +++ b/core/vendor/codemirror/init.js @@ -2,7 +2,7 @@ * Initialisation de CodeMirror */ $(function() { - $(".editorCss").each(function() { + $(".editor").each(function() { var _this = this; // Initialisation de CodeMirror var codeMirror = CodeMirror.fromTextArea(_this, {