[system] / trunk / pg / macros / parserRadioButtons.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/parserRadioButtons.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5072 Revision 5073
82# 82#
83# Create a new RadioButtons object 83# Create a new RadioButtons object
84# 84#
85sub new { 85sub new {
86 my $self = shift; my $class = ref($self) || $self; 86 my $self = shift; my $class = ref($self) || $self;
87 my $context = (Value::isContext($_[0]) ? shift : $self->context);
87 my $choices = shift; my $value = shift; 88 my $choices = shift; my $value = shift;
88 my %options; 89 my %options;
89 main::set_default_options(\%options, 90 main::set_default_options(\%options,
90 labels => [], 91 labels => [],
91 separator => $main::BR, 92 separator => $main::BR,
99 my $self = bless {%options, choices=>$choices}, $class; # temporary to so we can call our methods 100 my $self = bless {%options, choices=>$choices}, $class; # temporary to so we can call our methods
100 Value::Error("A RadioButton's first argument should be a list of button labels") 101 Value::Error("A RadioButton's first argument should be a list of button labels")
101 unless ref($choices) eq 'ARRAY'; 102 unless ref($choices) eq 'ARRAY';
102 Value::Error("A RadioButton's second argument should be the correct button choice") 103 Value::Error("A RadioButton's second argument should be the correct button choice")
103 unless defined($value) && $value ne ""; 104 unless defined($value) && $value ne "";
104 my $oldContext = main::Context(); 105 my $context = Parser::Context->getCopy(undef,"String");
105 my $context = $main::context{String}->copy;
106 main::Context($context);
107 my %choiceHash = $self->choiceHash(1); 106 my %choiceHash = $self->choiceHash(1);
108 $context->strings->add(map {$_=>{}} (keys %choiceHash)); 107 $context->strings->add(map {$_=>{}} (keys %choiceHash));
109 $value = $self->correctChoice($value); 108 $value = $self->correctChoice($value);
110 $self = bless Value::String->new($value)->with( 109 $self = bless $context->Package("String")->new($context,$value)->with(
111 isValue => 1, context => $context, 110 isValue => 1, choices => $choices, %options), $class;
112 choices => $choices,
113 %options,
114 ), $class;
115 main::Context($oldContext);
116 $self->JavaScript if $self->{uncheckable}; 111 $self->JavaScript if $self->{uncheckable};
117 return $self; 112 return $self;
118} 113}
119 114
120# 115#

Legend:
Removed from v.5072  
changed lines
  Added in v.5073

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9