- Timestamp:
- May 29, 2012, 1:09:22 AM (12 years ago)
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/messages.php
r260 r261 1 1 <?php 2 /** 3 * t29v6 Message subsystem. 4 * 5 **/ 2 6 7 // You can run this script to get all messages as JSON. 8 // See also /shared/js/modules/msg.js and js.php. 3 9 if(realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__) { 4 10 header('Content-Type: application/json'); … … 9 15 10 16 class t29Messages { 17 /// when instanciated, stores the language to lookup for _() 11 18 public $lang; 19 20 /// The order of array elements in $msg. This array maps 21 /// $lang shortstring to array index position. 12 22 public static $order = array('de' => 0, 'en' => 1); 13 23 … … 16 26 } 17 27 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 **/ 18 34 function _($str_id) { 19 35 if(!isset(self::$msg[$str_id])) { … … 28 44 29 45 /** 46 * Returns a function which prints the output of _. Usage: 47 * 30 48 * $msg = new t29Messages("foo"); 31 49 * print $msg->_("foobar"); // ordinary long version … … 38 56 } 39 57 40 /// same but return instead of print58 /// same like get_shorthand_printer but return instead of print 41 59 function get_shorthand_returner() { 42 60 $t = $this; … … 44 62 } 45 63 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 **/ 46 71 static function create_json($filter_regexp=false) { 47 72 $msg = $filter_regexp ? array_intersect_key(self::$msg, … … 54 79 } 55 80 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 **/ 56 87 public static $msg = array( 57 88 'html-title' => 'technikum29', … … 88 119 // used in /shared/js/modules/img_license.js 89 120 'js-img-license' => array( 90 '© technikum29. <a href="/de-v6/impressum. shtm#image-copyright">Lizenzbestimmungen</a>',91 '© technikum29. <a href="/en /contact.shtm#image-copyright">Licensing terms</a>',121 '© technikum29. <a href="/de-v6/impressum.php#image-copyright">Lizenzbestimmungen</a>', 122 '© technikum29. <a href="/en-v6/contact.php#image-copyright">Licensing terms</a>', 92 123 ), 93 124 ); -
lib/template.php
r260 r261 42 42 $this->page_relations = $this->menu->get_page_relations(); 43 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) 44 50 } 45 51 … … 66 72 67 73 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 } 69 77 } 70 71 if( file_put_contents($this->conf['cache_file'], $whole_page))78 79 if(@file_put_contents($this->conf['cache_file'], $whole_page)) 72 80 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>"; 73 83 } 74 84 … … 86 96 <head> 87 97 <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> 89 99 <meta name="description" content="Produziert am 08.01.2012"> 90 100 <meta name="author" content="Sven"> … … 118 128 <link rel="stylesheet" href="/shared/css-v6/style.css"> 119 129 <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 ?> 120 134 121 135 <script src="/shared/js-v6/libs/modernizr-2.0.6.min.js"></script> … … 205 219 verwendet werden. Erkundigen Sie sich.--> 206 220 </div> 207 208 <!--Copyright-Hinweis<br>209 technikum29-Logo, Link aufs Impressum, Kontakt<br>210 Creative-Commons-Tag<br>211 Designed by Ufopixel<br>-->212 221 </footer> 213 222 </div> <!--! end of #container --> … … 220 229 <script>window.jQuery || document.write('<script src="/shared/js-v6/libs/jquery-1.7.2.min.js"><\/script>')</script> 221 230 222 <!--<script src="/lib/messages.php?pre=t29MSGDATA%3D&post=<?php echo urlencode('$(function(){t29.msg.setup();});'); ?>"></script>-->223 231 <script>window.t29={'conf': <?php print json_encode($this->javascript_config); ?>};</script> 224 232 <script src="/lib/js.php"></script>
Note: See TracChangeset
for help on using the changeset viewer.