-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchangelanguage.php
300 lines (283 loc) · 10.4 KB
/
changelanguage.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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<?php
/**
* Display a diff between two language files to help in translating.
*
* Genmod: Genealogy Viewer
* Copyright (C) 2005 - 2012 Genmod Development Team
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @package Genmod
* @subpackage Languages
* @version $Id: changelanguage.php 29 2022-07-17 13:18:20Z Boudewijn $
*/
/**
* Inclusion of the configuration file
*/
require "config.php";
//-- make sure that they have admin status before they can use this page
//-- otherwise have them login again
if ($gm_user->username = "") {
if (LOGIN_URL == "") header("Location: login.php?url=changelanguage.php");
else header("Location: ".LOGIN_URL."?url=changelanguage.php");
exit;
}
if (!isset($action) or $action=="") $action="editold";
switch ($action) {
case "addnew" :
$helpindex = "add_new_language_help";
PrintHeader(GM_LANG_add_new_language);
break;
case "editold" :
default :
PrintHeader(GM_LANG_edit_lang_utility);
}
?>
<script language="JavaScript" type="text/javascript">
<!--
function postform(which) {
window.open('editlang_edit_settings.php?action=new_lang&new_shortcut=' + document.new_lang_form.new_shortcut.value, '', 'top=50,left=10,width=1000,height=600,scrollbars=1,resizable=1');
return false;
}
//-->
</script>
<?php
// Create array with configured languages in gedcoms and users
$configuredlanguages = AdminFunctions::LanguageInUse();
// Sort the Language table into localized language name order
foreach ($gm_language as $key => $value){
$d_LangName = "lang_name_".$key;
$Sorted_Langs[$key] = constant("GM_LANG_".$d_LangName);
}
asort($Sorted_Langs);
// Split defined languages into active and inactive
$split_langs_active = array();
$split_langs_inactive = array();
foreach ($Sorted_Langs as $key => $value){
if ($gm_lang_use["$key"]) {
$split_langs_active[count($split_langs_active)+1] = $key;
}
else {
$split_langs_inactive[count($split_langs_inactive)+1] = $key;
}
}
$active = count($split_langs_active);
$inactive = count($split_langs_inactive);
$maxlines = max($active, $inactive);
?>
<!-- Setup the left box -->
<div id="AdminColumnLeft">
<?php AdminFunctions::AdminLink("admin.php", GM_LANG_admin); ?>
<?php AdminFunctions::AdminLink("editlang.php", GM_LANG_translator_tools); ?>
</div>
<div id="AdminColumnMiddle">
<?php
switch ($action) {
case "addnew" : ?>
<form name="new_lang_form" method="post" onsubmit="postform(this); return false;">
<input type="hidden" name="action" value="new_lang" />
<input type="hidden" name="execute" value="true" />
<div class="admin_topbottombar">
<?php print GM_LANG_add_new_language; ?>
</div>
<div class="admin_item_box">
<div class="width25 choice_left">
<div class="HelpIconContainer">
<?php PrintHelpLink("add_new_language_help", "qm", "add_new_language");?>
</div>
<div class="AdminNavBlockOptionText">
<?php require(SystemConfig::$GM_BASE_DIRECTORY . "includes/values/lang_codes_std.php"); ?>
<select name="new_shortcut">
<?php
asort($lng_codes); // Sort the language codes table into language name order
foreach ($lng_codes as $key => $value) {
$showLang = true;
foreach ($lang_short_cut as $key02=>$value) {
if ($value == $key) { // This language is already in GM
$showLang = false;
break;
}
}
if ($showLang) {
print "<option value=\"".$key."\"";
print ">".$lng_codes[$key][0]."</option>\n";
}
}
?>
</select>
</div>
</div>
<div class="width25 center choice_right">
<input type="submit" value="<?php print GM_LANG_add_new_lang_button;?>" />
</div>
</div>
</form>
<?php
$USERLANG = $LANGUAGE;
break;
default : ?>
<form name="lang_config_form" method="get" action="<?php print SCRIPT_NAME;?>">
<input type="hidden" name="action" value="config_lang" />
<table class="NavBlockTable AdminNavBlockTable">
<tr>
<td colspan="6" class="NavBlockHeader AdminNavBlockHeader">
<div class="AdminNavBlockTitle">
<?php PrintHelpLink("config_lang_utility_help", "qm", "config_lang_utility");?>
<?php print GM_LANG_config_lang_utility; ?>
</div>
</td>
</tr>
<tr>
<td class="NavBlockColumnHeader AdminNavBlockColumnHeader">
<?php print GM_LANG_lang_language; ?>
</td>
<td class="NavBlockColumnHeader AdminNavBlockColumnHeader">
<?php print GM_LANG_active; ?>
</td>
<td class="NavBlockColumnHeader AdminNavBlockColumnHeader">
<?php print GM_LANG_edit_settings; ?>
</td>
<td class="NavBlockColumnHeader AdminNavBlockColumnHeader">
<?php print GM_LANG_lang_language; ?>
</td>
<td class="NavBlockColumnHeader AdminNavBlockColumnHeader">
<?php print GM_LANG_active; ?>
</td>
<td class="NavBlockColumnHeader AdminNavBlockColumnHeader">
<?php print GM_LANG_edit_settings; ?>
</td>
</tr>
<?php
// Print the Language table in sorted name order
for ($i=1; $i<=$maxlines; $i++) { ?>
<tr>
<?php
// Left 3 columns: Active language
$value = "";
if ($i <= $active) $value = $split_langs_active[$i];
if ($value == "") { ?>
<td class="NavBlockLabel"> </td>
<td class="NavBlockLabel"> </td>
<td class="NavBlockLabel"> </td>
<?php
}
else {
$d_LangName = "lang_name_" . $value; ?>
<td class="NavBlockLabel">
<?php print constant("GM_LANG_".$d_LangName) ?>
</td>
<td class="NavBlockLabel NavBlockCheckRadio">
<input
<?php
if (AdminFunctions::LanguageInUse($value)) print " disabled=\"disabled\"";
print " type=\"checkbox\" value=\"$value\" checked=\"checked\" onclick=\"enabledisablelanguage('$value');\" />";
?>
</td>
<td class="NavBlockLabel">
<a href="javascript: <?php print $value;?>" onclick="window.open('editlang_edit_settings.php?action=editold&ln=<?php print $value;?>', '', 'top=50,left=10,width=1000,height=600,scrollbars=1,resizable=1'); return false;"><?php print GM_LANG_lang_edit;?></a>
</td>
<?php
}
// Right 3 columns: Inactive language
$value = "";
if ($i <= $inactive) $value = $split_langs_inactive[$i];
if ($value == "") { ?>
<td class="NavBlockLabel"> </td>
<td class="NavBlockLabel"> </td>
<td class="NavBlockLabel"> </td>
<?php
}
else {
$d_LangName = "lang_name_" . $value; ?>
<td class="NavBlockLabel">
<?php print constant("GM_LANG_".$d_LangName); ?>
</td>
<td class="NavBlockLabel NavBlockCheckRadio">
<input type="checkbox" value="<?php print $value; ?>" onclick="enabledisablelanguage('<?php print $value; ?>');" />
</td>
<td class="NavBlockLabel">
<a href="javascript: <?php print $value;?>" onclick="window.open('editlang_edit_settings.php?action=editold&ln=<?php print $value;?>', '', 'top=50,left=10,width=1000,height=600,scrollbars=1,resizable=1'); return false;"><?php print GM_LANG_lang_edit;?></a>
</td>
<?php
}
?>
</tr>
<?php
}
print "</table></form>";
$USERLANG = $LANGUAGE;
?>
<table class="NavBlockTable AdminNavBlockTable">
<tr>
<td colspan="3" class="NavBlockRowSpacer">
</td>
</tr>
<tr>
<td colspan="3" class="NavBlockHeader AdminNavBlockHeader">
<?php print GM_LANG_configured_languages; ?>
</td>
</tr>
<?php
$count = 1;
foreach ($configuredlanguages["gedcom"] as $key => $value) {
foreach($value as $gedcomname => $used) {
$count++;
}
}
$first = true;
foreach ($configuredlanguages["gedcom"] as $key => $value) {
print "<tr>";
if ($first) {
print "<td class=\"NavBlockLabel AdminNavBlockLabel\" rowspan=\"".$count."\">";
print GM_LANG_current_gedcoms;
print "</td>";
$first = false;
}
print "<td class=\"NavBlockLabel AdminNavBlockLabel\">";
// Print gedcom names
foreach($value as $gedcomname => $used) {
print "<a href=\"editconfig_gedcom.php?gedid=".get_id_from_gedcom($gedcomname)."\" target=\"blank\">".$gedcomname."</a>";
}
print "</td>";
print "<td class=\"NavBlockLabel AdminNavBlockLabel\">";
// Print language name and flag
print "<img src=\"".$language_settings[$key]["flagsfile"]."\" class=\"BrightFlag\" alt=\"".constant("GM_LANG_lang_name_".$key)."\" title=\"".constant("GM_LANG_lang_name_".$key)."\" />".constant("GM_LANG_lang_name_".$key);
print "</td></tr>";
}
print "<tr><td class=\"NavBlockLabel AdminNavBlockLabel\" colspan=\"2\"> </td></tr>";
$first = true;
foreach ($configuredlanguages["users"] as $key => $value) {
print "<tr>";
if ($first) {
?><td rowspan="<?php print (count($configuredlanguages["users"])+1); ?>" class="NavBlockLabel AdminNavBlockLabel">
<?php print GM_LANG_users_langs;?>
</td>
<?php
$first = false;
}
print "<td class=\"NavBlockLabel AdminNavBlockLabel\"><a href=\"useradmin.php?action=listusers&filter=language&usrlang=".$key."\">".count($value)."</a></td>";
print "<td class=\"NavBlockLabel AdminNavBlockLabel\">";
print "<img src=\"".$language_settings[$key]["flagsfile"]."\" class=\"BrightFlag\" alt=\"".constant("GM_LANG_lang_name_".$key)."\" title=\"".constant("GM_LANG_lang_name_".$key)."\" />".constant("GM_LANG_lang_name_".$key)."</td></tr>";
}
?>
</table>
<?php
break;
}
$LANGUAGE = $USERLANG;
print "</div>";
PrintFooter();
?>