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

Last change on this file since 783 was 649, checked in by sven, 10 years ago

RSS-Feed-Probebetrieb ausgeweitet: Internationalisiert, fuer englische Version gibts jetzt auch einen RSS-Feed.

Insbesondere ist in auf englischen Newsseite jetzt testweise ein alternatives Format zum Deutschen geschaltet, auf welches das Deutsche dann auch umgeschaltet werden soll. Es bedarf weniger Pflege und generiert gleichzeitig die Newsseite, das Newsmenü und den abonnierbaren News-Feed. Wenn sich das Format bewährt, kann die deutsche Newsseite darauf auch umgestellt werden.

Ferner wurden die RSS-Feeds auf den News-Seiten textuell erwähnt. Testweise werden auch im englischen Menü wieder Vorschaubilder (Thumbnails) bei den Neuigkeiten eingeblendet, die allerdings derzeit nur auf max 64x64px verkleinerte Einblendungen der entsprechenden News-Bilder sind. Hierfür fehlt noch eine sinnvollere Methode.

  • Property svn:keywords set to Id
File size: 4.5 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// is it an external call?
13$external = isset($external);
14
15// at least the $seiten_id must be defined
16if(!isset($seiten_id)) {
17        print "<html><pre>The t29v6 WebStart file\n";
18        print 'technikum29.php is the main include, but requires at least global <tt>$seiten_id</tt> to be defined.';
19        print "\n<a href='https://labs.technikum29.de/browser/technikum29%20Website/lib/technikum29.php'>Read my sourcecode</a>";
20        return false;
21}
22
23$lib = dirname(__FILE__);
24$webroot = realpath("$lib/../");  # file path to root of t29 web installation
25
26// early import host specific settings for making low level corrections like Bugfix #32
27require "$lib/host.php";
28$host = $external ? t29Host::create('t29ExternalHost') : t29Host::detect();
29$file = $host->slash_filename; # e.g.: "/de/page.php"
30
31// exactly define debugging behaviour
32if(isset($_GET['debug'])) {
33        $_GET['purge_cache'] = true;
34        $_GET['rl_debug'] = true;
35}
36
37// check for url rewriting neccessarity (skip at external calls)
38if($host->check_url_rewrite()) exit;
39
40$cache_dir = "$webroot/shared/cache";
41$languages = array(
42// shorthand => array(full name in page, path from webroot)
43        "de" => array("Deutsch",  "/de"),
44        "en" => array("English", "/en"),
45);
46
47// make sure we have a page title
48if(isset($title)) $titel = $title;
49elseif(isset($titel)) $title = $titel;
50else $titel = $title = false; // to be determined by navigation seiten_id.
51
52// try to determine the language from the file path
53if(!isset($lang)) $lang = substr($file, 1, 2);
54if(!in_array($lang, array_keys($languages))) $lang = "de"; # check if language exists
55$lang_path = $languages[$lang][1]; # shorthand, relative to webroot. use "$webroot$lang_path" for local.
56
57// "AJAX" calls are our meaning for pages without chrome
58$ajax = isset($_GET['ajax']);
59if(!$external && $ajax) {
60        // print only a minimal chrome, no caching.
61        require "$lib/ajax-template.php";
62        $ajax_tmpl = new t29AJAXTemplate($GLOBALS);
63        $ajax_tmpl->print_page();
64        // important: do not execute code further down (Templating stuff)
65        return true;
66}
67
68require "$lib/cache.php";
69
70// "External" pages which are not part of the t29 website
71if($external) {
72        // skip caching stuff. External pages don't get in touch with
73        // any navigation.xml or news.php etc.
74        require "$lib/template.php";
75        $header_cache = new t29Cache(/*debug*/false, /*verbose*/true, /*skip=memory only*/true);
76        $footer_cache = new t29Cache(/*debug*/false, /*verbose*/true, /*skip=memory only*/true);
77        $tmpl = new t29Template($GLOBALS);
78        $tmpl->create_separate_caches($header_cache, $footer_cache);
79        // important: do not execute caching stuff below
80        return true;
81}
82
83$page_cache = new t29Cache(false, true); // debug, verbose
84$page_cache->set_cache_file($webroot, $file);
85// You can define "$test_files" for additionall files to check. See e.g. /lib/sitemap.php
86$page_cache->test_files = isset($test_files) ? $test_files : array();
87$page_cache->test_files += array(
88        __FILE__,
89        $_SERVER['SCRIPT_FILENAME'],
90        "$lib/template.php",
91        "$lib/menu.php",
92        "$lib/messages.php",
93        "$lib/host.php",
94        "$webroot$lang_path/navigation.xml",
95        "$webroot$lang_path/news.php",
96        $webroot.$host->ressources_get_pagestyle($seiten_id),
97);
98
99// dynamical content:
100$static_page = !isset($dynamischer_inhalt);
101
102if(!$static_page) {
103        // Pages with dynamical content: only cache header and footer, seperately.
104        // they depend on same test files, so there is only one is_valid check.
105        $header_cache = $page_cache;
106        $footer_cache = clone $page_cache;
107
108        $header_cache->set_cache_file($webroot, $file.'-header');
109        $footer_cache->set_cache_file($webroot, $file.'-footer');
110}
111
112if($page_cache->shall_use()) {
113        if($static_page)
114                $page_cache->print_cache_and_exit();
115        else {
116                $header_cache->print_cache(true);
117                register_shutdown_function(function() use ($footer_cache) {
118                        $footer_cache->print_cache(true);
119                });
120                // now print your dynamical stuff in your page, the
121                // footer content will be automatically added afterwards.
122        }
123} else {
124        // cache missed, rebuild cache
125        require "$lib/template.php";
126        $tmpl = new t29Template($GLOBALS);
127        if($static_page)
128                // rebuild complete site cache
129                $tmpl->create_cache($page_cache);
130        else
131                // rebuild each header and footer cache
132                $tmpl->create_separate_caches($header_cache, $footer_cache);
133}
134
135
136// 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