diff options
Diffstat (limited to 'inc/module.inc.php')
-rw-r--r-- | inc/module.inc.php | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/inc/module.inc.php b/inc/module.inc.php index 597cfb57..7211c68c 100644 --- a/inc/module.inc.php +++ b/inc/module.inc.php @@ -142,13 +142,23 @@ class Module private $activated = false; private $dependencies = array(); private $name; + /** + * @var array assoc list of 'filename.css' => true|false (true = always load, false = only if module is main module) + */ + private $css = array(); + /** + * @var array assoc list of 'filename.js' => true|false (true = always load, false = only if module is main module) + */ + private $scripts = array(); private function __construct($name) { $file = 'modules/' . $name . '/config.json'; $json = @json_decode(@file_get_contents($file), true); - if (isset($json['dependencies']) && is_array($json['dependencies'])) { - $this->dependencies = $json['dependencies']; + foreach (['dependencies', 'css', 'scripts'] as $key) { + if (isset($json[$key]) && is_array($json[$key])) { + $this->$key = $json[$key]; + } } if (isset($json['category']) && is_string($json['category'])) { $this->category = $json['category']; @@ -251,4 +261,26 @@ class Module return 'modules/' . $this->name; } + public function getScripts($externalOnly) + { + if (!$externalOnly) { + if (!isset($this->scripts['clientscript.js']) && file_exists($this->getDir() . '/clientscript.js')) { + $this->scripts['clientscript.js'] = false; + } + return array_keys($this->scripts); + } + return array_keys(array_filter($this->scripts)); + } + + public function getCss($externalOnly) + { + if (!$externalOnly) { + if (!isset($this->css['style.css']) && file_exists($this->getDir() . '/style.css')) { + $this->css['style.css'] = false; + } + return array_keys($this->css); + } + return array_keys(array_filter($this->css)); + } + } |