<?php
/*
* OIDplus 2.0
* Copyright 2019 Daniel Marschall, ViaThinkSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use MatthiasMullie\Minify;
require_once __DIR__ . '/includes/oidplus.inc.php';
require_once __DIR__ . '/3p/minify/path-converter/ConverterInterface.php';
require_once __DIR__ . '/3p/minify/path-converter/Converter.php';
require_once __DIR__ . '/3p/minify/src/Minify.php';
require_once __DIR__ . '/3p/minify/src/CSS.php';
require_once __DIR__ . '/3p/minify/src/Exception.php';
$out = '';
# ---
$do_minify = OIDplus::baseConfig()->getValue('MINIFY_CSS', true);
function process_file($filename) {
global $do_minify;
if ($do_minify) {
$minifier = new Minify\CSS($filename);
$cont = $minifier->minify();
} else {
}
return $cont."\n\n";
}
# ---
// Third-party products
$out .= process_file(__DIR__ . '/3p/jstree/themes/default/style'.($do_minify ? '.min' : '').'.css');
$out .= process_file(__DIR__ . '/3p/jquery-ui/jquery-ui'.($do_minify ? '.min' : '').'.css');
$out .= process_file(__DIR__ . '/3p/bootstrap4/css/bootstrap'.($do_minify ? '.min' : '').'.css');
// Find out base CSS
if (isset($_REQUEST['theme'])) {
$theme = $_REQUEST['theme'];
if (strpos($theme,'/') !== false) $theme = 'default';
if (strpos($theme,'\\') !== false) $theme = 'default';
if (strpos($theme,'..') !== false) $theme = 'default';
if (!is_dir(__DIR__
.'/plugins/design/'.$theme)) $theme = 'default';
} else {
$theme = 'default';
}
$base_css = __DIR__ . '/plugins/design/'.$theme.'/oidplus_base.css';
// OIDplus basic definitions
if (file_exists(__DIR__
. '/userdata/styles/oidplus_base.css')) {
$out .= process_file(__DIR__ . '/userdata/styles/oidplus_base.css');
} else {
$out .= process_file($base_css);
}
// Then plugins
$manifests = OIDplus::getAllPluginManifests('*Pages', true);
foreach ($manifests as $manifest) {
foreach ($manifest->getCSSFiles() as $css_file) {
$out .= process_file($css_file);
}
}
// Now user-defined definitions
if (file_exists(__DIR__
. '/userdata/styles/oidplus_add.css')) {
$out .= process_file(__DIR__ . '/userdata/styles/oidplus_add.css');
}
# ---
$inv = isset($_REQUEST['invert']) ?
$_REQUEST['invert'] : 0;
if ($inv != 0) {
$out = invertColorsOfCSS($out);
}
$hs = isset($_REQUEST['h_shift']) ?
$_REQUEST['h_shift'] : 0;
$ss = isset($_REQUEST['s_shift']) ?
$_REQUEST['s_shift'] : 0;
$vs = isset($_REQUEST['v_shift']) ?
$_REQUEST['v_shift'] : 0;
if (($hs != 0) ||($ss != 0) || ($vs != 0)) {
$out = changeHueOfCSS($out, $hs, $ss, $vs);
}
# ---
httpOutWithETag($out, 'text/css', 'oidplus.css');