source: t29-www/lib/loader.php @ 301

Last change on this file since 301 was 301, checked in by sven, 12 years ago

Zwei grosse Bugfixes die einige Backendänderungen nach sich zogen:

  • Impressum: Google Maps-Karte lädt wieder. Dafür wurde endlich ein seitenspezifisches Scriptsystem geschrieben, welches im RessourceLoader verankert Scriptfiles direkt einbindet. Das ermöglicht besseres Debugging, bessere Ladezeit und eine Symmetrie zu seitenspezifischen CSS. Insbesondere aber (bislang eher dreckige) Hooks, mit denen externe Scripts eingebunden werden können, was per pagescripts.js nicht geht. pagescripts.js gibts für kleine Scripte immernoch, könnte man dann ggf. auflösen.
  • Relationale Rücklinks für Geräteseiten: Geräteseiten haben nun wie ehemals einen Rücklink auf die verweisende Seite. Dieser wird anhand ihrer Einordnung in der Navigation erlangt. Bei Seiten, die nicht klar einzuordnen waren, könnte dieses Vorgehen ggf. Fehler erzeugen. Das müsste man dann im Einzelfall überprüfen.
File size: 2.3 KB
RevLine 
[269]1<?php
2/**
3 * t29 ressource loading system.
[271]4 *
[269]5 * Entry point for loading javascript and css style sheet files in a bundled and
[271]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.
[269]9 *
10 **/
[273]11 
12if(!defined('T29_GRAB_LOADER_DEFS')) {
13        $lib = dirname(__FILE__);
14        $webroot = realpath("$lib/../");  # file path to root of t29 web installation
[269]15
[273]16        if(!isset($_GET['type'])) {
17                die("Provide ?type=js or ?type=css.");
18        }
[269]19}
20
21$types = array('js', 'css'); // mapping position (numeric key) => $conf array position
22$conf = array(
23        'cache_file' => array('compressed.js', 'style.css'),
24        'module_dir' => array("$webroot/shared/js-v6/modules", "$webroot/shared/css-v6/modules"),
[301]25        'page_dir' => array("$webroot/shared/js-v6/pagescripts", "$webroot/shared/css-v6/pagestyles"),
[269]26        'glob_pattern' => array('*.js', '*.css'),
27        'content_types' => array('application/javascript', 'text/css'),
28        'class' => array('t29JavaScriptRessourceLoader', 't29StyleSheetRessourceLoader'),
[273]29        'modules' => function($conf){ return glob($conf['module_dir'] . '/' . $conf['glob_pattern']); },
[269]30);
[273]31$conf_for_type = function($type, $debug_flag=false) use ($conf, $types) {
32        $typepos = array_search($type, $types);
33        if($typepos === FALSE) return null;
34        array_walk($conf, function(&$val, $key) use($typepos) { if(is_array($val)) $val = $val[$typepos]; });
35        $conf['type'] = $type;
36        $conf['modules'] = call_user_func($conf['modules'], $conf);
37        $conf['debug'] = $debug_flag; // skip cache and just concat everything
38        return $conf;
39};
[269]40
[273]41if(defined('T29_GRAB_LOADER_DEFS')) {
42        return; // just grab the vars in the local scope
43}
44
[269]45$type = $_GET['type'];
[273]46$conf = $conf_for_type($type, isset($_GET['debug']));
47if($conf == null)
[269]48        die("Illegal type. Valid types are: ". implode($types));
49extract($conf); // for saving long human reading times :D
50
51require "$lib/cache.php";
52$js_cache = new t29Cache();
53$js_cache->test_files = $modules;
54$js_cache->set_cache_file($webroot, $cache_file);
[271]55
56header("Content-Type: $content_types");
[269]57if(!$debug) $js_cache->try_cache_and_exit();
58
59# so we are still in the game
60require "$lib/ressourceloader.php";
61$loader = new $class($conf);
[277]62if(!$debug) $js_cache->start_cache(array($loader, 'compression_filter'), true);
[269]63$loader->run();
Note: See TracBrowser for help on using the repository browser.
© 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