improving systempreferences to show lists, radio button where applicable (was partial...
authortipaul <tipaul>
Fri, 28 May 2004 13:43:25 +0000 (13:43 +0000)
committertipaul <tipaul>
Fri, 28 May 2004 13:43:25 +0000 (13:43 +0000)
admin/systempreferences.pl
koha-tmpl/intranet-tmpl/default/en/parameters/systempreferences.tmpl

index d126927..36a0c44 100755 (executable)
@@ -131,14 +131,14 @@ if ($op eq 'update_and_reedit') {
        $sth->execute($input->param('variable'));
        if ($sth->rows) {
                unless (C4::Context->config('demo') eq 1) {
-                       my $sth=$dbh->prepare("update systempreferences set value=?,explanation=? where variable=?");
-                       $sth->execute($value, $input->param('explanation'), $input->param('variable'));
+                       my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
+                       $sth->execute($value, $input->param('explanation'), $input->param('variable'), $input->param('preftype'), $input->param('prefoptions'));
                        $sth->finish;
                }
     } else {
                unless (C4::Context->config('demo') eq 1) {
-                       my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?)");
-                       $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'));
+                       my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?,?,?)");
+                       $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
                        $sth->finish;
                }
        }
@@ -173,17 +173,18 @@ if ($op eq 'add_form') {
                $template->param('type-yesno' => 1);
                $data->{'value'}=C4::Context->boolean_preference($data->{'variable'});
                ($data->{'value'} eq '1') ? ($template->param('value-yes'=>1)) : ($template->param('value-no'=>1));
-       } elsif ($data->{'type'} eq 'free') {
-               $template->param('type-free' => 1);
-               $template->param('fieldlength' => $data->{'options'});
        } elsif ($data->{'type'} eq 'Integer') {
                $template->param('type-free' => 1);
                $template->param('fieldlength' => $data->{'options'});
+       } elsif ($data->{'type'} eq 'Textarea') {
+               $template->param('type-textarea' => 1);
+               $data->{options} =~ /(.*)\|(.*)/;
+               $template->param('cols' => $1, 'rows' => $2);;
        } elsif ($data->{'type'} eq 'Float') {
                $template->param('type-free' => 1);
                $template->param('fieldlength' => $data->{'options'});
        } elsif ($data->{'type'} eq 'Themes') {
-               $template->param('type-reorderlist' => 1);
+               $template->param('type-choice' => 1);
                my $type='';
                ($data->{'variable'}=~m#opac#i) ? ($type='opac') : ($type='intranet');
                @options=();
@@ -201,7 +202,7 @@ if ($op eq 'add_form') {
                        $counter++;
                }
        } elsif ($data->{'type'} eq 'Languages') {
-               $template->param('type-reorderlist' => 1);
+               $template->param('type-choice' => 1);
                my $type='';
                @options=();
                my $currently_selected_languages;
@@ -219,11 +220,16 @@ if ($op eq 'add_form') {
                        push @options, { option => $language, counter => $counter };
                        $counter++;
                }
+       } else {
+               $template->param('type-free' => 1);
+               $template->param('fieldlength' => $data->{'options'}>0?$data->{'options'}:60);
        }
        $template->param(explanation => $data->{'explanation'},
                         value => $data->{'value'},
                         type => $data->{'type'},
                         options => \@options,
+                        preftype => $data->{'type'},
+                        prefoptions => $data->{'options'},
                         searchfield => $searchfield);
 
 ################## ADD_VALIDATE ##################################
@@ -234,14 +240,14 @@ if ($op eq 'add_form') {
        $sth->execute($input->param('variable'));
        if ($sth->rows) {
                unless (C4::Context->config('demo') eq 1) {
-                       my $sth=$dbh->prepare("update systempreferences set value=?,explanation=? where variable=?");
-                       $sth->execute($input->param('value'), $input->param('explanation'), $input->param('variable'));
+                       my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
+                       $sth->execute($input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'), $input->param('variable'));
                        $sth->finish;
                }
        } else {
                unless (C4::Context->config('demo') eq 1) {
-                       my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?)");
-                       $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'));
+                       my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation,type,options) values (?,?,?)");
+                       $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
                        $sth->finish;
                }
        }
index 3686f07..941157b 100644 (file)
                        <h1>Add a system preference</h1>
                <!-- /TMPL_IF -->
                <form action="<!-- TMPL_VAR name="script_name" -->" name="Aform" method="post">
-               <input type="hidden" name="op" value="add_validate">
-               <!-- TMPL_IF NAME="searchfield" -->
-                       <label>Variable</label><!-- TMPL_VAR name="searchfield" -->
-                               <input type="hidden" name="variable" value="<!-- TMPL_VAR NAME="searchfield" -->">
-               <!-- TMPL_ELSE -->
-                       <label>Variable</label><input type="text" name="variable" size="60">
-               <!-- /TMPL_IF -->
-               <p><label>Value</label><input type="text" name="value" value="<!-- TMPL_VAR name="value" escape="HTML" -->" size="100"></p>
-               <p><label>Explanation</label><input type="text" name="explanation" size="60" value="<!-- TMPL_VAR name="explanation" escape="HTML" -->"></p>
-               <p><label>&nbsp;</label><INPUT type="button" value="OK" class="button" onclick="Check(this.form)"></p>
+               <div id="bloc25">
+                       <h2 class="parameters"><input type="text" name="explanation" size="60" value="<!-- TMPL_VAR name="explanation" escape="HTML" -->"></h2>
+                       <input type="hidden" name="op" value="add_validate">
+                       <p>
+                       <!-- TMPL_IF NAME="searchfield" -->
+                               <label>Variable</label><!-- TMPL_VAR name="searchfield" --><input type="hidden" name="variable" value="<!-- TMPL_VAR NAME="searchfield" -->">
+                       <!-- TMPL_ELSE -->
+                               <label>Variable</label><input type="text" name="variable" size="60">
+                       <!-- /TMPL_IF -->
+                       </p>
+                       <p><label>Value</label>
+                               <!-- TMPL_IF name="type-free" -->
+                                       <input type="text" name="value" value="<!-- TMPL_VAR name="value" escape="HTML" -->" size="<!-- TMPL_VAR name="fieldlength" -->">
+                               <!-- /TMPL_IF -->
+                               <!-- TMPL_IF name="type-textarea" -->
+                                       <textarea name="value" rows="<!--TMPL_VAR name="rows" -->" cols="<!-- TMPL_VAR name="cols" -->">
+                                               <!-- TMPL_VAR name="value" escape="HTML" -->
+                                       </textarea>
+                               <!-- /TMPL_IF -->
+                               <!-- TMPL_IF name="type-choice" -->
+                                       <select name="value">
+                                               <!-- TMPL_LOOP name="options" -->
+                                                       <option value="<!-- TMPL_VAR name="option" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="option" --></option>
+                                               <!-- /TMPL_LOOP -->
+                                       </select>
+                               <!-- /TMPL_IF -->
+                               <!-- TMPL_IF name="type-yesno" -->
+                                       <input type="radio" name="value" value="1" <!-- TMPL_IF name="value-yes" -->checked<!-- /TMPL_IF -->>Yes
+                                       <input type="radio" name="value" value="0" <!-- TMPL_IF name="value-no" -->checked<!-- /TMPL_IF -->>No
+                               <!-- /TMPL_IF -->
+       
+                       </p>
+                       <p><label>&nbsp;</label><input type="submit" value="OK" class="button"></p>
+               </div>
+               <div id="bloc25">
+                       <h2 class="parameters">Koha internal (you should have no reasons to modify the following default values)</h2>
+                       <p>Variable type: <input type="text" name="preftype" value="<!--TMPL_VAR name="preftype" -->" size=40 maxlength=40> (Choice, YesNo,Integer,Textarea,Float,Themes,Languages)</p>
+                       Variable options :<input type="text" name="prefoptions" value="<!-- TMPL_VAR name="prefoptions" -->" size=80 maxlength=80> (choice list for Choice (separated by |) and cols|rows for Texarea)
+               </div>
                </form>
        <!-- /TMPL_IF -->