Moved external code to internal PHP file

This commit is contained in:
Christian Wolf 2022-09-05 16:29:00 +02:00
parent 6fec5c16da
commit 84717425cc
2 changed files with 35 additions and 83 deletions

View File

@ -1,77 +0,0 @@
<?php
define('_JEXEC', 1);
define('JPATH_BASE', '../../../');
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
$container = \Joomla\CMS\Factory::getContainer();
$container->alias(\Joomla\Session\SessionInterface::class, 'session.web.site');
$mainframe = $container->get(\Joomla\CMS\Application\SiteApplication::class);
$template = $mainframe->getTemplate(true);
$params = $template->params;
header('content-type: text/css');
// duration of cached content (1 hour)
$offset = 60 * 60;
// cache control to process
header("Cache-Control: must-revalidate, max-age=$offset, public");
// expiration header format
// $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s",time() + $offset) . " GMT";
// send cache expiration header to broswer
// header($ExpStr);
$leftImageValue = empty($params['imgleft'])
? 'none'
: "url(\"" . JPATH_BASE . $params['imgleft'] . "\")";
$rightImageValue = empty($params['imgright'])
? 'none'
: "url(\"" . JPATH_BASE . $params['imgright'] . "\")";
?>
<?php if ($params['titlepage'] === '1') {
echo "#left-menu { display: none; }\n";
} ?>
:root {
--color-fg-top: <?php echo $params['topfgcolor1']; ?>;
--color-bg-top: <?php echo $params['topbgcolor1']; ?>;
--color-fg-top-dark: <?php echo $params['topfgcolor2']; ?>;
--color-bg-top-dark: <?php echo $params['topbgcolor2']; ?>;
--color-fg-top-light: <?php echo $params['topfgcolor3']; ?>;
--color-bg-top-light: <?php echo $params['topbgcolor3']; ?>;
--color-main: <?php echo $params['mainfgcolor']; ?>;
--color-main-link: <?php echo $params['mainlicolor']; ?>;
--color-header-link: <?php echo $params['headercolor']; ?>;
--color-page-bg-top: <?php echo $params['mainbgcolortop']; ?>;
--color-page-bg-bottom: <?php echo $params['mainbgcolorbot']; ?>;
--color-menu: <?php echo $params['fgcolor1']; ?>;
--color-menu-background: <?php echo $params['bgcolor1']; ?>;
--color-menu-active: <?php echo $params['fgcolor2']; ?>;
--color-menu-background-active: <?php echo $params['bgcolor2']; ?>;
--color-effect: <?php echo $params['fgeffect']; ?>;
--color-effect-background: <?php echo $params['bgeffect']; ?>;
--color-effect-header: <?php echo $params['fgeffecthdr']; ?>;
--color-effect-background-header: <?php echo $params['bgeffecthdr']; ?>;
--color-side-background: <?php echo $params['bgcolorside']; ?>;
--image-left-side: <?php echo $leftImageValue; ?>;
--image-right-side: <?php echo $rightImageValue; ?>;
}
<?php // Stop execution here, the rest is for debugging
exit(); ?>
:root {
--color-effect: blue;
--color-effect-background: red;
--color-effect-header: yellow;
--color-effect-background-header: green;
}

View File

@ -7,6 +7,7 @@ use Joomla\CMS\Uri\Uri;
//JHTML::_('behavior.framework', true);
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$wa = $this->getWebAssetManager();
// Add JavaScript Frameworks
JHtml::_('bootstrap.framework');
@ -25,11 +26,40 @@ JHtml::_('stylesheet', 'style.css', ['version' => 'auto', 'relative' => true]);
$doc->addStyleSheet(
$this->baseurl . '/media/system/css/joomla-fontawesome.css'
);
$doc->addStyleSheet(
$this->baseurl .
'/templates/slt/css/dynamic-styles.css.php?Itemid=' .
$app->input->getInt('Itemid')
);
$params = $this->params;
$leftImageValue = empty($params['imgleft'])
? 'none'
: "url(\"" . JPATH_BASE . $params['imgleft'] . "\")";
$rightImageValue = empty($params['imgright'])
? 'none'
: "url(\"" . JPATH_BASE . $params['imgright'] . "\")";
$wa->addInlineStyle(":root {
--color-fg-top: {$params['topfgcolor1']};
--color-bg-top: {$params['topbgcolor1']};
--color-fg-top-dark: {$params['topfgcolor2']};
--color-bg-top-dark: {$params['topbgcolor2']};
--color-fg-top-light: {$params['topfgcolor3']};
--color-bg-top-light: {$params['topbgcolor3']};
--color-main: {$params['mainfgcolor']};
--color-main-link: {$params['mainlicolor']};
--color-header-link: {$params['headercolor']};
--color-page-bg-top: {$params['mainbgcolortop']};
--color-page-bg-bottom: {$params['mainbgcolorbot']};
--color-menu: {$params['fgcolor1']};
--color-menu-background: {$params['bgcolor1']};
--color-menu-active: {$params['fgcolor2']};
--color-menu-background-active: {$params['bgcolor2']};
--color-effect: {$params['fgeffect']};
--color-effect-background: {$params['bgeffect']};
--color-effect-header: {$params['fgeffecthdr']};
--color-effect-background-header: {$params['bgeffecthdr']};
--color-side-background: {$params['bgcolorside']};
--image-left-side: {$leftImageValue};
--image-right-side: {$rightImageValue};
}");
// Add Javascript for mobile menu
JHtml::_('script', 'mobile.js', ['version' => 'auto', 'relative' => true]);
@ -40,7 +70,6 @@ JHtml::_('stylesheet', 'user.css', ['version' => 'auto', 'relative' => true]);
// Check for a custom js file
JHtml::_('script', 'user.js', ['version' => 'auto', 'relative' => true]);
?>
<?php echo '<!DOCTYPE html>'; ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" >