-################## ADD_FORM ##################################
-# called by default. Used to create form to add or modify a record
-if ($op eq 'add_form') {
- $template->param(add_form => 1);
- #---- if primkey exists, it's a modify action, so read values to modify...
- my $data;
- if ($searchfield) {
- my $dbh = C4::Context->dbh;
- my $sth=$dbh->prepare("select word from stopwords where word=?");
- $sth->execute($searchfield);
- $data=$sth->fetchrow_hashref;
- $sth->finish;
- }
-
- # END $OP eq ADD_FORM
-################## ADD_VALIDATE ##################################
-# called by add_form, used to insert/modify data in DB
-} elsif ($op eq 'add_validate') {
- $template->param(add_validate => 1);
- my $dbh = C4::Context->dbh;
- my @tab = split / |,/, $input->param('word');
- my $sth=$dbh->prepare("replace stopwords (word) values (?)");
- foreach my $insert_value (@tab) {
- $sth->execute($insert_value);
- }
- $sth->finish;
- # END $OP eq ADD_VALIDATE
-################## DELETE_CONFIRM ##################################
-# called by default form, used to confirm deletion of data in DB
-} elsif ($op eq 'delete_confirm') {
- $template->param(delete_confirm => 1);
- my $dbh = C4::Context->dbh;
- my $sth=$dbh->prepare("select word from stopwords where word=?");
- $sth->execute($searchfield);
- my $data=$sth->fetchrow_hashref;
- $sth->finish;
- # END $OP eq DELETE_CONFIRM
-################## DELETE_CONFIRMED ##################################
-# called by delete_confirm, used to effectively confirm deletion of data in DB
-} elsif ($op eq 'delete_confirmed') {
- $template->param(delete_confirmed => 1);
- my $dbh = C4::Context->dbh;
- my $sth=$dbh->prepare("delete from stopwords where word=?");
- $sth->execute($searchfield);
- $sth->finish;
- # END $OP eq DELETE_CONFIRMED
-################## DEFAULT ##################################
-} else { # DEFAULT
- $template->param(else => 1);
-
- my $env;
- my ($count,$results)=StringSearch($env,$searchfield,'web');
- my @loop;
- my $toggle = 'white';
- for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
- my %row = (word => $results->[$i]{'word'},
- toggle => $toggle);
- push @loop, \%row;
-
- if ( $toggle eq 'white' )
- {
- $toggle = '#ffffcc';
- }
- else
- {
- $toggle = 'white';
- }
- }
- $template->param(loop => \@loop);
-
- if ($offset>0) {
- $template->param(offsetgtzero => 1,
- prevpage => $offset-$pagesize);
- }
- if ($offset+$pagesize<$count) {
- $template->param(ltcount => 1,
- nextpage => $offset+$pagesize);
- }