+sub GetPrefParams {
+ my $data = shift;
+ my $params = $data;
+ my @options;
+
+ if ( defined $data->{'options'} ) {
+ foreach my $option ( split( /\|/, $data->{'options'} ) ) {
+ my $selected = '0';
+ defined( $data->{'value'} ) and $option eq $data->{'value'} and $selected = 1;
+ push @options, { option => $option, selected => $selected };
+ }
+ }
+
+ $params->{'prefoptions'} = $data->{'options'};
+
+ if ( not defined( $data->{'type'} ) ) {
+ $params->{'type-free'} = 1;
+ $params->{'fieldlength'} = ( defined( $data->{'options'} ) and $data->{'options'} and $data->{'options'} > 0 );
+ } elsif ( $data->{'type'} eq 'Choice' ) {
+ $params->{'type-choice'} = 1;
+ } elsif ( $data->{'type'} eq 'YesNo' ) {
+ $params->{'type-yesno'} = 1;
+ $data->{'value'} = C4::Context->boolean_preference( $data->{'variable'} );
+ if ( defined( $data->{'value'} ) and $data->{'value'} eq '1' ) {
+ $params->{'value-yes'} = 1;
+ } else {
+ $params->{'value-no'} = 1;
+ }
+ } elsif ( $data->{'type'} eq 'Integer' || $data->{'type'} eq 'Float' ) {
+ $params->{'type-free'} = 1;
+ $params->{'fieldlength'} = ( defined( $data->{'options'} ) and $data->{'options'} and $data->{'options'} > 0 ) ? $data->{'options'} : 10;
+ } elsif ( $data->{'type'} eq 'Textarea' ) {
+ $params->{'type-textarea'} = 1;
+ $data->{options} =~ /(.*)\|(.*)/;
+ $params->{'cols'} = $1;
+ $params->{'rows'} = $2;
+ } elsif ( $data->{'type'} eq 'Themes' ) {
+ $params->{'type-choice'} = 1;
+ my $type = '';
+ ( $data->{'variable'} =~ m#opac#i ) ? ( $type = 'opac' ) : ( $type = 'intranet' );
+ @options = ();
+ my $currently_selected_themes;
+ my $counter = 0;
+ foreach my $theme ( split /\s+/, $data->{'value'} ) {
+ push @options, { option => $theme, counter => $counter };
+ $currently_selected_themes->{$theme} = 1;
+ $counter++;
+ }
+ foreach my $theme ( getallthemes($type) ) {
+ my $selected = '0';
+ next if $currently_selected_themes->{$theme};
+ push @options, { option => $theme, counter => $counter };
+ $counter++;
+ }
+ } elsif ( $data->{'type'} eq 'ClassSources' ) {
+ $params->{'type-choice'} = 1;
+ my $type = '';
+ @options = ();
+ my $sources = GetClassSources();
+ my $counter = 0;
+ foreach my $cn_source ( sort keys %$sources ) {
+ if ( $cn_source eq $data->{'value'} ) {
+ push @options, { option => $cn_source, counter => $counter, selected => 1 };
+ } else {
+ push @options, { option => $cn_source, counter => $counter };
+ }
+ $counter++;
+ }
+ } elsif ( $data->{'type'} eq 'Languages' ) {
+ my $currently_selected_languages;
+ foreach my $language ( split /\s+/, $data->{'value'} ) {
+ $currently_selected_languages->{$language} = 1;
+ }
+
+ # current language
+ my $lang = $params->{'lang'};
+ my $theme;
+ my $interface;
+ if ( $data->{'variable'} =~ /opac/ ) {
+
+ # this is the OPAC
+ $interface = 'opac';
+ $theme = C4::Context->preference('opacthemes');
+ } else {
+
+ # this is the staff client
+ $interface = 'intranet';
+ $theme = C4::Context->preference('template');
+ }
+ my $languages_loop = getTranslatedLanguages( $interface, $theme, $lang, $currently_selected_languages );
+
+ $params->{'languages_loop'} = $languages_loop;
+ $params->{'type-langselector'} = 1;
+ } else {
+ $params->{'type-free'} = 1;
+ $params->{'fieldlength'} = ( defined( $data->{'options'} ) and $data->{'options'} and $data->{'options'} > 0 ) ? $data->{'options'} : 30;
+ }
+
+ if ( $params->{'type-choice'} || $params->{'type-free'} || $params->{'type-yesno'} ) {
+ $params->{'oneline'} = 1;
+ }
+
+ $params->{'preftype'} = $data->{'type'};
+ $params->{'options'} = \@options;
+
+ return $params;
+}
+
+my $input = new CGI;
+my $searchfield = $input->param('searchfield') || '';
+my $Tvalue = $input->param('Tvalue');
+my $offset = $input->param('offset') || 0;
+my $script_name = "/cgi-bin/koha/admin/systempreferences.pl";
+
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+ { template_name => "admin/systempreferences.tmpl",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { parameters => 1 },
+ debug => 1,
+ }
+);
+my $pagesize = 100;
+my $op = $input->param('op') || '';
+$searchfield =~ s/\,//g;