Changeset 516 in t29-www for lib/loader.php
- Timestamp:
- Feb 19, 2014, 12:39:35 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/loader.php
r357 r516 9 9 * 10 10 **/ 11 12 if(!defined('T29_GRAB_LOADER_DEFS')) {13 $lib = dirname(__FILE__);14 $webroot = realpath("$lib/../"); # file path to root of t29 web installation15 11 16 if(!isset($_GET['type'])) { 17 print "<html><pre>The t29v6 Ressource loader.\n"; 18 print "Provide ?type=js or ?type=css.\n"; 19 print '<a href="https://labs.technikum29.de/browser/technikum29%20Website/lib/loader.php">Read my sourcecode</a>'; 20 exit; 21 } 22 } 12 $lib = dirname(__FILE__); 13 $webroot = realpath("$lib/../"); # file path to root of t29 web installation 23 14 24 $types = array('js', 'css'); // mapping position (numeric key) => $conf array position 25 $conf = array( 26 'cache_file' => array('compressed.js', 'style.css'), 27 'module_dir' => array("$webroot/shared/js-v6/modules", "$webroot/shared/css-v6/modules"), 28 'page_dir' => array("$webroot/shared/js-v6/pagescripts", "$webroot/shared/css-v6/pagestyles"), 29 'glob_pattern' => array('*.js', '*.css'), 30 'content_types' => array('application/javascript', 'text/css'), 31 'class' => array('t29JavaScriptRessourceLoader', 't29StyleSheetRessourceLoader'), 32 'modules' => function($conf){ return glob($conf['module_dir'] . '/' . $conf['glob_pattern']); }, 33 ); 34 $conf_for_type = function($type, $debug_flag=false) use ($conf, $types) { 35 $typepos = array_search($type, $types); 36 if($typepos === FALSE) return null; 37 array_walk($conf, function(&$val, $key) use($typepos) { if(is_array($val)) $val = $val[$typepos]; }); 38 $conf['type'] = $type; 39 $conf['modules'] = call_user_func($conf['modules'], $conf); 40 $conf['debug'] = $debug_flag; // skip cache and just concat everything 41 return $conf; 42 }; 15 require_once "$lib/host.php"; 16 $host = t29Host::detect(); 43 17 44 if(defined('T29_GRAB_LOADER_DEFS')) { 45 return; // just grab the vars in the local scope 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; 46 23 } 47 24 48 25 $type = $_GET['type']; 49 $conf = $ conf_for_type($type, isset($_GET['debug']));26 $conf = $host->get_ressources($type, $webroot, isset($_GET['debug'])); //$conf_for_type($type, isset($_GET['debug'])); 50 27 if($conf == null) 51 28 die("Illegal type. Valid types are: ". implode($types));
Note: See TracChangeset
for help on using the changeset viewer.