-=head2 marcfromkohafield
-
- $dbh = C4::Context->marcfromkohafield;
-
-Returns a hash with marcfromkohafield.
-
-This hash is cached for future use: if you call
-C<C4::Context-E<gt>marcfromkohafield> twice, you will get the same hash without real DB access
-
-=cut
-
-#'
-sub marcfromkohafield
-{
- my $retval = {};
-
- # If the hash already exists, return it.
- return $context->{"marcfromkohafield"} if defined($context->{"marcfromkohafield"});
-
- # No hash. Create one.
- $context->{"marcfromkohafield"} = &_new_marcfromkohafield();
-
- return $context->{"marcfromkohafield"};
-}
-
-# _new_marcfromkohafield
-# Internal helper function (not a method!). This creates a new
-# hash with stopwords
-sub _new_marcfromkohafield
-{
- my $dbh = C4::Context->dbh;
- my $marcfromkohafield;
- my $sth = $dbh->prepare("select frameworkcode,kohafield,tagfield,tagsubfield from marc_subfield_structure where kohafield > ''");
- $sth->execute;
- while (my ($frameworkcode,$kohafield,$tagfield,$tagsubfield) = $sth->fetchrow) {
- my $retval = {};
- $marcfromkohafield->{$frameworkcode}->{$kohafield} = [$tagfield,$tagsubfield];
- }
- return $marcfromkohafield;
-}
-
-=head2 stopwords
-
- $dbh = C4::Context->stopwords;
-
-Returns a hash with stopwords.
-
-This hash is cached for future use: if you call
-C<C4::Context-E<gt>stopwords> twice, you will get the same hash without real DB access
-
-=cut
-
-#'
-sub stopwords
-{
- my $retval = {};
-
- # If the hash already exists, return it.
- return $context->{"stopwords"} if defined($context->{"stopwords"});
-
- # No hash. Create one.
- $context->{"stopwords"} = &_new_stopwords();
-
- return $context->{"stopwords"};
-}
-
-# _new_stopwords
-# Internal helper function (not a method!). This creates a new
-# hash with stopwords
-sub _new_stopwords
-{
- my $dbh = C4::Context->dbh;
- my $stopwordlist;
- my $sth = $dbh->prepare("select word from stopwords");
- $sth->execute;
- while (my $stopword = $sth->fetchrow_array) {
- $stopwordlist->{$stopword} = uc($stopword);
- }
- $stopwordlist->{A} = "A" unless $stopwordlist;
- return $stopwordlist;
-}
-