source: t29-www/lib/template.php @ 264

Last change on this file since 264 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: 7.7 KB
Line 
1<?php
2/**
3 * technikum29v6 Page Template
4 *
5 * Global vars:
6 *  $lang = de | en
7 *  $seiten_id = kurzkennung der aktuellen seite
8 *  $root = Seiten-Root fuer URLs ($root/de, $root/shared, etc.)
9 *  $titel = Seitentitel
10 *  $header_cache_file, $footer_cache_file.
11 **/
12 
13class t29Template {
14        public $conf, $menu, $msg;
15        public $body_classes = array();
16        public $javascript_config = array();
17        public $page_relations, $interlang_links;
18
19        function __construct($conf_array) {
20                $this->conf = $conf_array;
21
22                // create a menu:
23                require_once $this->conf['lib'].'/menu.php';
24                $this->menu = new t29Menu($this->conf);
25
26                // create localisation class:
27                require_once $this->conf['lib'].'/messages.php';
28                $this->msg = new t29Messages($this->conf['lang']);
29
30                // fill up configuration
31                $this->conf['legal_pagename'] = $this->conf['lang_path'] . $this->msg->_('footer-legal-file');
32
33                // setup body classes:
34                $this->body_classes[] = "lang-" . $this->conf['lang'];
35                $this->body_classes[] = "page-" . $this->conf['seiten_id'];
36               
37                // setup javascript configuration
38                $this->javascript_config['lang'] = $this->conf['lang'];
39                $this->javascript_config['seiten_id'] = $this->conf['seiten_id'];
40               
41                // get all kind of relations
42                $this->page_relations = $this->menu->get_page_relations();
43                $this->interlang_links = $this->menu->get_interlanguage_link();
44               
45                // check and load additional css
46                $this->conf['pagecss'] = '/shared/css-v6/pagestyles/'.$this->conf['seiten_id'].'.css';
47                $this->conf['has_pagecss'] = file_exists($this->conf['webroot'].$this->conf['pagecss']);
48                // FIXME: There is no caching check yet for this setting
49                //        (new pagecss file won't be detected and wont purge the tmpl cache)
50        }
51       
52        /**
53         * Main caching and output system.
54         * Parameters (global configuration):
55         *    skip_cache  -  if true, skips writing output to cache file
56         *    purge_cache -  if true, forces creation of new cache file
57         *                   (does not change behaviour of this file's code)
58         **/
59        function create_cache($cache_object) {
60                $cache_object->start_cache(array($this, 'print_footer'));
61                $this->print_header();
62        }
63
64        function print_header() {
65                $p = $this->msg->get_shorthand_printer();
66                $_ = $this->msg->get_shorthand_returner();
67?>
68<!doctype html>
69<html class="no-js" lang="<?php echo $this->conf['lang']; ?>">
70<head>
71  <meta charset="utf-8">
72  <title><?php echo isset($this->conf['titel']) ? $this->conf['titel'].' - ' : ''; $p('html-title'); ?></title>
73  <meta name="description" content="Produziert am 08.01.2012">
74  <meta name="author" content="Sven">
75  <meta name="generator" content="t29v6">
76  <meta name="t29.cachedate" content="<?php print date('r'); ?>">
77  <?php
78        if(isset($this->conf['version'])) printf('<meta name="t29.version" content="%s">', $this->conf['version']);
79  ?>
80 
81  <?php
82        foreach(array_merge(array("first" => t29Menu::dom_new_link($this->conf['lang_path'], $_('head-rel-first'))),
83          $this->page_relations) as $rel => $a) {
84                if($rel == 'start') continue; // not in standard
85                printf("\n  <link rel='%s' href='%s' title='%s' />",
86                        $rel, $a['href'], sprintf($_('head-rel-'.$rel), $a)
87                );
88        }
89  ?>
90 
91  <link rel="copyright" href="<?php echo $this->conf['legal_pagename']; ?>" title="<?php $p('footer-legal-link'); ?>">
92  <?php
93        // print interlanguage links for all languages except the active one
94        foreach($this->interlang_links as $lang => $a) {
95                if($lang != $this->conf['lang']) {
96                        printf('<link rel="alternate" href="%s" hreflang="%s" title="%s">',
97                                $a['href'], $lang, sprintf($_('head-rel-interlang'), $a)
98                        );
99                }
100        }
101  ?>
102 
103  <meta name="viewport" content="width=device-width,initial-scale=1">
104  <link rel="stylesheet" href="/shared/css-v6/boiler.css">
105  <link rel="stylesheet" href="/shared/css-v6/style.css">
106  <link rel="stylesheet" href="/shared/css/common.css">
107  <?php
108        if($this->conf['has_pagecss'])
109                printf('<link rel="stylesheet" href="%s">', $this->conf['pagecss']);
110  ?>
111
112  <script src="/shared/js-v6/libs/modernizr-2.0.6.min.js"></script>
113</head>
114
115<body class="<?php echo implode(' ', $this->body_classes) ?>">
116<div id="footer-background-container"><!-- helper -->
117  <div id="container">
118        <h1 role="banner"><a href="/" title="<?php $p('head-h1-title'); ?>"><?php $p('head-h1'); ?></a></h1>
119        <div id="background-color-container"><!-- helper -->
120        <section class="main content" role="main" id="content">
121                <!--<header class="teaser">
122                        <h2 id="pdp8L">Wissenschaftliche Rechner und Minicomputer</h2>
123                        <img width=880 src="http://www.technikum29.de/shared/photos/rechnertechnik/univac/panorama-rechts.jpg">
124                </header>-->
125        <!-- start content -->
126<?php 
127} // function print_header().
128
129        function print_footer() {
130                $p = $this->msg->get_shorthand_printer();
131                $_ = $this->msg->get_shorthand_returner();
132        ?>
133        <!-- end content -->
134        </section>
135        <hr>
136        <section class="sidebar">
137                        <h2 class="visuallyhidden"><?php $p("sidebar-h2-tour"); ?></h2>
138                        <nav class="side">
139                                <?php $this->menu->print_menu(t29Menu::sidebar_menu); ?>
140                        </nav>
141                        <!-- menu changing buttons are made with javascript -->
142        </section>
143        </div><!-- div id="background-color-container" helper end -->
144        <hr>
145        <header class="banner">
146                <h2 class="visuallyhidden"><?php $p("sidebar-h2-mainnav"); ?></h2>
147                <nav class="horizontal">
148                        <?php $this->menu->print_menu(t29Menu::horizontal_menu); ?>
149                </nav>
150                <nav class="top">
151                        <h3 class="visuallyhidden"><?php $p("sidebar-h2-lang"); ?></h3>
152                        <ul>
153                                <?php
154                                        foreach($this->interlang_links as $lang => $a) {
155                                                printf("\t\t\t\t<li%s><a href='%s' title='%s'>%s</a></li>\n",
156                                                        ($lang == $this->conf['lang'] ? ' class="active"' : ''),
157                                                        $a['href'], sprintf($_('topnav-interlang-title'), $a),
158                                                        $this->conf['languages'][$lang][0] // verbose language name
159                                                );
160                                        }
161                                ?>
162                        </ul>
163                        <form method="get" action="#"><?php printf('
164                                <span class="no-js">%s:</span>
165                                <input type="text" value="" data-defaultvalue="%s" name="q" class="text">
166                                <input type="submit" value="%s" class="button">
167                                ', $_('topnav-search-label'), $_('topnav-search-label'), $_('topnav-search-label')); ?>
168                        </form>
169                </nav>
170    </header>
171        <hr>
172    <footer>
173                <nav class="guide">
174                        <!-- hier wird nav.side die Liste per JS reinkopiert -->
175                </nav>
176                <nav class="rel clearfix">
177                <ul>
178                        <?php
179                                foreach($this->page_relations as $rel => $a) {
180                                        printf("\t<li class='%s'><a href='%s' title='%s'>%s <strong>%s</strong></a>\n",
181                                                $rel, $a['href'], 'TITLE', $_('nav-rel-'.$rel), $a
182                                        );
183                                }
184                        ?>
185                </ul>
186                </nav>
187                <div class="right">
188                        <img src="/shared/img-v6/logo.footer.png" title="technikum29 Logo" alt="Logo" class="logo">
189                        <?php $p('footer-copyright-tag'); ?>
190                        <br/><?php printf('<a href="%s">%s</a>', $this->conf['legal_pagename'], $_('footer-legal-link')); ?>
191                        <div class="icons">
192                                <a href="<?php echo $this->conf['legal_pagename']; ?>#image-copyright"><img src="/shared/img-v6/cc-icon.png"></a>
193                                <!--<a href="http://ufopixel.de" title="Designed by Ufopixel"><img src="http://svenk.homeip.net/dropbox/Ufopixel/Ufopixel-Design/logo_90x30/ufopixel_logo_90x30_version2.png"></a>-->
194                        </div>
195                        <!--CC<br>Viele Bilder können unter einer CreativeCommons-Lizenz
196                        verwendet werden. Erkundigen Sie sich.-->
197                </div>
198    </footer>
199  </div> <!--! end of #container -->
200
201
202  <!-- JavaScript at the bottom for fast page loading -->
203
204  <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
205  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
206  <script>window.jQuery || document.write('<script src="/shared/js-v6/libs/jquery-1.7.2.min.js"><\/script>')</script>
207
208  <script>window.t29={'conf': <?php print json_encode($this->javascript_config); ?>};</script>
209  <script src="/lib/js.php"></script>
210</div><!-- end of div id="footer-background-container" helper -->
211</body>
212</html>
213<?php
214        } // function print_footer()
215       
216} // class t29Template
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