Changeset 261 in t29-www


Ignore:
Timestamp:
May 29, 2012, 1:09:22 AM (12 years ago)
Author:
sven
Message:

Some minor improvements:

  • template.php: Loading page specific CSS if present
  • messages.php: Documentation added
  • style.css: Precedence for correct display of old content
Files:
9 added
3 edited

Legend:

Unmodified
Added
Removed
  • lib/messages.php

    r260 r261  
    11<?php
     2/**
     3 * t29v6 Message subsystem.
     4 *
     5 **/
    26
     7// You can run this script to get all messages as JSON.
     8// See also /shared/js/modules/msg.js and js.php.
    39if(realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__) {
    410        header('Content-Type: application/json');
     
    915
    1016class t29Messages {
     17        /// when instanciated, stores the language to lookup for _()
    1118        public $lang;
     19
     20        /// The order of array elements in $msg. This array maps
     21        /// $lang shortstring to array index position.
    1222        public static $order = array('de' => 0, 'en' => 1);
    1323       
     
    1626        }
    1727
     28        /**
     29         * The translate function, shorthand like the gettext shorthand.
     30         * There's actually no long method name version :D
     31         * @param str_id  Some key from the $msg array
     32         * @returns Found string in current locale ($lang)
     33         **/
    1834        function _($str_id) {
    1935                if(!isset(self::$msg[$str_id])) {
     
    2844       
    2945        /**
     46         * Returns a function which prints the output of _. Usage:
     47         *
    3048         * $msg = new t29Messages("foo");
    3149         * print $msg->_("foobar");              // ordinary long version
     
    3856        }
    3957
    40         /// same but return instead of print
     58        /// same like get_shorthand_printer but return instead of print
    4159        function get_shorthand_returner() {
    4260                $t = $this;
     
    4462        }
    4563
     64        /**
     65         * Returns the $msg array as well as the order array encoded as JSON.
     66         * The output will look like '{order:{de:0,en:1},msg:{'foo':['bar,'baz']}}'.
     67         * A given $filter_regexp will be run on the msg keys and hence give
     68         * out only matching entries. Example: $filter_regexp = "/^js-/"
     69         * would filter out all JavaScript related entries.
     70         **/
    4671        static function create_json($filter_regexp=false) {
    4772                $msg = $filter_regexp ? array_intersect_key(self::$msg,
     
    5479        }
    5580
     81        /**
     82         * The Messages array maps a message id (string) to the message text
     83         * (string or numeric array). If the message value is an array, it will be
     84         * interpreted as multi language string, whereas the mapping from language
     85         * to index is supposed to be done via the $order array (see above).
     86         **/
    5687        public static $msg = array(
    5788                'html-title'             => 'technikum29',
     
    88119                // used in /shared/js/modules/img_license.js
    89120                'js-img-license'         => array(
    90                                                                                 '&copy; technikum29. <a href="/de-v6/impressum.shtm#image-copyright">Lizenzbestimmungen</a>',
    91                                                                                 '&copy; technikum29. <a href="/en/contact.shtm#image-copyright">Licensing terms</a>',
     121                                                                                '&copy; technikum29. <a href="/de-v6/impressum.php#image-copyright">Lizenzbestimmungen</a>',
     122                                                                                '&copy; technikum29. <a href="/en-v6/contact.php#image-copyright">Licensing terms</a>',
    92123                                                                        ),
    93124        );
  • lib/template.php

    r260 r261  
    4242                $this->page_relations = $this->menu->get_page_relations();
    4343                $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)
    4450        }
    4551       
     
    6672               
    6773                if(!file_exists($this->conf['cache_file'])) {
    68                         self::mkdir_recursive(dirname($this->conf['cache_file']));
     74                        if(!self::mkdir_recursive(dirname($this->conf['cache_file']))) {
     75                                print "<div class='error'>Could not create recursive caching directories</div>";
     76                        }
    6977                }
    70 
    71                 if(file_put_contents($this->conf['cache_file'], $whole_page))
     78               
     79                if(@file_put_contents($this->conf['cache_file'], $whole_page))
    7280                        print "<!-- Wrote output cache successfully -->\n";
     81                else
     82                        print "<div class='error'>Could not write page output cache to ".$this->conf['cache_file']."</div>";
    7383        }
    7484
     
    8696<head>
    8797  <meta charset="utf-8">
    88   <title><?php isset($this->conf['titel']) ? $this->conf['titel'].' - ' : ''; $p('html-title'); ?></title>
     98  <title><?php echo isset($this->conf['titel']) ? $this->conf['titel'].' - ' : ''; $p('html-title'); ?></title>
    8999  <meta name="description" content="Produziert am 08.01.2012">
    90100  <meta name="author" content="Sven">
     
    118128  <link rel="stylesheet" href="/shared/css-v6/style.css">
    119129  <link rel="stylesheet" href="/shared/css/common.css">
     130  <?php
     131        if($this->conf['has_pagecss'])
     132                printf('<link rel="stylesheet" href="%s">', $this->conf['pagecss']);
     133  ?>
    120134
    121135  <script src="/shared/js-v6/libs/modernizr-2.0.6.min.js"></script>
     
    205219                        verwendet werden. Erkundigen Sie sich.-->
    206220                </div>
    207                                
    208                 <!--Copyright-Hinweis<br>
    209                 technikum29-Logo, Link aufs Impressum, Kontakt<br>
    210                 Creative-Commons-Tag<br>
    211                 Designed by Ufopixel<br>-->
    212221    </footer>
    213222  </div> <!--! end of #container -->
     
    220229  <script>window.jQuery || document.write('<script src="/shared/js-v6/libs/jquery-1.7.2.min.js"><\/script>')</script>
    221230
    222   <!--<script src="/lib/messages.php?pre=t29MSGDATA%3D&post=<?php echo urlencode('$(function(){t29.msg.setup();});'); ?>"></script>-->
    223231  <script>window.t29={'conf': <?php print json_encode($this->javascript_config); ?>};</script>
    224232  <script src="/lib/js.php"></script>
  • shared/css-v6/style.css

    r260 r261  
    88
    99/* Anpassungsstyles, die benoetigt werden damit der Text aussieht wie frueher */
    10 .center { text-align: center; }
    1110#content p { text-align: justify } /* !! */
     11#content .center { text-align: center; }
    1212
    1313body, input { /* font */
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