Index: lib/loader.php =================================================================== --- lib/loader.php (revision 357) +++ lib/loader.php (revision 516) @@ -9,43 +9,20 @@ * **/ - -if(!defined('T29_GRAB_LOADER_DEFS')) { - $lib = dirname(__FILE__); - $webroot = realpath("$lib/../"); # file path to root of t29 web installation - if(!isset($_GET['type'])) { - print "
The t29v6 Ressource loader.\n"; - print "Provide ?type=js or ?type=css.\n"; - print 'Read my sourcecode'; - exit; - } -} +$lib = dirname(__FILE__); +$webroot = realpath("$lib/../"); # file path to root of t29 web installation -$types = array('js', 'css'); // mapping position (numeric key) => $conf array position -$conf = array( - 'cache_file' => array('compressed.js', 'style.css'), - 'module_dir' => array("$webroot/shared/js-v6/modules", "$webroot/shared/css-v6/modules"), - 'page_dir' => array("$webroot/shared/js-v6/pagescripts", "$webroot/shared/css-v6/pagestyles"), - 'glob_pattern' => array('*.js', '*.css'), - 'content_types' => array('application/javascript', 'text/css'), - 'class' => array('t29JavaScriptRessourceLoader', 't29StyleSheetRessourceLoader'), - 'modules' => function($conf){ return glob($conf['module_dir'] . '/' . $conf['glob_pattern']); }, -); -$conf_for_type = function($type, $debug_flag=false) use ($conf, $types) { - $typepos = array_search($type, $types); - if($typepos === FALSE) return null; - array_walk($conf, function(&$val, $key) use($typepos) { if(is_array($val)) $val = $val[$typepos]; }); - $conf['type'] = $type; - $conf['modules'] = call_user_func($conf['modules'], $conf); - $conf['debug'] = $debug_flag; // skip cache and just concat everything - return $conf; -}; +require_once "$lib/host.php"; +$host = t29Host::detect(); -if(defined('T29_GRAB_LOADER_DEFS')) { - return; // just grab the vars in the local scope +if(!isset($_GET['type'])) { + print "The t29v6 Ressource loader.\n"; + print "Provide ?type=js or ?type=css.\n"; + print 'Read my sourcecode'; + exit; } $type = $_GET['type']; -$conf = $conf_for_type($type, isset($_GET['debug'])); +$conf = $host->get_ressources($type, $webroot, isset($_GET['debug'])); //$conf_for_type($type, isset($_GET['debug'])); if($conf == null) die("Illegal type. Valid types are: ". implode($types));