Fix JS support for modules
This commit is contained in:
parent
aa6d6b1d41
commit
3059228378
|
@ -163,6 +163,7 @@ class Module
|
|||
$this->name = $name;
|
||||
$this->basedir = $basedir;
|
||||
$this->cssdir = $basedir . '/public/css';
|
||||
$this->jsdir = $basedir . '/public/js';
|
||||
$this->libdir = $basedir . '/library';
|
||||
$this->configdir = $basedir . '/config';
|
||||
$this->localedir = $basedir . '/application/locale';
|
||||
|
@ -250,6 +251,26 @@ class Module
|
|||
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
|
||||
*
|
||||
|
|
|
@ -31,7 +31,18 @@ class JavaScript
|
|||
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue