Rev 286 | Rev 307 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
112 | daniel-mar | 1 | <?php |
2 | |||
3 | /* |
||
4 | * OIDplus 2.0 |
||
5 | * Copyright 2019 Daniel Marschall, ViaThinkSoft |
||
6 | * |
||
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
8 | * you may not use this file except in compliance with the License. |
||
9 | * You may obtain a copy of the License at |
||
10 | * |
||
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
12 | * |
||
13 | * Unless required by applicable law or agreed to in writing, software |
||
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
16 | * See the License for the specific language governing permissions and |
||
17 | * limitations under the License. |
||
18 | */ |
||
19 | |||
20 | use MatthiasMullie\Minify; |
||
21 | |||
261 | daniel-mar | 22 | require_once __DIR__ . '/includes/oidplus.inc.php'; |
112 | daniel-mar | 23 | require_once __DIR__ . '/3p/minify/path-converter/ConverterInterface.php'; |
24 | require_once __DIR__ . '/3p/minify/path-converter/Converter.php'; |
||
25 | require_once __DIR__ . '/3p/minify/src/Minify.php'; |
||
26 | require_once __DIR__ . '/3p/minify/src/CSS.php'; |
||
27 | require_once __DIR__ . '/3p/minify/src/Exception.php'; |
||
28 | |||
29 | error_reporting(E_ALL); |
||
30 | |||
142 | daniel-mar | 31 | $out = ''; |
112 | daniel-mar | 32 | |
142 | daniel-mar | 33 | # --- |
112 | daniel-mar | 34 | |
142 | daniel-mar | 35 | function process_file($filename) { |
215 | daniel-mar | 36 | $dir = dirname((strpos($filename, __DIR__.'/') === 0) ? substr($filename, strlen(__DIR__.'/')) : $filename); |
261 | daniel-mar | 37 | if (OIDplus::baseConfig()->getValue('MINIFY_CSS', true)) { |
215 | daniel-mar | 38 | $minifier = new Minify\CSS($filename); |
142 | daniel-mar | 39 | $cont = $minifier->minify(); |
40 | $cont = str_ireplace("url(data:", "url###(data:", $cont); |
||
215 | daniel-mar | 41 | $cont = str_ireplace("url(", "url(".$dir.'/', $cont); |
142 | daniel-mar | 42 | } else { |
215 | daniel-mar | 43 | $cont = file_get_contents($filename); |
142 | daniel-mar | 44 | $cont = str_ireplace('url("data:', 'url###("data:', $cont); |
215 | daniel-mar | 45 | $cont = str_ireplace('url("', 'url("'.$dir.'/', $cont); |
142 | daniel-mar | 46 | $cont = str_ireplace("url('data:", "url###('data:", $cont); |
215 | daniel-mar | 47 | $cont = str_ireplace("url('", "url('".$dir.'/', $cont); |
142 | daniel-mar | 48 | } |
49 | $cont = str_ireplace("url###(", "url(", $cont); |
||
261 | daniel-mar | 50 | return $cont."\n\n"; |
142 | daniel-mar | 51 | } |
112 | daniel-mar | 52 | |
142 | daniel-mar | 53 | # --- |
112 | daniel-mar | 54 | |
287 | daniel-mar | 55 | if (file_exists(__DIR__ . '/oidplus_base.local.css')) { |
56 | $out .= process_file(__DIR__ . '/oidplus_base.local.css'); |
||
57 | } else { |
||
58 | $out .= process_file(__DIR__ . '/oidplus_base.css'); |
||
59 | } |
||
142 | daniel-mar | 60 | |
277 | daniel-mar | 61 | $ary = OIDplus::getAllPluginManifests('*Pages'); |
62 | foreach ($ary as $plugintype_folder => $bry) { |
||
63 | foreach ($bry as $pluginname_folder => $cry) { |
||
64 | if (!isset($cry['CSS'])) continue; |
||
65 | foreach ($cry['CSS'] as $dry_name => $dry) { |
||
66 | if ($dry_name != 'file') continue; |
||
67 | foreach ($dry as $css_file) { |
||
68 | $out .= process_file(__DIR__ . '/plugins/'.$plugintype_folder.'/'.$pluginname_folder.'/'.$css_file); |
||
69 | } |
||
70 | } |
||
71 | } |
||
142 | daniel-mar | 72 | } |
73 | |||
261 | daniel-mar | 74 | $out .= process_file(__DIR__ . '/3p/jstree/themes/default/style.css'); |
75 | $out .= process_file(__DIR__ . '/3p/jquery-ui/jquery-ui.css'); |
||
76 | $out .= process_file(__DIR__ . '/3p/bootstrap/css/bootstrap.css'); |
||
142 | daniel-mar | 77 | |
78 | # --- |
||
79 | |||
286 | daniel-mar | 80 | $inv = isset($_REQUEST['invert']) ? $_REQUEST['invert'] : 0; |
81 | if ($inv != 0) { |
||
82 | $out = invertColorsOfCSS($out); |
||
83 | } |
||
84 | |||
142 | daniel-mar | 85 | $hs = isset($_REQUEST['h_shift']) ? $_REQUEST['h_shift'] : 0; |
86 | $ss = isset($_REQUEST['s_shift']) ? $_REQUEST['s_shift'] : 0; |
||
87 | $vs = isset($_REQUEST['v_shift']) ? $_REQUEST['v_shift'] : 0; |
||
286 | daniel-mar | 88 | if (($hs != 0) ||($ss != 0) || ($vs != 0)) { |
89 | $out = changeHueOfCSS($out, $hs, $ss, $vs); |
||
90 | } |
||
142 | daniel-mar | 91 | |
92 | # --- |
||
93 | |||
112 | daniel-mar | 94 | $etag = md5($out); |
95 | header("Etag: $etag"); |
||
96 | if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && (trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag)) { |
||
97 | header("HTTP/1.1 304 Not Modified"); |
||
98 | } else { |
||
99 | header('Content-Type:text/css'); |
||
100 | echo $out; |
||
101 | } |