getModuleManager()->getLoadedModules() as $name => $module) { if ($module->hasJs()) { $list[] = 'js/' . $name . '/module.js'; } } return $list; } public static function sendMinified() { return self::send(true); } public static function send($minified = false) { header('Content-Type: application/javascript'); $basedir = Icinga::app()->getBootstrapDirecory(); $js = $out = ''; $min = $minified ? '.min' : ''; // TODO: Cache header header('Content-Type: application/javascript'); $cacheFile = '/tmp/cache_icinga' . $min . '.js'; if (file_exists($cacheFile)) { readfile($cacheFile); exit; } // We do not minify vendor files foreach (self::$vendorFiles as $file) { $out .= file_get_contents($basedir . '/' . $file . $min . '.js'); } foreach (self::$jsFiles as $file) { $js .= file_get_contents($basedir . '/' . $file); } foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $name => $module) { if ($module->hasJs()) { $js .= file_get_contents($module->getJsFilename()); } } if ($minified) { require_once ICINGA_LIBDIR . '/vendor/JShrink/Minifier.php'; $out .= Minifier::minify($js, array('flaggedComments' => false)); } else { $out .= $js; } // Not yet, this is for tests only. Waiting for Icinga\Web\Cache // file_put_contents($cacheFile, $out); echo $out; } }