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

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

CSS modular sauber verteilt und JS-Loading-Framework generalisiert zu einem OOP RessourceLoader, der sowohl JS als auch CSS vom Verzeichnis einlesen kann, Cachefile erzeugt und mit Hooks sowie Postprozessor verarbeiten kann (etwa fuer Minify, LESS, usw.). Noch nicht ausgiebig getestet.

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