diff --git a/core/core.php b/core/core.php index 0be84de..75c55ba 100644 --- a/core/core.php +++ b/core/core.php @@ -107,22 +107,26 @@ class common { 'state' => false, 'style' => '', 'title' => null, // Null car un titre peut être vide - // Trié par ordre d'exécution 'vendor' => [ 'jquery', + 'swiper', + 'simplelightbox' + ], + 'vendorCss' => [ 'normalize', 'lity', - 'filemanager', - //'flatpickr', Appelé par les modules désactivé par défaut - // 'tinycolorpicker', Désactivé par défaut - // 'tinymce', Désactivé par défaut - // 'codemirror', // Désactivé par défaut 'tippy', 'zwiico', - 'imagemap', 'simplelightbox', 'swiper' ], + // Trié par ordre d'exécution + 'vendorJsBody' => [ + 'lity', + 'filemanager', + 'tippy', + 'imagemap', + ], 'view' => '' ]; // Langues proposées, conserver ces 5 variables $i18nList... @@ -2134,9 +2138,8 @@ class common { echo ''; } } - /** - * Affiche l'import des librairies + * Affiche dans le head l'import des scripts déclarés dans 'vendor' et ceux déclarés dans le dossier vendor des modules */ public function showVendor() { // Variables partagées @@ -2149,39 +2152,86 @@ class common { $vars .= 'var privateKey = ' . json_encode(md5_file(self::DATA_DIR.'core.json')) . ';'; } echo ''; - // Librairies - $moduleId = $this->getData(['page', $this->getUrl(0), 'moduleId']); + // Scripts + $moduleId = $this->getData(['page', $this->getUrl(0), 'moduleId']); foreach($this->output['vendor'] as $vendorName) { // Coeur if(file_exists('core/vendor/' . $vendorName . '/inc.json')) { $vendorPath = 'core/vendor/' . $vendorName . '/'; + } + // Modules + elseif( $moduleId + AND in_array($moduleId, self::$coreModuleIds) === false + AND file_exists('module/' . $moduleId . '/vendor/' . $vendorName . '/inc.json') + ) { + $vendorPath = 'module/' . $moduleId . '/vendor/' . $vendorName . '/'; + } else { + continue; } - // Module - elseif( - $moduleId + $vendorFiles = json_decode(file_get_contents($vendorPath . 'inc.json')); + foreach($vendorFiles as $vendorFile) { + if( pathinfo($vendorFile, PATHINFO_EXTENSION) === 'js') { + echo ''; + } + } + } + } + /** + /** + * Affiche dans le head l'import des styles déclarés dans 'vendorCss' et ceux déclarés dans le dossier vendor des modules + */ + public function showVendorCss() { + foreach($this->output['vendorCss'] as $vendorName) { + if(file_exists('core/vendor/' . $vendorName . '/inc.json')) { + $vendorPath = 'core/vendor/' . $vendorName . '/'; + } else { + continue; + } + $vendorFiles = json_decode(file_get_contents($vendorPath . 'inc.json')); + foreach($vendorFiles as $vendorFile) { + if( pathinfo($vendorFile, PATHINFO_EXTENSION) === 'css') { + // Force le rechargement lors d'une mise à jour du jeu d'icônes + $reload = $vendorPath === 'core/vendor/zwiico/' + ? '?' . md5_file('core/vendor/zwiico/css/zwiico-codes.css') + : ''; + echo ''; + } + } + } + // Css du module avec fichier inc.json + $moduleId = $this->getData(['page', $this->getUrl(0), 'moduleId']); + foreach($this->output['vendor'] as $vendorName) { + if( $moduleId AND in_array($moduleId, self::$coreModuleIds) === false AND file_exists('module/' . $moduleId . '/vendor/' . $vendorName . '/inc.json') ) { $vendorPath = 'module/' . $moduleId . '/vendor/' . $vendorName . '/'; } - // Sinon continue else { continue; } - // Détermine le type d'import en fonction de l'extension de la librairie $vendorFiles = json_decode(file_get_contents($vendorPath . 'inc.json')); foreach($vendorFiles as $vendorFile) { - switch(pathinfo($vendorFile, PATHINFO_EXTENSION)) { - case 'css': - // Force le rechargement lors d'une mise à jour du jeu d'icônes - $reload = $vendorPath === 'core/vendor/zwiico/' - ? '?' . md5_file('core/vendor/zwiico/css/zwiico-codes.css') - : ''; - echo ''; - break; - case 'js': - echo ''; - break; + if(pathinfo($vendorFile, PATHINFO_EXTENSION) === 'css') { + echo ''; + } + } + } + } + /** + * Affiche à la fin du body l'import des scripts déclarés dans 'vendorJsBody' + */ + public function showVendorJsBody() { + foreach($this->output['vendorJsBody'] as $vendorName) { + if(file_exists('core/vendor/' . $vendorName . '/inc.json')) { + $vendorPath = 'core/vendor/' . $vendorName . '/'; + } else { + continue; + } + $vendorFiles = json_decode(file_get_contents($vendorPath . 'inc.json')); + foreach($vendorFiles as $vendorFile) { + if(pathinfo($vendorFile, PATHINFO_EXTENSION) === 'js') { + echo ''; } } } diff --git a/core/layout/blank.php b/core/layout/blank.php index 6e80095..a366902 100644 --- a/core/layout/blank.php +++ b/core/layout/blank.php @@ -6,17 +6,19 @@ showMetaTitle(); $this->showFavicon(); - $this->showVendor(); ?> - showStyle(); ?> + showStyle(); + $this->showVendorCss();?> + showVendor(); ?> showContent(); ?> showScript(); ?> +showVendorJsBody(); ?> diff --git a/core/layout/light.php b/core/layout/light.php index 63e32af..26631c5 100644 --- a/core/layout/light.php +++ b/core/layout/light.php @@ -6,14 +6,15 @@ showMetaTitle(); $this->showFavicon(); - $this->showVendor(); ?> - showStyle(); ?> + showStyle(); + $this->showVendorCss(); ?> + showVendor(); ?> showNotification(); ?> @@ -21,5 +22,6 @@
showContent(); ?>
showScript(); ?> +showVendorJsBody(); ?> diff --git a/core/layout/main.php b/core/layout/main.php index 81e464f..33e3084 100644 --- a/core/layout/main.php +++ b/core/layout/main.php @@ -12,15 +12,14 @@ else { echo ''; } $this->showMetaTitle(); if( $this->getData(['config', 'social', 'headFacebook' ]) === true) $this->showMetaPropertyFacebook(); ?> - showFavicon(); - $this->showVendor(); echo PHP_EOL; - ?> + showFavicon(); ?> - showStyle(); ?> + showStyle(); + $this->showVendorCss(); echo PHP_EOL;?> + showVendor(); ?> getData(['page', $this->getUrl(0), 'moduleId']) === 'blog' OR $this->getData(['page', $this->getUrl(0), 'moduleId']) === 'news' ) @@ -246,6 +245,6 @@ else { echo ''; } showCookies(); ?> showScript();?> - + showVendorJsBody(); ?>