Subversion Repositories oidplus

Rev

Rev 379 | Rev 411 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
364 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
 
22
require_once __DIR__ . '/../includes/oidplus.inc.php';
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
 
31
$out = '';
32
 
33
# ---
34
 
35
function process_file($filename) {
36
        $dir = dirname((strpos($filename, __DIR__.'/') === 0) ? substr($filename, strlen(__DIR__.'/')) : $filename);
37
        if (OIDplus::baseConfig()->getValue('MINIFY_CSS', true)) {
38
                $minifier = new Minify\CSS($filename);
39
                $cont = $minifier->minify();
40
                $cont = str_ireplace("url(data:", "url###(data:", $cont);
41
                $cont = str_ireplace("url(", "url(".$dir.'/', $cont);
42
        } else {
43
                $cont = file_get_contents($filename);
44
                $cont = str_ireplace('url("data:', 'url###("data:', $cont);
45
                $cont = str_ireplace('url("', 'url("'.$dir.'/', $cont);
46
                $cont = str_ireplace("url('data:", "url###('data:", $cont);
47
                $cont = str_ireplace("url('", "url('".$dir.'/', $cont);
48
        }
49
        $cont = str_ireplace("url###(", "url(", $cont);
50
        return $cont."\n\n";
51
}
52
 
53
# ---
54
 
380 daniel-mar 55
OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', array('OIDplus','registerDatabasePlugin'));
56
foreach (OIDplus::getDatabasePlugins() as $plugin) {
57
        $out .= $plugin::setupCSS();
58
}
59
 
364 daniel-mar 60
if (file_exists(__DIR__ . '/../userdata/styles/setup_base.css')) {
61
        $out .= process_file(__DIR__ . '/../userdata/styles/setup_base.css');
62
} else {
63
        $out .= process_file(__DIR__ . '/setup_base.css');
64
}
65
 
366 daniel-mar 66
if (file_exists(__DIR__ . '/userdata/styles/setup_add.css')) {
67
        $out .= process_file(__DIR__ . '/userdata/styles/setup_add.css');
68
}
69
 
364 daniel-mar 70
# ---
71
 
379 daniel-mar 72
httpOutWithETag($out, 'text/css', 'oidplus_setup.css');
73