From d57fe033269afc4202b44effc3720495562f5ebd Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 8 Jul 2021 16:57:47 +0200 Subject: [PATCH] use same method (prefer .min.js over .js) for app.js include in Etemplate and Framework fixes double include of /mail/js/app.js and /mail/js/app.min.js --- api/src/Etemplate.php | 9 +++------ api/src/Framework.php | 8 ++++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/api/src/Etemplate.php b/api/src/Etemplate.php index ec94c213d8..5bf84b6651 100644 --- a/api/src/Etemplate.php +++ b/api/src/Etemplate.php @@ -234,13 +234,10 @@ class Etemplate extends Etemplate\Widget\Template { // check if application of template has a app.js file --> load it, preferring local min file if there list($app) = explode('.',$this->name); - if (file_exists(EGW_SERVER_ROOT.'/'.$app.'/js/app.min.js')) + if (file_exists(EGW_SERVER_ROOT.($path = '/'.$app.'/js/app.min.js')) || + file_exists(EGW_SERVER_ROOT.($path = '/'.$app.'/js/app.js'))) { - Framework::includeJS('.','app.min',$app,true); - } - else if (file_exists(EGW_SERVER_ROOT.'/'.$app.'/js/app.js')) - { - Framework::includeJS('.','app',$app,true); + Framework::includeJS($path); } // Category styles Categories::css($app); diff --git a/api/src/Framework.php b/api/src/Framework.php index d50e989cbf..74db8d5a58 100644 --- a/api/src/Framework.php +++ b/api/src/Framework.php @@ -1490,7 +1490,7 @@ abstract class Framework extends Framework\Extra * @param string $app ='phpgwapi' application directory to search - default = phpgwapi * @param boolean $append =true should the file be added */ - static function includeJS($package, $file=null, $app='phpgwapi', $append=true) + static function includeJS($package, $file=null, $app='api', $append=true) { self::$js_include_mgr->include_js_file($package, $file, $app, $append); } @@ -1584,7 +1584,11 @@ abstract class Framework extends Framework\Extra } // try to add app specific js file - self::includeJS('.', 'app', $app); + if (file_exists(EGW_SERVER_ROOT.($path = '/'.$app.'/js/app.min.js')) || + file_exists(EGW_SERVER_ROOT.($path = '/'.$app.'/js/app.js'))) + { + self::includeJS($path); + } // add all js files from Framework::includeJS() $files = Framework\Bundle::js_includes(self::$js_include_mgr->get_included_files());