-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface_edit_added.cgi
executable file
·99 lines (87 loc) · 2.72 KB
/
interface_edit_added.cgi
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
#!/usr/bin/perl
# Copyright (C) 2004-2019
# Emmanuel Saracco <emmanuel@esaracco.fr>
#
# GNU GENERAL PUBLIC LICENSE
require './translator-lib.pl';
my $app = $in{'app'};
my $lang = $in{'t'};
my $webmin_lang = $in{'webmin_lang'};
my %file = ($webmin_lang eq 'lang') ?
&trans_get_items ("$root_directory/lang/$lang") :
&trans_get_items (&trans_get_path ($app, "lang/$lang"));
my %file_ref = ($webmin_lang eq 'lang') ?
&trans_get_items ("$root_directory/lang/$ref_lang") :
&trans_get_items (&trans_get_path ($app, "lang/$ref_lang"));
my %new = &trans_get_hash_diff_new ($ref_lang, $lang, \%file_ref, \%file);
##### POST actions #####
#
# add new items in the translation file
if (defined ($in{'update'}))
{
my $updated = 0;
my $url = "interface_main.cgi?app=$app&t=$lang&webmin_lang=$webmin_lang";
foreach my $item (keys %in)
{
if ($item =~ /newitem_/)
{
$item =~ s/newitem_//g;
if ($in{"newitem_$item"} ne '')
{
$updated = 1;
$file{$item} = $in{"newitem_$item"};
}
}
}
if ($updated)
{
($webmin_lang eq 'lang') ?
open (H, '>', "$root_directory/lang/$lang") :
open (H, '>', &trans_get_path ($app, "lang/$lang"));
foreach my $item (sort keys %file)
{
next if ($item eq '');
print H "$item=$file{$item}\n";
}
close (H);
# FIXME
# do not encode webmin "/lang/*" files
($webmin_lang eq 'lang') ?
&trans_char2ent ("$root_directory/lang/$lang", 'work') :
&trans_char2ent (&trans_get_path ($app, "lang/$lang"), 'html');
$url .= '&o=add_new';
}
else
{
$url .= '&o=add_new_none';
}
&redirect ($url);
exit;
}
#
########################
&trans_header ($text{'EDIT_ADDED_TITLE'}, $app, $lang);
printf (qq(<br/>$text{'EDIT_ADDED_DESCRIPTION'}), $ref_lang, $lang);
print qq(<p>);
print qq(<form action="interface_edit_added.cgi" method="post">);
print qq(<input type="hidden" name="app" value="$app">);
print qq(<input type="hidden" name="t" value="$lang">);
print qq(<input type="hidden" name="webmin_lang" value="$webmin_lang">);
print qq(<table class="trans keys-values" width="100%">);
foreach my $key (sort keys %new)
{
printf (qq(
<tr>
<td>$key:</td>
<td class="to-translate">%s</td>
</tr>
<tr>
<td></td>
<td><textarea name="newitem_$key" rows=5>$in{"newitem_$key"}</textarea></td>
</tr>), &html_escape ($new{"$key"}));
}
print qq(</table>);
print qq(<p/><div><button type="submit" name="update" class="btn btn-success ui_form_end_submit"><i class="fa fa-fw fa-check-circle-o"></i> <span>$text{'UPDATE_TRANSLATION_FILE'}</span></button></div>);
print qq(</form>);
print qq(</p>);
&trans_footer ("interface_main.cgi?app=$app&webmin_lang=$webmin_lang", $text{'INTERFACE_INDEX'});