3 #script to administer the stopwords table
4 #written 20/02/2002 by paul.poulain@free.fr
5 # This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along
21 # with Koha; if not, write to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 my $sth = C4
::Context
->dbh->prepare("
33 SELECT word FROM stopwords WHERE (word LIKE ?) ORDER BY word
35 $sth->execute((shift || '') . "%");
36 return $sth->fetchall_arrayref({});
40 my $searchfield = $input->param('searchfield');
41 my $offset = $input->param('offset') || 0;
42 my $script_name = "/cgi-bin/koha/admin/stopwords.pl";
45 my $op = $input->param('op') || '';
47 my ($template, $loggedinuser, $cookie)
48 = get_template_and_user
({template_name
=> "admin/stopwords.tmpl",
51 flagsrequired
=> {parameters
=> 1},
56 $template->param(script_name
=> $script_name,
57 searchfield
=> $searchfield);
59 my $dbh = C4
::Context
->dbh;
60 if ($op eq 'add_form') {
61 $template->param(add_form
=> 1);
62 } elsif ($op eq 'add_validate') {
63 $template->param(add_validate
=> 1);
64 my @tab = split / |,/, $input->param('word');
65 my $sth=$dbh->prepare("INSERT INTO stopwords (word) VALUES (?)");
66 foreach my $insert_value (@tab) {
67 $sth->execute($insert_value);
69 } elsif ($op eq 'delete_confirm') {
70 $template->param(delete_confirm
=> 1);
71 } elsif ($op eq 'delete_confirmed') {
72 $template->param(delete_confirmed
=> 1);
73 my $sth=$dbh->prepare("delete from stopwords where word=?");
74 $sth->execute($searchfield);
76 $template->param(else => 1);
77 my $results = StringSearch
($searchfield);
78 my $count = scalar(@
$results);
80 # FIXME: limit and offset should get to the SQL query
81 for (my $i=$offset; $i < ($offset+$pagesize<$count?
$offset+$pagesize:$count); $i++){
82 push @loop, {word
=> $results->[$i]{'word'}};
84 $template->param(loop => \
@loop);
86 $template->param(offsetgtzero
=> 1,
87 prevpage
=> $offset-$pagesize);
89 if ($offset+$pagesize < scalar(@
$results)) {
90 $template->param(ltcount
=> 1,
91 nextpage
=> $offset+$pagesize);
95 output_html_with_http_headers
$input, $cookie, $template->output;