Changeset 273 in t29-www for lib/loader.php


Ignore:
Timestamp:
Jun 2, 2012, 8:15:28 PM (12 years ago)
Author:
sven
Message:

Backend modifications:

  • ressourceloader.php can generate URLs for its own system and can instanciate an RL instance by grabbing the config from loader.php
  • template.php requests RessourceLoader for URLs (so debugging URLs can directly be injected in the template)
  • template.php and cache.php can handle header/footer seperatedly in two cache files for dynamical page content
  • suche.php and search.php as the search framework basis; they can already print a XML opensarch description.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/loader.php

    r271 r273  
    99 *
    1010 **/
     11 
     12if(!defined('T29_GRAB_LOADER_DEFS')) {
     13        $lib = dirname(__FILE__);
     14        $webroot = realpath("$lib/../");  # file path to root of t29 web installation
    1115
    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        }
    1719}
    1820
     
    2426        'content_types' => array('application/javascript', 'text/css'),
    2527        'class' => array('t29JavaScriptRessourceLoader', 't29StyleSheetRessourceLoader'),
     28        'modules' => function($conf){ return glob($conf['module_dir'] . '/' . $conf['glob_pattern']); },
    2629);
     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
     40if(defined('T29_GRAB_LOADER_DEFS')) {
     41        return; // just grab the vars in the local scope
     42}
    2743
    2844$type = $_GET['type'];
    29 $typepos = array_search($type, $types);
    30 if($typepos === FALSE) {
     45$conf = $conf_for_type($type, isset($_GET['debug']));
     46if($conf == null)
    3147        die("Illegal type. Valid types are: ". implode($types));
    32 }
     48extract($conf); // for saving long human reading times :D
    3349
    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 everything
    37 extract($conf); // for saving long human reading times :D
    38 // alternative approach for direct extract in global namespace
    39 // (no more applicable because configuration is given as array to constructor):
    40 // foreach($conf as $var => $val) { $GLOBALS[$var] = $val[$typepos]; }
    4150
    4251require "$lib/cache.php";
Note: See TracChangeset for help on using the changeset viewer.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License