source: t29-www/lib/technikum29.php @ 266

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

Saubere Caching-Klasse eingefuehrt, um Code-Redundanzen in technikum29.php und js.php zu vermeiden und mehr/einheitliche Caching-Funktionalitaet bereitzustellen. Das Caching kann jetzt debuggt werden und so. Und ist prima dokumentiert. Ausserdem kann der Caching-Ordner jetzt einfach gewechselt werden.

  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1<?php
2/**
3 * technikum29v6 - PHP Subsystem.
4 * Haupteinstiegspunkt ("WebStart.php"), welches
5 * ohne weiteren Funktionsaufruf alles macht.
6 *
7 **/
8
9if(defined('T29')) return false; // no nesting
10define('T29', true);
11
12$lib = dirname(__FILE__);
13$webroot = realpath("$lib/../");  # file path to root of t29 web installation
14$file = substr($_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT'])); # e.g.: "/de/page.php"
15
16$cache_dir = "$webroot/shared/cache";
17$languages = array(
18// shorthand => array(full name in page, path from webroot)
19        "de" => array("Deutsch",  "/de-v6"),
20        "en" => array("English", "/en-v6"),
21);
22
23// try to determine the language from the file path
24$lang = substr($file, 1, 2);
25if(!in_array($lang, array_keys($languages))) $lang = "de"; # check if language exists
26$lang_path = $languages[$lang][1]; # shorthand, relative to webroot. use "$webroot$lang_path" for local.
27
28require "$lib/cache.php";
29
30$page_cache = new t29Cache(false, true); // debug, verbose
31$page_cache->set_cache_file($webroot, $file);
32$page_cache->test_files = array(
33        __FILE__,
34        $_SERVER['SCRIPT_FILENAME'],
35        "$lib/template.php",
36        "$lib/menu.php",
37        "$lib/messages.php",
38        "$webroot$lang_path/navigation.xml",
39        "$webroot$lang_path/news.php",
40);
41
42$page_cache->try_cache_and_exit();
43
44// cache missed, rebuild cache
45require "$lib/template.php";
46$tmpl = new t29Template($GLOBALS);
47$tmpl->create_cache($page_cache);
48
49// end of technikum29.php
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