[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 # CMS - CMS Made Simple 3 # (c)2004-6 by Ted Kulp (ted@cmsmadesimple.org) 4 # This project's homepage is: http://cmsmadesimple.org 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$ 20 21 /** 22 * Methods for modules to do language related functions 23 * 24 * @since 1.0 25 * @package CMS 26 */ 27 28 function cms_module_Lang(&$modinstance) 29 { 30 global $gCms; 31 32 $name = ''; 33 $params = array(); 34 35 if (func_num_args() > 0) 36 { 37 38 $name = func_get_arg(1); 39 if (func_num_args() == 3 && is_array(func_get_arg(2))) 40 { 41 $params = func_get_arg(2); 42 } 43 else if (func_num_args() > 2) 44 { 45 $params = array_slice(func_get_args(), 2); 46 } 47 } 48 else 49 { 50 return ''; 51 } 52 53 if ($modinstance->curlang == '' && isset($gCms->current_language)) 54 { 55 $modinstance->curlang = $gCms->current_language; 56 } 57 $ourlang = $modinstance->curlang; 58 59 #Load the language if it's not loaded 60 if (!isset($modinstance->langhash[$ourlang]) || !is_array($modinstance->langhash[$ourlang]) || 61 (is_array($modinstance->langhash[$ourlang]) && count(array_keys($modinstance->langhash[$ourlang])) == 0)) 62 { 63 $dir = $gCms->config['root_path']; 64 65 $lang = array(); 66 67 //First load the default language to remove any "Add Me's" 68 if (@is_file("$dir/modules/".$modinstance->GetName()."/lang/".$modinstance->DefaultLanguage()."/".$modinstance->DefaultLanguage().".php")) 69 { 70 include("$dir/modules/".$modinstance->GetName()."/lang/".$modinstance->DefaultLanguage()."/".$modinstance->DefaultLanguage().".php"); 71 } 72 else if (@is_file("$dir/modules/".$modinstance->GetName()."/lang/".$modinstance->DefaultLanguage().".php")) 73 { 74 include("$dir/modules/".$modinstance->GetName()."/lang/".$modinstance->DefaultLanguage().".php"); 75 } 76 77 //Now load the other language if necessary 78 if (count($lang) == 0 || $modinstance->DefaultLanguage() != $ourlang) 79 { 80 if (@is_file("$dir/modules/".$modinstance->GetName()."/lang/$ourlang/$ourlang.php")) 81 { 82 include("$dir/modules/".$modinstance->GetName()."/lang/$ourlang/$ourlang.php"); 83 } 84 else if (@is_file("$dir/modules/".$modinstance->GetName()."/lang/ext/$ourlang.php")) 85 { 86 include("$dir/modules/".$modinstance->GetName()."/lang/ext/$ourlang.php"); 87 } 88 else if (@is_file("$dir/modules/".$modinstance->GetName()."/lang/$ourlang.php")) 89 { 90 include("$dir/modules/".$modinstance->GetName()."/lang/$ourlang.php"); 91 } 92 else if (count($lang) == 0) 93 { 94 if (@is_file("$dir/modules/".$modinstance->GetName()."/lang/".$modinstance->DefaultLanguage()."/".$modinstance->DefaultLanguage().".php")) 95 { 96 include("$dir/modules/".$modinstance->GetName()."/lang/".$modinstance->DefaultLanguage()."/".$modinstance->DefaultLanguage().".php"); 97 } 98 else if (@is_file("$dir/modules/".$modinstance->GetName()."/lang/".$modinstance->DefaultLanguage().".php")) 99 { 100 include("$dir/modules/".$modinstance->GetName()."/lang/".$modinstance->DefaultLanguage().".php"); 101 } 102 } 103 else 104 { 105 # Sucks to be here... Don't use Lang unless there are language files... 106 # Get ready for a lot of Add Me's 107 } 108 } 109 110 # try to load an admin modifiable version of the lang file if one exists 111 if( @is_file("$dir/module_custom/".$modinstance->GetName()."/lang/".$modinstance->DefaultLanguage().".php") ) 112 { 113 include("$dir/module_custom/".$modinstance->GetName()."/lang/".$modinstance->DefaultLanguage().".php"); 114 } 115 116 $modinstance->langhash[$ourlang] = &$lang; 117 } 118 119 $result = ''; 120 121 if (isset($modinstance->langhash[$ourlang][$name])) 122 { 123 if (count($params)) 124 { 125 $result = @vsprintf($modinstance->langhash[$ourlang][$name], $params); 126 } 127 else 128 { 129 $result = $modinstance->langhash[$ourlang][$name]; 130 } 131 } 132 else 133 { 134 $result = "--Add Me - module:".$modinstance->GetName()." string:$name--"; 135 } 136 137 if (isset($gCms->config['admin_encoding']) && isset($gCms->variables['convertclass'])) 138 { 139 if (strtolower(get_encoding('', false)) != strtolower($gCms->config['admin_encoding'])) 140 { 141 $class =& $gCms->variables['convertclass']; 142 $result = $class->Convert($result, get_encoding('', false), $gCms->config['admin_encoding']); 143 } 144 } 145 146 return $result; 147 } 148 149 ?>
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 |