home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / perl5 / Debconf / Element / Web / Multiselect.pm < prev    next >
Encoding:
Perl POD Document  |  2006-07-24  |  958 b   |  52 lines

  1. #!/usr/bin/perl -w
  2. # This file was preprocessed, do not edit!
  3.  
  4.  
  5. package Debconf::Element::Web::Multiselect;
  6. use strict;
  7. use base qw(Debconf::Element::Multiselect);
  8.  
  9.  
  10. sub show {
  11.     my $this=shift;
  12.  
  13.     $_=$this->question->extended_description;
  14.     s/\n/\n<br>\n/g;
  15.     $_.="\n<p>\n";
  16.  
  17.     my %value = map { $_ => 1 } $this->translate_default;
  18.  
  19.     my $id=$this->id;
  20.     $_.="<b>".$this->question->description."</b>\n<select multiple name=\"$id\">\n";
  21.     my $c=0;
  22.     foreach my $x ($this->question->choices_split) {
  23.         if (! $value{$x}) {
  24.             $_.="<option value=".$c++.">$x\n";
  25.         }
  26.         else {
  27.             $_.="<option value=".$c++." selected>$x\n";
  28.         }
  29.     }
  30.     $_.="</select>\n";
  31.     
  32.     return $_;
  33. }
  34.  
  35.  
  36. sub value {
  37.     my $this=shift;
  38.  
  39.     return $this->SUPER::value() unless @_;
  40.  
  41.     my @values=@_;
  42.  
  43.     $this->question->template->i18n('');
  44.     my @choices=$this->question->choices_split;
  45.     $this->question->template->i18n(1);
  46.     
  47.     $this->SUPER::value(join(', ',  $this->order_values(map { $choices[$_] } @values)));
  48. }
  49.  
  50.  
  51. 1
  52.