Changeset 255 in t29-www for lib/template.php


Ignore:
Timestamp:
May 28, 2012, 2:55:06 PM (12 years ago)
Author:
sven
Message:

Backend: Class cleanup, multi language support builtin, Message system (with experimental JSON connection). Template is ready to be deployed for multi language.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/template.php

    r254 r255  
    1212 
    1313class t29Template {
    14         public $conf;
    15         public $menu;
     14        private static $legal_pagenames = array( // should be const
     15        # lang => file relative to $lang_path, with starting "/".
     16                "de" => "/impressum.php",
     17                "en" => "/contact.php",
     18        );
     19
     20        public $conf, $menu, $msg;
     21        public $body_classes = array();
     22        public $javascript_config = array();
    1623
    1724        function __construct($conf_array) {
    1825                $this->conf = $conf_array;
    19                
     26
     27                // fill up configuration
     28                $this->conf['legal_pagename'] = $this->conf['lang_path'] . self::$legal_pagenames[$this->conf['lang']];
     29
    2030                // create a menu:
    2131                require_once $this->conf['lib'].'/menu.php';
    2232                $this->menu = new t29Menu($this->conf);
     33
     34                // create localisation class:
     35                require_once $this->conf['lib'].'/messages.php';
     36                $this->msg = new t29Messages($this->conf['lang']);
     37
     38                // setup body classes:
     39                $this->body_classes[] = "lang-" . $this->conf['lang'];
     40                $this->body_classes[] = "page-" . $this->conf['seiten_id'];
     41               
     42                // setup javascript configuration
     43                $this->javascript_config['lang'] = $this->conf['lang'];
     44                $this->javascript_config['seiten_id'] = $this->conf['seiten_id'];
    2345        }
    2446       
     
    5779
    5880        function print_header() {
     81                $_ = $this->msg->get_shorthand_printer();
    5982?>
    6083<!doctype html>
    61 <html class="no-js" lang="de">
     84<html class="no-js" lang="<?php echo $this->conf['lang']; ?>">
    6285<head>
    6386  <meta charset="utf-8">
    64   <title><?php isset($this->conf['titel']) ? $this->conf['titel'].' - ' : ''; ?> technikum29</title>
     87  <title><?php isset($this->conf['titel']) ? $this->conf['titel'].' - ' : ''; $_('html-title'); ?></title>
    6588  <meta name="description" content="Produziert am 08.01.2012">
    6689  <meta name="author" content="Sven">
     
    7598</head>
    7699
    77 <body>
     100<body class="<?php echo implode(' ', $this->body_classes) ?>">
    78101<div id="footer-background-container"><!-- helper -->
    79102  <div id="container">
    80         <h1 role="banner"><a href="#/" title="Zur technikum29 Startseite">technikum29</a></h1>
     103        <h1 role="banner"><a href="/" title="<?php $_('head-h1-title'); ?>"><?php $_('head-h1'); ?></a></h1>
    81104        <div id="background-color-container"><!-- helper -->
    82105        <section class="main content" role="main" id="content">
     
    90113
    91114function print_footer() {
     115        $p = $this->msg->get_shorthand_printer();
     116        $_ = $this->msg->get_shorthand_returner();
    92117?>
    93118        <!-- end content -->
     
    95120        <hr>
    96121        <section class="sidebar">
    97                         <h2 class="visuallyhidden">Museumstour</h2>
     122                        <h2 class="visuallyhidden"><?php $p("sidebar-h2-tour"); ?></h2>
    98123                        <nav class="side">
    99                                 <?php $this->menu->print_menu($this->menu->sidebar_menu); ?>
    100                                 <span class="button collapse-menu">Menü ausklappen</span>
     124                                <?php $this->menu->print_menu(t29Menu::sidebar_menu); ?>
    101125                        </nav>
    102                         <!-- hier dann die Buttons, die dynamisch erzeugt werden, zum Aufklappen, etc. -->
    103                         <!-- die werden dann mit Javascript gemacht -->
    104                         <span class="button get-menu">Menü anzeigen</span>
     126                        <!-- menu changing buttons are made with javascript -->
    105127        </section>
    106128        </div><!-- div id="background-color-container" helper end -->
    107129        <hr>
    108130        <header class="banner">
    109                 <h2 class="visuallyhidden">Hauptnavigation</h2>
     131                <h2 class="visuallyhidden"><?php $p("sidebar-h2-mainnav"); ?></h2>
    110132                <nav class="horizontal">
    111                         <?php $this->menu->print_menu($this->menu->horizontal_menu); ?>
     133                        <?php $this->menu->print_menu(t29Menu::horizontal_menu); ?>
    112134                </nav>
    113135                <nav class="top">
    114                         <h3 class="visuallyhidden">Sprachauswahl</h3>
     136                        <h3 class="visuallyhidden"><?php $p("sidebar-h2-lang"); ?></h3>
    115137                        <ul>
    116                                 <li class="active"><a href="#">Deutsch</a>
    117                                 <li><a href="#">Englisch</a>
     138                                <?php
     139                                        foreach($this->conf['languages'] as $l => $sets) {
     140                                                printf("\t\t\t\t<li%s><a href='%s' title='%s'>%s</a></li>\n",
     141                                                        ($l == $this->conf['lang'] ? ' class="active"' : ''),
     142                                                        $sets[1].'#',
     143                                                        "View in $sets[0]",
     144                                                        $sets[0]
     145                                                );
     146                                       
     147                                        }
     148                                ?>
    118149                        </ul>
    119                         <form method="get" action="#">
    120                                 <span class="no-js">Suchen:</span>
    121                                 <input type="text" value="" data-defaultvalue="Suchen" name="q" class="text">
    122                                 <input type="submit" value="Suchen" class="button">
     150                        <form method="get" action="#"><?php printf('
     151                                <span class="no-js">%s:</span>
     152                                <input type="text" value="" data-defaultvalue="%s" name="q" class="text">
     153                                <input type="submit" value="%s" class="button">
     154                                ', $_('sidebar-search-label'), $_('sidebar-search-label'), $_('sidebar-search-label')); ?>
    123155                        </form>
    124156                </nav>
     
    140172                <div class="right">
    141173                        <img src="/shared/img-v6/logo.footer.png" title="technikum29 Logo" alt="Logo" class="logo">
    142                         &copy; 2003-2012 technikum29.
    143                         <br/><a href="/de-v6/impressum.php">Impressum und Kontakt</a>
     174                        <?php $p('footer-copyright-tag'); ?>
     175                        <br/><?php printf('<a href="%s">%s</a>', $this->conf['legal_pagename'], $_('footer-legal-link')); ?>
    144176                        <div class="icons">
    145                                 <a href="/de-v6/impressum.php#image-copyright"><img src="/shared/img-v6/cc-icon.png"></a>
     177                                <a href="<?php echo $this->conf['legal_pagename']; ?>#image-copyright"><img src="/shared/img-v6/cc-icon.png"></a>
    146178                                <!--<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>-->
    147179                        </div>
     
    164196  <script>window.jQuery || document.write('<script src="/shared/js-v6/libs/jquery-1.6.2.min.js"><\/script>')</script>
    165197
    166 
    167   <script defer src="/shared/js-v6/plugins.js"></script>
    168   <script defer src="/shared/js-v6/script.js"></script>
     198  <script src="/lib/messages.php?pre=t29MSGDATA%3D&post=<?php echo urlencode('$(function(){t29.msg.setup();});'); ?>"></script>
     199  <script>$(function(){t29.config = <?php print json_encode($this->javascript_config); ?>; });</script>
     200  <script src="/shared/js-v6/plugins.js"></script>
     201  <script src="/shared/js-v6/script.js"></script>
    169202</div><!-- end of div id="footer-background-container" helper -->
    170203</body>
Note: See TracChangeset for help on using the changeset viewer.
© 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