[Koha-cvs] CVS: koha/C4 Context.pm,1.2.2.1,1.2.2.2

Andrew Arensburger arensb at users.sourceforge.net
Sat Oct 5 09:10:37 CEST 2002


Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv16698

Modified Files:
      Tag: arensb-context
	Context.pm 
Log Message:
Merged in changes from main branch.


Index: Context.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Context.pm,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -C2 -r1.2.2.1 -r1.2.2.2
*** Context.pm	4 Oct 2002 02:59:28 -0000	1.2.2.1
--- Context.pm	5 Oct 2002 07:10:34 -0000	1.2.2.2
***************
*** 39,42 ****
--- 39,43 ----
    $config_value = C4::Context->config("config_variable");
    $db_handle = C4::Context->dbh;
+   $stopwordhash = C4::Context->stopwords;
  
  =head1 DESCRIPTION
***************
*** 183,186 ****
--- 184,188 ----
  
  	$self->{"dbh"} = undef;		# Database handle
+ 	$self->{"stopwords"} = undef; # stopwords list
  
  	bless $self, $class;
***************
*** 421,424 ****
--- 423,466 ----
  	# FIXME - If it is determined that restore_context should
  	# return something, then this function should, too.
+ }
+ 
+ =item 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) {
+ 		my $retval = {};
+ 		$stopwordlist->{$stopword} = uc($stopword);
+ 	}
+ 	return $stopwordlist;
  }
  





More information about the Koha-cvs mailing list