1 | <?php |
---|
2 | /** |
---|
3 | * t29 ressource loading system. |
---|
4 | * |
---|
5 | * Entry point for loading javascript and css style sheet files in a bundled and |
---|
6 | * compressed manner, including caching. This file only checks up the caches and |
---|
7 | * contains the main configuration. See ressourceloader.php for all constructing |
---|
8 | * code. |
---|
9 | * |
---|
10 | **/ |
---|
11 | |
---|
12 | $lib = dirname(__FILE__); |
---|
13 | $webroot = realpath("$lib/../"); # file path to root of t29 web installation |
---|
14 | |
---|
15 | require_once "$lib/host.php"; |
---|
16 | $host = t29Host::detect(); |
---|
17 | |
---|
18 | if(!isset($_GET['type'])) { |
---|
19 | print "<html><pre>The t29v6 Ressource loader.\n"; |
---|
20 | print "Provide ?type=js or ?type=css.\n"; |
---|
21 | print '<a href="https://labs.technikum29.de/browser/technikum29%20Website/lib/loader.php">Read my sourcecode</a>'; |
---|
22 | exit; |
---|
23 | } |
---|
24 | |
---|
25 | $type = $_GET['type']; |
---|
26 | $conf = $host->get_ressources($type, $webroot, isset($_GET['debug'])); //$conf_for_type($type, isset($_GET['debug'])); |
---|
27 | if($conf == null) |
---|
28 | die("Illegal type. Valid types are: ". implode($types)); |
---|
29 | extract($conf); // for saving long human reading times :D |
---|
30 | |
---|
31 | require "$lib/cache.php"; |
---|
32 | $js_cache = new t29Cache(); |
---|
33 | $js_cache->test_files = $modules; |
---|
34 | $js_cache->set_cache_file($webroot, $cache_file); |
---|
35 | |
---|
36 | header("Content-Type: $content_types"); |
---|
37 | if(!$debug) $js_cache->try_cache_and_exit(); |
---|
38 | |
---|
39 | # so we are still in the game |
---|
40 | require "$lib/ressourceloader.php"; |
---|
41 | $loader = new $class($conf); |
---|
42 | // TODO: there is a known bug with the filter function issue: Since t29Host variable web prefixes the |
---|
43 | // filter function for CSS also does path rewriting which doesn't work when it is in debug mode. |
---|
44 | // Anyway a page in debug mode also imports all untouched CSS files, anyway |
---|
45 | if(!$debug) |
---|
46 | $js_cache->start_cache(array( |
---|
47 | 'shutdown_func' => null, // nothing to do afterwards for the cache |
---|
48 | 'filter_func' => array($loader, 'compression_filter'), // compress if not debugging |
---|
49 | 'write_cache' => true, // write the cache if not debugging |
---|
50 | )); |
---|
51 | $loader->run(); |
---|