[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (wishy@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.sf.net 5 # 6 #This program is free software; you can redistribute it and/or modify 7 #it under the terms of the GNU General Public License as published by 8 #the Free Software Foundation; either version 2 of the License, or 9 #(at your option) any later version. 10 # 11 #This program is distributed in the hope that it will be useful, 12 #but WITHOUT ANY WARRANTY; without even the implied warranty of 13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 #GNU General Public License for more details. 15 #You should have received a copy of the GNU General Public License 16 #along with this program; if not, write to the Free Software 17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 # 19 #$Id: translation.functions.php 2674 2006-03-28 01:14:43Z wishy $ 20 21 /** 22 * Translation functions/classes 23 * 24 * @package CMS 25 */ 26 27 function lang() 28 { 29 global $gCms; 30 global $lang; 31 global $nls; 32 33 $name = ''; 34 $params = array(); 35 $realm = 'admin'; 36 37 if (func_num_args() > 0) 38 { 39 $name = func_get_arg(0); 40 if (func_num_args() == 2 && is_array(func_get_arg(1))) 41 { 42 $params = func_get_arg(1); 43 } 44 else if (func_num_args() > 1) 45 { 46 $params = array_slice(func_get_args(), 1); 47 } 48 } 49 else 50 { 51 return ''; 52 } 53 54 //echo strtolower(get_encoding()) . ':' . strtolower($nls['encoding'][$gCms->current_language]); 55 56 $result = ''; 57 58 if (isset($lang[$realm][$name])) 59 { 60 if (isset($params)) 61 { 62 $result = vsprintf($lang[$realm][$name], $params); 63 } 64 else 65 { 66 $result = $lang[$realm][$name]; 67 } 68 } 69 else 70 { 71 $result = "--Add Me - $name --"; 72 } 73 74 /* 75 if (isset($gCms->current_language) && isset($gCms->config['admin_encoding']) && $gCms->config['admin_encoding'] != '' && isset($gCms->variables['convertclass']) && ($nls['encoding'][$gCms->current_language] != $gCms->config['admin_encoding'])) 76 { 77 $class =& $gCms->variables['convertclass']; 78 $result = $class->Convert($result, $nls['encoding'][$gCms->current_language], $gCms->config['admin_encoding']); 79 } 80 else if (isset($gCms->current_language) && (strtolower(get_encoding()) != strtolower($nls['encoding'][$gCms->current_language])) && isset($gCms->variables['convertclass'])) 81 { 82 $class =& $gCms->variables['convertclass']; 83 $result = $class->Convert($result, $nls['encoding'][$gCms->current_language], get_encoding()); 84 } 85 */ 86 87 if (isset($gCms->config['admin_encoding']) && isset($gCms->variables['convertclass'])) 88 { 89 if (strtolower(get_encoding('', false)) != strtolower($gCms->config['admin_encoding'])) 90 { 91 $class =& $gCms->variables['convertclass']; 92 $result = $class->Convert($result, get_encoding('', false), $gCms->config['admin_encoding']); 93 } 94 } 95 96 //return strtolower(get_encoding('', false)) . ':' . strtolower($gCms->config['admin_encoding']) . ' - ' . $result; 97 return $result; 98 } 99 100 function get_encoding($charset='', $defaultoverrides=true) 101 { 102 global $nls; 103 global $current_language; 104 global $config; 105 106 if ($charset != '') 107 { 108 return $charset; 109 } 110 else if (isset($config['default_encoding']) && $config['default_encoding'] != "" && $defaultoverrides == true) 111 { 112 return $config['default_encoding']; 113 } 114 else if (isset($nls['encoding'][$current_language])) 115 { 116 return $nls['encoding'][$current_language]; 117 } 118 else 119 { 120 return "UTF-8"; //can't hurt 121 } 122 } 123 124 // Returns true if $string is valid UTF-8 and false otherwise. 125 function is_utf8($string) 126 { 127 // From http://w3.org/International/questions/qa-forms-utf-8.html 128 return preg_match('%^(?: 129 [\x09\x0A\x0D\x20-\x7E] # ASCII 130 | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte 131 | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs 132 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte 133 | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates 134 | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 135 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 136 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 137 )*$%xs', $string); 138 139 } // function is_utf8 140 141 # vim:ts=4 sw=4 noet 142 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |