use C4::Context;
use C4::Debug;
+use Module::Load::Conditional qw/check_install/;
#use Data::Dumper;
use constant TAG_FIELDS => qw(tag_id borrowernumber biblionumber term language date_created);
use constant TAG_SELECT => "SELECT " . join(',', TAG_FIELDS) . "\n FROM tags_all\n";
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
-our $ext_dict;
+use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
BEGIN {
- $VERSION = 3.07.00.049;
@ISA = qw(Exporter);
@EXPORT_OK = qw(
&get_tag &get_tags &get_tag_rows
stratify_tags
);
# %EXPORT_TAGS = ();
- $ext_dict = C4::Context->preference('TagsExternalDictionary');
+ my $ext_dict = C4::Context->preference('TagsExternalDictionary');
+ if ( $ext_dict && ! check_install( module => 'Lingua::Ispell' ) ) {
+ warn "Ignoring TagsExternalDictionary, because Lingua::Ispell is not installed.";
+ $ext_dict = q{};
+ }
if ($debug) {
require Data::Dumper;
import Data::Dumper qw(:DEFAULT);
}
if ($ext_dict) {
require Lingua::Ispell;
- import Lingua::Ispell qw(spellcheck add_word_lc save_dictionary);
+ import Lingua::Ispell qw(spellcheck add_word_lc);
+ $Lingua::Ispell::path = $ext_dict;
+ $debug and print STDERR "\$Lingua::Ispell::path = $Lingua::Ispell::path\n";
}
}
=cut
-INIT {
- $ext_dict and $Lingua::Ispell::path = $ext_dict;
- $debug and print STDERR "\$Lingua::Ispell::path = $Lingua::Ispell::path\n";
-}
-
sub get_filters {
my $query = "SELECT * FROM tags_filters ";
my ($sth);
carp "Empty argument key to get_tag_rows: ignoring!";
next;
}
- unless (1 == scalar grep {/^ $key $/x} @ok_fields) {
+ unless (1 == scalar grep { $_ eq $key } @ok_fields) {
carp "get_tag_rows received unreconized argument key '$key'.";
next;
}
carp "Empty argument key to get_tags: ignoring!";
next;
}
- unless (1 == scalar grep {/^ $key $/x} @ok_fields) {
+ unless (1 == scalar grep { $_ eq $key } @ok_fields) {
carp "get_tags received unreconized argument key '$key'.";
next;
}
carp "Empty argument key to get_approval_rows: ignoring!";
next;
}
- unless (1 == scalar grep {/^ $key $/x} @ok_fields) {
+ unless (1 == scalar grep { $_ eq $key } @ok_fields) {
carp "get_approval_rows received unreconized argument key '$key'.";
next;
}
my $term = shift or return;
my $sth = C4::Context->dbh->prepare("SELECT approved FROM tags_approval WHERE term = ?");
$sth->execute($term);
+ my $ext_dict = C4::Context->preference('TagsExternalDictionary');
unless ($sth->rows) {
$ext_dict and return (spellcheck($term) ? 0 : 1); # spellcheck returns empty on OK word
return 0;
sub whitelist {
my $operator = shift;
defined $operator or return; # have to test defined to allow =0 (kohaadmin)
+ my $ext_dict = C4::Context->preference('TagsExternalDictionary');
if ($ext_dict) {
foreach (@_) {
spellcheck($_) or next;