Lines 92-97
sub _get_chunk {
Link Here
|
92 |
$chunk->{'languages'} = getTranslatedLanguages( $interface, $theme, undef, $current_languages ); |
92 |
$chunk->{'languages'} = getTranslatedLanguages( $interface, $theme, undef, $current_languages ); |
93 |
$chunk->{'type'} = 'languages'; |
93 |
$chunk->{'type'} = 'languages'; |
94 |
} elsif ( $options{ 'choices' } ) { |
94 |
} elsif ( $options{ 'choices' } ) { |
|
|
95 |
my $add_blank; |
95 |
if ( $options{'choices'} && ref( $options{ 'choices' } ) eq '' ) { |
96 |
if ( $options{'choices'} && ref( $options{ 'choices' } ) eq '' ) { |
96 |
if ( $options{'choices'} eq 'class-sources' ) { |
97 |
if ( $options{'choices'} eq 'class-sources' ) { |
97 |
my $sources = GetClassSources(); |
98 |
my $sources = GetClassSources(); |
Lines 100-105
sub _get_chunk {
Link Here
|
100 |
$options{'choices'} = { map { $_ => $_ } getallthemes( 'opac' ) } |
101 |
$options{'choices'} = { map { $_ => $_ } getallthemes( 'opac' ) } |
101 |
} elsif ( $options{'choices'} eq 'staff-templates' ) { |
102 |
} elsif ( $options{'choices'} eq 'staff-templates' ) { |
102 |
$options{'choices'} = { map { $_ => $_ } getallthemes( 'intranet' ) } |
103 |
$options{'choices'} = { map { $_ => $_ } getallthemes( 'intranet' ) } |
|
|
104 |
} elsif ( $options{choices} eq 'patron-categories' ) { |
105 |
$options{choices} = { map { $_->categorycode => $_->description } Koha::Patron::Categories->search }; |
106 |
$add_blank = 1; |
103 |
} else { |
107 |
} else { |
104 |
die 'Unrecognized source of preference values: ' . $options{'choices'}; |
108 |
die 'Unrecognized source of preference values: ' . $options{'choices'}; |
105 |
} |
109 |
} |
Lines 107-118
sub _get_chunk {
Link Here
|
107 |
|
111 |
|
108 |
$value ||= 0; |
112 |
$value ||= 0; |
109 |
|
113 |
|
110 |
$chunk->{'type'} = 'select'; |
114 |
$chunk->{'type'} = ( $options{class} && $options{class} eq 'multiple' ) ? 'multiple' : 'select'; |
|
|
115 |
|
116 |
my @values; |
117 |
@values = split /,/, $value if defined($value); |
111 |
$chunk->{'CHOICES'} = [ |
118 |
$chunk->{'CHOICES'} = [ |
112 |
sort { $a->{'text'} cmp $b->{'text'} } |
119 |
sort { $a->{'text'} cmp $b->{'text'} } |
113 |
map { { text => $options{'choices'}->{$_}, value => $_, selected => ( $_ eq $value || ( $_ eq '' && ( $value eq '0' || !$value ) ) ) } } |
120 |
map { |
|
|
121 |
my $c = $_; |
122 |
{ |
123 |
text => $options{'choices'}->{$c}, |
124 |
value => $c, |
125 |
selected => ( |
126 |
grep { $_ eq $c || ( $c eq '' && ($value eq '0' || !$value ) ) } @values |
127 |
) ? 1 : 0, |
128 |
} |
129 |
} |
114 |
keys %{ $options{'choices'} } |
130 |
keys %{ $options{'choices'} } |
115 |
]; |
131 |
]; |
|
|
132 |
|
133 |
# Add a first blank value if needed |
134 |
unshift @{ $chunk->{CHOICES} }, { |
135 |
text => '', |
136 |
value => '', |
137 |
} if $add_blank && $chunk->{type} eq 'select'; |
138 |
|
116 |
} elsif ( $options{'multiple'} ) { |
139 |
} elsif ( $options{'multiple'} ) { |
117 |
my @values; |
140 |
my @values; |
118 |
@values = split /,/, $value if defined($value); |
141 |
@values = split /,/, $value if defined($value); |