class_Language.inc.php
6.01 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
/**
* @file Language.inc.php
* @category freeSN
* @mailto code [at] netz.coop
* @version 0.4.200901
* @link http://netz.coop
*
* @copyright Copyright by netz.coop e.G. 2015
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
class Language {
private static $choosenLang;
public static function getGeneralLinks($param_key, $param_link=null) {
if($param_link) {
return TreeLanguage::$GeneralLinks[$param_key][$param_link];
} else if(array_key_exists($param_key, TreeLanguage::$GeneralLinks) && TreeLanguage::$GeneralLinks[$param_key]) {
return TreeLanguage::$GeneralLinks[$param_key];
} else {
return array('label' => $param_key, 'image' => '');
}
}
public static function getBCRightManagement($param_BasisClipboardname) {
$var_BCLanguage = Language::getClassLinks($param_BasisClipboardname, 'RightManagement');
if(array_key_exists('ReadKeys', $var_BCLanguage) && array_key_exists('WriteKeys', $var_BCLanguage)) {
return $var_BCLanguage;
} else {
return Language::getClassLinks('BasisClipboard', 'RightManagement');
}
}
/**
* return the languge data
*
* @param string param_class (@see TreeConfig::$ClassLinks[param_class])
* @param string param_link (@see TreeConfig::$ClassLinks[param_class][$param_link])
* @param string param_index (@see TreeConfig::$ClassLinks[param_class][$param_link][param_index])
*/
public static function getClassLinks($param_class, $param_link=null, $param_index = null) {
//D::li('Language::getClassLinks('.$param_class.", $param_link=null, $param_index = null".')');
$param_class = trim($param_class);
$param_link = trim($param_link);
$var_ClassCategoryArray = CONFIG::transformStringToArray($param_class, 'category');
/**
* @if Klassename (evt. mit Kategorie bei BasisClipboard (dann BasisClipboard::Category))
*/
if(array_key_exists($param_class, TreeLanguage::$ClassLinks) && array_key_exists($param_link, TreeLanguage::$ClassLinks[$param_class]) && $param_link!=null) {
if($param_index == null){
return TreeLanguage::$ClassLinks[$param_class][$param_link];
// $var_return = TreeLanguage::$ClassLinks[$param_class][$param_link];
}
else{
return TreeLanguage::$ClassLinks[$param_class][$param_link][$param_index];
// $var_return = TreeLanguage::$ClassLinks[$param_class][$param_link][$param_index];
}
/**
* @elseif wenn nicht kompletter Klasssenname gefunden wurde, dann ohne Category (falls vorhanden)
*/
} else if(array_key_exists($var_ClassCategoryArray[0], TreeLanguage::$ClassLinks) && array_key_exists($param_link, TreeLanguage::$ClassLinks[$var_ClassCategoryArray[0]]) && $param_link!=null) {
if($param_index == null){
// return TreeLanguage::$ClassLinks[$var_ClassCategoryArray[0]][$param_link];
return TreeLanguage::$ClassLinks[$var_ClassCategoryArray[0]][$param_link];
}
else{
// return TreeLanguage::$ClassLinks[$var_ClassCategoryArray[0]][$param_link][$param_index];
return TreeLanguage::$ClassLinks[$var_ClassCategoryArray[0]][$param_link][$param_index];
}
}
// return false;
return array('label' => $param_link);
}
public static function getService($param_index) {
if(TreeLanguage::$GroupArray['Services'][$param_index]) {
return TreeLanguage::$GroupArray['Services'][$param_index];
} else {
return $param_index;
}
}
public static function getWord($param_word) {
if(array_key_exists(trim($param_word), TreeLanguage::$Words)) {
return TreeLanguage::$Words[trim($param_word)];
} else {
return $param_word;
}
}
public static function getGroupLanguage($param_Group, $param_index) {
if(array_key_exists($param_Group, TreeLanguage::$GroupArray) && array_key_exists($param_index, TreeLanguage::$GroupArray[$param_Group]) && TreeLanguage::$GroupArray[$param_Group][$param_index]) {
return TreeLanguage::$GroupArray[$param_Group][$param_index];
} else {
return array('label' => $param_index);
}
}
public static function getMessage($param_kind, $param_index) {
if(TreeLanguage::$Lang_Message[$param_kind][$param_index]) {
return TreeLanguage::$Lang_Message[$param_kind][$param_index];
} else {
return false;
}
}
/**
* Function returns a XML Language Filename defined in class TreeLanguage.
* If param_key doesn't exists in the array, the default Filename will be returned!
*
* @param String param_kind
*
* @return String XML Language Filename
*/
public static function getLanguageFilename($param_key = false) {
if(!$param_key){
$param_key=TreeLanguage::$DefaultLanguage;
}
else if(!array_key_exists($param_key,TreeLanguage::$LanguageFilename)){
Error::newError("Language","Language option ".$param_key." does not exist! Language is set to default -> ".TreeLanguage::$DefaultLanguage,"256");
$param_key=TreeLanguage::$DefaultLanguage;
}
if(array_key_exists($param_key,TreeLanguage::$LanguageFilename)) {
self::setISOLanguage($param_key);
return TreeLanguage::$LanguageFilename[$param_key];
}
}
private static function setISOLanguage($param_key) {
self::$choosenLang = $param_key;
$_GET[CONSTKindOf::LANG]=$param_key;
}
public static function getISOLanguage() {
return self::$choosenLang;
}
public static function addISOLanguages(&$param_DOMDocument){
foreach(TreeLanguage::$LanguageFilename as $key => $value){
$DOMElement = $param_DOMDocument->createElement('ISO');
$DOMElement->setAttribute('code',$key);
$param_DOMDocument->documentElement->appendChild($DOMElement);
}
}
}
?>