This repository has been archived by the owner on Dec 18, 2020. It is now read-only.
forked from srsolutionsag/Uni_Freiburg_5.0-Skin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphysik.css.php.old
78 lines (70 loc) · 2.69 KB
/
physik.css.php.old
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* PHYSIK ONLINE 5.1 skin - Server Side LESS compiler, gemaess
* POTT Ticket #641.
* Diese PHP-File gibt eine CSS-Datei aus.
**/
header('Content-type: text/css');
// Parameter:
// Temporaere nur interne Cache-Datei auf dem Server
$cssfile = "/tmp/po51-ilias-generated.css";
// Einstiegs-LESS-File, die kompiliert wird. Sie kann per @include
// andere CSS/LESS-Files einbinden, diese Einbindungen werden aufgeloest.
$lessfile = "less.d/po-v5.1.less";
// Alle Dateien, die auf diese Globbing-Pattern passen, werden bei jedem
// PHP-Aufruf auf Aenderungen ueberprueft.
$watch_files = array_merge( glob("css.d/*"), glob("less.d/*") );
// Damit @imports aufgeloest werden koennen, muessen die lokalen Dateisystem-
// Pfade klar sein. Da Philip /Customizing/... verwendet, der volle Pfad.
$less_import_dir = array(
// Customizing ist relativ dazu
"/home/elearning-www/public_html/elearning/local/",
"css.d/",
"less.d/",
);
// Soll Browser-Cache-Information verwendet werden (spart Bandbreite) oder
// nicht? Default: false.
$ignore_http_caching = false;
// Ab hier das Programm
$mtime_cache_file = @filemtime($cssfile);
$mtime_test_files = array_map(
function($x){return @filemtime($x);},
$watch_files);
$mtime_test_max = array_reduce($mtime_test_files, 'max');
$cache_is_valid = $mtime_cache_file
&& $mtime_test_max < $mtime_cache_file;
$debug = isset($_GET["debug"]);
$regenerate = !$cache_is_valid || $debug;
header("Last-Modified: ".gmdate("D, d M Y H:i:s", $mtime_cache_file)." GMT");
if($regenerate) {
// LESS-Files erzeugen
require "lib/lessc.inc.php";
$less = new lessc;
$less->setImportDir($less_import_dir);
if (!$debug) {
$less->setFormatter("compressed");
}
$out = $less->compileFile($lessfile);
file_put_contents($cssfile, $out);
} else {
// Cache is valid!
// HTTP Caching verwenden, wenn Client bereits neuste Version hat, nicht nochmal
// uebertragen
if(!$ignore_http_caching && @strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $mtime_cache_file) {
header("HTTP/1.1 304 Not Modified");
// important - no more output!
exit;
} // else: Ausgaben machen, siehe unten:
}
?>
/*!
* PhysikOnline (PO5) CSS Code - https://elearning.physik.uni-frankfurt.de/
* Generated from LESS files
* --- DIESE DATEI NICHT VON HAND BEARBEITEN ---
* Design by Philip Arnold, Uni Freiburg
*
* Packed: <?php echo implode(' ', $watch_files); ?>
* Arguments: ?debug=true - regenerate cache file
* Generation Date: <?php print date('r', $mtime_cache_file); ?><?php #print $regenerate ? "Just regenerated" : date('r', $mtime_cache_file); ?>
**/
<?php if($regenerate) print $out; else readfile($cssfile); ?>