diff --git a/api/src/Framework.php b/api/src/Framework.php index ef149a0a2b..8192d6460f 100644 --- a/api/src/Framework.php +++ b/api/src/Framework.php @@ -1240,9 +1240,9 @@ 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') + static function includeJS($package, $file=null, $app='phpgwapi', $append=true) { - self::$js_include_mgr->include_js_file($package, $file, $app); + self::$js_include_mgr->include_js_file($package, $file, $app, $append); } /** diff --git a/api/src/Framework/IncludeMgr.php b/api/src/Framework/IncludeMgr.php index 14009a73a7..d70a0dd399 100644 --- a/api/src/Framework/IncludeMgr.php +++ b/api/src/Framework/IncludeMgr.php @@ -252,14 +252,25 @@ class IncludeMgr /** * Includes the given module files - this function will have the task to * cache/shrink/concatenate the files in the future. + * + * @param array $modules pathes to include + * @param boolean $append =true false: prepend modules before already included ones, keeping their order */ - private function include_module(array $module) + private function include_module(array $modules, $append=true) { if (self::$DEBUG_MODE) { - foreach ($module as $path) + if ($append) { - $this->included_files[$path] = true; + foreach ($modules as $path) + { + $this->included_files[$path] = true; + } + } + else + { + $this->included_files = array_merge(array_combine($modules, array_fill(0, count($modules), true)), + $this->included_files); } } else @@ -346,8 +357,9 @@ class IncludeMgr * @param string $package package or complete path (relative to EGW_SERVER_ROOT) to be included * @param string|array $file =null file to be included - no ".js" on the end or array with get params * @param string $app ='phpgwapi' application directory to search - default = phpgwapi + * @param boolean $append =true true append file, false prepend (add as first) file used eg. for template itself */ - public function include_js_file($package, $file = null, $app = 'phpgwapi') + public function include_js_file($package, $file = null, $app = 'phpgwapi', $append=true) { // Translate the given parameters into a valid path - false is returned // if the file is not found or the file is already included/has already