-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcss-config.php
More file actions
42 lines (33 loc) · 1.41 KB
/
css-config.php
File metadata and controls
42 lines (33 loc) · 1.41 KB
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
<?php
/**
* Define files that should be built as key and as value an array of source files the content should be read from.
* The built file will be placed in 'static/css/' and the source files will be read from this directory 'js-components/'
*/
define('BUILD_FILES', array(
"start.css" => array("default.css", "start.css"),
));
// ---------------------------------------------------------------------------------------
// INTERAL PROCESSING OF REQUESTS
// ---------------------------------------------------------------------------------------
$file = substr(FULL_REQUEST, strlen(_CSS)+1);
if(isset(BUILD_FILES[$file])){
$fullFile = STATICS.FULL_REQUEST;
$lastUpdate = file_exists($fullFile) ? filemtime($fullFile) : false;
if($lastUpdate)
foreach(BUILD_FILES[$file] as $srcFile){
$fullSrcFile = CSS_COMPONENTS.$srcFile;
$lu = file_exists($fullSrcFile) ? filemtime($fullSrcFile) : false;
if(!$lu || $lu > $lastUpdate){ $lastUpdate = false; break; }
}
if($lastUpdate) return; // no update needed
// build new file
$contents = '';
foreach(BUILD_FILES[$file] as $srcFile){
$fullSrcFile = CSS_COMPONENTS.$srcFile;
$cnt = file_exists($fullSrcFile) ? file_get_contents($fullSrcFile) : false;
$contents .= $cnt ? $cnt.
' : '';
}
file_put_contents($fullFile, $contents);
}
?>