language.inc.php
gehe zur Dokumentation dieser Datei00001 <?php
00002
00003 #
00004 # DaCMS Content Management System
00005 # Copyright (C) 2002,2003 Jan Dankert, cms@jandankert.de
00006 #
00007 # This program is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU General Public License
00009 # as published by the Free Software Foundation; either version 2
00010 # of the License, or (at your option) any later version.
00011 #
00012 # This program is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015 # GNU General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU General Public License
00018 # along with this program; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00020 #
00021
00022
00032 function lang( $textVar,$vars = array() )
00033 {
00034 global $conf;
00035 $lang = $conf['language'];
00036
00037 $text = strtoupper($textVar);
00038
00039
00040 if ( !isset( $lang[$text] ) && substr($text,0,9)=='GLOBAL_' )
00041 $text = substr($text,7);
00042
00043
00044 if ( !isset( $lang[$text] ))
00045 $text = 'GLOBAL_'.$text;
00046
00047
00048 if ( isset( $lang[$text] ) )
00049 {
00050 $text = $lang[$text];
00051
00052
00053 foreach( $vars as $var=>$value )
00054 $text = str_replace('{'.$var.'}',$value,$text);
00055
00056 str_replace("''",'"',$text);
00057
00058 return $text;
00059 }
00060
00061
00062 return( '?'.$textVar.'?' );
00063 }
00064
00065
00066
00067
00079 function langHtml( $key,$vars = array() ) {
00080
00081 return encodeHtml( lang($key,$vars) );
00082 }
00083
00089 function encodeHtml($text)
00090 {
00091 $charset = lang('CHARSET');
00092 if ( in_array( $charset, array('ISO-8859-1','ISO-8859-15','UTF-8')) )
00093 {
00094 return htmlentities($text,ENT_QUOTES,$charset );
00095 }
00096 else
00097 {
00098 return $text;
00099
00100
00101 $t2 = '';
00102
00103 for ( $i=0;$i<strlen($text);$i++)
00104 {
00105 $o = ord($text[$i]);
00106 if ( $o <= 127 )
00107 $t2 .= $text[$i];
00108 else
00109 $t2 .= '&#'.$o.';';
00110 }
00111
00112 return $t2;
00113 }
00114 }
00115
00116
00124 function hasLang( $text )
00125 {
00126 $text = strtoupper($text);
00127
00128 global $conf;
00129 $lang = $conf['language'];
00130
00131 return isset( $lang[$text] );
00132 }
00133
00134
00135 ?>