From 47657731433248410e681640b2a53c0783651134 Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Wed, 10 May 2017 17:36:05 +0200
Subject: Add support to declare multiple css/js per module with loading
condition:
A css/js can be declared to only load if the module in question is the
page module being rendered, or to always be loaded even if the module
is just a dependency. The second case is useful for plugin type
modules. See one of the config.json files updated in this commit on
how to specify css/js to load. true = always load, false = only if page
module.
---
inc/render.inc.php | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
(limited to 'inc/render.inc.php')
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 '';
+ $files = $module->getCss($module != $pageModule);
+ foreach ($files as $file) {
+ echo '';
}
}
echo '
@@ -109,9 +111,9 @@ class Render
';
foreach ($modules as $module) {
- $file = $module->getDir() . '/clientscript.js';
- if (file_exists($file)) {
- echo '';
+ $files = $module->getScripts($module != $pageModule);
+ foreach ($files as $file) {
+ echo '';
}
}
echo
--
cgit v1.2.3-55-g7522