-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_view_unused.cgi
executable file
·83 lines (70 loc) · 2.2 KB
/
admin_view_unused.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
#!/usr/bin/perl
# Copyright (C) 2004-2021
# Emmanuel Saracco <emmanuel@esaracco.fr>
#
# GNU GENERAL PUBLIC LICENSE
require './translator-lib.pl';
my ($_success, $_error, $_info) = ('', '', '');
my $app = $in{'app'};
my $search_type = $in{'search_type'};
my %unused = &trans_get_unused ($search_type, $ref_lang, $app);
my $default_tab = $in{'tab'}||'';
sub _purge_items ( $ $ $ )
{
my ($file, $fcontent, $unused) = @_;
open (H, '>', $file);
while (my ($k, $v) = each (%$fcontent))
{
print H "$k=$v\n" if (!exists ($unused->{$k}));
}
close (H);
}
##### POST actions #####
#
# remove unused items
if (defined ($in{'remove'}))
{
my $path_lang = &trans_get_path ($app);
my %fcontent;
# interface
if ($search_type eq 'interface')
{
if (-s "$path_lang/lang/en")
{
%fcontent = &trans_get_items ("$path_lang/lang/en");
&_purge_items ("$path_lang/lang/en", \%fcontent, \%unused);
}
}
# config
else
{
%fcontent = &trans_get_items ("$path_lang/config.info");
&_purge_items ("$path_lang/config.info", \%fcontent, \%unused);
}
&redirect ("$in{'referer'}.cgi?app=$app&o=remove_unused&tab=$default_tab");
exit;
}
#
########################
&trans_header ($text{'VIEW_UNUSED_TITLE'}, $app);
printf (qq(<br/>$text{'VIEW_UNUSED_DESCRIPTION'}), $app);
$_info = $text{'VIEW_UNUSED_WARNING'};
print qq(<p>);
print qq(<form action="admin_view_unused.cgi" method="post">);
print qq(<input type="hidden" name="app" value="$app">);
print qq(<input type="hidden" name="search_type" value="$search_type">);
print qq(<input type="hidden" name="referer" value="$in{'referer'}">);
print qq(<input type="hidden" name="tab" value="$default_tab">);
print qq(<table class="trans keys-values">);
foreach my $key (sort keys %unused)
{
print qq(
<tr><td>$key:</td><td>);
print &html_escape ($unused{"$key"});
print qq(</td></tr>);
}
print qq(</table>);
print qq(<p/><div><button type="submit" class="btn btn-danger ui_form_end_submit" name="remove"><i class="fa fa-fw fa-trash"></i> <span>$text{'REMOVED_FROM_TRANSLATION_FILE'}</span></button></div>);
print qq(</form>);
print qq(</p>);
&trans_footer("$in{'referer'}.cgi?app=$app&tab=$default_tab", $text{'PREVIOUS'}, $_success, $_error, $_info);