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

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

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

Revision 1783 Revision 1784
460 $value = shift @buttons; $tag = shift @buttons; 460 $value = shift @buttons; $tag = shift @buttons;
461 push(@out, ANS_RADIO_OPTION($number, $value,$tag)); 461 push(@out, ANS_RADIO_OPTION($number, $value,$tag));
462 } 462 }
463 (wantarray) ? @out : join(" ",@out); 463 (wantarray) ? @out : join(" ",@out);
464} 464}
465##############################################
466# contained_in( $elem, $array_reference or null separated string);
467# determine whether element is equal
468# ( in the sense of eq, not ==, ) to an element in the array.
469##############################################
470sub contained_in {
471 my $element = shift;
472 my @input_list = @_;
473 my @output_list = ();
474 # Expand the list -- convert references to arrays to arrays
475 # Convert null separated strings to arrays
476 foreach my $item (@input_list ) {
477 if ($item =~ /\0/) {
478 push @output_list, split('\0', $item);
479 } elsif (ref($item) =~/ARRAY/) {
480 push @output_list, @{$item};
481 } else {
482 push @output_list, $item;
483 }
484 }
485
486 my @match_list = grep {$element eq $_ } @output_list;
487 if ( @match_list ) {
488 return 1;
489 } else {
490 return 0;
491 }
492}
493
494##########################
495# If multiple boxes are checked then the $inputs_ref->{name }will be a null separated string
496# or a reference to an array.
497##########################
465 498
466sub NAMED_ANS_CHECKBOX { 499sub NAMED_ANS_CHECKBOX {
467 my $name = shift; 500 my $name = shift;
468 my $value = shift; 501 my $value = shift;
469 my $tag =shift; 502 my $tag =shift;
474 $value =~ s/^\%//; 507 $value =~ s/^\%//;
475 $checked = 'CHECKED' 508 $checked = 'CHECKED'
476 } 509 }
477 510
478 if (defined($inputs_ref->{$name}) ) { 511 if (defined($inputs_ref->{$name}) ) {
479 if ($inputs_ref->{$name} eq $value) { 512 if ( contained_in($value, $inputs_ref->{$name} ) ) {
480 $checked = 'CHECKED' 513 $checked = 'CHECKED'
481 } 514 }
482 else { 515 else {
483 $checked = ''; 516 $checked = '';
484 } 517 }
503 $value =~ s/^\%//; 536 $value =~ s/^\%//;
504 $checked = 'CHECKED' 537 $checked = 'CHECKED'
505 } 538 }
506 539
507 if (defined($inputs_ref->{$name}) ) { 540 if (defined($inputs_ref->{$name}) ) {
508 if ($inputs_ref->{$name} eq $value) { 541 if ( contained_in($value, $inputs_ref->{$name}) ) {
509 $checked = 'CHECKED' 542 $checked = 'CHECKED'
510 } 543 }
511 else { 544 else {
512 $checked = ''; 545 $checked = '';
513 } 546 }
554 my $tag =shift; 587 my $tag =shift;
555 my $name = ANS_NUM_TO_NAME($number); 588 my $name = ANS_NUM_TO_NAME($number);
556 589
557 NAMED_ANS_CHECKBOX_OPTION($name,$value,$tag); 590 NAMED_ANS_CHECKBOX_OPTION($name,$value,$tag);
558} 591}
592
593
559 594
560sub ANS_CHECKBOX_BUTTONS { 595sub ANS_CHECKBOX_BUTTONS {
561 my $number =shift; 596 my $number =shift;
562 my $value = shift; 597 my $value = shift;
563 my $tag = shift; 598 my $tag = shift;

Legend:
Removed from v.1783  
changed lines
  Added in v.1784

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9