[Koha-cvs] koha search.marc/search.pl koha-tmpl/intranet-t... [rel_3_0]

Antoine Farnault antoine at koha-fr.org
Mon Oct 9 18:22:02 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Antoine Farnault <toins>	06/10/09 16:22:02

Modified files:
	search.marc    : search.pl 
Added files:
	koha-tmpl/intranet-tmpl/prog/en/catalogue: advsearch.tmpl 
	                                           results.tmpl 

Log message:
	New search API on intranet.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/catalogue/advsearch.tmpl?cvsroot=koha&only_with_tag=rel_3_0&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/catalogue/results.tmpl?cvsroot=koha&only_with_tag=rel_3_0&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/search.marc/search.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.33.2.2&r2=1.33.2.3

Patches:
Index: search.marc/search.pl
===================================================================
RCS file: /sources/koha/koha/search.marc/Attic/search.pl,v
retrieving revision 1.33.2.2
retrieving revision 1.33.2.3
diff -u -b -r1.33.2.2 -r1.33.2.3
--- search.marc/search.pl	18 Sep 2006 11:58:08 -0000	1.33.2.2
+++ search.marc/search.pl	9 Oct 2006 16:22:01 -0000	1.33.2.3
@@ -1,9 +1,12 @@
 #!/usr/bin/perl
-# WARNING: 4-character tab stops here
-
-# Copyright 2000-2002 Katipo Communications
+# Script to perform searching
+# For documentation try 'perldoc /path/to/search'
+#
+# $Header: /sources/koha/koha/search.marc/Attic/search.pl,v 1.33.2.3 2006/10/09 16:22:01 toins Exp $
+#
+# Copyright 2006 LibLime
 #
-# This file is part of Koha.
+# This file is part of Koha
 #
 # Koha is free software; you can redistribute it and/or modify it under the
 # terms of the GNU General Public License as published by the Free Software
@@ -18,368 +21,500 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-use strict;
-require Exporter;
-use CGI;
-use C4::Auth;
-use HTML::Template;
-use C4::Context;
-use C4::Search;
-use C4::Auth;
-use C4::Output;
-use C4::Interface::CGI::Output;
-use C4::Biblio;
-use C4::Acquisition;
-use C4::Koha; # XXX subfield_is_koha_internal_p
-
-# Creates the list of active tags using the active MARC configuration
-sub create_marclist {
-	my $dbh = C4::Context->dbh;
-	my $tagslib = &MARCgettagslib($dbh,1);
-	my @marcarray;
-	push @marcarray,"";
-	my $widest_menu_item_width = 0;
-	for (my $pass = 1; $pass <= 2; $pass += 1)
-	{
-		for (my $tabloop = 0; $tabloop<=10;$tabloop++)
-		{
-			my $separator_inserted_p = 0; # FIXME... should not use!!
-			foreach my $tag (sort(keys (%{$tagslib})))
-			{
-				foreach my $subfield (sort(keys %{$tagslib->{$tag}}))
-				{
-					next if subfield_is_koha_internal_p($subfield);
-					next unless ($tagslib->{$tag}->{$subfield}->{tab} eq $tabloop);
-					my $menu_item = "$tag$subfield - $tagslib->{$tag}->{$subfield}->{lib}";
-					if ($pass == 1)
-					{
-						$widest_menu_item_width = length $menu_item if($widest_menu_item_width < length $menu_item);
-					} else {
-						if (!$separator_inserted_p)
-						{
-							my $w = int(($widest_menu_item_width - 3 + 0.5)/2);
-							my $s = ('-' x ($w * 4/5));
-							push @marcarray,  "$s $tabloop $s";
-							$separator_inserted_p = 1;
-						}
-					push @marcarray, $menu_item;
-					}
-				}
-			}
-		}
-	}
-	return \@marcarray;
-}
+=head1 NAME
 
-# Creates a scrolling list with the associated default value.
-# Using more than one scrolling list in a CGI assigns the same default value to all the
-# scrolling lists on the page !?!? That's why this function was written.
-sub create_scrolling_list {
-	my ($params) = @_;
-	my $scrollist = sprintf("<select name=\"%s\" size=\"%d\" onChange='%s'>\n", $params->{'name'}, $params->{'size'}, $params->{'onChange'});
-
-	foreach my $tag (@{$params->{'values'}})
-	{
-		my $selected = "selected " if($params->{'default'} eq $tag);
-		$scrollist .= sprintf("<option %svalue=\"%s\">%s</option>\n", $selected, $tag, $tag);
-	}
+search - a search script for finding records in a Koha system (Version 2.4)
 
-	$scrollist .= "</select>\n";
+=head1 OVERVIEW
 
-	return $scrollist;
-}
+This script contains a demonstration of a new search API for Koha 2.4. It is
+designed to be simple to use and configure, yet capable of performing feats
+like stemming, field weighting, relevance ranking, support for multiple 
+query language formats (CCL, CQL, PQF), full or nearly full support for the
+bib1 attribute set, extended attribute sets defined in Zebra profiles, access
+to the full range of Z39.50 query options, federated searches on Z39.50
+targets, etc.
 
-my $query=new CGI;
-my $type=$query->param('type');
-my $op = $query->param('op') || "";
-my $dbh = C4::Context->dbh;
-
-my $startfrom=$query->param('startfrom');
-$startfrom=0 if(!defined $startfrom);
-my ($template, $loggedinuser, $cookie)
-		= get_template_and_user({template_name => "search.marc/result.tmpl",
-				query => $query,
-				type => $type,
-				authnotrequired => 0,
-				flagsrequired => {borrowers => 1},
-				flagsrequired => {catalogue => 1},
-				debug => 1,
-				});
-my $searchdesc;
-my $resultsperpage;
-
-if ($op eq "do_search") {
-	my @marclist = $query->param('marclist');
-	my @and_or = $query->param('and_or');
-	my @excluding = $query->param('excluding');
-	my @operator = $query->param('operator');
-	my @value = $query->param('value');
-
-		for (my $i=0;$i<=$#marclist;$i++) {
-		if ($searchdesc) { # don't put the and_or on the 1st search term
-			$searchdesc .= $and_or[$i]." ".$excluding[$i]." ".($marclist[$i]?$marclist[$i]:"*")." ".$operator[$i]." ".$value[$i]." " if ($value[$i]);
-			} else {
-			$searchdesc = $excluding[$i]." ".($marclist[$i]?$marclist[$i]:"*")." ".$operator[$i]." ".$value[$i]." " if ($value[$i]);
-			}
-		}
-	
-	$resultsperpage= $query->param('resultsperpage');
-	$resultsperpage = 19 if(!defined $resultsperpage);
-	my $orderby = $query->param('orderby');
-	my $desc_or_asc = $query->param('desc_or_asc');
-
-	# builds tag and subfield arrays
-	my @tags;
-
-	foreach my $marc (@marclist) {
-		if ($marc) {
-			my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,$marc,'');
-			if ($tag) {
-				push @tags,$dbh->quote("$tag$subfield");
-			} else {
-				if ($marc =~ /^(\d){3}(. -)(.)*/)
-				{
-					# The user is using the search catalogue part, more fields
-					push @tags, $dbh->quote(substr($marc,0,4));
-				}
-				else
-				{
-					push @tags, $marc;
-				}
-			}
-		} else {
-			push @tags, "";
-		}
-	}
-	findseealso($dbh,\@tags);
-	my ($results,$total) = catalogsearch($dbh, \@tags,\@and_or,
-										\@excluding, \@operator, \@value,
-										$startfrom*$resultsperpage, $resultsperpage,$orderby,$desc_or_asc);
-	if ($total == 1) {
-	 # if only 1 answer, jump directly to the biblio
-	if (C4::Context->preference("IntranetBiblioDefaultView") eq "normal") {
-	     print $query->redirect("/cgi-bin/koha/catalogue/detail.pl?bib=".@$results[0]->{biblionumber});
-	} elsif (C4::Context->preference("IntranetBiblioDefaultView") eq "marc") {
-	     print $query->redirect("/cgi-bin/koha/catalogue/MARCdetail.pl?bib=".@$results[0]->{biblionumber});
-	} else {
-	     print $query->redirect("/cgi-bin/koha/catalogue/ISBDdetail.pl?bib=".@$results[0]->{biblionumber});
-	}
-	 exit
-	}
-
-	# multi page display gestion
-	my $displaynext=0;
-	my $displayprev=$startfrom;
-	if(($total - (($startfrom+1)*($resultsperpage))) > 0 ) {
-		$displaynext = 1;
-	}
-
-	my @field_data = ();
-
-	for(my $i = 0 ; $i <= $#marclist ; $i++) {
-		push @field_data, { term => "marclist", val=>$marclist[$i] };
-		push @field_data, { term => "and_or", val=>$and_or[$i] };
-		push @field_data, { term => "excluding", val=>$excluding[$i] };
-		push @field_data, { term => "operator", val=>$operator[$i] };
-		push @field_data, { term => "value", val=>$value[$i] };
-	}
-
-	my @numbers = ();
-
-	if ($total>$resultsperpage) {
-		for (my $i=1; $i<$total/$resultsperpage+1; $i++) {
-			if ($i<16) {
-	    		my $highlight=0;
-	    		($startfrom==($i-1)) && ($highlight=1);
-	    		push @numbers, { number => $i,
-					highlight => $highlight ,
-					searchdata=> \@field_data,
-					startfrom => ($i-1)};
-			}
-    	}
-	}
-
-	my $from = $startfrom*$resultsperpage+1;
-	my $to;
-
- 	if($total < (($startfrom+1)*$resultsperpage))
-	{
-		$to = $total;
-	} else {
-		$to = (($startfrom+1)*$resultsperpage);
-	}
-	my $defaultview = 'BiblioDefaultView'.C4::Context->preference('IntranetBiblioDefaultView');
-	$template->param(result => $results,
-							startfrom=> $startfrom,
-							displaynext=> $displaynext,
-							displayprev=> $displayprev,
-							resultsperpage => $resultsperpage,
-							startfromnext => $startfrom+1,
-							startfromprev => $startfrom-1,
-							searchdata=>\@field_data,
-							total=>$total,
-							from=>$from,
-							to=>$to,
-							numbers=>\@numbers,
-							searchdesc=> $searchdesc,
-							desc_asc=>$desc_or_asc,
-							orderby=>$orderby,
-							MARC_ON => C4::Context->preference("marc"),
-							$defaultview => 1,
-							);
+I believe the API as represented in this script is mostly sound, even if the
+individual functions in Search.pm and Koha.pm need to be cleaned up. Of course,
+you are free to disagree :-)
 
-} elsif ($op eq "AddStatement") {
-	($template, $loggedinuser, $cookie)
-		= get_template_and_user({template_name => "search.marc/search.tmpl",
-				query => $query,
-				type => $type,
-				authnotrequired => 0,
-				flagsrequired => {catalogue => 1},
-				debug => 1,
-				});
-
-	# Gets the entered information
-	my @marcfields = $query->param('marclist');
-	my @and_or = $query->param('and_or');
-	my @excluding = $query->param('excluding');
-	my @operator = $query->param('operator');
-	my @value = $query->param('value');
-
-	my @statements = ();
-
-	# List of the marc tags to display
-	my $marcarray = create_marclist();
-
-	my $nbstatements = $query->param('nbstatements');
-	$nbstatements = 1 if(!defined $nbstatements);
-
-	for(my $i = 0 ; $i < $nbstatements ; $i++)
-	{
-		my %fields = ();
-
-		# Recreates the old scrolling lists with the previously selected values
-		my $marclist = create_scrolling_list({name=>"marclist",
-					values=> $marcarray,
-					size=> 1,
-					default=>$marcfields[$i],
-					onChange => "sql_update()"}
-					);
+I will attempt to describe what is happening at each part of this script.
+-- JF
+
+=head2 INTRO
+
+This script performs two functions:
+
+=over 
+
+=item 1. interacts with Koha to retrieve and display the results of a search
+
+=item 2. loads the advanced search page
+
+=back
+
+These two functions share many of the same variables and modules, so the first
+task is to load what they have in common and determine which template to use.
+Once determined, proceed to only load the variables and procedures necessary
+for that function.
+
+=head2 THE ADVANCED SEARCH PAGE
+
+If we're loading the advanced search page this script will call a number of
+display* routines which populate objects that are sent to the template for 
+display of things like search indexes, languages, search limits, branches,
+etc. These are not stored in the template for two reasons:
+
+=over
+
+=item 1. Efficiency - we have more control over objects inside the script, and it's possible to not duplicate things like indexes (if the search indexes were stored in the template they would need to be repeated)
+
+=item 2. Customization - if these elements were moved to the sql database it would allow a simple librarian to determine which fields to display on the page without editing any html (also how the fields should behave when being searched).
+
+=back
+
+However, they create one problem : the strings aren't translated. I have an idea
+for how to do this that I will purusue soon.
+
+=head2 PERFORMING A SEARCH
+
+If we're performing a search, this script  performs three primary
+operations:
+
+=over 
+
+=item 1. builds query strings (yes, plural)
+
+=item 2. perform the search and return the results array
+
+=item 3. build the HTML for output to the template
+
+=back
 
-		$fields{'marclist'} = $marclist;
-		$fields{'first'} = 1 if($i == 0);
+There are several additional secondary functions performed that I will
+not cover in detail.
 
-		# Restores the and/or parameters (no need to test the 'and' for activation because it's the default value)
-		$fields{'or'} = 1 if($and_or[$i] eq "or");
+=head3 1. Building Query Strings
 
-		#Restores the "not" parameters
-		$fields{'not'} = 1 if($excluding[$i]);
+There are several types of queries needed in the process of search and retrieve:
 
-		#Restores the operators (most common operators first);
-		if($operator[$i] eq "=") { $fields{'eq'} = 1; }
-		elsif($operator[$i] eq "contains") { $fields{'contains'} = 1; }
-		elsif($operator[$i] eq "start") { $fields{'start'} = 1; }
-		elsif($operator[$i] eq ">") { $fields{'gt'} = 1; }	#greater than
-		elsif($operator[$i] eq ">=") { $fields{'ge'} = 1; } #greater or equal
-		elsif($operator[$i] eq "<") { $fields{'lt'} = 1; } #lower than
-		elsif($operator[$i] eq "<=") { $fields{'le'} = 1; } #lower or equal
-
-		#Restores the value
-		$fields{'value'} = $value[$i];
-
-		push @statements, \%fields;
-	}
-	$nbstatements++;
-
-	# The new scrolling list
-	my $marclist = create_scrolling_list({name=>"marclist",
-				values=> $marcarray,
-				size=>1,
-				onChange => "sql_update()"});
-	push @statements, {"marclist" => $marclist };
+=over
 
-	$template->param("statements" => \@statements,
-						"nbstatements" => $nbstatements);
+=item 1 Koha query - the query that is passed to Zebra
 
+This is the most complex query that needs to be built.The original design goal was to use a custom CCL2PQF query parser to translate an incoming CCL query into a multi-leaf query to pass to Zebra. It needs to be multi-leaf to allow field weighting, koha-specific relevance ranking, and stemming. When I have a chance I'll try to flesh out this section to better explain.
+
+This query incorporates query profiles that aren't compatible with non-Zebra Z39.50 targets to acomplish the field weighting and relevance ranking.
+
+=item 2 Federated query - the query that is passed to other Z39.50 targets
+
+This query is just the user's query expressed in CCL CQL, or PQF for passing to a non-zebra Z39.50 target (one that doesn't support the extended profile that Zebra does).
+
+=item 3 Search description - passed to the template / saved for future refinements of the query (by user)
+
+This is a simple string that completely expresses the query in a way that can be parsed by Koha for future refinements of the query or as a part of a history feature. It differs from the human search description in several ways:
+
+1. it does not contain commas or = signs
+2. 
+
+=item 4 Human search description - what the user sees in the search_desc area
+
+This is a simple string nearly identical to the Search description, but more human readable. It will contain = signs or commas, etc.
+
+=back
+
+=head3 2. Perform the Search
+
+This section takes the query strings and performs searches on the named servers, including the Koha Zebra server, stores the results in a deeply nested object, builds 'faceted results', and returns these objects.
+
+=head3 3. Build HTML
+
+The final major section of this script takes the objects collected thusfar and builds the HTML for output to the template and user.
+
+=head3 Additional Notes
+
+Not yet completed...
+
+=cut
+
+use strict;			# always use
+#use warnings;		# use only for development
+
+## STEP 1. Load things that are used in both search page and
+# results page and decide which template to load, operations 
+# to perform, etc.
+## load Koha modules
+use C4::Context;
+use C4::Interface::CGI::Output;
+use C4::Auth;
+use C4::Search;
+use C4::Koha;
+use POSIX qw(ceil floor);
+# create a new CGI object
+# not sure undef_params option is working, need to test
+use CGI qw('-no_undef_params');
+my $cgi = new CGI;
+
+my ($template,$borrowernumber,$cookie);
+
+# decide which template to use
+my $template_name;
+my @params = $cgi->param("limit");
+if ((@params>1) || ($cgi->param("q")) ) {
+	$template_name = 'catalogue/results.tmpl';
 }
 else {
-	($template, $loggedinuser, $cookie)
-		= get_template_and_user({template_name => "search.marc/search.tmpl",
-				query => $query,
-				type => $type,
-				authnotrequired => 0,
-				flagsrequired => {catalogue => 1},
-				debug => 1,
-				});
-	#$template->param(loggedinuser => $loggedinuser);
-
-	my $marcarray = create_marclist();
-
-	my $marclist = CGI::scrolling_list(-name=>"marclist",
-					-values=> $marcarray,
-					-size=>1,
-		 			-tabindex=>'',
-					-multiple=>0,
-					-onChange => "sql_update()",
-					);
+	$template_name = 'catalogue/advsearch.tmpl';
+}
 
-	my @statements = ();
+# load the template
+($template, $borrowernumber, $cookie) = get_template_and_user({
+    template_name => $template_name,
+    query => $cgi,
+    type => "intranet",
+    authnotrequired => 0,}
+);
+
+=head1 BUGS and FIXMEs
+
+There are many, most are documented in the code. The one that
+isn't fully documented, but referred to is the need for a full
+query parser.
+
+=cut
+
+## URI Re-Writing
+# FIXME: URI re-writing should be tested more carefully and may better
+# handled by mod_rewrite or something else. The code below almost works,
+# but doesn't quite handle limits correctly when they are the only
+# param passed -- I'll work on this soon -- JF
+#my $rewrite_flag;
+#my $uri = $cgi->url(-base => 1);
+#my $relative_url = $cgi->url(-relative=>1);
+#$uri.="/".$relative_url."?";
+#warn "URI:$uri";
+#my @cgi_params_list = $cgi->param();
+#my $url_params = $cgi->Vars;
+
+#for my $each_param_set (@cgi_params_list) {
+#	$uri.= join "",  map "\&$each_param_set=".$_, split("\0",$url_params->{$each_param_set}) if $url_params->{$each_param_set};
+#}
+#warn "New URI:$uri";
+# Only re-write a URI if there are params or if it already hasn't been re-written
+#unless (($cgi->param('r')) || (!$cgi->param()) ) {
+#	print $cgi->redirect( 	-uri=>$uri."&r=1",
+#                			-cookie => $cookie);
+#	exit;
+#}
+
+# load the branches
+my $branches = GetBranches();
+my @branch_loop;
+push @branch_loop, {value => "", branchname => "All Branches", };
+for my $branch_hash (keys %$branches) {
+	push @branch_loop, {value => "branch: $branch_hash", branchname => $branches->{$branch_hash}->{'branchname'}, };	
+}
+$template->param(branchloop => \@branch_loop,);
 
-	# Considering initial search with 3 criterias
-	push @statements, { "marclist" => $marclist, "first" => 1 };
-	push @statements, { "marclist" => $marclist, "first" => 0 };
-	push @statements, { "marclist" => $marclist, "first" => 0 };
-	my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
-	$sth->execute;
-	my  @itemtype;
-	my %itemtypes;
-	push @itemtype, "";
-	$itemtypes{''} = "";
-	while (my ($value,$lib) = $sth->fetchrow_array) {
-		push @itemtype, $value;
-		$itemtypes{$value}=$lib;
-	}
-
-	my $CGIitemtype=CGI::scrolling_list( -name     => 'value',
-				-id => 'itemtype',
-				-values   => \@itemtype,
- 				-labels   => \%itemtypes,
-				-size     => 1,
-	 			-tabindex=>'',
-				-multiple => 0 );
-	$sth->finish;
-
-	my @branches;
-	my @select_branch;
-	my %select_branches;
-	my $branches=GetBranches();
-	my @branchloop;
-	foreach my $thisbranch (sort keys %$branches) {
-# 		my $selected = 1 if $thisbranch eq $branch;
-		my %row =(value => $thisbranch,
-# 					selected => $selected,
-					branchname => $branches->{$thisbranch}->{'branchname'},
-				);
-		push @branchloop, \%row;
-	}
-	$sth->finish;
+# load the itemtypes (Called Collection Codes in the template -- used for circ rules )
+my ($itemtypecount, at item_type_loop) = GetItemTypes();
+$template->param(itemtypeloop=>\@item_type_loop,);
+
+# load the itypes (Called item types in the template -- just authorized values for searching)
+my ($itypecount, at itype_loop) = GetCcodes();
+$template->param(itypeloop=>\@itype_loop,);
+
+# load the languages ( for switching from one template to another )
+my @languages_options = displayLanguages($cgi);
+my $languages_count = @languages_options;
+if($languages_count > 1){
+        $template->param(languages => \@languages_options);
+}
 
+# The following should only be loaded if we're bringing up the advanced search template
+if ( $template_name eq "catalogue/advsearch.tmpl" ) {
+    warn "template name is advsearch";
+	# load the servers (used for searching -- to do federated searching, etc.)
+	my $primary_servers_loop = displayPrimaryServers(); 
+	$template->param(outer_servers_loop =>  $primary_servers_loop,);
+	
+	my $secondary_servers_loop = displaySecondaryServers();
+	$template->param(outer_sup_servers_loop => $secondary_servers_loop,);
+	
+	# load the limit types (icon-based limits in advanced search page)
+	my $outer_limit_types_loop = displayLimitTypes();
+	$template->param(outer_limit_types_loop =>  $outer_limit_types_loop,);
+	
+	# load the search indexes (what a user can choose to search by)
+	my $indexes = displayIndexes();
+	
+	# determine what to display next to the search boxes (ie, boolean option
+	# shouldn't appear on the first one, scan indexes should, adding a new
+	# box should only appear on the last, etc.
+	# FIXME: this stuff should be cleaned up a bit and the html should be turned
+	# into flags for the template -- I'll work on that soon -- JF
+	my @search_boxes_array;
+	my $search_boxes_count = 3; # should be a syspref
+	for (my $i=0;$i<=$search_boxes_count;$i++) {
+		my $this_index =[@$indexes]; # clone the data, not just the reference
+		#@$this_index[$i]->{selected} = "selected";
+		if ($i==0) {
+			push @search_boxes_array, 
+				{indexes => $this_index,
+				search_boxes_label => "<span class='labels'>Search for:</span>",
+				scan_index => "<label for='scan'></label><input type='checkbox' name='scan' id='scan' value='1'/>Scan Indexes",
+				};
+		
+    	} 
+		elsif ($i==$search_boxes_count) {
+        	push @search_boxes_array,
+            	{indexes => $indexes,
+            	left_content => " <select name='op'><option value='and' selected='selected'>and</option><option value='or'>or</option><option value='not'>not</option></select>",
+				add_field => "1"};
+		} 
+		else {
+			push @search_boxes_array,
+				{indexes => $indexes,
+				left_content => " <select name='op'><option value='and' selected='selected'>and</option><option value='or'>or</option><option value='not'>not</option></select>",};
+		}
+	}
+	$template->param(search_boxes_loop => \@search_boxes_array,);
+
+	# load the language limits (for search)
+	my $languages_limit_loop = displayLanguagesLimit();
+	$template->param(search_languages_loop => $languages_limit_loop,);
+	
+	# load the subtype limits
+	my $outer_subtype_limits_loop = displaySubtypesLimit();
+	$template->param(outer_subtype_limits_loop => $outer_subtype_limits_loop,);
+
+    my $expanded_options = $cgi->param('expanded_options');
+    $template->param(expanded_options => $expanded_options);
+
+	# load the sort_by options for the template
+	my $sort_by = $cgi->param('sort_by');
+	my $sort_by_loop = displaySortby($sort_by);
+	$template->param(sort_by_loop => $sort_by_loop);
+
+    #warn "loading the template";
+    output_html_with_http_headers $cgi, $cookie, $template->output;
+    exit;
+}
 
-	$template->param('Disable_Dictionary'=>C4::Context->preference("Disable_Dictionary")) if (C4::Context->preference("Disable_Dictionary"));
-	$template->param("statements" => \@statements,
-			"nbstatements" => 3,
-			CGIitemtype => $CGIitemtype,
-			branchloop => \@branchloop,
-			);
+### OK, if we're this far, we're performing an actual search
+
+# Fetch the paramater list as a hash in scalar context:
+#  * returns paramater list as tied hash ref
+#  * we can edit the values by changing the key
+#  * multivalued CGI paramaters are returned as a packaged string separated by "\0" (null)
+warn "getting the params";
+my $params = $cgi->Vars;
+
+# Params that can have more than one value
+# sort by is used to sort the query
+my @sort_by;
+ at sort_by = split("\0",$params->{'sort_by'}) if $params->{'sort_by'};
+# load the sort_by options for the template
+my $sort_by = $params->{'sort_by'};
+my $sort_by_loop = displaySortby($sort_by);
+$template->param(sort_by_loop => $sort_by_loop);
+#
+# Use the servers defined, or just search our local catalog(default)
+my @servers;
+ at servers = split("\0",$params->{'server'}) if $params->{'server'};
+unless (@servers) {
+	#FIXME: this should be handled using Context.pm
+	@servers = ("biblioserver");
+	# @servers = C4::Context->config("biblioserver");
+}
+
+# operators include boolean and proximity operators and are used
+# to evaluate multiple operands
+my @operators;
+ at operators = split("\0",$params->{'op'}) if $params->{'op'};
+
+# indexes are query qualifiers, like 'title', 'author', etc. They
+# can be simple or complex
+my @indexes;
+ at indexes = split("\0",$params->{'idx'}) if $params->{'idx'};
+
+# an operand can be a single term, a phrase, or a complete ccl query
+my @operands;
+ at operands = split("\0",$params->{'q'}) if $params->{'q'};
+
+# limits are use to limit to results to a pre-defined category such as branch or language
+my @limits;
+ at limits = split("\0",$params->{'limit'}) if $params->{'limit'};
+
+my $available;
+foreach my $limit(@limits) {
+	if ($limit =~/available/) {
+		$available = 1;
+	}
 }
+$template->param(available => $available);
+push @limits, map "yr:".$_, split("\0",$params->{'limit-yr'}) if $params->{'limit-yr'};
 
+# Params that can only have one value
+my $query = $params->{'q'};
+my $scan = $params->{'scan'};
+my $results_per_page = $params->{'count'} || 20;
+my $offset = $params->{'offset'} || 0;
+my $hits;
+my $expanded_facet = $params->{'expand'};
+
+# Define some global variables
+my $error; # used for error handling
+my $search_desc; # the query expressed in terms that humans understand
+my $koha_query; # the query expressed in terms that zoom understands with field weighting and stemming
+my $federated_query;
+my $query_type; # usually not needed, but can be used to trigger ccl, cql, or pqf queries if set
+my @results;
+warn "Building the Query";
+## I. BUILD THE QUERY
+($error,$search_desc,$koha_query,$federated_query,$query_type) = buildQuery($query,\@operators,\@operands,\@indexes,\@limits);
+use Data::Dumper;
+warn "buildQuery==>".Dumper($error,$search_desc,$koha_query,$federated_query,$query_type);
+## II. DO THE SEARCH AND GET THE RESULTS
+my $total; # the total results for the whole set
+my $facets; # this object stores the faceted results that display on the left-hand of the results page
+my @results_array;
+my $results_hashref;
+eval {
+
+	($error, $results_hashref, $facets) = getRecords($koha_query,$federated_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
+
+};
+if ($@ || $error) {
+	$template->param(query_error => $error.$@);
+	warn "error: ".$error.$@;
+	output_html_with_http_headers $cgi, $cookie, $template->output;
+	exit;
+}
+
+# At this point, each server has given us a result set
+# now we build that set for template display
+my @sup_results_array;
+warn "SERVERS ARE==>".Dumper(@servers);
+for (my $i=0;$i<=@servers;$i++) {
+	my $server = $servers[$i];
+	if ($server =~/biblioserver/) { # this is the local bibliographic server
+		$hits = $results_hashref->{$server}->{"hits"};
+		my @newresults = searchResults( $search_desc,$hits,$results_per_page,$offset,@{$results_hashref->{$server}->{"RECORDS"}});
+		warn "RESULTS ARE==>".Dumper(@{$results_hashref->{$server}->{"RECORDS"}});
+		$total = $total + $results_hashref->{$server}->{"hits"};
+		if ($hits) {
+    		$template->param(total => $hits);
+    		$template->param(searchdesc => $search_desc );
+    		$template->param(results_per_page =>  $results_per_page);
+    		$template->param(SEARCH_RESULTS => \@newresults);
+
+			my @page_numbers;
+			my $pages = ceil($hits / $results_per_page);
+			my $current_page_number = 1;
+			$current_page_number = ($offset / $results_per_page + 1) if $offset;
+			my $previous_page_offset = $offset - $results_per_page unless ($offset - $results_per_page <0);
+			my $next_page_offset = $offset + $results_per_page;
+			for ($i=1; $i<=$pages;$i++) {
+				my $this_offset = (($i*$results_per_page)-$results_per_page);
+				my $this_page_number = $i;
+				my $highlight = 1 if ($this_page_number == $current_page_number);
+				push @page_numbers, { offset => $this_offset, pg => $this_page_number, highlight => $highlight, sort_by => join " ", at sort_by };
+			}
+			$template->param(PAGE_NUMBERS => \@page_numbers,
+							previous_page_offset => $previous_page_offset,
+							next_page_offset => $next_page_offset) unless $pages < 2;
+		}
+	} # end of the if local
+	else {
+		# check if it's a z3950 or opensearch source
+		my $zed3950 = 0; 
+		if ($zed3950) {
+			my @inner_sup_results_array;
+			for my $sup_record ( @{$results_hashref->{$server}->{"RECORDS"}} ) {
+				my $marc_record_object = MARC::Record->new_from_usmarc($sup_record);
+				my $control_number = $marc_record_object->field('010')->subfield('a') if $marc_record_object->field('010');
+				$control_number =~ s/^ //g;
+				my $link = "http://catalog.loc.gov/cgi-bin/Pwebrecon.cgi?SAB1=".$control_number."&BOOL1=all+of+these&FLD1=LC+Control+Number+LCCN+%28K010%29+%28K010%29&GRP1=AND+with+next+set&SAB2=&BOOL2=all+of+these&FLD2=Keyword+Anywhere+%28GKEY%29+%28GKEY%29&PID=6211&SEQ=20060816121838&CNT=25&HIST=1";
+				my $title = $marc_record_object->title();
+				push @inner_sup_results_array, {
+					'title' => $title,
+					'link' => $link,
+				};
+			}
+			my $servername = $server;
+			push @sup_results_array, { servername => $servername, inner_sup_results_loop => \@inner_sup_results_array};
+			$template->param(outer_sup_results_loop => \@sup_results_array);
+		}
+	}
+
+} #/end of the for loop
+#$template->param(FEDERATED_RESULTS => \@results_array);
+
+$template->param('Disable_Dictionary'=>C4::Context->preference("Disable_Dictionary")) if (C4::Context->preference("Disable_Dictionary"));
+
+$template->param(
+            #classlist => $classlist,
+			total => $total,
+			searchdesc => $search_desc,
+			opacfacets => 1,
+			facets_loop => $facets,
+            suggestion => C4::Context->preference("suggestion"),
+            virtualshelves => C4::Context->preference("virtualshelves"),
+            LibraryName => C4::Context->preference("LibraryName"),
+            OpacNav => C4::Context->preference("OpacNav"),
+            opaccredits => C4::Context->preference("opaccredits"),
+            AmazonContent => C4::Context->preference("AmazonContent"),
+            opacsmallimage => C4::Context->preference("opacsmallimage"),
+            opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"),
+            opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"),
+            scan_use => $scan,
+            search_error => $error,
+);
+## Now let's find out if we have any supplemental data to show the user
+#  and in the meantime, save the current query for statistical purposes, etc.
+my $koha_spsuggest; # a flag to tell if we've got suggestions coming from Koha
+my @koha_spsuggest; # place we store the suggestions to be returned to the template as LOOP
+my $phrases = $search_desc;
+my $ipaddress;
+
+if ( C4::Context->preference("kohaspsuggest") ) {
+        eval {
+            my $koha_spsuggest_dbh;
+			# FIXME: this needs to be moved to Context.pm
+            eval {
+                $koha_spsuggest_dbh=DBI->connect("DBI:mysql:suggest:66.213.78.76","auth","Free2cirC");
+            };
+            if ($@) { warn "can't connect to spsuggest db";
+            }
+            else {
+                my $koha_spsuggest_insert = "INSERT INTO phrase_log(phr_phrase,phr_resultcount,phr_ip) VALUES(?,?,?)";
+                my $koha_spsuggest_query = "SELECT display FROM distincts WHERE strcmp(soundex(suggestion), soundex(?)) = 0 order by soundex(suggestion) limit 0,5";
+                my $koha_spsuggest_sth = $koha_spsuggest_dbh->prepare($koha_spsuggest_query);
+                $koha_spsuggest_sth->execute($phrases);
+                while (my $spsuggestion = $koha_spsuggest_sth->fetchrow_array) {
+                    $spsuggestion =~ s/(:|\/)//g;
+                    my %line;
+                    $line{spsuggestion} = $spsuggestion;
+                    push @koha_spsuggest,\%line;
+                    $koha_spsuggest = 1;
+                }
+
+                # Now save the current query
+                $koha_spsuggest_sth=$koha_spsuggest_dbh->prepare($koha_spsuggest_insert);
+                #$koha_spsuggest_sth->execute($phrases,$results_per_page,$ipaddress);
+                $koha_spsuggest_sth->finish;
 
-# Print the page
-$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
-		intranetstylesheet => C4::Context->preference("intranetstylesheet"),
-		IntranetNav => C4::Context->preference("IntranetNav"),
+                $template->param( koha_spsuggest => $koha_spsuggest ) unless $hits;
+                $template->param( SPELL_SUGGEST => \@koha_spsuggest,
 		);
-output_html_with_http_headers $query, $cookie, $template->output;
+            }
+	};
+	if ($@) {
+            warn "Kohaspsuggest failure:".$@;
+	}
+}
 
-# Local Variables:
-# tab-width: 4
-# End:
+# VI. BUILD THE TEMPLATE
+output_html_with_http_headers $cgi, $cookie, $template->output;

Index: koha-tmpl/intranet-tmpl/prog/en/catalogue/advsearch.tmpl
===================================================================
RCS file: koha-tmpl/intranet-tmpl/prog/en/catalogue/advsearch.tmpl
diff -N koha-tmpl/intranet-tmpl/prog/en/catalogue/advsearch.tmpl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ koha-tmpl/intranet-tmpl/prog/en/catalogue/advsearch.tmpl	9 Oct 2006 16:22:01 -0000	1.1.2.1
@@ -0,0 +1,186 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->Koha -- Catalog: Advanced Search<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<!-- TMPL_INCLUDE NAME="menus.inc" -->
+<!-- TMPL_INCLUDE NAME="menu-catalogue.inc" -->
+
+<form action="search.pl" method="get">
+<div id="main-sidebar"><div id="advanced-search">
+<!-- TMPL_IF NAME="expanded_options" -->
+<h3>Advanced Search</h3>
+<!-- TMPL_ELSE -->
+<h3>Search the Library Catalog</h3>
+<!-- /TMPL_IF -->
+
+<!-- TMPL_IF NAME="if_expanded_options_actually_worked" -->
+<!-- TMPL_IF NAME="outer_servers_loop" -->
+<!-- DATABASES -->
+
+<fieldset>
+		<legend>Select local databases:</legend>
+			<p>
+				<!-- TMPL_LOOP NAME="outer_servers_loop" -->
+				<!-- TMPL_LOOP NAME="inner_servers_loop" -->
+				<input type="checkbox" id="<!-- TMPL_VAR NAME="id" -->" name="<!-- TMPL_VAR NAME="name" -->" <!-- TMPL_IF NAME="checked" -->checked="<!-- TMPL_VAR NAME="checked" -->"<!-- /TMPL_IF --> value="<!-- TMPL_VAR NAME="value" -->"/><label for="<!-- TMPL_VAR NAME="id" -->"><img width="16" height="16" alt="<!-- TMPL_VAR NAME="id" -->" src="<!-- TMPL_VAR NAME="themelang" -->/images/<!-- TMPL_VAR NAME="icon" -->" /> <!-- TMPL_VAR NAME="label" --></label>
+				<!-- /TMPL_LOOP -->
+				<!-- /TMPL_LOOP -->
+			</p>
+</fieldset>
+<!-- /DATABASES -->
+<!-- /TMPL_IF -->
+
+<!-- TMPL_IF NAME="outer_sup_servers_loop" -->
+<!-- REMOTE DATABASES -->
+<fieldset>
+    <legend>Select remote databases:</legend>
+        <p>
+                <!-- TMPL_LOOP NAME="outer_sup_servers_loop" -->
+                <!-- TMPL_LOOP NAME="inner_sup_servers_loop" -->
+                <input type="checkbox" id="<!-- TMPL_VAR NAME="id" -->" name="<!-- TMPL_VAR NAME="name" -->" <!-- TMPL_IF NAME="checked" -->checked="<!-- TMPL_VAR NAME="checked" -->"<!-- /TMPL_IF --> value="<!-- TMPL_VAR NAME="value" -->"/><label for="<!-- TMPL_VAR NAME="id" -->"><img alt="<!-- TMPL_VAR NAME="id" -->" src="<!-- TMPL_VAR NAME="themelang" -->/images/<!-- TMPL_VAR NAME="icon" -->"/><!-- TMPL_VAR NAME="label" --></label>
+                <!-- /TMPL_LOOP -->
+                <!-- /TMPL_LOOP -->
+	</p>
+	</fieldset>
+<!-- /REMOTE DATABASES -->
+<!-- /TMPL_IF -->
+<!-- /TMPL_IF -->
+
+<!-- BOOLEAN SEARCH OPTIONS -->
+	<fieldset>
+	<!-- TMPL_IF NAME="expanded_options" --><legend>Search For:</legend><!-- /TMPL_IF --> 
+	<!-- TMPL_LOOP NAME="search_boxes_loop" -->
+		
+		<!-- TMPL_IF NAME="expanded_options" --><!-- TMPL_IF NAME="search_boxes_label" --><p style="text-indent: 4.5em;"><!-- TMPL_ELSE --><p><!-- /TMPL_IF --><!-- TMPL_ELSE --><p><!-- /TMPL_IF -->
+		<!-- TMPL_IF NAME="expanded_options" --><!-- TMPL_VAR NAME="left_content" --><!-- /TMPL_IF --> 
+		<select name="idx">
+			<!-- TMPL_LOOP NAME="indexes" -->
+			<option value="<!-- TMPL_VAR NAME="value" -->" <!-- TMPL_IF NAME="selected" -->selected="<!-- TMPL_VAR NAME="selected" -->"<!-- /TMPL_IF -->><!-- TMPL_VAR NAME="label" --></option>
+		<!-- /TMPL_LOOP -->
+		</select>
+		<input size="30" name="q" title="Enter search terms" value=""/>
+		    <!-- TMPL_IF NAME="expanded_options" -->
+		<!-- TMPL_IF NAME="scan_index" --><!-- TMPL_VAR NAME="scan_index" --><!-- /TMPL_IF -->
+		<!-- TMPL_IF NAME="add_field" --><a href="" title="Add another field">[+]</a><!-- /TMPL_IF -->
+			<!-- /TMPL_IF -->
+		</p>
+
+	<!-- /TMPL_LOOP -->
+	</fieldset>
+<!-- /BOOLEAN SEARCH OPTIONS --> 
+
+    <!-- TMPL_IF NAME="expanded_options" -->
+<!-- BASIC LIMITS -->
+ <fieldset>
+			<legend>Limits:</legend>
+				<!-- PUB / COPY YEAR LIMIT --><!-- FIXME: add publication,copyright,acquisition options -->
+						<p><label for="limit-yr">Year: </label>
+			<input size="15" name="limit-yr" id="" value=""/>&nbsp;&nbsp;(format: yyyy-yyyy)</p>
+				<!-- /PUB / COPY YEAR LIMIT -->
+                <!-- /YEAR LIMIT -->
+				
+	<!-- LANGUAGE LIMIT -->
+		<p><label for="language-limit">Language: </label>
+					<select name="limit">	
+				<!-- TMPL_LOOP NAME="search_languages_loop" -->
+				<option value="<!-- TMPL_VAR NAME="value" -->" <!-- TMPL_IF NAME="selected" -->selected="<!-- TMPL_VAR NAME="selected" -->"<!-- /TMPL_IF -->><!-- TMPL_VAR NAME="language_label" --> <!-- TMPL_IF NAME="locale_label" -->(<!-- TMPL_VAR NAME="locale_label" -->)<!-- /TMPL_IF --></option>
+				<!-- /TMPL_LOOP -->
+				</select></p><!-- <a href="">Show all languages</a>-->
+				<!-- /LANGUAGE LIMIT -->
+	</fieldset>
+<!-- /BASIC LIMITS -->
+	<!-- /TMPL_IF -->
+
+<!-- TYPE LIMITS -->	
+	<fieldset>
+	<legend>Limit type to: match any of the following <a href="http://wiki.koha.org/?id=en:opachelp#" class="help"  onclick="window.open('http://wiki.koha.org/?id=en:opachelp#',' Help','width=350,top=50,left=50,resizable,scrollbars,height=650');  return false;">[ ? ]</a></legend>
+	<table class="itemtypes">
+			<!-- TMPL_LOOP NAME="outer_limit_types_loop" -->
+			<tr>
+				<!-- TMPL_LOOP NAME="inner_limit_types_loop" -->
+				<td<!-- TMPL_IF NAME="colspan" --> colspan="<!-- TMPL_VAR NAME="colspan" -->"<!-- /TMPL_IF -->><input type="checkbox" id="<!-- TMPL_VAR NAME="id" -->" name="<!-- TMPL_VAR NAME="name" -->" value="<!-- TMPL_VAR NAME="value" -->"/><label for="<!-- TMPL_VAR NAME="id" -->" title="<!-- TMPL_VAR NAME="title" -->"><a href="http://wiki.koha.org/?id=en:opachelp#<!-- TMPL_VAR NAME="id" -->" class="help"  onclick="window.open('http://wiki.koha.org/?id=en:opachelp#<!-- TMPL_VAR NAME="id" -->','<!-- TMPL_VAR NAME="label" --> Help','width=350,top=50,left=50,resizable,scrollbars,height=650');  return false;"><img border="0" src="<!-- TMPL_VAR NAME="themelang">/images/<!-- TMPL_VAR NAME="icon" -->" alt="<!-- TMPL_VAR NAME="label" -->" /></a><!-- TMPL_VAR NAME="label" --></label></td>
+				<!-- /TMPL_LOOP -->
+			</tr>
+			<!-- /TMPL_LOOP -->
+			</table>
+</fieldset>
+<!-- /TYPE LIMITS -->
+
+
+</div>
+</div>
+
+<div id="sidebar">
+
+<!-- TMPL_IF NAME="outer_subtype_limits_loop" -->
+<!-- SUBTYPE LIMITS -->
+		<fieldset>
+		<legend>Subtype limits</legend><p>
+		<!-- TMPL_LOOP NAME="outer_subtype_limits_loop" -->
+		<select name="<!-- TMPL_VAR NAME="name" -->" class="subtype">
+			<!-- TMPL_LOOP NAME="inner_subtype_limits_loop" -->
+			<option value="<!-- TMPL_VAR NAME="value" -->" <!-- TMPL_IF NAME="selected" -->selected="<!-- TMPL_VAR NAME="selected" -->" class="menuheader"<!-- /TMPL_IF -->><!-- TMPL_VAR NAME="label" --></option>
+			<!-- /TMPL_LOOP -->
+		</select>
+		<!-- /TMPL_LOOP --><a href="http://wiki.koha.org/?id=en:opachelp#" class="help"  onclick="window.open('http://wiki.koha.org/?id=en:opachelp#subtypes','Sub-types Help','width=350,top=50,left=50,resizable,scrollbars,height=650');  return false;">[ ? ]</a></p>
+
+</fieldset>
+<!-- /SUBTYPE LIMITS -->
+<!-- /TMPL_IF -->
+
+
+<!-- TMPL_IF NAME="itemtypeloop" -->
+<fieldset><legend>Collection Code Limits: </legend>
+			<p><select name="limit">
+			<option value="">All Collection Codes</option>
+		<!-- TMPL_LOOP NAME="itemtypeloop" -->
+			<option value="collection-code:<!-- TMPL_VAR NAME="itemtype" -->"><!-- TMPL_VAR NAME="description" --></option>
+		<!-- /TMPL_LOOP -->
+			</select>
+<!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="itypeloop" -->
+            <select name="limit">
+            <option value="">All Item Types</option>
+        <!-- TMPL_LOOP NAME="itypeloop" -->
+            <option value="collection-code:<!-- TMPL_VAR NAME="authorised_value" -->"><!-- TMPL_VAR NAME="lib" --></option>
+        <!-- /TMPL_LOOP -->
+		</select></p></fieldset>
+<!-- /TMPL_IF -->
+
+<!-- AVAILABILITY LIMITS -->
+	<fieldset><legend>Location and availability: </legend>
+		<p><select name="limit" id="branchloop">
+		<!-- TMPL_LOOP NAME="branchloop" -->
+		<option value="<!-- TMPL_VAR NAME='value' -->"><!-- TMPL_VAR NAME='branchname' --></option>
+		<!-- /TMPL_LOOP -->
+		</select>
+
+		<input type="checkbox" id="available-items" name="limit" value="datedue:0000-00-00"/><label for="available-items">Only items currently available</label></p>
+	</fieldset>
+<!-- /AVAILABILITY LIMITS -->
+
+<!-- RANK LIMITS -->
+<!-- TMPL_IF NAME="sort_by_loop" -->
+<fieldset><legend>Sort by: </legend>
+	<p><select id="sort_by" name="sort_by">
+		<option value="">Field-weighted, Relevance Ranked</option>
+		<!-- TMPL_LOOP NAME="sort_by_loop" -->
+		<option value="<!-- TMPL_VAR NAME="value" -->" <!-- TMPL_IF NAME="selected" -->selected="<!-- TMPL_VAR NAME="selected" -->"<!-- /TMPL_IF -->><!-- TMPL_VAR NAME="label" --></option>
+		<!-- /TMPL_LOOP -->
+	</select>
+		<a href="http://wiki.koha.org/?id=en:opachelp#sort_by" class="help"  onclick="window.open('http://wiki.koha.org/?id=en:opachelp#sort_by','Sort By Help','width=350,top=50,left=50,resizable,scrollbars,height=650');  return false;">[ ? ]</a></p>
+</fieldset>
+<!-- /TMPL_IF -->
+<!-- RANK LIMITS -->
+<p></p>
+<!-- SEARCH BUTTONS -->
+        	<p><input class="submit" type="submit" accesskey="s" name="do" title="Search" value="Search"/>
+<!-- TMPL_IF NAME="expanded_options" -->
+			<a href="search.pl">[Fewer Options]</a>
+			<!-- TMPL_ELSE -->
+			<a href="search.pl?expanded_options=1">[More options]</a>
+			<!-- /TMPL_IF -->
+			<a href="search.pl?do=Clear">[New Search]</a> 
+			</p>
+<!-- /SEARCH BUTTONS -->
+</div>
+</form>
+
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

Index: koha-tmpl/intranet-tmpl/prog/en/catalogue/results.tmpl
===================================================================
RCS file: koha-tmpl/intranet-tmpl/prog/en/catalogue/results.tmpl
diff -N koha-tmpl/intranet-tmpl/prog/en/catalogue/results.tmpl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ koha-tmpl/intranet-tmpl/prog/en/catalogue/results.tmpl	9 Oct 2006 16:22:01 -0000	1.1.2.1
@@ -0,0 +1,158 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->Koha -- Catalog -- <!-- TMPL_IF NAME="searchdesc" -->Results of Search for '<!-- TMPL_VAR NAME="searchdesc" -->'<!-- TMPL_ELSE -->You did not specify any search criteria<!-- /TMPL_IF -->
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<!-- TMPL_INCLUDE NAME="menus.inc" -->
+<!-- TMPL_INCLUDE NAME="menu-catalogue.inc" -->
+
+<div class="content-block">
+<!-- TMPL_IF NAME="koha_spsuggest" --><div style="font-size: 12px;">Did you mean: <ul style="list-style: none;"><!-- TMPL_LOOP NAME="SPELL_SUGGEST" --> <li><a href="/search?q=<!-- TMPL_VAR NAME="spsuggestion" -->"><!-- TMPL_VAR NAME="spsuggestion" --></a></li><!-- /TMPL_LOOP --></ul></div><!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="total" -->
+<!-- TMPL_ELSE -->
+<!-- TMPL_IF NAME="searchdesc" -->
+No results match your search for <span style="font-weight: bold;">&ldquo;<!-- TMPL_VAR NAME="searchdesc" -->&rdquo;</span> in <!-- TMPL_VAR NAME="LibraryName" --> Catalog.
+<!-- TMPL_ELSE -->
+<h3> You did not specify any search criteria. </h3>
+<!-- /TMPL_IF -->
+<!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="query_error" -->
+<!-- TMPL_VAR NAME="query_error" -->
+<!-- /TMPL_IF -->
+
+<!-- Search Results Table -->
+<!-- TMPL_IF NAME="total" -->
+<!-- TMPL_IF NAME="scan" -->
+<h1>Scan Index:</h1>
+                <form action="search.pl" method="get">
+<table>
+        <tr><td>
+	Scan Index for: <input type="text" name="qf" id="scan-index" size="35" value="" />
+	</td>
+	</tr><tr><td>
+                <label for="scan-index">Indexed in:</label>
+                <select name="idx" id="scan-index">
+                <option value="">Any Word</option>
+		<option value="any/phr:">Any Phrase</option>
+                <option value="ti:">Title</option>
+		<option value="ti,phr:">Title Phrase</option>
+                <option value="au,phr:">Author</option>
+                <option value="su:">Subject</option>
+		<option value="su,phr:">Subject Phrase</option>
+                <option value="se:">Series</option>
+                <option value="pb:">Publisher</option>
+                <option value="nt:">Notes</option>
+                <option value="se:">Series Title</option>
+                <option value="sn:">ISBN</option>
+                <option value="ss:">ISSN</option>
+                </select>
+		<input type="hidden" name="scan" value="1" />
+</td></tr>
+</table>
+</form>
+
+<form action="search.pl" method="get">
+<table>
+	<tr>
+		<th>Term/Phrase</th>
+		<th>Count</th>
+	</tr>
+<!-- TMPL_LOOP NAME="SEARCH_RESULTS" -->
+
+			<tr<!-- TMPL_IF name="even" --> class="highlight"<!-- /TMPL_IF -->><td>
+                        <a href="search.pl?q=<!-- TMPL_VAR NAME="scan_use" escape="url" -->&quot;<!-- TMPL_VAR NAME="title" -->&quot;"><!-- TMPL_VAR NAME="title" --></a>
+			</td>
+			<td>
+			<!-- TMPL_VAR NAME="subtitle" -->
+			</td></tr>
+<!-- /TMPL_LOOP -->
+
+</table>
+</form>
+<!-- TMPL_ELSE -->
+
+<form action="search.pl" method="get" name="myform" id="mainform">
+
+	<!-- TMPL_IF NAME="searchdesc" -->
+    <input type="hidden" name="q" value="<!-- TMPL_VAR NAME="searchdesc" escape="html" -->" />
+	<!-- /TMPL_IF -->
+
+	<!-- TMPL_IF NAME="sort_by_loop" -->
+    <p><select id="sort_by" name="sort_by" onChange="document.myform.submit();">
+        <option value="">Field-weighted, Relevance Ranked</option>
+        <!-- TMPL_LOOP NAME="sort_by_loop" -->
+        <option value="<!-- TMPL_VAR NAME="value" -->" <!-- TMPL_IF NAME="selected" -->selected="<!-- TMPL_VAR NAME="selected" -->"<!-- /TMPL_IF -->><!-- TMPL_VAR NAME="label" --></option>
+        <!-- /TMPL_LOOP -->
+    </select>
+	<input type="submit" value="Re-sort" class="submit" />
+        <a href="http://wiki.koha.org/?id=en:opachelp#sort_by" class="help"  onclick="window.open('http://wiki.koha.org/?id=en:opachelp#sort_by','Sort By Help','width=350,top=50,left=50,resizable,scrollbars,height=650');  return false;">[ ? ]</a></p>
+	<!-- /TMPL_IF -->
+
+<div class="searchresults"><table>
+	<tr>
+	<th>&nbsp;</th>
+	<th>Title</th>
+	<th>Call No.</th>
+	<th>Location</th>
+	<th>&nbsp;</th>
+	</tr>
+		<!-- Actual Search Results -->
+		<!-- TMPL_LOOP NAME="SEARCH_RESULTS" -->
+		<!-- TMPL_IF name="even" --><tr class="highlight"><!-- TMPL_ELSE --><tr><!-- /TMPL_IF -->
+			<td><!-- TMPL_IF NAME="AmazonContent" --><a class="p1" href="/cgi-bin/koha/detail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->"><img src="<!-- TMPL_IF NAME="isbn" -->http://images.amazon.com/images/P/<!-- TMPL_VAR name="isbn" -->.01.TZZZZZZZ.jpg<!-- TMPL_ELSE -->http://g-images.amazon.com/images/G/01/x-site/icons/no-img-sm.gif<!-- /TMPL_IF -->" alt="image" class="thumbnail" /></a><!-- /TMPL_IF --></td>
+			<td><p><!-- TMPL_IF name="BiblioDefaultViewmarc" --><a class="title" href="/cgi-bin/koha/MARCdetail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->"><!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="subtitle" --></a><!-- TMPL_ELSE --><!-- TMPL_IF name="BiblioDefaultViewisbd" --><a class="title" href="/cgi-bin/koha/ISBDdetail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->"><!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="subtitle" --></a><!-- TMPL_ELSE --><a class="title" href="/cgi-bin/koha/detail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->"><!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="subtitle" --></a><!-- /TMPL_IF --><!-- /TMPL_IF --></p> 
+<p> <!-- TMPL_IF NAME="author" --><a href="/search?q=au:<!-- TMPL_VAR NAME="author" ESCAPE="URL" -->"><!-- TMPL_VAR NAME="author" --></a><!-- TMPL_ELSE -->&nbsp;<!-- /TMPL_IF -->
+				<!-- TMPL_IF name="publicationyear" --> - <!-- TMPL_VAR name="publicationyear" --><!-- /TMPL_IF -->
+						<!-- TMPL_IF name="publishercode" -->- <!-- TMPL_VAR name="publishercode" --><!-- /TMPL_IF -->
+						<!-- TMPL_IF name="place" --> ; <!-- TMPL_VAR name="place" --><!-- /TMPL_IF -->
+						<!-- TMPL_IF name="pages" --> - <!-- TMPL_VAR name="pages" --><!-- /TMPL_IF -->
+						<!-- TMPL_IF name="notes" --> : <!-- TMPL_VAR name="notes" --><!-- /TMPL_IF -->
+						<!-- TMPL_IF name="size" --> ; <!-- TMPL_VAR name="size" --><!-- /TMPL_IF -->
+						<!-- TMPL_IF name="timestamp" --> <i>(modified on <!-- TMPL_VAR name="timestamp" -->)</i><!-- /TMPL_IF --></p></td>
+				<td><a href="/search?q=callnum:<!-- TMPL_VAR NAME="classification" ESCAPE="URL" -->"><!-- TMPL_VAR NAME="classification" --></a></td>
+			<td style="white-space: nowrap">
+<!-- TMPL_IF NAME="items_loop" -->
+<span class="available"><!-- TMPL_LOOP NAME="items_loop" -->
+                <!-- <!-- TMPL_VAR NAME="branchcode" --> -->
+                <!-- TMPL_VAR NAME="branchname" -->
+                (<!-- TMPL_VAR NAME="count" -->),<br />
+<!-- /TMPL_LOOP --></span>
+<!-- /TMPL_IF -->
+<span class="unavailable">
+<!-- TMPL_IF NAME="onloancount" --> On loan (<!-- TMPL_VAR NAME="onloancount" -->),<br /> <!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="wthdrawncount" --> Withdrawn (<!-- TMPL_VAR NAME="wthdrawncount" -->),<br /> <!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="itemlostcount" --> Lost (<!-- TMPL_VAR NAME="itemlostcount" -->)<br /><!-- /TMPL_IF --></span>
+				</td>
+				<td><!-- TMPL_IF NAME="norequests" -->Not Reserveable<!-- TMPL_ELSE --><a class="reserve" href="/cgi-bin/koha/request.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->">Reserves</a><!-- /TMPL_IF --></td>
+		</tr>
+		<!-- /TMPL_LOOP -->
+	</table></div>
+</form>
+<!-- /TMPL_IF -->
+
+<!-- TMPL_IF NAME="PAGE_NUMBERS" --><div class="pages">
+    <!-- Row of numbers corresponding to search result pages -->
+	<!-- TMPL_IF NAME="previous_page_offset" --><a class="nav" href="/search?q=<!-- TMPL_VAR NAME="searchdesc" -->&amp;offset=<!-- TMPL_VAR NAME="previous_page_offset" -->">&lt;&lt; Previous</a><!-- /TMPL_IF -->
+    <!-- TMPL_LOOP NAME="PAGE_NUMBERS" --><!-- TMPL_IF NAME="highlight" --><span class="current"><!-- TMPL_VAR NAME="pg" --></span><!-- TMPL_ELSE -->
+	<a class="nav" href="/search?q=<!-- TMPL_VAR NAME="searchdesc" -->&amp;offset=<!-- TMPL_VAR NAME="offset" --><!-- TMPL_IF NAME="sort_by" -->&amp;sort_by=<!-- TMPL_VAR NAME="sort_by" --><!-- /TMPL_IF -->"><!-- TMPL_VAR NAME="pg" --></a><!-- /TMPL_IF -->
+    <!-- /TMPL_LOOP -->
+	<!-- TMPL_IF NAME="next_page_offset" --><a class="nav" href="/search?q=<!-- TMPL_VAR NAME="searchdesc" -->&amp;offset=<!-- TMPL_VAR NAME="next_page_offset" -->">Next &gt;&gt;</a><!-- /TMPL_IF -->
+</div><!-- /TMPL_IF -->
+
+	<!-- TMPL_IF NAME="outer_sup_results_loop" -->
+		<h3><!-- TMPL_LOOP NAME="outer_sup_results_loop" --></h3>
+			<!-- TMPL_IF NAME="inner_sup_results_loop" -->
+			<!-- TMPL_VAR NAME="servername" -->
+			<!-- TMPL_LOOP NAME="inner_sup_results_loop" -->
+				<div><a href="<!-- TMPL_VAR NAME="link" -->"><!-- TMPL_VAR NAME="title" --></a></div>
+			<!-- /TMPL_LOOP -->
+			<!-- /TMPL_IF -->
+		<!-- /TMPL_LOOP -->
+   <!-- /TMPL_IF -->
+
+<!-- TMPL_ELSE -->
+
+
+<!-- /TMPL_IF -->
+
+</div>
+</div>
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->





More information about the Koha-cvs mailing list