Lines 18-23
Link Here
|
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
|
|
21 |
use Data::Dumper; |
21 |
|
22 |
|
22 |
use CGI qw ( -utf8 ); |
23 |
use CGI qw ( -utf8 ); |
23 |
use C4::Auth; |
24 |
use C4::Auth; |
Lines 57-77
sub GetTab {
Link Here
|
57 |
} |
58 |
} |
58 |
|
59 |
|
59 |
sub _get_chunk { |
60 |
sub _get_chunk { |
60 |
my ( $value, %options ) = @_; |
61 |
my ( $value, %options ) = @_; |
61 |
|
62 |
|
62 |
my $name = $options{'pref'}; |
63 |
my $name = $options{'pref'}; |
63 |
my $chunk = { name => $name, value => $value, type => $options{'type'} || 'input', class => $options{'class'} }; |
64 |
my $chunk = { name => $name, value => $value, type => $options{'type'} || 'input', class => $options{'class'} }; |
64 |
|
65 |
|
65 |
if ( $options{'class'} && $options{'class'} eq 'password' ) { |
66 |
if ( $options{'class'} && $options{'class'} eq 'password' ) { |
66 |
$chunk->{'input_type'} = 'password'; |
67 |
$chunk->{'input_type'} = 'password'; |
67 |
} elsif ( $options{'class'} && $options{'class'} eq 'date' ) { |
68 |
} elsif ( $options{'class'} && $options{'class'} eq 'date' ) { |
68 |
$chunk->{'dateinput'} = 1; |
69 |
$chunk->{'dateinput'} = 1; |
69 |
} elsif ( $options{'type'} && ( $options{'type'} eq 'opac-languages' || $options{'type'} eq 'staff-languages' ) ) { |
70 |
} elsif ( $options{'type'} && ( $options{'type'} eq 'opac-languages' || $options{'type'} eq 'staff-languages' ) ) { |
70 |
my $current_languages = { map { +$_, 1 } split( /\s*,\s*/, $value ) }; |
71 |
my $current_languages = { map { +$_, 1 } split( /\s*,\s*/, $value ) }; |
71 |
|
72 |
|
72 |
my $theme; |
73 |
my $theme; |
73 |
my $interface; |
74 |
my $interface; |
74 |
if ( $options{'type'} eq 'opac-languages' ) { |
75 |
if ( $options{'type'} eq 'opac-languages' ) { |
75 |
# this is the OPAC |
76 |
# this is the OPAC |
76 |
$interface = 'opac'; |
77 |
$interface = 'opac'; |
77 |
$theme = C4::Context->preference('opacthemes'); |
78 |
$theme = C4::Context->preference('opacthemes'); |
Lines 80-86
sub _get_chunk {
Link Here
|
80 |
$interface = 'intranet'; |
81 |
$interface = 'intranet'; |
81 |
$theme = C4::Context->preference('template'); |
82 |
$theme = C4::Context->preference('template'); |
82 |
} |
83 |
} |
83 |
$chunk->{'languages'} = getTranslatedLanguages( $interface, $theme, $lang, $current_languages ); |
84 |
$chunk->{'languages'} = getTranslatedLanguages( $interface, $theme, undef, $current_languages ); |
84 |
$chunk->{'type'} = 'languages'; |
85 |
$chunk->{'type'} = 'languages'; |
85 |
} elsif ( $options{ 'choices' } ) { |
86 |
} elsif ( $options{ 'choices' } ) { |
86 |
if ( $options{'choices'} && ref( $options{ 'choices' } ) eq '' ) { |
87 |
if ( $options{'choices'} && ref( $options{ 'choices' } ) eq '' ) { |
Lines 99-130
sub _get_chunk {
Link Here
|
99 |
$value ||= 0; |
100 |
$value ||= 0; |
100 |
|
101 |
|
101 |
$chunk->{'type'} = 'select'; |
102 |
$chunk->{'type'} = 'select'; |
102 |
$chunk->{'CHOICES'} = [ |
103 |
$chunk->{'CHOICES'} = [ |
103 |
sort { $a->{'text'} cmp $b->{'text'} } |
104 |
sort { $a->{'text'} cmp $b->{'text'} } |
104 |
map { { text => $options{'choices'}->{$_}, value => $_, selected => ( $_ eq $value || ( $_ eq '' && ( $value eq '0' || !$value ) ) ) } } |
105 |
map { { text => $options{'choices'}->{$_}, value => $_, selected => ( $_ eq $value || ( $_ eq '' && ( $value eq '0' || !$value ) ) ) } } |
105 |
keys %{ $options{'choices'} } |
106 |
keys %{ $options{'choices'} } |
106 |
]; |
107 |
]; |
107 |
} elsif ( $options{'multiple'} ) { |
108 |
} elsif ( $options{'multiple'} ) { |
108 |
my @values; |
109 |
my @values; |
109 |
@values = split /,/, $value if defined($value); |
110 |
@values = split /,/, $value if defined($value); |
110 |
$chunk->{type} = 'multiple'; |
111 |
$chunk->{type} = 'multiple'; |
111 |
$chunk->{CHOICES} = [ |
112 |
$chunk->{CHOICES} = [ |
112 |
sort { $a->{'text'} cmp $b->{'text'} } |
113 |
sort { $a->{'text'} cmp $b->{'text'} } |
113 |
map { |
114 |
map { |
114 |
my $option_value = $_; |
115 |
my $option_value = $_; |
115 |
{ |
116 |
{ |
116 |
text => $options{multiple}->{$option_value}, |
117 |
text => $options{multiple}->{$option_value}, |
117 |
value => $option_value, |
118 |
value => $option_value, |
118 |
selected => (grep /^$option_value$/, @values) ? 1 : 0, |
119 |
selected => (grep /^$option_value$/, @values) ? 1 : 0, |
119 |
} |
120 |
} |
120 |
} |
121 |
} |
121 |
keys %{ $options{multiple} } |
122 |
keys %{ $options{multiple} } |
122 |
]; |
123 |
]; |
123 |
} |
124 |
} |
124 |
|
125 |
|
125 |
$chunk->{ 'type_' . $chunk->{'type'} } = 1; |
126 |
$chunk->{ 'type_' . $chunk->{'type'} } = 1; |
126 |
|
127 |
|
127 |
return $chunk; |
128 |
return $chunk; |
128 |
} |
129 |
} |
129 |
|
130 |
|
130 |
sub TransformPrefsToHTML { |
131 |
sub TransformPrefsToHTML { |
Lines 149-154
sub TransformPrefsToHTML {
Link Here
|
149 |
} |
150 |
} |
150 |
|
151 |
|
151 |
foreach my $line ( @{ $tab->{ $group } } ) { |
152 |
foreach my $line ( @{ $tab->{ $group } } ) { |
|
|
153 |
warn Dumper($line); |
152 |
my @chunks; |
154 |
my @chunks; |
153 |
my @names; |
155 |
my @names; |
154 |
|
156 |
|
Lines 164-171
sub TransformPrefsToHTML {
Link Here
|
164 |
} else { |
166 |
} else { |
165 |
$value = $row->{'value'}; |
167 |
$value = $row->{'value'}; |
166 |
} |
168 |
} |
167 |
my $source = "preferences"; |
169 |
my $chunk = _get_chunk( $value, %$piece ); |
168 |
my $chunk = _get_chunk( $value, $source, %$piece ); |
|
|
169 |
|
170 |
|
170 |
# No highlighting of inputs yet, but would be useful |
171 |
# No highlighting of inputs yet, but would be useful |
171 |
$chunk->{'highlighted'} = 1 if ( $searchfield && $name =~ /^$searchfield$/i ); |
172 |
$chunk->{'highlighted'} = 1 if ( $searchfield && $name =~ /^$searchfield$/i ); |
Lines 225-231
sub SearchPrefs {
Link Here
|
225 |
my ( $input, $searchfield ) = @_; |
226 |
my ( $input, $searchfield ) = @_; |
226 |
my @tabs; |
227 |
my @tabs; |
227 |
|
228 |
|
228 |
warn $input, $searchfield; |
|
|
229 |
my %tab_files = _get_pref_files( $input ); |
229 |
my %tab_files = _get_pref_files( $input ); |
230 |
our @terms = split( /\s+/, $searchfield ); |
230 |
our @terms = split( /\s+/, $searchfield ); |
231 |
|
231 |
|