-
Notifications
You must be signed in to change notification settings - Fork 0
/
help_main.cgi
executable file
·192 lines (166 loc) · 5 KB
/
help_main.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
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
#!/usr/bin/perl
# Copyright (C) 2004-2019
# Emmanuel Saracco <emmanuel@esaracco.fr>
#
# GNU GENERAL PUBLIC LICENSE
require './translator-lib.pl';
my ($_success, $_error, $_info) = ('', '', '');
my $app = $in{'app'};
my $old_app = $in{'old_app'};
my $app_print = &urlize ($app);
my @files = ();
my $path = &trans_get_path ($app, 'help');
# retrieve all files for this module
if ($app ne '')
{
opendir (DH, $path);
foreach my $item (readdir (DH))
{
push (@files, $item) if ($item =~ /^[^\.]+.html$/);
}
closedir (DH);
}
# init_msg ()
#
# Set success or error message.
#
sub init_msg ()
{
# Updated a help file
if ($in{'o'} eq 'update_trans')
{
$_success = sprintf ($text{'MSG_UPDATED_TRANSLATION'}, $in{'t'});
}
}
&trans_header ($text{'HELP_TITLE'}, $app);
&trans_get_menu_icons_panel ('help_main', $app);
print qq(<br>$text{'HELP_DESCRIPTION1'});
#FIXME
# print javascript section
print qq(
<script language="javascript">
function go_to (f1, fname)
{
eval ('f2 = document.forms[0].' + fname + '.value');
document.location.href =
'help_edit.cgi?app=$app' +
'&f1=' + escape (f1) +
'&f2=' + escape (f2);
}
</script>
);
print qq(<p>);
print qq(<form action="help_main.cgi" method="post">);
print qq(<input type="hidden" name="old_app" value="$app">);
print qq(<input type="hidden" name="radio_select" value="">);
&trans_modules_list_get_options ([$app], '');
if (@files && (my $msg = &trans_monitor_panel ($app, $in{'monitor'})))
{
$_success = $msg;
}
# Set success or error msg
&init_msg ();
# if a module have been chosen
if ($app ne '')
{
my $form_name = 0;
if (@files)
{
my @lang_array = &trans_get_existing_translations ([$app]);
print qq(<p>$text{'HELP_DESCRIPTION2'}</p>);
# display translation table for the selected module
print qq(<p>);
print qq(<table class="trans header" width="100%">);
print qq(
<tr>
<td>$text{'STATE'}</td>
<td>$text{'FILE'}</td>
<td>$text{'SIZE'}</td>
<td>$text{'MODIFIED'}</td>
<td>$text{'TRANSLATIONS'}</td>
<td>$text{'TO_TRANSLATE'}</td>
<td>$text{'TO_UPDATE'}</td>
<td>$text{'ACTION'}</td>
</tr>
);
foreach my $key (sort (@files))
{
my ($size, $modified) = (stat ("$path/$key"))[7,9];
my $to_translate = 0;
my $not_translated = 0;
my $state_icon = '';
my $line = sprintf qq(
<td>%s</td>
<td>%s</td>
<td align=center>%s</td>
<td><select name="select_file$form_name">
),
$key,
&trans_get_string_from_size ($size),
strftime ("%Y-%m-%d", localtime ($modified));
foreach my $item (@lang_array)
{
next if ($item eq $reg_lang || !&trans_is_language ($item));
my $file = '';
my $state= '';
my $size1 = 0;
my $modified1 = '';
$key =~ /^(.*)\.htm/;
$file = "$1.$item.html";
($size1, $modified1) = (stat ("$path/$file"))[7,9];
if ((! -f "$path/$file") || (!$size1))
{
$state = '[!] - ';
$not_translated++;
}
else
{
if (Date_Cmp (
strftime ("%Y-%m-%d", localtime ($modified1)),
strftime ("%Y-%m-%d", localtime ($modified))) < 0)
{
$state = '[X] - ';
++$to_translate;
};
}
$line .= sprintf (qq(<option value="$file"%s>$state$file</option>\n),
($item eq $current_lang) ? 'selected="selected"':'');
}
$line .= sprintf qq(
</select></td>
<td>%s</td>
<td>%s</td>
<td align="center"><a href="javascript:go_to('$key', 'select_file$form_name')"><img src="images/edit.png" alt="$text{'EDIT'}" title="$text{'EDIT_SELECTION'}"></a></td>
</tr>
),
($not_translated == 0) ?
qq(<img src="images/ok.png">) :
qq(<img src="images/bad.png"> $not_translated),
($to_translate == 0) ?
qq(<img src="images/ok.png">) :
qq(<img src="images/bad.png"> $to_translate);
$state_icon =
(!$to_translate && !$not_translated) ?
qq(<img src="images/smiley_ok.png" alt="$text{'GOOD'}"
title="$text{'GOOD'}">) :
($to_translate && $not_translated) ?
qq(<img src="images/smiley_bad.png" alt="$text{'BAD'}"
title="$text{'BAD'}">) :
qq(<img src="images/smiley_notbad.png"
alt="$text{'NOT_SO_BAD'}" title="$text{'NOT_SO_BAD'}">);
$line = "<tr><td align=center>$state_icon</td>$line";
print $line;
++$form_name;
}
print qq(</table>);
print qq(<p><font size="-1">$text{'HELP_LEGEND'}</font></p>);
print qq(</p>);
}
else
{
$_error = $text{'HELP_NOEXIST'};
}
}
print qq(</form>);
print qq(</p>);
&trans_footer ('', $text{'MODULE_INDEX'}, $_success, $_error, $_info);