diff --git a/core/core.php b/core/core.php index 4da8153e..3cd0db36 100644 --- a/core/core.php +++ b/core/core.php @@ -1940,6 +1940,7 @@ class common { $notificationClass = 'notificationSuccess'; } if(common::$inputNotices) { + var_dump(common::$inputNotices); $notification = 'Impossible de soumettre le formulaire, car il contient des erreurs'; $notificationClass = 'notificationError'; } diff --git a/core/module/theme/theme.php b/core/module/theme/theme.php index 7046ac92..658e5e83 100644 --- a/core/module/theme/theme.php +++ b/core/module/theme/theme.php @@ -30,7 +30,9 @@ class theme extends common { 'export' => self::GROUP_ADMIN, 'import' => self::GROUP_ADMIN, 'save' => self::GROUP_ADMIN, - 'fonts' => self::GROUP_ADMIN + 'fonts' => self::GROUP_ADMIN, + 'fontAdd' => self::GROUP_ADMIN, + 'fontDelete' => self::GROUP_ADMIN ]; public static $aligns = [ 'left' => 'À gauche', @@ -548,16 +550,22 @@ class theme extends common { // Soumission du formulaire if($this->isPost()) { } - //Polices trouvées dans la configuration - - if ( file_exists(self::DATA_DIR . 'fonts.json') ) { - $localFonts = $this->getData(['fonts', 'files']); - } + //Polices trouvées dans la configuration + $fonts = $this->getData(['fonts']); // Parcourir les fontes installées et construire le tableau pour le formulaire foreach (self::$fonts as $fontId => $fontName) { - self::$fontsList [] = [ + self::$fontsList [] = [ $fontName, - $fontId + $fontId, + array_key_exists($fontId, $fonts['imported']) ? 'Importée' : '', + array_key_exists($fontId, $fonts['files']) ? $fonts['files'][$fontId] : 'CDN Fonts', + array_key_exists($fontId, $fonts['imported']) || array_key_exists($fontId, $fonts['files']) + ? template::button('themeFontDelete' . $fontId, [ + 'class' => 'themeFontDelete buttonRed', + 'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $fontId . '/' . $_SESSION['csrf'], + 'value' => template::ico('cancel') + ]) + : '' ]; } // Valeurs en sortie @@ -567,6 +575,80 @@ class theme extends common { ]); } + /** + * Ajouter une fonte + */ + public function fontAdd() { + // Soumission du formulaire + if ($this->isPost()) { + $fontId = $this->getInput('fontAddFontId', null, true); + $fontName = $this->getInput('fontAddFontName', null, true); + $file = $this->getInput('fontAddFile', null, true); + + // Charger les données des fontes + $files = $this->getData(['fonts', 'files']); + $imported = $this->getData(['fonts', 'imported']); + // Concaténation dans les tableaux existants + $imported = array_merge([$fontId => $fontName], $imported); + $files = array_merge([$fontId => $file], $files); + // Mettre à jour le fichier des fontes + $this->setData(['fonts', 'imported', $imported ]); + $this->setData(['fonts', 'files', $files ]); + // Valeurs en sortie + $this->addOutput([ + 'notification' => 'Fonte importée', + 'redirect' => helper::baseUrl() . 'theme/fonts', + 'state' => true + ]); + } + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Ajouter une fonte', + 'view' => 'fontAdd' + ]); + } + + /** + * Effacer une fonte + */ + public function fontDelete() { + // Jeton incorrect + if ($this->getUrl(3) !== $_SESSION['csrf']) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'theme/fonts', + 'notification' => 'Action non autorisée' + ]); + } + // Suppression + else { + + // Charger les données des fontes + $files = $this->getData(['fonts', 'files']); + $imported = $this->getData(['fonts', 'imported']); + + // Effacer le fichier existant + if ( file_exists(self::DATA_DIR . $files[$this->getUrl(2)]) ) { + unlink(self::DATA_DIR . $files[$this->getUrl(2)]); + } + + // Supprimer les entrées + unset($file[$this->getUrl(2)]); + unset($imported[$this->getUrl(2)]); + + // Mettre à jour le fichier des fontes + $this->setData(['fonts', 'files', $files ]); + $this->setData(['fonts', 'imported', $imported ]); + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'theme/fonts', + 'notification' => 'Fonte supprimée', + 'state' => true + ]); + } + } + + /** * Réinitialisation de la personnalisation avancée */ diff --git a/core/module/theme/view/fontAdd/fontAdd.css b/core/module/theme/view/fontAdd/fontAdd.css new file mode 100644 index 00000000..52709ea6 --- /dev/null +++ b/core/module/theme/view/fontAdd/fontAdd.css @@ -0,0 +1,18 @@ +/** + * This file is part of Zwii. + * + * For full copyright and license information, please see the LICENSE + * file that was distributed with this source code. + * + * @author Rémi Jean + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2022, Frédéric Tempez + * @license GNU General Public License, version 3 + * @link http://zwiicms.fr/ + */ + + +/** NE PAS EFFACER +* admin.css +*/ \ No newline at end of file diff --git a/core/module/theme/view/fontAdd/fontAdd.php b/core/module/theme/view/fontAdd/fontAdd.php new file mode 100644 index 00000000..5b42a036 --- /dev/null +++ b/core/module/theme/view/fontAdd/fontAdd.php @@ -0,0 +1,58 @@ + +
+
+ 'buttonGrey', + 'href' => helper::baseUrl() . $this->getUrl(0) . '/theme/font', + 'ico' => 'left', + 'value' => 'Retour' + ]); ?> +
+
+ 'Valider', + 'uniqueSubmission' => true + ]); ?> +
+
+
+
+
+

Identification

+
+
+ 'off', + 'label' => 'Identifiant', + 'placeholder' => 'perry-gothic' + + ]); ?> +
+
+ 'off', + 'label' => 'Nom (Font Family)', + 'placeholder' => 'PerryGothic' + ]); ?> +
+
+
+
+
+
+
+
+

Source

+
+
+ 'Fichier de police (Format WOFF)', + 'placeholder' => 'https://fonts.cdnfonts.com/s/7896/PERRYGOT.woff' + ]); ?> +
+
+
+
+
+ + \ No newline at end of file diff --git a/core/module/theme/view/fonts/fonts.js.php b/core/module/theme/view/fonts/fonts.js.php new file mode 100644 index 00000000..07553822 --- /dev/null +++ b/core/module/theme/view/fonts/fonts.js.php @@ -0,0 +1,21 @@ +/** + * This file is part of Zwii. + * For full copyright and license information, please see the LICENSE + * file that was distributed with this source code. + * + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2022, Frédéric Tempez + * @license GNU General Public License, version 3 + * @link http://zwiicms.fr/ + */ + + +/** + * Confirmation de suppression + */ + $(".themeFontDelete").on("click", function() { + var _this = $(this); + return core.confirm("Êtes-vous sûr de vouloir supprimer cette fonte ?", function() { + $(location).attr("href", _this.attr("href")); + }); +}); \ No newline at end of file diff --git a/core/module/theme/view/fonts/fonts.php b/core/module/theme/view/fonts/fonts.php index 1f5efa0b..34094a38 100644 --- a/core/module/theme/view/fonts/fonts.php +++ b/core/module/theme/view/fonts/fonts.php @@ -1,5 +1,22 @@ +
+
+ 'buttonGrey', + 'href' => helper::baseUrl() . 'theme', + 'ico' => 'left', + 'value' => 'Retour' + ]); ?> +
+
+ helper::baseUrl() . $this->getUrl(0) . '/fontAdd', + 'ico' => 'plus', + 'value' => 'Fonte' + ]); ?> +
+
- + - + \ No newline at end of file diff --git a/core/vendor/filemanager/config/config.php b/core/vendor/filemanager/config/config.php index bb114c4b..786a9b0b 100644 --- a/core/vendor/filemanager/config/config.php +++ b/core/vendor/filemanager/config/config.php @@ -458,7 +458,7 @@ $config = array( 'ext_file' => array( 'doc', 'docx', 'rtf', 'pdf', 'xls', 'xlsx', 'txt', 'csv', 'html', 'xhtml', 'psd', 'sql', 'log', 'fla', 'xml', 'ade', 'adp', 'mdb', 'accdb', 'ppt', 'pptx', 'odt', 'ots', 'ott', 'odb', 'odg', 'otp', 'otg', 'odf', 'ods', 'odp', 'css', 'ai', 'kmz','dwg', 'dxf', 'hpgl', 'plt', 'spl', 'step', 'stp', 'iges', 'igs', 'sat', 'cgm', 'ics', 'gpx', 'kml', ''), //Files 'ext_video' => array( 'mov', 'mpeg', 'm4v', 'mp4', 'avi', 'mpg', 'wma', "flv", "webm" ), //Video 'ext_music' => array( 'mp3', 'mpga', 'm4a', 'ac3', 'aiff', 'mid', 'ogg', 'wav' ), //Audio - 'ext_misc' => array( 'zip', 'rar', 'gz', 'tar', 'iso', 'dmg' ), //Archives + 'ext_misc' => array( 'zip', 'rar', 'gz', 'tar', 'iso', 'dmg', 'woff' ), //Archives et polices de caractères //*********************