Handle hostnames with upper-case letters
[webmin.git] / package-updates / view.cgi
1 #!/usr/local/bin/perl
2 # Show details of one package and available updates
3
4 require './package-updates-lib.pl';
5 &ui_print_header(undef, $text{'view_title'}, "");
6 &ReadParse();
7
8 # Get the package
9 @avail = &list_for_mode($in{'mode'}, 0);
10 ($a) = grep { $_->{'name'} eq $in{'name'} &&
11               $_->{'system'} eq $in{'system'} } @avail;
12 @current = &list_current(0);
13 ($c) = grep { $_->{'name'} eq $in{'name'} &&
14               $_->{'system'} eq $in{'system'} } @current;
15 $p = $a || $c;
16
17 print &ui_form_start("save_view.cgi");
18 print &ui_hidden("name", $p->{'name'});
19 print &ui_hidden("system", $p->{'system'});
20 print &ui_hidden("version", $p->{'version'});
21 print &ui_hidden("mode", $in{'mode'});
22 print &ui_table_start($text{'view_header'}, undef, 2);
23
24 # Package name and type
25 print &ui_table_row($text{'view_name'}, $p->{'name'});
26 print &ui_table_row($text{'view_system'}, $text{'system_'.$p->{'system'}} ||
27                                           uc($p->{'system'}));
28 print &ui_table_row($text{'view_desc'}, $c->{'desc'});
29
30 # Current state
31 print &ui_table_row($text{'view_state'},
32         $a && !$c ? "<font color=#00aa00>$text{'index_caninstall'}</font>" :
33         !$a && $c ? "<font color=#ffaa00>".
34                      &text('index_noupdate', $c->{'version'})."</font>" :
35         &compare_versions($a, $c) > 0 ?
36                     "<font color=#00aa00>".
37                      &text('index_new', $a->{'version'})."</font>" :
38                     &text('index_ok', $c->{'version'}));
39
40 # Version(s) available
41 if ($c) {
42         print &ui_table_row($text{'view_cversion'},
43                 ($c->{'epoch'} ? $c->{'epoch'}.":" : "").$c->{'version'});
44         }
45 if ($a) {
46         print &ui_table_row($text{'view_aversion'},
47                 ($a->{'epoch'} ? $a->{'epoch'}.":" : "").$a->{'version'});
48         }
49
50 # Source, if available
51 if ($a->{'source'}) {
52         print &ui_table_row($text{'view_source'}, ucfirst($a->{'source'}));
53         }
54
55 # Change log, if possible
56 if ($a) {
57         $cl = &get_changelog($a);
58         if ($cl) {
59                 print &ui_table_row($text{'view_changelog'},
60                         "<pre>".&html_escape($cl)."</pre>");
61                 }
62         }
63
64 print &ui_table_end();
65
66 # Buttons to update / manage
67 @buts = ( );
68 if ($c && &foreign_available("software") && $c->{'software'}) {
69         push(@buts, [ "software", $text{'view_software'} ]);
70         }
71 if ($a && $c && &compare_versions($a, $c) > 0) {
72         push(@buts, [ "update", $text{'view_update'} ]);
73         }
74 elsif ($a && !$c) {
75         push(@buts, [ "update", $text{'view_install'} ]);
76         }
77 print &ui_form_end(\@buts);
78
79 &ui_print_footer("index.cgi?mode=$in{'mode'}&search=".
80                   &urlize($in{'search'}),
81                  $text{'index_return'});
82