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

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

Problem abgekuerzter Bezeichnungen im Menue angegangen durch vollstaendige title-Attribute (die den $titel-Variablen in den Seiten entsprechen sollten, das koennte man auf Wunsch auch noch automatisieren). Diese werden in den Seitenrelationen (template.php) sowie in der Beam-Footer-Navigation (menu.js) verwendet.

  • Property svn:keywords set to Id
File size: 8.2 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), $this->relational_link_to_string($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 top">
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        <section class="sidebar bottom">
144                <!-- inhalte die unten ueber dem header sind -->
145        </section>
146        </div><!-- div id="background-color-container" helper end -->
147        <hr>
148        <header class="banner">
149                <h2 class="visuallyhidden"><?php $p("sidebar-h2-mainnav"); ?></h2>
150                <nav class="horizontal">
151                        <?php $this->menu->print_menu(t29Menu::horizontal_menu); ?>
152                </nav>
153                <nav class="top">
154                        <h3 class="visuallyhidden"><?php $p("sidebar-h2-lang"); ?></h3>
155                        <ul>
156                                <?php
157                                        foreach($this->interlang_links as $lang => $a) {
158                                                printf("\t\t\t\t<li%s><a href='%s' title='%s'>%s</a></li>\n",
159                                                        ($lang == $this->conf['lang'] ? ' class="active"' : ''),
160                                                        $a['href'], sprintf($_('topnav-interlang-title'), $a),
161                                                        $this->conf['languages'][$lang][0] // verbose language name
162                                                );
163                                        }
164                                ?>
165                        </ul>
166                        <form method="get" action="#"><?php printf('
167                                <span class="no-js">%s:</span>
168                                <input type="text" value="" data-defaultvalue="%s" name="q" class="text">
169                                <input type="submit" value="%s" class="button">
170                                ', $_('topnav-search-label'), $_('topnav-search-label'), $_('topnav-search-label')); ?>
171                        </form>
172                </nav>
173    </header>
174        <hr>
175    <footer>
176                <nav class="guide">
177                        <!-- hier wird nav.side die Liste per JS reinkopiert -->
178                </nav>
179                <nav class="rel clearfix">
180                <ul>
181                        <?php
182                                foreach($this->page_relations as $rel => $a) {
183                                        printf("\t<li class='%s'><a href='%s' title='%s'>%s <strong>%s</strong></a>\n",
184                                                $rel, $a['href'], sprintf($_('head-rel-'.$rel), $this->relational_link_to_string($a)),
185                                                $_('nav-rel-'.$rel), $this->relational_link_to_string($a)
186                                        );
187                                }
188                        ?>
189                </ul>
190                </nav>
191                <div class="right">
192                        <img src="/shared/img-v6/logo.footer.png" title="technikum29 Logo" alt="Logo" class="logo">
193                        <?php $p('footer-copyright-tag'); ?>
194                        <br/><?php printf('<a href="%s">%s</a>', $this->conf['legal_pagename'], $_('footer-legal-link')); ?>
195                        <div class="icons">
196                                <a href="<?php echo $this->conf['legal_pagename']; ?>#image-copyright"><img src="/shared/img-v6/cc-icon.png"></a>
197                                <!--<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>-->
198                        </div>
199                        <!--CC<br>Viele Bilder können unter einer CreativeCommons-Lizenz
200                        verwendet werden. Erkundigen Sie sich.-->
201                </div>
202    </footer>
203  </div> <!--! end of #container -->
204
205
206  <!-- JavaScript at the bottom for fast page loading -->
207
208  <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
209  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
210  <script>window.jQuery || document.write('<script src="/shared/js-v6/libs/jquery-1.7.2.min.js"><\/script>')</script>
211
212  <script>window.t29={'conf': <?php print json_encode($this->javascript_config); ?>};</script>
213  <script src="/lib/js.php"></script>
214</div><!-- end of div id="footer-background-container" helper -->
215</body>
216</html>
217<?php
218        } // function print_footer()
219       
220        // Hilfsfunktionen
221        private function relational_link_to_string($a) {
222                // wenn es bei einem relationalen Link einen Titel gibt, diesen ausgeben, ansonsten die
223                // Linkbeschreibung. Die Links sind XML-Elemente in der Navigation.
224                return isset($a['title']) ? $a['title'] : $a;
225        }
226       
227} // 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