Debian Codegraph @

Debconf/Element/Noninteractive/Select.pm

raw
1 #!/usr/bin/perl
2
3 =head1 NAME
4
5 Debconf::Element::Noninteractive::Select - dummy select Element
6
7 =cut
8
9 package Debconf::Element::Noninteractive::Select;
10 use warnings;
11 use strict;
12 use base qw(Debconf::Element::Noninteractive);
13
14 =head1 DESCRIPTION
15
16 This is dummy select element.
17
18 =head1 METHODS
19
20 =over 4
21
22 =item show
23
24 The show method does not display anything. However, if the value of the
25 Question associated with it is not set, or is not one of the available
26 choices, then it will be set to the first item in the select list. This is
27 for consistency with the behavior of other select Elements.
28
29 =cut
30
31 sub show {
32 my $this=shift;
33
34 # Make sure the choices list is in the C locale, not localized.
35 $this->question->template->i18n('');
36 my @choices=$this->question->choices_split;
37 $this->question->template->i18n(1);
38 my $value=$this->question->value;
39 $value='' unless defined $value;
40 my $inlist=0;
41 map { $inlist=1 if $_ eq $value } @choices;
42
43 if (! $inlist) {
44 if (@choices) {
45 $this->value($choices[0]);
46 }
47 else {
48 $this->value('');
49 }
50 }
51 else {
52 $this->value($value);
53 }
54 }
55
56 =back
57
58 =head1 AUTHOR
59
60 Joey Hess <[email protected]>
61
62 =cut
63
64 1