From 9544c3305d6101a923c9d266914dbb7d6556a7a9 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Tue, 14 Feb 2023 16:53:28 +0100 Subject: [PATCH 1/9] Fix css if page with module WIP --- core/core.php | 28 ++++++++++++++++------------ core/module/page/page.php | 4 ++-- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/core/core.php b/core/core.php index f8ec7c75..f9efeb78 100644 --- a/core/core.php +++ b/core/core.php @@ -3003,12 +3003,13 @@ class core extends common ) and $access ) { + + $this->addOutput([ 'title' => $title, 'content' => $this->getPage($this->getUrl(0), self::$i18nContent) . - // Concatène avec les paramètres avancés. - $this->getData(['page', $this->getUrl(0), 'css']) . - $this->getData(['page', $this->getUrl(0), 'js']), + ($this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']) ). + ($this->getData(['page', $this->getUrl(0), 'js']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'js']) ), 'metaDescription' => $this->getData(['page', $this->getUrl(0), 'metaDescription']), 'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']), 'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']), @@ -3016,15 +3017,16 @@ class core extends common 'disable' => $this->getData(['page', $this->getUrl(0), 'disable']), 'contentRight' => $this->getData(['page', $this->getUrl(0), 'barRight']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) . - $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']) . - $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'js']) + ($this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']) == null ?'' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css'])) . + ($this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'js']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'js'])) : '', 'contentLeft' => $this->getData(['page', $this->getUrl(0), 'barLeft']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) . - $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']) . - $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'js']) + ($this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css'])) . + ($this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'js']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'js'])) : '' ]); + } // Importe le module else { @@ -3043,13 +3045,15 @@ class core extends common 'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']), 'disable' => $this->getData(['page', $this->getUrl(0), 'disable']), 'contentRight' => $this->getData(['page', $this->getUrl(0), 'barRight']) - ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) - : '', + ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) + : '', 'contentLeft' => $this->getData(['page', $this->getUrl(0), 'barLeft']) - ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) - : '' + ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) + : '' ]); - $pageContent = $this->getPage($this->getUrl(0), self::$i18nContent); + $pageContent = $this->getPage($this->getUrl(0), self::$i18nContent) . + ($this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']) ). + ($this->getData(['page', $this->getUrl(0), 'js']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'js']) ); } else { $moduleId = $this->getUrl(0); $pageContent = ''; diff --git a/core/module/page/page.php b/core/module/page/page.php index dae6717b..aee53002 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -563,7 +563,7 @@ class page extends common // Soumission du formulaire if ($this->isPost()) { // Supprime les balises styles si elles ont été saisies - $css = $this->getInput('pageCssEditorContent', null); + $css = $this->getInput('pageCssEditorContent') === null ? '': $this->getInput('pageCssEditorContent'); // Enregistre le CSS $this->setData([ 'page', $this->getUrl(2), 'css', @@ -594,7 +594,7 @@ class page extends common // Soumission du formulaire if ($this->isPost()) { // Supprime les balises scripts si elles ont été saisies - $js = $this->getInput('pageJsEditorContent', null); + $js = $this->getInput('pageJsEditorContent') === null ? '' : $this->getInput('pageJsEditorContent'); // Enregistre le JS $this->setData([ 'page', $this->getUrl(2), 'js', From c670443132e812a8775150d2fb38cab8cdd87b75 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Wed, 15 Feb 2023 18:17:24 +0100 Subject: [PATCH 2/9] showFontes --- core/core.php | 47 ++++++++++++++++++--------------------- core/layout/blank.php | 1 + core/layout/light.php | 1 + core/layout/main.php | 1 + core/module/page/page.php | 4 +--- 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/core/core.php b/core/core.php index f9efeb78..8c402422 100644 --- a/core/core.php +++ b/core/core.php @@ -350,9 +350,9 @@ class common self::$i18nUI = $this->getData(['user', $this->getUser('id'), 'language']); // Validation de la langue self::$i18nUI = (empty(self::$i18nUI) || is_null(self::$i18nUI)) - && !file_exists(self::I18N_DIR . self::$i18nUI . '.json') - ? 'fr_FR' - : self::$i18nUI; + && !file_exists(self::I18N_DIR . self::$i18nUI . '.json') + ? 'fr_FR' + : self::$i18nUI; } // Stocker le cookie de langue pour l'éditeur de texte @@ -2337,6 +2337,12 @@ class common } echo ''; } + } + + /** + * Importe les polices de carcatères + */ + public function showFonts() { // Import des fontes liées au thème if (file_exists(self::DATA_DIR . 'fonts/fonts.html')) { include_once(self::DATA_DIR . 'fonts/fonts.html'); @@ -3007,26 +3013,16 @@ class core extends common $this->addOutput([ 'title' => $title, - 'content' => $this->getPage($this->getUrl(0), self::$i18nContent) . - ($this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']) ). - ($this->getData(['page', $this->getUrl(0), 'js']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'js']) ), + 'content' => $this->getPage($this->getUrl(0), self::$i18nContent), 'metaDescription' => $this->getData(['page', $this->getUrl(0), 'metaDescription']), 'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']), 'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']), 'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']), 'disable' => $this->getData(['page', $this->getUrl(0), 'disable']), - 'contentRight' => $this->getData(['page', $this->getUrl(0), 'barRight']) - ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) . - ($this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']) == null ?'' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css'])) . - ($this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'js']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'js'])) - : '', - 'contentLeft' => $this->getData(['page', $this->getUrl(0), 'barLeft']) - ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) . - ($this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css'])) . - ($this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'js']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'js'])) - : '' + 'contentRight' => $this->getData(['page', $this->getUrl(0), 'barRight']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) : '', + 'contentLeft' => $this->getData(['page', $this->getUrl(0), 'barLeft']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) : '' ]); - + // ($this->getData(['page', $this->getUrl(0), 'js']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'js']) ); } // Importe le module else { @@ -3045,15 +3041,15 @@ class core extends common 'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']), 'disable' => $this->getData(['page', $this->getUrl(0), 'disable']), 'contentRight' => $this->getData(['page', $this->getUrl(0), 'barRight']) - ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) - : '', + ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) + : '', 'contentLeft' => $this->getData(['page', $this->getUrl(0), 'barLeft']) - ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) - : '' + ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) + : '' ]); - $pageContent = $this->getPage($this->getUrl(0), self::$i18nContent) . - ($this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']) ). - ($this->getData(['page', $this->getUrl(0), 'js']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'js']) ); + //$pageContent = $this->getPage($this->getUrl(0), self::$i18nContent) . + //($this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']) ). + //($this->getData(['page', $this->getUrl(0), 'js']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'js']) ); } else { $moduleId = $this->getUrl(0); $pageContent = ''; @@ -3148,7 +3144,8 @@ class core extends common } if ($output['style']) { $this->addOutput([ - 'style' => $this->output['style'] . file_get_contents($output['style']) + //'style' => $this->output['style'] . file_get_contents($output['style']) + 'style' => file_get_contents($output['style']) ]); } diff --git a/core/layout/blank.php b/core/layout/blank.php index 962ed73b..0b7813c3 100644 --- a/core/layout/blank.php +++ b/core/layout/blank.php @@ -10,6 +10,7 @@ showFavicon(); ?> showVendor(); ?> showStyle(); ?> + showFonts(); ?> diff --git a/core/layout/light.php b/core/layout/light.php index 4447176d..d25f9cf4 100644 --- a/core/layout/light.php +++ b/core/layout/light.php @@ -10,6 +10,7 @@ showFavicon(); ?> showVendor(); ?> showStyle(); ?> + showFonts(); ?> diff --git a/core/layout/main.php b/core/layout/main.php index 449ae7a4..f0b3474f 100644 --- a/core/layout/main.php +++ b/core/layout/main.php @@ -9,6 +9,7 @@ showMetaImage(); ?> showFavicon(); ?> showVendor(); ?> + showFonts(); ?> diff --git a/core/module/page/page.php b/core/module/page/page.php index aee53002..9cdaa197 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -562,8 +562,7 @@ class page extends common { // Soumission du formulaire if ($this->isPost()) { - // Supprime les balises styles si elles ont été saisies - $css = $this->getInput('pageCssEditorContent') === null ? '': $this->getInput('pageCssEditorContent'); + $css = $this->getInput('pageCssEditorContent') === null ? '': $this->getInput('pageCssEditorContent'); // Enregistre le CSS $this->setData([ 'page', $this->getUrl(2), 'css', @@ -593,7 +592,6 @@ class page extends common { // Soumission du formulaire if ($this->isPost()) { - // Supprime les balises scripts si elles ont été saisies $js = $this->getInput('pageJsEditorContent') === null ? '' : $this->getInput('pageJsEditorContent'); // Enregistre le JS $this->setData([ From a734c972cde10ad3fb17c0b58b761b281b05d0d0 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Wed, 15 Feb 2023 18:36:30 +0100 Subject: [PATCH 3/9] include CSS WIP --- core/Untitled-1 | 8 ++++++++ core/core.php | 13 ++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 core/Untitled-1 diff --git a/core/Untitled-1 b/core/Untitled-1 new file mode 100644 index 00000000..09a24eb1 --- /dev/null +++ b/core/Untitled-1 @@ -0,0 +1,8 @@ +// Créer les styles externes +if ($this->getData(['page', $this->getUrl(0), 'css' ])) { + $stylePath = self::TEMP_DIR . uniqid() . '.css'; + file_put_contents($stylePath, html_entity_decode($this->getData(['page', $this->getUrl(0), 'css']))); + $this->addOutput([ + 'style' => $stylePath + ]); +} \ No newline at end of file diff --git a/core/core.php b/core/core.php index 8c402422..1ee302a8 100644 --- a/core/core.php +++ b/core/core.php @@ -3010,10 +3010,9 @@ class core extends common and $access ) { - $this->addOutput([ 'title' => $title, - 'content' => $this->getPage($this->getUrl(0), self::$i18nContent), + //'content' => $this->getPage($this->getUrl(0), self::$i18nContent), 'metaDescription' => $this->getData(['page', $this->getUrl(0), 'metaDescription']), 'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']), 'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']), @@ -3022,7 +3021,15 @@ class core extends common 'contentRight' => $this->getData(['page', $this->getUrl(0), 'barRight']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) : '', 'contentLeft' => $this->getData(['page', $this->getUrl(0), 'barLeft']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) : '' ]); - // ($this->getData(['page', $this->getUrl(0), 'js']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'js']) ); + // Importe le CSS dans la page + $css = $this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']); + $css = strpos($css, ''; + //var_dump($css); + //die(); + $this->addOutput([ + 'content' => $this->getPage($this->getUrl(0), self::$i18nContent) . $css + ]); + } // Importe le module else { From 8eff28c8e39d7efd435d41c02c3781734db27cac Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Wed, 15 Feb 2023 19:01:16 +0100 Subject: [PATCH 4/9] CSS page and bar ok --- core/core.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/core/core.php b/core/core.php index 1ee302a8..9d8baa5e 100644 --- a/core/core.php +++ b/core/core.php @@ -3010,24 +3010,29 @@ class core extends common and $access ) { + // Importe le CSS de la page principale + $css = $this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']); + $css = strpos($css, '': $css; + + // Importe le CSS des barres + $contentRight = $this->getData(['page', $this->getUrl(0), 'barRight']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) : ''; + $cssRight = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']) === null ? '': $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']); + $cssRight = strpos($cssRight, '': $cssRight; + + $contentLeft = $this->getData(['page', $this->getUrl(0), 'barLeft']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) : ''; + $cssLeft = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']); + $cssLeft = strpos($cssRight, '': $cssLeft; + $this->addOutput([ 'title' => $title, - //'content' => $this->getPage($this->getUrl(0), self::$i18nContent), + 'content' => $this->getPage($this->getUrl(0), self::$i18nContent) . $css, 'metaDescription' => $this->getData(['page', $this->getUrl(0), 'metaDescription']), 'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']), 'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']), 'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']), 'disable' => $this->getData(['page', $this->getUrl(0), 'disable']), - 'contentRight' => $this->getData(['page', $this->getUrl(0), 'barRight']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) : '', - 'contentLeft' => $this->getData(['page', $this->getUrl(0), 'barLeft']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) : '' - ]); - // Importe le CSS dans la page - $css = $this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']); - $css = strpos($css, ''; - //var_dump($css); - //die(); - $this->addOutput([ - 'content' => $this->getPage($this->getUrl(0), self::$i18nContent) . $css + 'contentRight' => $contentRight . $cssRight, + 'contentLeft' => $contentLeft . $cssLeft, ]); } @@ -3054,9 +3059,6 @@ class core extends common ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) : '' ]); - //$pageContent = $this->getPage($this->getUrl(0), self::$i18nContent) . - //($this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']) ). - //($this->getData(['page', $this->getUrl(0), 'js']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'js']) ); } else { $moduleId = $this->getUrl(0); $pageContent = ''; From c58a2228876c54fb0acb2f6aa7bbd0a7e1df390a Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Wed, 15 Feb 2023 19:12:13 +0100 Subject: [PATCH 5/9] CSS ok barre and page avec plugin --- core/core.php | 55 ++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/core/core.php b/core/core.php index 9d8baa5e..fc301b13 100644 --- a/core/core.php +++ b/core/core.php @@ -2342,7 +2342,8 @@ class common /** * Importe les polices de carcatères */ - public function showFonts() { + public function showFonts() + { // Import des fontes liées au thème if (file_exists(self::DATA_DIR . 'fonts/fonts.html')) { include_once(self::DATA_DIR . 'fonts/fonts.html'); @@ -3002,6 +3003,21 @@ class core extends common $this->getData(['page', $this->getUrl(0), 'title']); } // Importe la page simple sans module ou avec un module inexistant + + // Importe le CSS de la page principale + $css = $this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']); + $css = strpos($css, '' : $css; + $pageContent = $this->getPage($this->getUrl(0), self::$i18nContent) . $css; + + // Importe le CSS des barres + $contentRight = $this->getData(['page', $this->getUrl(0), 'barRight']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) : ''; + $cssRight = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']); + $cssRight = strpos($cssRight, '' : $cssRight; + + $contentLeft = $this->getData(['page', $this->getUrl(0), 'barLeft']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) : ''; + $cssLeft = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']); + $cssLeft = strpos($cssRight, '' : $cssLeft; + if ( $this->getData(['page', $this->getUrl(0)]) !== null and ($this->getData(['page', $this->getUrl(0), 'moduleId']) === '' @@ -3010,22 +3026,9 @@ class core extends common and $access ) { - // Importe le CSS de la page principale - $css = $this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']); - $css = strpos($css, '': $css; - - // Importe le CSS des barres - $contentRight = $this->getData(['page', $this->getUrl(0), 'barRight']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) : ''; - $cssRight = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']) === null ? '': $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']); - $cssRight = strpos($cssRight, '': $cssRight; - - $contentLeft = $this->getData(['page', $this->getUrl(0), 'barLeft']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) : ''; - $cssLeft = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']); - $cssLeft = strpos($cssRight, '': $cssLeft; - $this->addOutput([ 'title' => $title, - 'content' => $this->getPage($this->getUrl(0), self::$i18nContent) . $css, + 'content' => $pageContent, 'metaDescription' => $this->getData(['page', $this->getUrl(0), 'metaDescription']), 'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']), 'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']), @@ -3038,26 +3041,28 @@ class core extends common } // Importe le module else { - // Id du module, et valeurs en sortie de la page si il s'agit d'un module de page + // Id du module, et valeurs en sortie de la page s'il s'agit d'un module de page if ($access and $this->getData(['page', $this->getUrl(0), 'moduleId'])) { $moduleId = $this->getData(['page', $this->getUrl(0), 'moduleId']); + + // Construit un meta absent + $metaDescription = $this->getData(['page', $this->getUrl(0), 'moduleId']) === 'blog' && !empty($this->getUrl(1)) && in_array($this->getUrl(1), $this->getData(['module'])) + ? strip_tags(substr($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'content']), 0, 159)) + : $this->getData(['page', $this->getUrl(0), 'metaDescription']); + $this->addOutput([ 'title' => $title, // Meta description = 160 premiers caractères de l'article - 'metaDescription' => $this->getData(['page', $this->getUrl(0), 'moduleId']) === 'blog' && !empty($this->getUrl(1)) && in_array($this->getUrl(1), $this->getData(['module'])) - ? strip_tags(substr($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'content']), 0, 159)) - : $this->getData(['page', $this->getUrl(0), 'metaDescription']), + 'content' => $pageContent, + 'metaDescription' => $metaDescription, + 'content' => $this->getPage($this->getUrl(0), self::$i18nContent) . $css, 'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']), 'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']), 'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']), 'disable' => $this->getData(['page', $this->getUrl(0), 'disable']), - 'contentRight' => $this->getData(['page', $this->getUrl(0), 'barRight']) - ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) - : '', - 'contentLeft' => $this->getData(['page', $this->getUrl(0), 'barLeft']) - ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) - : '' + 'contentRight' => $contentRight . $cssRight, + 'contentLeft' => $contentLeft . $cssLeft, ]); } else { $moduleId = $this->getUrl(0); From ab186d190e086d90f04ba883850b6b87d21a9f73 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Wed, 15 Feb 2023 19:29:12 +0100 Subject: [PATCH 6/9] showInLine style Function --- core/Untitled-1 | 8 ----- core/core.php | 69 +++++++++++++++++--------------------------- core/layout/main.php | 1 + 3 files changed, 28 insertions(+), 50 deletions(-) delete mode 100644 core/Untitled-1 diff --git a/core/Untitled-1 b/core/Untitled-1 deleted file mode 100644 index 09a24eb1..00000000 --- a/core/Untitled-1 +++ /dev/null @@ -1,8 +0,0 @@ -// Créer les styles externes -if ($this->getData(['page', $this->getUrl(0), 'css' ])) { - $stylePath = self::TEMP_DIR . uniqid() . '.css'; - file_put_contents($stylePath, html_entity_decode($this->getData(['page', $this->getUrl(0), 'css']))); - $this->addOutput([ - 'style' => $stylePath - ]); -} \ No newline at end of file diff --git a/core/core.php b/core/core.php index fc301b13..a2ba5f5d 100644 --- a/core/core.php +++ b/core/core.php @@ -117,6 +117,7 @@ class common 'showPageContent' => false, 'state' => false, 'style' => '', + 'inlineStyle' => '', 'title' => null, // Null car un titre peut être vide // Trié par ordre d'exécution @@ -1269,34 +1270,6 @@ class common $zip->close(); } - /** - * Summary of dateUTF8 - * @param mixed $format - * @param mixed $date time() - * @param mixed $scope UI ou Content - * @return string Date formatée - */ - public static function showDate($format, $date, $scope = "UI") - { - $d = new DateTime(time()); - $d->format($format); - - /* - $d = datefmt_create( - self::$i18nUI, - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - self::$timezone, - IntlDateFormatter::GREGORIAN, - $format - ); - exit (datefmt_format($d, $date)); - //return datefmt_format($d, $date); - */ - - } - - // Layout remplace la classe précédente @@ -2339,6 +2312,19 @@ class common } } + /** + * Affiche le style interne des pages + */ + public function showInlineStyle() + { + // Import des styles liés à la page + if ($this->output['inlineStyle']) { + foreach($this->output['inlineStyle'] as $style) { + echo ''; + } + } + } + /** * Importe les polices de carcatères */ @@ -3005,18 +2991,18 @@ class core extends common // Importe la page simple sans module ou avec un module inexistant // Importe le CSS de la page principale - $css = $this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']); - $css = strpos($css, '' : $css; - $pageContent = $this->getPage($this->getUrl(0), self::$i18nContent) . $css; + $pageContent = $this->getPage($this->getUrl(0), self::$i18nContent); + $inlineStyle[] = $this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']); + // $css = strpos($css, '' : $css; // Importe le CSS des barres $contentRight = $this->getData(['page', $this->getUrl(0), 'barRight']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) : ''; - $cssRight = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']); - $cssRight = strpos($cssRight, '' : $cssRight; + $inlineStyle[] = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']); + //$cssRight = strpos($cssRight, '' : $cssRight; $contentLeft = $this->getData(['page', $this->getUrl(0), 'barLeft']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) : ''; - $cssLeft = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']); - $cssLeft = strpos($cssRight, '' : $cssLeft; + $inlineStyle[] = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']); + //$cssLeft = strpos($cssRight, '' : $cssLeft; if ( $this->getData(['page', $this->getUrl(0)]) !== null @@ -3034,8 +3020,9 @@ class core extends common 'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']), 'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']), 'disable' => $this->getData(['page', $this->getUrl(0), 'disable']), - 'contentRight' => $contentRight . $cssRight, - 'contentLeft' => $contentLeft . $cssLeft, + 'contentRight' => $contentRight, + 'contentLeft' => $contentLeft, + 'inlineStyle' => $inlineStyle, ]); } @@ -3056,13 +3043,13 @@ class core extends common // Meta description = 160 premiers caractères de l'article 'content' => $pageContent, 'metaDescription' => $metaDescription, - 'content' => $this->getPage($this->getUrl(0), self::$i18nContent) . $css, 'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']), 'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']), 'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']), 'disable' => $this->getData(['page', $this->getUrl(0), 'disable']), - 'contentRight' => $contentRight . $cssRight, - 'contentLeft' => $contentLeft . $cssLeft, + 'contentRight' => $contentRight, + 'contentLeft' => $contentLeft, + 'inlineStyle' => $inlineStyle, ]); } else { $moduleId = $this->getUrl(0); @@ -3231,7 +3218,6 @@ class core extends common } } } - // Erreurs if ($access === 'login') { http_response_code(302); @@ -3290,7 +3276,6 @@ class core extends common 'metaDescription' => $this->getData(['locale', 'metaDescription']) ]); } - ; switch ($this->output['display']) { // Layout brut case self::DISPLAY_RAW: diff --git a/core/layout/main.php b/core/layout/main.php index f0b3474f..ae669e08 100644 --- a/core/layout/main.php +++ b/core/layout/main.php @@ -22,6 +22,7 @@ showStyle(); ?> + showInlineStyle(); ?> Date: Wed, 15 Feb 2023 19:33:02 +0100 Subject: [PATCH 7/9] changes --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 8e8db34f..8f8889ed 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,8 @@ - Contrôle des prérequis, Zwii ne démarre pas si la version de PHP n'est pas conforme ou si un module PHP nécessaire n'est pas installé. ### Nouveautés : - Paramétrage du délai de recherche automatique d'une mise à jour, tous les jours, deux jours, quatre jours, toutes les semaines, tous les mois. +### Corrections : +- Mauvais affichage du script ou du CSS déclaré dans une page. ## Version 12.2.03 - Corrections de bugs consécutifs au changement de format de languages.json From a3fdb3bc1e44bb52c3a6f90bca676416db80d2e7 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Wed, 15 Feb 2023 19:52:33 +0100 Subject: [PATCH 8/9] Edition de page ok --- core/core.php | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/core/core.php b/core/core.php index a2ba5f5d..6b722ec8 100644 --- a/core/core.php +++ b/core/core.php @@ -1077,16 +1077,12 @@ class common case 'image/jpeg': case 'image/jpg': return (imagejpeg($virtual_image, $dest)); - break; case 'image/png': return (imagepng($virtual_image, $dest)); - break; case 'image/gif': return (imagegif($virtual_image, $dest)); - break; case 'webp': $source_image = imagecreatefromwebp($src); - break; } } else { return (false); @@ -2319,7 +2315,7 @@ class common { // Import des styles liés à la page if ($this->output['inlineStyle']) { - foreach($this->output['inlineStyle'] as $style) { + foreach ($this->output['inlineStyle'] as $style) { echo ''; } } @@ -2988,22 +2984,15 @@ class core extends common ' › ' . $this->getData(['page', $this->getUrl(0), 'title']); } - // Importe la page simple sans module ou avec un module inexistant - - // Importe le CSS de la page principale - $pageContent = $this->getPage($this->getUrl(0), self::$i18nContent); - $inlineStyle[] = $this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']); - // $css = strpos($css, '' : $css; + // Importe le CSS des barres $contentRight = $this->getData(['page', $this->getUrl(0), 'barRight']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) : ''; $inlineStyle[] = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']); - //$cssRight = strpos($cssRight, '' : $cssRight; - $contentLeft = $this->getData(['page', $this->getUrl(0), 'barLeft']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) : ''; $inlineStyle[] = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']); - //$cssLeft = strpos($cssRight, '' : $cssLeft; + // Importe la page simple sans module ou avec un module inexistant if ( $this->getData(['page', $this->getUrl(0)]) !== null and ($this->getData(['page', $this->getUrl(0), 'moduleId']) === '' @@ -3012,6 +3001,10 @@ class core extends common and $access ) { + // Importe le CSS de la page principale + $pageContent = $this->getPage($this->getUrl(0), self::$i18nContent); + $inlineStyle[] = $this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']); + $this->addOutput([ 'title' => $title, 'content' => $pageContent, @@ -3038,6 +3031,10 @@ class core extends common ? strip_tags(substr($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'content']), 0, 159)) : $this->getData(['page', $this->getUrl(0), 'metaDescription']); + // Importe le CSS de la page principale + $pageContent = $this->getPage($this->getUrl(0), self::$i18nContent); + $inlineStyle[] = $this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']); + $this->addOutput([ 'title' => $title, // Meta description = 160 premiers caractères de l'article From aa5049555524a49168c94216ce0a3f61dc7228bf Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Thu, 16 Feb 2023 11:52:40 +0100 Subject: [PATCH 9/9] Js include in page okay --- core/core.php | 36 +++++++++++++++++++++++++----------- core/module/page/page.php | 4 ++-- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/core/core.php b/core/core.php index 6b722ec8..147901f8 100644 --- a/core/core.php +++ b/core/core.php @@ -117,7 +117,8 @@ class common 'showPageContent' => false, 'state' => false, 'style' => '', - 'inlineStyle' => '', + 'inlineStyle' => [], + 'inlineScript' => [], 'title' => null, // Null car un titre peut être vide // Trié par ordre d'exécution @@ -2286,11 +2287,14 @@ class common * Affiche le script */ public function showScript() - { + { ob_start(); require 'core/core.js.php'; $coreScript = ob_get_clean(); - echo ''; + if ($this->output['inlineScript']) { + $inlineScript = implode($this->output['inlineScript']); + } + echo ''; } /** @@ -2316,13 +2320,16 @@ class common // Import des styles liés à la page if ($this->output['inlineStyle']) { foreach ($this->output['inlineStyle'] as $style) { - echo ''; + if ($style) { + echo ''; + } + } } } /** - * Importe les polices de carcatères + * Importe les polices de caractères */ public function showFonts() { @@ -2984,13 +2991,21 @@ class core extends common ' › ' . $this->getData(['page', $this->getUrl(0), 'title']); } - - // Importe le CSS des barres + + // Importe le style de la page principale + $inlineStyle[] = $this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']); + // Importe le script de la page principale + $inlineScript[] = $this->getData(['page', $this->getUrl(0), 'js']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'js']); + + // Importe le contenu, le CSS et le script des barres $contentRight = $this->getData(['page', $this->getUrl(0), 'barRight']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) : ''; $inlineStyle[] = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']); + $inlineScript[] = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'js']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'js']); $contentLeft = $this->getData(['page', $this->getUrl(0), 'barLeft']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) : ''; $inlineStyle[] = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']); + $inlineScript[] = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'js']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'js']); + // Importe la page simple sans module ou avec un module inexistant if ( @@ -3002,12 +3017,10 @@ class core extends common ) { // Importe le CSS de la page principale - $pageContent = $this->getPage($this->getUrl(0), self::$i18nContent); - $inlineStyle[] = $this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']); $this->addOutput([ 'title' => $title, - 'content' => $pageContent, + 'content' => $this->getPage($this->getUrl(0), self::$i18nContent), 'metaDescription' => $this->getData(['page', $this->getUrl(0), 'metaDescription']), 'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']), 'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']), @@ -3016,6 +3029,7 @@ class core extends common 'contentRight' => $contentRight, 'contentLeft' => $contentLeft, 'inlineStyle' => $inlineStyle, + 'inlineScript' => $inlineScript, ]); } @@ -3033,7 +3047,6 @@ class core extends common // Importe le CSS de la page principale $pageContent = $this->getPage($this->getUrl(0), self::$i18nContent); - $inlineStyle[] = $this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']); $this->addOutput([ 'title' => $title, @@ -3047,6 +3060,7 @@ class core extends common 'contentRight' => $contentRight, 'contentLeft' => $contentLeft, 'inlineStyle' => $inlineStyle, + 'inlineScript' => $inlineScript, ]); } else { $moduleId = $this->getUrl(0); diff --git a/core/module/page/page.php b/core/module/page/page.php index 9cdaa197..f62b3117 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -492,8 +492,8 @@ class page extends common 'hideMenuHead' => $this->getinput('pageEditHideMenuHead', helper::FILTER_BOOLEAN), 'hideMenuChildren' => $this->getinput('pageEditHideMenuChildren', helper::FILTER_BOOLEAN), 'extraPosition' => $this->getinput('pageEditExtraPosition', helper::FILTER_BOOLEAN), - 'css' => $this->getData(['page', $this->getUrl(2), 'css']), - 'js' => $this->getData(['page', $this->getUrl(2), 'js']), + 'css' => $this->getData(['page', $this->getUrl(2), 'css']) == null ? '' : $this->getData(['page', $this->getUrl(2), 'css']), + 'js' => $this->getData(['page', $this->getUrl(2), 'js']) == null ? '' : $this->getData(['page', $this->getUrl(2), 'js']), ] ]);