Fix JS support for modules

This commit is contained in:
Thomas Gelf 2014-03-19 16:06:21 +00:00
parent aa6d6b1d41
commit 3059228378
2 changed files with 33 additions and 1 deletions

View File

@ -163,6 +163,7 @@ class Module
$this->name = $name; $this->name = $name;
$this->basedir = $basedir; $this->basedir = $basedir;
$this->cssdir = $basedir . '/public/css'; $this->cssdir = $basedir . '/public/css';
$this->jsdir = $basedir . '/public/js';
$this->libdir = $basedir . '/library'; $this->libdir = $basedir . '/library';
$this->configdir = $basedir . '/config'; $this->configdir = $basedir . '/config';
$this->localedir = $basedir . '/application/locale'; $this->localedir = $basedir . '/application/locale';
@ -250,6 +251,26 @@ class Module
return $this->cssdir . '/module.less'; return $this->cssdir . '/module.less';
} }
/**
* Test if module provides js
*
* @return bool
*/
public function hasJs()
{
return file_exists($this->getJsFilename());
}
/**
* Returns the complete js file name
*
* @return string
*/
public function getJsFilename()
{
return $this->jsdir . '/module.js';
}
/** /**
* Getter for module name * Getter for module name
* *

View File

@ -31,7 +31,18 @@ class JavaScript
public static function listFiles() public static function listFiles()
{ {
return array_merge(self::$vendorFiles, self::$jsFiles); return array_merge(self::$vendorFiles, self::$jsFiles, self::listModuleFiles());
}
public static function listModuleFiles()
{
$list = array();
foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $name => $module) {
if ($module->hasJs()) {
$list[] = 'js/' . $name . '/module.js';
}
}
return $list;
} }
public static function sendMinified() public static function sendMinified()