Changeset 273 in t29-www for lib/loader.php
- Timestamp:
- Jun 2, 2012, 8:15:28 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/loader.php
r271 r273 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 installation 11 15 12 $lib = dirname(__FILE__); 13 $webroot = realpath("$lib/../"); # file path to root of t29 web installation 14 15 if(!isset($_GET['type'])) { 16 die("Read manual."); 16 if(!isset($_GET['type'])) { 17 die("Provide ?type=js or ?type=css."); 18 } 17 19 } 18 20 … … 24 26 'content_types' => array('application/javascript', 'text/css'), 25 27 'class' => array('t29JavaScriptRessourceLoader', 't29StyleSheetRessourceLoader'), 28 'modules' => function($conf){ return glob($conf['module_dir'] . '/' . $conf['glob_pattern']); }, 26 29 ); 30 $conf_for_type = function($type, $debug_flag=false) use ($conf, $types) { 31 $typepos = array_search($type, $types); 32 if($typepos === FALSE) return null; 33 array_walk($conf, function(&$val, $key) use($typepos) { if(is_array($val)) $val = $val[$typepos]; }); 34 $conf['type'] = $type; 35 $conf['modules'] = call_user_func($conf['modules'], $conf); 36 $conf['debug'] = $debug_flag; // skip cache and just concat everything 37 return $conf; 38 }; 39 40 if(defined('T29_GRAB_LOADER_DEFS')) { 41 return; // just grab the vars in the local scope 42 } 27 43 28 44 $type = $_GET['type']; 29 $ typepos = array_search($type, $types);30 if($ typepos === FALSE) {45 $conf = $conf_for_type($type, isset($_GET['debug'])); 46 if($conf == null) 31 47 die("Illegal type. Valid types are: ". implode($types)); 32 } 48 extract($conf); // for saving long human reading times :D 33 49 34 array_walk($conf, function(&$val, $key) use($typepos) { $val = $val[$typepos]; });35 $conf['modules'] = glob($conf['module_dir'] . '/' . $conf['glob_pattern']);36 $conf['debug'] = isset($_GET['debug']); // skip cache and just concat everything37 extract($conf); // for saving long human reading times :D38 // alternative approach for direct extract in global namespace39 // (no more applicable because configuration is given as array to constructor):40 // foreach($conf as $var => $val) { $GLOBALS[$var] = $val[$typepos]; }41 50 42 51 require "$lib/cache.php";
Note: See TracChangeset
for help on using the changeset viewer.