-
Notifications
You must be signed in to change notification settings - Fork 4
/
class_lang.php
93 lines (82 loc) · 2.72 KB
/
class_lang.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?PHP
class class_lang {
var $language = "en";
var $parser_options = array(
"allow_html" => 0,
"allow_mycode" => 1,
"allow_smilies" => 0,
"allow_imgcode" => 0,
"filter_badwords" => 0
);
function load($sectionfile, $language=false) {
global $parser, $cfg;
if (!$language) { $language = $this->language; }
foreach (explode(",",$sectionfile) as $section) {
$section = trim($section);
$lfile = $cfg['language_abs']."/{$language}/".$section.".lang.php";
if($loadlang = simplexml_load_file($lfile)) {
}
elseif($loadlang = simplexml_load_file($this->path."/en/".$section.".lang.php")) {
$this->language = "en";
}
else {
die("Language file \"$section\" for \"{$language}\" does not exist or not loadable");
}
if($loadlang) {
foreach($loadlang as $key => $val) {
$val = $parser->parse_message(str_replace("'", "'", $val), $this->parser_options);
if(empty($this->$key) || $this->$key != $val) {
$this->$key = $val;
}
}
}
}
}
function sprintf($string)
{
$arg_list = func_get_args();
$num_args = count($arg_list);
for($i = 1; $i < $num_args; $i++)
{
$string = str_replace('{'.$i.'}', $arg_list[$i], $string);
}
return $string;
}
function get_languages() {
global $florensia;
/*
$header = array();
$querylang = MYSQL_QUERY("SHOW COLUMNS FROM flobase_language");
while ($lang = MYSQL_FETCH_ARRAY($querylang)) {
array_push($header, $lang[0]);
}
*/
$querylang = MYSQL_QUERY("SELECT * FROM flobase_language");
while ($lang = MYSQL_FETCH_ASSOC($querylang)) {
foreach ($lang as $headertitle => $langvalue) {
$this->lang[$lang['languageid']]->$headertitle = $langvalue;
}
}
}
function exportfile($filename, $langid) {
global $florensia;
$langfile = $florensia->language_abs."/{$langid}/{$filename}.lang.php";
if (!rename($langfile, $langfile.'_backup_'.date("Y.m.d-H.i.s"))) {
$florensia->notice("Cannot rename old file for backup. Please verify your chmod settings!", "warning");
return false;
}
if (!($newfile = fopen($langfile, 'a'))) {
$florensia->notice("Cannot create new file. Please verify your chmod settings!", "warning");
return false;
}
$newlangfile = new SimpleXMLElement("<{$filename} createdate=\"".date("Y-m-d H:i:s / U")."\"></{$filename}>");
$querylangvar = MYSQL_QUERY("SELECT varname, lang_{$langid} FROM flobase_languagefiles WHERE filename='".mysql_real_escape_string($filename)."'");
while ($langvar = MYSQL_FETCH_ARRAY($querylangvar)) {
$newlangfile->$langvar['varname'] = $langvar['lang_'.$langid];
}
$newlangfile->asXML($langfile);
$florensia->notice("Language file and backup for {$langid}/{$filename} successfully created", "successful");
return true;
}
}
?>