Rev 778 | Rev 1050 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 778 | Rev 1033 | ||
---|---|---|---|
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | /* |
3 | /* |
4 | * OIDplus 2.0 |
4 | * OIDplus 2.0 |
5 | * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft |
5 | * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft |
6 | * |
6 | * |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
8 | * you may not use this file except in compliance with 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 |
9 | * You may obtain a copy of the License at |
10 | * |
10 | * |
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
12 | * |
12 | * |
13 | * Unless required by applicable law or agreed to in writing, software |
13 | * Unless required by applicable law or agreed to in writing, software |
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | * See the License for the specific language governing permissions and |
16 | * See the License for the specific language governing permissions and |
17 | * limitations under the License. |
17 | * limitations under the License. |
18 | */ |
18 | */ |
19 | 19 | ||
20 | use MatthiasMullie\Minify; |
20 | use MatthiasMullie\Minify; |
21 | 21 | ||
22 | require_once __DIR__ . '/includes/oidplus.inc.php'; |
22 | require_once __DIR__ . '/includes/oidplus.inc.php'; |
23 | 23 | ||
24 | error_reporting(OIDplus::baseConfig()->getValue('DEBUG') ? E_ALL : 0); |
24 | error_reporting(OIDplus::baseConfig()->getValue('DEBUG') ? E_ALL : 0); |
25 | @ini_set('display_errors', OIDplus::baseConfig()->getValue('DEBUG') ? '1' : '0'); |
25 | @ini_set('display_errors', OIDplus::baseConfig()->getValue('DEBUG') ? '1' : '0'); |
26 | 26 | ||
27 | $out = ''; |
27 | $out = ''; |
28 | 28 | ||
29 | # --- |
29 | # --- |
30 | 30 | ||
31 | $do_minify = OIDplus::baseConfig()->getValue('MINIFY_CSS', true); |
31 | $do_minify = OIDplus::baseConfig()->getValue('MINIFY_CSS', true); |
32 | 32 | ||
33 | function process_file($filename) { |
33 | function process_file($filename) { |
34 | global $do_minify; |
34 | global $do_minify; |
35 | 35 | ||
36 | $filename_min = preg_replace('/\.[^.]+$/', '.min.css', $filename); |
36 | $filename_min = preg_replace('/\.[^.]+$/', '.min.css', $filename); |
37 | $filename_full = $filename; |
37 | $filename_full = $filename; |
38 | 38 | ||
39 | if ($do_minify) { |
39 | if ($do_minify) { |
40 | if (file_exists($filename_min)) { |
40 | if (file_exists($filename_min)) { |
41 | // There is a file which is already minified |
41 | // There is a file which is already minified |
42 | $filename = $filename_min; |
42 | $filename = $filename_min; |
43 | $cont = file_get_contents($filename); |
43 | $cont = file_get_contents($filename); |
44 | } else if (file_exists($filename_full)) { |
44 | } else if (file_exists($filename_full)) { |
45 | // Otherwise, we minify it ourself |
45 | // Otherwise, we minify it ourself |
46 | $filename = $filename_full; |
46 | $filename = $filename_full; |
47 | $minifier = new Minify\CSS($filename); |
47 | $minifier = new Minify\CSS($filename); |
48 | $cont = $minifier->minify(); |
48 | $cont = $minifier->minify(); |
49 | } else { |
49 | } else { |
50 | return; |
50 | return; |
51 | } |
51 | } |
52 | } else { |
52 | } else { |
53 | if (file_exists($filename_full)) { |
53 | if (file_exists($filename_full)) { |
54 | $filename = $filename_full; |
54 | $filename = $filename_full; |
55 | $cont = file_get_contents($filename); |
55 | $cont = file_get_contents($filename); |
56 | } else if (file_exists($filename_min)) { |
56 | } else if (file_exists($filename_min)) { |
57 | $filename = $filename_min; |
57 | $filename = $filename_min; |
58 | $cont = file_get_contents($filename); |
58 | $cont = file_get_contents($filename); |
59 | } else { |
59 | } else { |
60 | return; |
60 | return; |
61 | } |
61 | } |
62 | } |
62 | } |
63 | 63 | ||
64 | $thisdir = __DIR__; |
64 | $thisdir = __DIR__; |
65 | $thisdir = str_replace('\\', '/', $thisdir); // change Windows Backslashes into Web-Slashes |
65 | $thisdir = str_replace('\\', '/', $thisdir); // change Windows Backslashes into Web-Slashes |
66 | $filename = str_replace('\\', '/', $filename); // change Windows Backslashes into Web-Slashes |
66 | $filename = str_replace('\\', '/', $filename); // change Windows Backslashes into Web-Slashes |
67 | $dir = dirname((strpos($filename, $thisdir.'/') === 0) ? substr($filename, strlen($thisdir.'/')) : $filename); |
67 | $dir = dirname((strpos($filename, $thisdir.'/') === 0) ? substr($filename, strlen($thisdir.'/')) : $filename); |
68 | 68 | ||
69 | $cont = preg_replace('@url\\(\s+@ism', 'url(', $cont); |
69 | $cont = preg_replace('@url\\(\s+@ism', 'url(', $cont); |
70 | $cont = str_ireplace('url("data:', 'url###("data:', $cont); |
70 | $cont = str_ireplace('url("data:', 'url###("data:', $cont); |
71 | $cont = str_ireplace('url("', 'url###("'.$dir.'/', $cont); |
71 | $cont = str_ireplace('url("', 'url###("'.$dir.'/', $cont); |
72 | $cont = str_ireplace("url('data:", "url###('data:", $cont); |
72 | $cont = str_ireplace("url('data:", "url###('data:", $cont); |
73 | $cont = str_ireplace("url('", "url###('".$dir.'/', $cont); |
73 | $cont = str_ireplace("url('", "url###('".$dir.'/', $cont); |
74 | $cont = str_ireplace("url(data:", "url###(data:", $cont); |
74 | $cont = str_ireplace("url(data:", "url###(data:", $cont); |
75 | $cont = str_ireplace("url(", "url###(".$dir.'/', $cont); |
75 | $cont = str_ireplace("url(", "url###(".$dir.'/', $cont); |
76 | $cont = str_ireplace("url###(", "url(", $cont); |
76 | $cont = str_ireplace("url###(", "url(", $cont); |
77 | return $cont."\n\n"; |
77 | return $cont."\n\n"; |
78 | } |
78 | } |
79 | 79 | ||
80 | # --- |
80 | # --- |
81 | 81 | ||
82 | // Third-party products |
82 | // Third-party products |
83 | $out .= process_file(__DIR__ . '/vendor/vakata/jstree/dist/themes/default/style.css'); |
83 | $out .= process_file(__DIR__ . '/vendor/vakata/jstree/dist/themes/default/style.css'); |
84 | $out .= process_file(__DIR__ . '/vendor/components/jqueryui/themes/base/jquery-ui.css'); |
84 | $out .= process_file(__DIR__ . '/vendor/components/jqueryui/themes/base/jquery-ui.css'); |
85 | $out .= process_file(__DIR__ . '/vendor/twbs/bootstrap/dist/css/bootstrap.css'); |
85 | $out .= process_file(__DIR__ . '/vendor/twbs/bootstrap/dist/css/bootstrap.css'); |
86 | $out .= process_file(__DIR__ . '/vendor/gedmarc/layout/dist/layout-default.css'); |
86 | $out .= process_file(__DIR__ . '/vendor/gedmarc/layout/dist/layout-default.css'); |
87 | $out .= process_file(__DIR__ . '/includes/loading.css'); |
87 | $out .= process_file(__DIR__ . '/includes/loading.css'); |
88 | 88 | ||
89 | // Find out base CSS |
89 | // Find out base CSS |
90 | if (isset($_REQUEST['theme'])) { |
90 | if (isset($_GET['theme'])) { |
91 | $theme = $_REQUEST['theme']; |
91 | $theme = $_GET['theme']; |
92 | if (strpos($theme,'/') !== false) $theme = 'default'; |
92 | if (strpos($theme,'/') !== false) $theme = 'default'; |
93 | if (strpos($theme,'\\') !== false) $theme = 'default'; |
93 | if (strpos($theme,'\\') !== false) $theme = 'default'; |
94 | if (strpos($theme,'..') !== false) $theme = 'default'; |
94 | if (strpos($theme,'..') !== false) $theme = 'default'; |
95 | } else { |
95 | } else { |
96 | $theme = 'default'; |
96 | $theme = 'default'; |
97 | } |
97 | } |
98 | 98 | ||
99 | if (file_exists(__DIR__ . '/userdata/styles/oidplus_base.css')) { |
99 | if (file_exists(__DIR__ . '/userdata/styles/oidplus_base.css')) { |
100 | // There is a user defined CSS (not recommended, use design plugins instead!) |
100 | // There is a user defined CSS (not recommended, use design plugins instead!) |
101 | $out .= process_file(__DIR__ . '/userdata/styles/oidplus_base.css'); |
101 | $out .= process_file(__DIR__ . '/userdata/styles/oidplus_base.css'); |
102 | } else { |
102 | } else { |
103 | // Use CSS of the design plugin |
103 | // Use CSS of the design plugin |
104 | OIDplus::registerAllPlugins('design', 'OIDplusDesignPlugin', array('OIDplus','registerDesignPlugin')); |
104 | OIDplus::registerAllPlugins('design', 'OIDplusDesignPlugin', array('OIDplus','registerDesignPlugin')); |
105 | $plugins = OIDplus::getDesignPlugins(); |
105 | $plugins = OIDplus::getDesignPlugins(); |
106 | foreach ($plugins as $plugin) { |
106 | foreach ($plugins as $plugin) { |
107 | if ((basename($plugin->getPluginDirectory())) == $theme) { |
107 | if ((basename($plugin->getPluginDirectory())) == $theme) { |
108 | $manifest = $plugin->getManifest(); |
108 | $manifest = $plugin->getManifest(); |
109 | foreach ($manifest->getCSSFiles() as $css_file) { |
109 | foreach ($manifest->getCSSFiles() as $css_file) { |
110 | $out .= process_file($css_file); |
110 | $out .= process_file($css_file); |
111 | } |
111 | } |
112 | } |
112 | } |
113 | } |
113 | } |
114 | } |
114 | } |
115 | 115 | ||
116 | // Then plugins |
116 | // Then plugins |
117 | $manifests = OIDplus::getAllPluginManifests(implode(',',OIDplus::INTERACTIVE_PLUGIN_TYPES), true); // due to interface gridGeneratorLinks (1.3.6.1.4.1.37476.2.5.2.3.6) this plugin type can also have CSS |
117 | $manifests = OIDplus::getAllPluginManifests(implode(',',OIDplus::INTERACTIVE_PLUGIN_TYPES), true); // due to interface gridGeneratorLinks (1.3.6.1.4.1.37476.2.5.2.3.6) this plugin type can also have CSS |
118 | foreach ($manifests as $manifest) { |
118 | foreach ($manifests as $manifest) { |
119 | foreach ($manifest->getCSSFiles() as $css_file) { |
119 | foreach ($manifest->getCSSFiles() as $css_file) { |
120 | $out .= process_file($css_file); |
120 | $out .= process_file($css_file); |
121 | } |
121 | } |
122 | } |
122 | } |
123 | 123 | ||
124 | // Now user-defined (additional) definitions |
124 | // Now user-defined (additional) definitions |
125 | if (file_exists(__DIR__ . '/userdata/styles/oidplus_add.css')) { |
125 | if (file_exists(__DIR__ . '/userdata/styles/oidplus_add.css')) { |
126 | $out .= process_file(__DIR__ . '/userdata/styles/oidplus_add.css'); |
126 | $out .= process_file(__DIR__ . '/userdata/styles/oidplus_add.css'); |
127 | } |
127 | } |
128 | 128 | ||
129 | # --- |
129 | # --- |
130 | 130 | ||
131 | $inv = isset($_REQUEST['invert']) ? $_REQUEST['invert'] : 0; |
131 | $inv = isset($_GET['invert']) ? $_GET['invert'] : 0; |
132 | if ($inv != 0) { |
132 | if ($inv != 0) { |
133 | $out = invertColorsOfCSS($out); |
133 | $out = invertColorsOfCSS($out); |
134 | } |
134 | } |
135 | 135 | ||
136 | $hs = isset($_REQUEST['h_shift']) ? $_REQUEST['h_shift'] : 0; |
136 | $hs = isset($_GET['h_shift']) ? $_GET['h_shift'] : 0; |
137 | $ss = isset($_REQUEST['s_shift']) ? $_REQUEST['s_shift'] : 0; |
137 | $ss = isset($_GET['s_shift']) ? $_GET['s_shift'] : 0; |
138 | $vs = isset($_REQUEST['v_shift']) ? $_REQUEST['v_shift'] : 0; |
138 | $vs = isset($_GET['v_shift']) ? $_GET['v_shift'] : 0; |
139 | if (($hs != 0) ||($ss != 0) || ($vs != 0)) { |
139 | if (($hs != 0) ||($ss != 0) || ($vs != 0)) { |
140 | $out = changeHueOfCSS($out, $hs, $ss, $vs); |
140 | $out = changeHueOfCSS($out, $hs, $ss, $vs); |
141 | } |
141 | } |
142 | 142 | ||
143 | # --- |
143 | # --- |
144 | 144 | ||
145 | if (OIDplus::baseConfig()->getValue('DEBUG')) { |
145 | if (OIDplus::baseConfig()->getValue('DEBUG')) { |
146 | // In debug mode, we might get PHP error messages (see "error_reporting" above), |
146 | // In debug mode, we might get PHP error messages (see "error_reporting" above), |
147 | // so it would be severe if we would allow ETAG! (since $out does not contain the PHP error messages!) |
147 | // so it would be severe if we would allow ETAG! (since $out does not contain the PHP error messages!) |
148 | header('Content-Type:text/css'); |
148 | header('Content-Type:text/css'); |
149 | echo $out; |
149 | echo $out; |
150 | } else { |
150 | } else { |
151 | httpOutWithETag($out, 'text/css', 'oidplus.css'); |
151 | httpOutWithETag($out, 'text/css', 'oidplus.css'); |
152 | } |
152 | } |
153 | 153 |