From fc7687c07684110f66228f5f247873e5414d2225 Mon Sep 17 00:00:00 2001 From: Ortwin Pinke Date: Tue, 23 Feb 2021 20:25:55 +0100 Subject: [PATCH] add css and js file serving --- includes/config.plugin.php | 64 +++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/includes/config.plugin.php b/includes/config.plugin.php index 9b9c95b..4c9ff80 100644 --- a/includes/config.plugin.php +++ b/includes/config.plugin.php @@ -1,7 +1,69 @@ * - */ \ No newline at end of file + */ +if (!defined('CON_FRAMEWORK')) { + die('Illegal call'); +} + +$sPluginName = 'phpbo.cookie_consent'; + +function phpboccInjectFrontend($sHtml) { + $sInjection = ''; + $sInjection .= ''. "\n"; + $sInjection .= '' . "\n"; + $sInjection .= '' . "\n"; + $sInjection .= ''; + + + return str_replace('', $sInjection, $sHtml); +} + +function phpboccGetJs() { + if (isset($_GET['phpboccGetJs'])) { + $sFileContent = ''; + ob_end_clean(); + header("Content-Type: application/javascript"); + header("Cache-Control: max-age=604800, public"); + + switch ($_GET['phpboccGetJs']) { + case 'config.js': + $sFileContent = file_get_contents(dirname(__FILE__, 2).'/external/klaro/config.js'); + break; + case 'klaro.js': + $sFileContent = file_get_contents(dirname(__FILE__, 2).'/external/klaro/klaro.js'); + break; + default: + break; + } + echo $sFileContent; + die(); + } +} + +function phpboccGetCss() { + if (isset($_GET['phpboccGetCss'])) { + $sFileContent = ''; + ob_end_clean(); + header("Content-type: text/css; charset: UTF-8"); + header("Cache-Control: max-age=604800, public"); + + switch ($_GET['phpboccGetCss']) { + case 'klaro.css': + $sFileContent = file_get_contents(dirname(__FILE__, 2).'/external/klaro/klaro.css'); + break; + default: + break; + } + echo $sFileContent; + die(); + } +} + +$_cecRegistry->addChainFunction("Contenido.Frontend.HTMLCodeOutput", "phpboccInjectFrontend"); +$_cecRegistry->addChainFunction("Contenido.Frontend.AfterLoadPlugins", "phpboccGetJs"); +$_cecRegistry->addChainFunction("Contenido.Frontend.AfterLoadPlugins", "phpboccGetCss");