diff options
-rw-r--r-- | inc/module.inc.php | 39 | ||||
-rw-r--r-- | inc/render.inc.php | 14 | ||||
-rw-r--r-- | modules-available/bootstrap_datepicker/config.json | 8 | ||||
-rw-r--r-- | modules-available/bootstrap_dialog/config.json | 8 | ||||
-rw-r--r-- | modules-available/bootstrap_multiselect/config.json | 8 | ||||
-rw-r--r-- | modules-available/bootstrap_switch/config.json | 9 | ||||
-rw-r--r-- | modules-available/bootstrap_timepicker/config.json | 8 | ||||
-rw-r--r-- | modules-available/js_chart/config.json | 9 | ||||
-rw-r--r-- | modules-available/js_circles/config.json | 9 | ||||
-rw-r--r-- | modules-available/js_jqueryui/config.json | 8 | ||||
-rw-r--r-- | modules-available/js_moment/config.json | 8 | ||||
-rw-r--r-- | modules-available/js_selectize/config.json | 8 | ||||
-rw-r--r-- | modules-available/js_stupidtable/config.json | 9 | ||||
-rw-r--r-- | modules-available/js_vis/config.json | 8 |
14 files changed, 133 insertions, 20 deletions
diff --git a/inc/module.inc.php b/inc/module.inc.php index 597cfb57..52646983 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,29 @@ class Module return 'modules/' . $this->name; } + public function getScripts($externalOnly) + { + error_log($this->getIdentifier() . ' = ' . ($externalOnly ? 'true' : 'false')); + if (!$externalOnly) { + if (!isset($this->scripts['clientscript.js']) && file_exists($this->getDir() . '/clientscript.js')) { + $this->scripts['clientscript.js'] = false; + } + return array_keys($this->scripts); + } + error_log('Pre: ' . implode(', ', array_keys($this->scripts))); + error_log('Post: ' . implode(', ', array_keys(array_filter($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)); + } + } diff --git a/inc/render.inc.php b/inc/render.inc.php index 72993ab5..53e2f314 100644 --- a/inc/render.inc.php +++ b/inc/render.inc.php @@ -51,7 +51,9 @@ class Render public static function output() { Header('Content-Type: text/html; charset=utf-8'); + /* @var $modules Module[] */ $modules = array_reverse(Module::getActivated()); + $pageModule = Page::getModule(); $title = Property::get('page-title-prefix', ''); $bgcolor = Property::get('logo-background', ''); if (!empty($bgcolor) || !empty($title)) { @@ -79,9 +81,9 @@ class Render '; // Include any module specific styles foreach ($modules as $module) { - $file = $module->getDir() . '/style.css'; - if (file_exists($file)) { - echo '<link href="', $file, '" rel="stylesheet" media="screen">'; + $files = $module->getCss($module != $pageModule); + foreach ($files as $file) { + echo '<link href="', $module->getDir(), '/', $file, '" rel="stylesheet" media="screen">'; } } echo ' @@ -109,9 +111,9 @@ class Render <script src="script/collapse.js"></script> '; foreach ($modules as $module) { - $file = $module->getDir() . '/clientscript.js'; - if (file_exists($file)) { - echo '<script src="', $file, '"></script>'; + $files = $module->getScripts($module != $pageModule); + foreach ($files as $file) { + echo '<script src="', $module->getDir(), '/', $file, '"></script>'; } } echo diff --git a/modules-available/bootstrap_datepicker/config.json b/modules-available/bootstrap_datepicker/config.json index d1261653..5a0c7960 100644 --- a/modules-available/bootstrap_datepicker/config.json +++ b/modules-available/bootstrap_datepicker/config.json @@ -1,3 +1,9 @@ { - "dependencies" : [] + "dependencies" : [], + "css": { + "style.css": true + }, + "scripts": { + "clientscript.js": true + } } diff --git a/modules-available/bootstrap_dialog/config.json b/modules-available/bootstrap_dialog/config.json index d1261653..5a0c7960 100644 --- a/modules-available/bootstrap_dialog/config.json +++ b/modules-available/bootstrap_dialog/config.json @@ -1,3 +1,9 @@ { - "dependencies" : [] + "dependencies" : [], + "css": { + "style.css": true + }, + "scripts": { + "clientscript.js": true + } } diff --git a/modules-available/bootstrap_multiselect/config.json b/modules-available/bootstrap_multiselect/config.json index d1261653..5a0c7960 100644 --- a/modules-available/bootstrap_multiselect/config.json +++ b/modules-available/bootstrap_multiselect/config.json @@ -1,3 +1,9 @@ { - "dependencies" : [] + "dependencies" : [], + "css": { + "style.css": true + }, + "scripts": { + "clientscript.js": true + } } diff --git a/modules-available/bootstrap_switch/config.json b/modules-available/bootstrap_switch/config.json index 9e26dfee..de4d37b4 100644 --- a/modules-available/bootstrap_switch/config.json +++ b/modules-available/bootstrap_switch/config.json @@ -1 +1,8 @@ -{}
\ No newline at end of file +{ + "css": { + "style.css": true + }, + "scripts": { + "clientscript.js": true + } +}
\ No newline at end of file diff --git a/modules-available/bootstrap_timepicker/config.json b/modules-available/bootstrap_timepicker/config.json index d1261653..5a0c7960 100644 --- a/modules-available/bootstrap_timepicker/config.json +++ b/modules-available/bootstrap_timepicker/config.json @@ -1,3 +1,9 @@ { - "dependencies" : [] + "dependencies" : [], + "css": { + "style.css": true + }, + "scripts": { + "clientscript.js": true + } } diff --git a/modules-available/js_chart/config.json b/modules-available/js_chart/config.json index 9e26dfee..de4d37b4 100644 --- a/modules-available/js_chart/config.json +++ b/modules-available/js_chart/config.json @@ -1 +1,8 @@ -{}
\ No newline at end of file +{ + "css": { + "style.css": true + }, + "scripts": { + "clientscript.js": true + } +}
\ No newline at end of file diff --git a/modules-available/js_circles/config.json b/modules-available/js_circles/config.json index 9e26dfee..de4d37b4 100644 --- a/modules-available/js_circles/config.json +++ b/modules-available/js_circles/config.json @@ -1 +1,8 @@ -{}
\ No newline at end of file +{ + "css": { + "style.css": true + }, + "scripts": { + "clientscript.js": true + } +}
\ No newline at end of file diff --git a/modules-available/js_jqueryui/config.json b/modules-available/js_jqueryui/config.json index d1261653..5a0c7960 100644 --- a/modules-available/js_jqueryui/config.json +++ b/modules-available/js_jqueryui/config.json @@ -1,3 +1,9 @@ { - "dependencies" : [] + "dependencies" : [], + "css": { + "style.css": true + }, + "scripts": { + "clientscript.js": true + } } diff --git a/modules-available/js_moment/config.json b/modules-available/js_moment/config.json index d1261653..5a0c7960 100644 --- a/modules-available/js_moment/config.json +++ b/modules-available/js_moment/config.json @@ -1,3 +1,9 @@ { - "dependencies" : [] + "dependencies" : [], + "css": { + "style.css": true + }, + "scripts": { + "clientscript.js": true + } } diff --git a/modules-available/js_selectize/config.json b/modules-available/js_selectize/config.json index d1261653..5a0c7960 100644 --- a/modules-available/js_selectize/config.json +++ b/modules-available/js_selectize/config.json @@ -1,3 +1,9 @@ { - "dependencies" : [] + "dependencies" : [], + "css": { + "style.css": true + }, + "scripts": { + "clientscript.js": true + } } diff --git a/modules-available/js_stupidtable/config.json b/modules-available/js_stupidtable/config.json index 9e26dfee..cf932d7e 100644 --- a/modules-available/js_stupidtable/config.json +++ b/modules-available/js_stupidtable/config.json @@ -1 +1,8 @@ -{}
\ No newline at end of file +{ + "css": { + "style.css": true + }, + "scripts": { + "clientscript.js": true + } +}
\ No newline at end of file diff --git a/modules-available/js_vis/config.json b/modules-available/js_vis/config.json index ccdf64b7..3b027d31 100644 --- a/modules-available/js_vis/config.json +++ b/modules-available/js_vis/config.json @@ -1,3 +1,9 @@ { - "dependencies" : ["js_moment"] + "dependencies" : ["js_moment"], + "css": { + "style.css": true + }, + "scripts": { + "clientscript.js": true + } } |