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

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

Umfangreiche Abarbeitung der Todo-Liste für das Launching der neuen Website.
Insbesondere wurden alle englischen Geräteseiten in das neue System übersetzt (wurden vergessen), die Univac-Seiten mussten dafür auch noch umbenannt werden.
Dafür wurde auch die englische Navigation um die Extraseiten vervollständigt.

Ferner:

  • Angefangen: Hostsystem zur Implementierung des aus v5 javascript-basierten hostinfo-Systems (aber mächtiger, mit server- und clientseitigen Hooks). Findet derzeit nur Verwendung in hostspezifischer Veränderung der Template-Konfiguration, etwa auf Heriberts Computer. (Mit den momentanen Einstellungen wird das Bearbeiten auf Heriberts Computer derzeit wieder nicht funktionieren)
  • Derzeit sind (kurzfristig) alle Extraseiten im Menü sichtbar, wenn man es aufklappt.
  • Einige Bugs beseitigt (telefunken-t40w.js, etc.)

Es gibt zwei Extraseiten, bei denen die Bilder gelöscht wurden: LAB 8e und Telefunken 650. Wenn sie nicht mehr verlinkt werden, sollten die Extraseiten auch gelöscht und aus dem Menü entfernt werden.

  • Property svn:keywords set to Id
File size: 12.1 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
13require dirname(__FILE__) . "/ressourceloader.php";
14
15class t29Template {
16        public $conf, $menu, $msg, $host;
17        public $body_classes = array();
18        public $javascript_config = array();
19        public $page_relations, $interlang_links;
20        public $log; // lightweight logging system
21
22        function __construct($conf_array) {
23                $this->conf = $conf_array;
24               
25                // create a lightweight logging object:
26                require_once $this->conf['lib'].'/logging.php';
27                $this->log = new t29Log();
28
29                // create a menu:
30                require_once $this->conf['lib'].'/menu.php';
31                $this->menu = new t29Menu($this->conf);
32
33                // create a host instance:
34                require_once $this->conf['lib'].'/host.php';
35                $this->host = t29Host::detect($this->conf);
36
37                // create localisation class:
38                require_once $this->conf['lib'].'/messages.php';
39                $this->msg = new t29Messages($this->conf['lang']);
40
41                // fill up configuration
42                // optional configuration which can be filled by hooks or parts
43                if(!isset($this->conf['header_prepend']))
44                        $this->conf['header_prepend'] = array(); // list
45               
46                // Path names in messages
47                foreach(array('footer-legal-file', 'topnav-search-page') as $msg_id)
48                        $this->msg->set($msg_id, $this->conf['lang_path'].$this->msg->_($msg_id));
49
50                // store informations about the current page
51                $this->conf['seiten_link'] = $this->menu->get_link();
52                $this->conf['seite_in_nav'] = $this->menu->get_link_navigation_class($this->conf['seiten_link']);
53                $this->conf['seite_in_ul'] = $this->menu->get_link_ul_classes($this->conf['seiten_link']);
54
55                // setup body classes:
56                $body_classprefixes = array(
57                        // css prefix => configuration array value
58                        'lang-' => 'lang',
59                        'page-' => 'seiten_id',
60                        'in-nav-' => 'seite_in_nav',
61                        'in-' => 'seite_in_ul',
62                );
63                foreach($body_classprefixes as $prefix => $key) {
64                        if(is_array($this->conf[$key]))
65                                // append each element of array conf values
66                                foreach($this->conf[$key] as $x)
67                                        $this->body_classes[] = $prefix . $x;
68                        elseif($this->conf[$key]) // skip null/false/empty conf values
69                                $this->body_classes[] = $prefix . $this->conf[$key];
70                }
71               
72                // setup javascript configuration
73                $javascript_transfer = array('lang', 'seiten_id', 'seite_in_nav', 'seite_in_ul');
74                foreach($javascript_transfer as $key)
75                        $this->javascript_config[$key] = $this->conf[$key];
76               
77                // get all kind of relations
78                $this->page_relations = $this->menu->get_page_relations();
79                $this->interlang_links = $this->menu->get_interlanguage_link();
80               
81                // check and load additional css
82                $this->conf['pagecss'] = '/shared/css-v6/pagestyles/'.$this->conf['seiten_id'].'.css';
83                $this->conf['has_pagecss'] = file_exists($this->conf['webroot'].$this->conf['pagecss']);
84                // FIXME: There is no caching check yet for this setting
85                //        (new pagecss file won't be detected and wont purge the tmpl cache)
86               
87                // setup html title
88                $this->conf['html_title'] = '';
89                if(isset($this->conf['titel']) && !empty($this->conf['titel']))
90                        $this->conf['html_title'] = $this->conf['titel'] . ' - ';
91                elseif($this->conf['seiten_id'] == $this->msg->_('homepage-pagename'))
92                        {} // nop: Startseitentitel soll nur sein "technikum29"
93                elseif($this->conf['seiten_link'])
94                        // Titel vom Menu nehmen
95                        $this->conf['html_title'] = $this->conf['seiten_link'] . ' - ';
96                $this->conf['html_title'] .= $this->msg->_('html-title');
97        }
98       
99        /**
100         * Main caching and output system.
101         * Parameters (global configuration):
102         *    skip_cache  -  if true, skips writing output to cache file
103         *    purge_cache -  if true, forces creation of new cache file
104         *                   (does not change behaviour of this file's code)
105         **/
106        function create_cache($cache_object) {
107                $cache_object->start_cache(array($this, 'print_footer'));
108                $this->print_header();
109        }
110       
111        /**
112         * Write header and footer in separate cache files.
113         **/
114        function create_separate_caches($header_cache, $footer_cache) {
115                $header_cache->start_cache();
116                $this->print_header();
117                $header_cache->write_cache(); // will also print out header immediately.
118               
119                $footer_cache->start_cache();
120                $this->print_footer();
121                $footer_content = $footer_cache->write_cache(null, true); // don't print footer immediately.
122               
123                // print footer on exit.
124                register_shutdown_function(function() use ($footer_content) {
125                        print $footer_content;
126                });
127        }
128
129        function print_header() {
130                $p = $this->msg->get_shorthand_printer();
131                $_ = $this->msg->get_shorthand_returner();
132?>
133<!doctype html>
134<html class="no-js" lang="<?php echo $this->conf['lang']; ?>">
135<head>
136  <meta charset="utf-8">
137  <title><?php echo $this->conf['html_title']; ?></title>
138  <meta name="description" content="Produziert am 08.01.2012">
139  <meta name="author" content="technikum29-Team">
140  <meta name="generator" content="t29v6">
141  <meta name="t29.cachedate" content="<?php print date('r'); ?>">
142  <?php
143        foreach($this->conf['header_prepend'] as $h) print $h;
144 
145        if(isset($this->conf['version'])) printf('<meta name="t29.version" content="%s">', $this->conf['version']);
146        if(isset($_GET['debug']))
147                foreach(explode(' ','debug rl_debug skip_cache purge_cache verbose_cache') as $x)
148                        printf("\n  <meta name='t29.template.data-%s' content='%s'>", $x, isset($_GET[$x])?'true':'false');
149  ?>
150 
151  <?php
152        foreach(array_merge(array("first" => t29Menu::dom_new_link($this->conf['lang_path'], $_('head-rel-first'))),
153          $this->page_relations) as $rel => $a) {
154                if($rel == 'start') continue; // not in standard
155                printf("\n  <link rel='%s' href='%s' title='%s' />",
156                        $rel, $a['href'], sprintf($_('head-rel-'.$rel), $this->relational_link_to_string($a))
157                );
158        }
159  ?>
160 
161  <link rel="copyright" href="<?php $p('footer-legal-file'); ?>" title="<?php $p('footer-legal-link'); ?>">
162  <link rel="search" type="application/opensearchdescription+xml" href="<?php $p('topnav-search-page'); print '?action=opensearch-desc&amp;lang='.$this->conf['lang']; ?>" title="<?php $p('opensearch-desc'); ?>">
163  <?php
164        // print interlanguage links for all languages except the active one
165        foreach($this->interlang_links as $lang => $a) {
166                if($lang != $this->conf['lang'] && !is_null($a)) {
167                        printf('<link rel="alternate" href="%s" hreflang="%s" title="%s">',
168                                $a['href'], $lang, sprintf($_('head-rel-interlang', $lang), $a)
169                        );
170                }
171        }
172  ?>
173 
174  <meta name="viewport" content="width=device-width,initial-scale=1">
175  <?php
176        $csslinktmpl = PHP_EOL.'  <link rel="stylesheet" href="%s">';
177        foreach($this->get_ressourceloader_links('css') as $css)
178                printf($csslinktmpl, $css);
179 
180        if($this->conf['has_pagecss'])
181                printf($csslinktmpl, $this->conf['pagecss']);
182  ?>
183
184  <script src="/shared/js-v6/libs/modernizr-2.0.6.min.js"></script>
185</head>
186
187<body class="<?php echo implode(' ', $this->body_classes) ?>">
188  <div id="container">
189        <h1 role="banner"><a href="/" title="<?php $p('head-h1-title'); ?>"><?php $p('head-h1'); ?></a></h1>
190        <div id="background-color-container"><!-- helper -->
191        <section class="main content" role="main" id="content">
192                <?php 
193                        if(!$this->log->is_empty()) {
194                                print '<div class="errorpane">';
195                                $this->log->print_all();
196                                print '</div>';
197                        }
198                ?>
199                <!--<header class="teaser">
200                        <h2 id="pdp8L">Wissenschaftliche Rechner und Minicomputer</h2>
201                        <img width=880 src="http://www.technikum29.de/shared/photos/rechnertechnik/univac/panorama-rechts.jpg">
202                </header>-->
203        <!-- start content -->
204<?php 
205} // function print_header().
206
207        function print_footer() {
208                $p = $this->msg->get_shorthand_printer();
209                $_ = $this->msg->get_shorthand_returner();
210        ?>
211        <!-- end content -->
212        </section>
213        <hr>
214        <section class="sidebar top">
215                        <h2 class="visuallyhidden"><?php $p("sidebar-h2-tour"); ?></h2>
216                        <nav class="side">
217                                <?php $this->menu->print_menu(t29Menu::sidebar_menu); ?>
218                        </nav>
219                        <!-- menu changing buttons are made with javascript -->
220        </section>
221        <section class="sidebar bottom">
222                <!-- inhalte die unten ueber dem header sind -->
223        </section>
224        </div><!-- div id="background-color-container" helper end -->
225        <hr>
226        <header class="banner">
227                <h2 class="visuallyhidden"><?php $p("sidebar-h2-mainnav"); ?></h2>
228                <nav class="horizontal">
229                        <?php $this->menu->print_menu(t29Menu::horizontal_menu); ?>
230                </nav>
231                <nav class="top">
232                        <h3 class="visuallyhidden"><?php $p("sidebar-h2-lang"); ?></h3>
233                        <ul>
234                                <?php
235                                        foreach($this->interlang_links as $lang => $a) {
236                                                $is_current_lang = $lang == $this->conf['lang'];
237                                                if(is_null($a)) {
238                                                        // when interlanguage link not present (null) = no translation exists
239                                                        $a = t29Menu::dom_new_link('#', 'not present');
240                                                        $title = sprintf($_('topnav-interlang-nonexistent', $lang));
241                                                        $class = 'nonexistent';
242                                                } elseif($is_current_lang) {
243                                                        $title = sprintf($_('topnav-interlang-active'), $a);
244                                                        $class = 'active';
245                                                } else {
246                                                        // ordinary interlang link
247                                                        $title = sprintf($_('topnav-interlang-title', $lang), $a);
248                                                        $class = '';
249                                                }
250                                                printf("\t\t\t\t<li%s><a href='%s' title='%s'>%s</a></li>\n",
251                                                        (empty($class) ? '' : " class='$class'"),
252                                                        $a['href'], htmlspecialchars($title),
253                                                        $this->conf['languages'][$lang][0] // verbose language name
254                                                );
255                                        }
256                                ?>
257                        </ul>
258                        <form method="get" action="<?php $p('topnav-search-page'); ?>">
259                                <span class="no-js"><?php $p('topnav-search-label'); ?>:</span>
260                                <input type="text" value="" data-defaultvalue="<?php $p('topnav-search-label'); ?>" name="q" class="text">
261                                <input type="submit" value="<? $p('topnav-search-label'); ?>" class="button">
262                        </form>
263                </nav>
264    </header>
265        <hr>
266    <footer class="in-sheet">
267                <nav class="guide">
268                        <!-- hier wird nav.side die Liste per JS reinkopiert -->
269                </nav>
270                <nav class="rel clearfix">
271                <ul>
272                        <?php
273                          // only print menu when in sidebar where it applies
274                          if($this->conf['seite_in_nav'] == 'side')
275                                foreach($this->page_relations as $rel => $a) {
276                                        printf("\t<li class='%s'><a href='%s' title='%s'>%s <strong>%s</strong></a>\n",
277                                                $rel, $a['href'], sprintf($_('head-rel-'.$rel), $this->relational_link_to_string($a)),
278                                                $_('nav-rel-'.$rel), $this->relational_link_to_string($a)
279                                        );
280                                }
281                        ?>
282                </ul>
283                </nav>
284                <div class="right">
285                        <!-- text der rechts unten steht -->
286                </div>
287    </footer>
288  </div> <!--! end of #container -->
289  <footer class="attached">
290    <div class="legacy"><?php $p('footer-legacy-text'); ?></div>
291        <!--
292        <ul class="clearfix">
293        <li class="logo">
294                <a href="<?php $p('footer-legal-file'); ?>" class="img" title="technikum29 Logo">Logo</a>
295                <p><?php $p('footer-copyright-tag'); ?>
296                   <br><?php printf('<a href="%s">%s</a>', $_('footer-legal-file'), $_('footer-legal-link')); ?>
297                </p>
298        </li>
299        <li class="copy">
300                <a href="<?php $p('footer-legal-file'); ?>#image-copyright" class="img">CC</a>
301                <p>Viele Bilder können unter einer <a href="<?php $p('footer-legal-file'); ?>#image-copyright">CreativeCommons-Lizenz</a>
302                   verwendet werden. <a href="<?php $p('footer-legal-file'); ?>#image-copyright">Erkundigen Sie sich</a>.</p>
303        </li>
304        </ul>
305        -->
306  </footer>
307</div><!-- end of div id="footer-background-container" helper -->
308
309  <!-- JavaScript at the bottom for fast page loading -->
310
311  <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
312  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
313  <script>window.jQuery || document.write('<script src="/shared/js-v6/libs/jquery-1.7.2.min.js"><\/script>')</script>
314
315  <script>window.t29={'conf': <?php print json_encode($this->javascript_config); ?>};</script>
316  <?php
317        foreach($this->get_ressourceloader_links('js') as $js)
318                printf('  <script src="%s"></script>'.PHP_EOL, $js);
319  ?>
320</body>
321</html>
322<?php
323        } // function print_footer()
324       
325        // Hilfsfunktionen
326        private function relational_link_to_string($a) {
327                // wenn es bei einem relationalen Link einen Titel gibt, diesen ausgeben, ansonsten die
328                // Linkbeschreibung. Die Links sind XML-Elemente in der Navigation.
329                return isset($a['title']) ? $a['title'] : $a;
330        }
331
332        function get_ressourceloader_links($type) {
333                $rl = t29RessourceLoader::create_from_type($type, $this->conf);
334                return $rl->get_urls( isset($_GET['rl_debug']) );
335        }
336
337} // 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