[ 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: lang.php 3576 2006-12-15 12:18:22Z dittmann $ 20 21 #Nice decent default 22 $current_language = isset($frontendlang) ? $frontendlang : 'en_US'; 23 24 #Only do language stuff for admin pages 25 if (isset($CMS_ADMIN_PAGE) || isset($CMS_STYLESHEET)) 26 { 27 $nls = array(); 28 $lang = array(); 29 30 #Read in all current languages... 31 $dir = dirname(__FILE__)."/lang"; 32 33 $handle = opendir($dir); 34 while (false!==($file = readdir($handle))) { 35 if (is_file("$dir/$file") && strpos($file, "nls.php") != 0) { 36 include("$dir/$file"); 37 } 38 } 39 closedir($handle); 40 41 #Check to see if there is already a language in use... 42 if (isset($_POST["default_cms_lang"])) 43 { 44 $current_language = $_POST["default_cms_lang"]; 45 if ($current_language == '') 46 { 47 setcookie("cms_language", '', time() - 3600); 48 } 49 else 50 { 51 setcookie("cms_language", $_POST["change_cms_lang"]); 52 } 53 } 54 else if (isset($_SESSION['login_cms_language'])) 55 { 56 debug_buffer('Setting language to: ' . $_SESSION['login_cms_language']); 57 $current_language = $_SESSION['login_cms_language']; 58 setcookie('cms_language', $_SESSION['login_cms_language']); 59 unset($_SESSION['login_cms_language']); 60 } 61 else if (isset($_COOKIE["cms_language"])) 62 { 63 $current_language = $_COOKIE["cms_language"]; 64 } 65 66 if ($current_language == '') 67 { 68 if (isset($gCms->config['locale']) && $gCms->config['locale'] != '') 69 { 70 $current_language = $gCms->config['locale']; 71 } 72 else 73 { 74 75 #No, take a stab at figuring out the default language... 76 #Figure out default language and set it if it exists 77 if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) 78 { 79 $alllang = $_SERVER["HTTP_ACCEPT_LANGUAGE"]; 80 if (strpos($alllang, ";") !== FALSE) 81 $alllang = substr($alllang,0,strpos($alllang, ";")); 82 $langs = explode(",", $alllang); 83 84 foreach ($langs as $onelang) 85 { 86 #Check to see if lang exists... 87 if (isset($nls['language'][$onelang])) 88 { 89 $current_language = $onelang; 90 setcookie("cms_language", $onelang); 91 break; 92 } 93 #Check to see if alias exists... 94 if (isset($nls['alias'][$onelang])) 95 { 96 $alias = $nls['alias'][$onelang]; 97 if (isset($nls['language'][$alias])) 98 { 99 $current_language = $alias; 100 setcookie("cms_language", $alias); 101 break; 102 } 103 } 104 } 105 } 106 } 107 } 108 109 #First load the english one so that we have strings to fall back on 110 @include(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . 'en_US' . DIRECTORY_SEPARATOR . "admin.inc.php"); 111 112 #Now load the real file 113 if ($lang != 'en_US') 114 { 115 $file = dirname(__FILE__) . "/lang/ext/" . $current_language . "/admin.inc.php"; 116 if (!is_file($file)) 117 { 118 $file = dirname(__FILE__) . "/lang/" . $current_language . "/admin.inc.php"; 119 } 120 121 if (is_file($file) && strlen($current_language) == 5 && strpos($current_language, ".") === false) 122 { 123 include ($file); 124 } 125 } 126 127 $nls['direction'] = (isset($nls['direction']) && $nls['direction'] == 'rtl') ? 'rtl' : 'ltr'; 128 129 global $gCms; 130 $gCms->nls = $nls; 131 $gCms->current_language = $current_language; 132 } 133 134 # vim:ts=4 sw=4 noet 135 ?>
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 |