forked from AricStewart/CIAB-Portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
style.php
51 lines (44 loc) · 1.37 KB
/
style.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/*.
require_module 'standard';
.*/
require_once __DIR__."/vendor/autoload.php";
$resource_cache = @sys_get_temp_dir().'/scss_cache/';
$scss = new scssc();
$scss->addImportPath("scss");
$scss->setFormatter("scss_formatter_compressed");
$uri = explode("/", $_SERVER['REQUEST_URI']);
if (!is_dir($resource_cache)) {
@mkdir($resource_cache, 0777, true);
@chmod($resource_cache, 0777);
}
$MODULESDIR = "modules";
if (count($uri) > 3) {
$tgt_path = $MODULESDIR.'/'.$uri[3];
$scss_cache = $resource_cache.$uri[3];
$scss->addImportPath($tgt_path."/scss");
$scss_dir = "modules";
} elseif ($uri[2] === 'panel.scss') {
$scss_cache = $resource_cache."panel";
$source = "@import 'styles';";
$modules = @scandir($MODULESDIR);
foreach ($modules as $key => $value) {
if (!in_array($value, array(".", ".."))) {
$tgt_path = $MODULESDIR.'/'.$value.'/scss';
if (is_dir($tgt_path)) {
if (is_file($tgt_path."/panel.scss")) {
$source .= "@import \"$tgt_path/panel.scss\";";
}
}
}
}
$scss->setFormatter("scss_formatter_compressed");
header("Content-type: text/css");
echo $scss->compile($source);
exit;
} else {
$scss_cache = $resource_cache;
$scss_dir = "scss";
}
$server = new scss_server($scss_dir, $scss_cache, $scss);
$server->serve();