koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha/opac opac-account.pl opac-detail.pl opac-I... [dev_week]


From: Joshua Ferraro
Subject: [Koha-cvs] koha/opac opac-account.pl opac-detail.pl opac-I... [dev_week]
Date: Tue, 19 Sep 2006 04:46:31 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         dev_week
Changes by:     Joshua Ferraro <kados>  06/09/19 04:46:31

Modified files:
        opac           : opac-account.pl opac-detail.pl 
                         opac-ISBDdetail.pl opac-main.pl 
                         opac-MARCdetail.pl opac-shelves.pl opac-user.pl 
                         search 

Log message:
        Toins, this is what you've been waiting for. the 'search' file has the
        new API defined (I hope clearly). Let me know if you have questions.
        
        This commit also includes some changes made to other OPAC scripts such
        as adding language changing capability to each script, etc.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-account.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.8.2.6.2.1&r2=1.8.2.6.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-detail.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.14.2.19.2.4&r2=1.14.2.19.2.5
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-ISBDdetail.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.5.2.10.2.1&r2=1.5.2.10.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-main.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.16.2.10.2.1&r2=1.16.2.10.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-MARCdetail.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.4.2.14.2.2&r2=1.4.2.14.2.3
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-shelves.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.3.2.8.2.2&r2=1.3.2.8.2.3
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-user.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.14.2.9.2.3&r2=1.14.2.9.2.4
http://cvs.savannah.gnu.org/viewcvs/koha/opac/search?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1&r2=1.1.2.2

Patches:
Index: opac-account.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-account.pl,v
retrieving revision 1.8.2.6.2.1
retrieving revision 1.8.2.6.2.2
diff -u -b -r1.8.2.6.2.1 -r1.8.2.6.2.2
--- opac-account.pl     18 Aug 2006 16:14:15 -0000      1.8.2.6.2.1
+++ opac-account.pl     19 Sep 2006 04:46:31 -0000      1.8.2.6.2.2
@@ -2,7 +2,6 @@
 
 # wrriten 15/10/2002 by address@hidden
 # script to display borrowers account details in the opac
-
 use strict;
 use C4::Output;
 use CGI;
@@ -12,7 +11,7 @@
 use C4::Interface::CGI::Output;
 use HTML::Template;
 use C4::Date;
-
+use C4::Koha;
 my $query = new CGI;
 my ($template, $borrowernumber, $cookie)
     = get_template_and_user({template_name => "opac-account.tmpl",

Index: opac-detail.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-detail.pl,v
retrieving revision 1.14.2.19.2.4
retrieving revision 1.14.2.19.2.5
diff -u -b -r1.14.2.19.2.4 -r1.14.2.19.2.5
--- opac-detail.pl      29 Aug 2006 15:11:45 -0000      1.14.2.19.2.4
+++ opac-detail.pl      19 Sep 2006 04:46:31 -0000      1.14.2.19.2.5
@@ -3,6 +3,7 @@
 require Exporter;
 use CGI;
 use C4::Search;
+use C4::Koha;
 use C4::Auth;
 use C4::Bull; #uses getsubscriptionfrom biblionumber
 use C4::Interface::CGI::Output;

Index: opac-ISBDdetail.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-ISBDdetail.pl,v
retrieving revision 1.5.2.10.2.1
retrieving revision 1.5.2.10.2.2
diff -u -b -r1.5.2.10.2.1 -r1.5.2.10.2.2
--- opac-ISBDdetail.pl  18 Aug 2006 16:14:15 -0000      1.5.2.10.2.1
+++ opac-ISBDdetail.pl  19 Sep 2006 04:46:31 -0000      1.5.2.10.2.2
@@ -53,6 +53,7 @@
 use C4::Interface::CGI::Output;
 use CGI;
 use C4::Search;
+use C4::Koha;
 use MARC::Record;
 use C4::Biblio;
 use C4::Acquisition;

Index: opac-main.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-main.pl,v
retrieving revision 1.16.2.10.2.1
retrieving revision 1.16.2.10.2.2
diff -u -b -r1.16.2.10.2.1 -r1.16.2.10.2.2
--- opac-main.pl        18 Aug 2006 16:14:15 -0000      1.16.2.10.2.1
+++ opac-main.pl        19 Sep 2006 04:46:31 -0000      1.16.2.10.2.2
@@ -2,8 +2,7 @@
 use strict;
 require Exporter;
 use CGI;
-use HTML::Template;
-
+#use HTML::Template;
 use C4::Auth;       # get_template_and_user
 use C4::Interface::CGI::Output;
 use C4::BookShelves;

Index: opac-MARCdetail.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-MARCdetail.pl,v
retrieving revision 1.4.2.14.2.2
retrieving revision 1.4.2.14.2.3
diff -u -b -r1.4.2.14.2.2 -r1.4.2.14.2.3
--- opac-MARCdetail.pl  18 Aug 2006 16:14:15 -0000      1.4.2.14.2.2
+++ opac-MARCdetail.pl  19 Sep 2006 04:46:31 -0000      1.4.2.14.2.3
@@ -53,6 +53,7 @@
 use C4::Interface::CGI::Output;
 use CGI;
 use C4::Search;
+use C4::Koha;
 use MARC::Record;
 use C4::Biblio;
 use C4::Acquisition;

Index: opac-shelves.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-shelves.pl,v
retrieving revision 1.3.2.8.2.2
retrieving revision 1.3.2.8.2.3
diff -u -b -r1.3.2.8.2.2 -r1.3.2.8.2.3
--- opac-shelves.pl     29 Aug 2006 14:04:58 -0000      1.3.2.8.2.2
+++ opac-shelves.pl     19 Sep 2006 04:46:31 -0000      1.3.2.8.2.3
@@ -2,7 +2,7 @@
 #script to provide bookshelf management
 # WARNING: This file uses 4-character tabs!
 #
-# $Header: /sources/koha/koha/opac/opac-shelves.pl,v 1.3.2.8.2.2 2006/08/29 
14:04:58 kados Exp $
+# $Header: /sources/koha/koha/opac/opac-shelves.pl,v 1.3.2.8.2.3 2006/09/19 
04:46:31 kados Exp $
 #
 # Copyright 2000-2002 Katipo Communications
 #
@@ -23,6 +23,7 @@
 
 use strict;
 use C4::Search;
+use C4::Koha;
 use CGI;
 use C4::Output;
 use C4::BookShelves;
@@ -176,9 +177,12 @@
                $line{'itemnumber'}=$item->{'itemnumber'};
                $line{'barcode'}=$item->{'barcode'};
                $line{'title'}=$item->{'title'};
+               $line{'isbn'}=$item->{'isbn'};
+               $line{'subtitle'}=$item->{'subtitle'};
                $line{'author'}=$item->{'author'};
                $line{'classification'}=$item->{'classification'};              
                $line{'itemtype'}=$item->{'itemtype'};          
+               $line{'ccode'}=$item->{'ccode'};
                $line{biblionumber} = $item->{biblionumber};
                push(@itemsloop, \%line);
                }
@@ -193,6 +197,13 @@
 
 #
 # $Log: opac-shelves.pl,v $
+# Revision 1.3.2.8.2.3  2006/09/19 04:46:31  kados
+# Toins, this is what you've been waiting for. the 'search' file has the
+# new API defined (I hope clearly). Let me know if you have questions.
+#
+# This commit also includes some changes made to other OPAC scripts such
+# as adding language changing capability to each script, etc.
+#
 # Revision 1.3.2.8.2.2  2006/08/29 14:04:58  kados
 # some bugfixes to shelves:
 #

Index: opac-user.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-user.pl,v
retrieving revision 1.14.2.9.2.3
retrieving revision 1.14.2.9.2.4
diff -u -b -r1.14.2.9.2.3 -r1.14.2.9.2.4
--- opac-user.pl        18 Aug 2006 16:14:15 -0000      1.14.2.9.2.3
+++ opac-user.pl        19 Sep 2006 04:46:31 -0000      1.14.2.9.2.4
@@ -147,12 +147,10 @@
 $template->param(WAITING => address@hidden);
 $template->param(waiting_count => $wcount,
                                textmessaging => $borr->{textmessaging},
-                               OpacPasswordChange => 
C4::Context->preference("OpacPasswordChange"),
                                opaclargeimage => 
C4::Context->preference("opaclargeimage"),
                 LibraryName => C4::Context->preference("LibraryName"),
                 OpacNav => C4::Context->preference("OpacNav"),
                 opaccredits => C4::Context->preference("opaccredits"),
-                opacreadinghistory => 
C4::Context->preference("opacreadinghistory"),
                 opacsmallimage => C4::Context->preference("opacsmallimage"),
                 opaclayoutstylesheet => 
C4::Context->preference("opaclayoutstylesheet"),
                 opaccolorstylesheet => 
C4::Context->preference("opaccolorstylesheet"),

Index: search
===================================================================
RCS file: /sources/koha/koha/opac/Attic/search,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- search      18 Aug 2006 16:14:15 -0000      1.1.2.1
+++ search      19 Sep 2006 04:46:31 -0000      1.1.2.2
@@ -1,8 +1,151 @@
 #!/usr/bin/perl
+# Script to perform searching
+# For documentation try 'perldoc /path/to/search'
+#
+# $Header: /sources/koha/koha/opac/Attic/search,v 1.1.2.2 2006/09/19 04:46:31 
kados Exp $
+#
+# Copyright 2006 LibLime
+#
+# 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
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+=head1 NAME
+
+search - a search script for finding records in a Koha system (Version 2.4)
+
+=head1 OVERVIEW
+
+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.
+
+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 :-)
+
+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
+
+There are several additional secondary functions performed that I will
+not cover in detail.
+
+=head3 1. Building Query Strings
+       
+There are several types of queries needed in the process of search and 
retrieve:
+
+=over
+
+=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
 
-## load our Koha modules
+## 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;
@@ -12,20 +155,20 @@
 use POSIX qw(ceil floor);
 
 # create a new CGI object
-use CGI;
+# 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 $do = $cgi->param("do");
 my $template_name;
-if ((lc($do) =~/search/)|| $cgi->param("q")) {
-       warn "loading results";
+if (($cgi->param("limit")) || ($cgi->param("q")) ) {
+       #warn "loading results";
        $template_name = 'opac-results.tmpl';
 }
 else {
-       warn "loading adv search page";
+       #warn "loading adv search page";
        $template_name = 'opac-advsearch.tmpl';
 }
 
@@ -37,6 +180,38 @@
     authnotrequired => 1,}
 );
 
+=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 = getallbranches();
 my @branch_loop;
@@ -44,136 +219,47 @@
 for my $branch_hash (keys %$branches) {
        push @branch_loop, {value => "branch: $branch_hash", branchname => 
$branches->{$branch_hash}->{'branchname'}, };        
 }
+$template->param(branchloop => address@hidden,);
 
-# load the itemtypes
+# load the itemtypes (Called Collection Codes in the template -- used for circ 
rules )
 my ($itemtypecount,@item_type_loop) = getitemtypes();
 $template->param(itemtypeloop=>address@hidden,);
 
-# load the languages
+# load the itypes (Called item types in the template -- just authorized values 
for searching)
+my ($itypecount,@itype_loop) = get_itypes();
+$template->param(itypeloop=>address@hidden,);
+
+# 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 => address@hidden);
 }
-# load the servers
-my $outer_servers_loop = [
-       { inner_servers_loop => [
-               {label => C4::Context->preference('LibraryName')." Catalog", 
id=>"NPL", name=>"server", 
value=>"localhost:9900/biblios",checked=>"checked",icon => "npl.png",zed => 
"1"},
-               {label => "OPLIN Databases", id=>"OPLIN", name=>"server", 
value=>"",checked=>"",icon => "oplin.ico",zed => "1"},
-       ],
-       },
-];
-$template->param(outer_servers_loop =>  $outer_servers_loop,);
-
-my $outer_sup_servers_loop = [
-       { inner_sup_servers_loop => [
-               {label => "Google", id=>"GOOG", value=>"google",icon => 
"google.ico",opensearch => "1"},
-               {label => "Yahoo", id=>"YAH", value=>"yahoo", icon 
=>"yahoo.ico", zed => "1"},
-               {label => "Worldcat", id=>"WCT", value=>"worldcat", icon => 
"worldcat.gif", zed => "1"},
-               {label => "Library of Congress", id=>"LOC", name=> "server", 
value=>"z3950.loc.gov:7090/Voyager", icon =>"loc.ico", zed => "1"},
-       ],
-       },
-];
-$template->param(outer_sup_servers_loop => $outer_sup_servers_loop,);
-
-# Here's a loop that can eventually be stored in the database
-# to store limit types and how to display them
-my $outer_limit_types_loop = [
-
-{ inner_limit_types_loop => [
-       {label => "Books",
-       id => "mc-bks",
-       name => "limit",
-       value => "mc:t",
-       icon => "AF.gif",
-       title => "Books, Pamphlets, Technical reports, Manuscripts, Legal 
papers, Theses and dissertations",},
-
-       {label => "Visual Materials",
-    id => "mc-vis",
-    name => "limit",
-       value => "mc:v",
-       icon => "AV Aids.gif",
-    title => "Motion pictures, Videorecordings, Filmstrips, Slides, 
Transparencies, Photos, Cards, Charts, Drawings",},
-
-       {label => "Sound Recordings",
-    id => "mc-sr",
-    name => "limit",
-       value => "mc:s",
-       icon => "AF.gif",
-    title => "Musical, Spoken, Books on Tape, etc. on DVD, CD, Cassette, and 
LP recordings",},
-
-       ],
-},
-{ inner_limit_types_loop => [
-    {label => "Computer Files",
-    id => "mc-cf",
-    name => "limit",
-    value => "mc:c",
-       icon => "CD-ROM software.gif",
-    title => "Computer files, Data, Software",},
-
-    {label => "Local History Materials",
-    id => "mc-lh",
-    name => "limit",
-    value => "mt-collection:LH",
-       icon => "Local history.gif",
-    title => "Local History Materials",},
-
-    {label => "Maps",
-    id => "mc-map",
-    name => "limit",
-    value => "mc:a",
-       icon => "PF.gif ",
-    title => "Maps, Globes",},
-    ],
-},
-
-];
-
-$template->param(outer_limit_types_loop =>  $outer_limit_types_loop,);
-
-# Here's a loop that can eventually be stored in the database used to 
-# display the advanced search input boxes, indexes, boolean, etc.
-my $indexes = [
-    { value => 'kw', label => 'Keyword' },
-    { value => 'au', label => 'Author' },
-    { value => 'au,phr', label => '&nbsp;&nbsp;&nbsp;&nbsp; Author Phrase' },
-#    { value => 'cpn', label => '&nbsp;&nbsp;&nbsp;&nbsp; Corporate Name' },
-#      { value => 'cfn', label => '&nbsp;&nbsp;&nbsp;&nbsp; Conference Name' },
-#   { value => 'cpn,phr', label => '&nbsp;&nbsp;&nbsp;&nbsp; Corporate Name 
Phrase' },
-#      { value => 'cfn,phr', label => '&nbsp;&nbsp;&nbsp;&nbsp; Conference 
Name Phrase' },
-#    { value => 'pn', label => '&nbsp;&nbsp;&nbsp;&nbsp; Personal Name' },
-#    { value => 'pn,phr', label => '&nbsp;&nbsp;&nbsp;&nbsp; Personal Name 
Phrase' },
-#    { value => 'ln', label => 'Language' },
-#    { value => 'mt', label => 'Material Type' },
-#    { value => 'mt,phr', label => 'Material Type Phrase' },
-#    { value => 'mc', label => 'Musical Composition' },
-#    { value => 'mc,phr', label => 'Musical Composition Phrase' },
-
-    { value => 'nt', label => 'Notes/Comments' },
-    { value => 'pb', label => 'Publisher' },
-    { value => 'pl', label => 'Publisher Location' },
-    { value => 'sn', label => 'Standard Number' },
-    { value => 'nb', label => '&nbsp;&nbsp;&nbsp;&nbsp; ISBN' },
-    { value => 'ns', label => '&nbsp;&nbsp;&nbsp;&nbsp; ISSN' },
-       { value => 'lcn', label => '&nbsp;&nbsp;&nbsp;&nbsp; Call Number' },
-    { value => 'su', label => 'Subject' },
-    { value => 'su,phr', label => '&nbsp;&nbsp;&nbsp;&nbsp; Subject Phrase' },
-#    { value => 'de', label => '&nbsp;&nbsp;&nbsp;&nbsp; Descriptor' },
-#    { value => 'ge', label => '&nbsp;&nbsp;&nbsp;&nbsp; Genre/Form' },
-#    { value => 'gc', label => '&nbsp;&nbsp;&nbsp;&nbsp; Geographic Coverage' 
},
-
-#    { value => 'nc', label => '&nbsp;&nbsp;&nbsp;&nbsp; Named Corporation and 
Conference' },
-#    { value => 'na', label => '&nbsp;&nbsp;&nbsp;&nbsp; Named Person' },
-
-    { value => 'ti', label => 'Title' },
-    { value => 'ti,phr', label => '&nbsp;&nbsp;&nbsp;&nbsp; Title Phrase' },
-    { value => 'se', label => '&nbsp;&nbsp;&nbsp;&nbsp; Series Title' },
-                       
-];
-my @search_boxes_array;
-my $search_boxes_count = 3;
-for (my $i=0;$i<=$search_boxes_count;$i++) {
+# The following should only be loaded if we're bringing up the advanced search 
template
+if ( $template_name eq "opac-advsearch.tmpl" ) {
+
+       # 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 address@hidden; # clone the data, not just the reference
        address@hidden>{selected} = "selected";
        if ($i==0) {
@@ -195,122 +281,25 @@
                        {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 => address@hidden,);
+       }
+       $template->param(search_boxes_loop => address@hidden,);
 
-# Here's another loop that will eventually be stored in the database
-# It controls the languages that show up in the language limit section of the
-# advanced search page
-my $languages_loop = [
-       {value => "", language_label => "No Limit", locale_label => "",selected 
=> "selected",},
-       {value => "ln:ara", language_label => 
"&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;", locale_label => 
"Arabic",,},
-       {value => "ln:bul", language_label => 
"&#1041;&#1098;&#1083;&#1075;&#1072;&#1088;&#1089;&#1082;&#1080;", locale_label 
=> "Bulgarian",,},
-       {value => "ln:chi", language_label => "&#20013;&#25991;", locale_label 
=> "Chinese",,},
-       {value => "ln:scr", language_label => "Hrvatski", locale_label => 
"Croatian",,},
-    {value => "ln:cze", language_label => "&#x010D;e&#353;tina", locale_label 
=> "Czech",,},
-    {value => "ln:dan", language_label => "D&aelig;nsk", locale_label => 
"Danish",,},
-    {value => "ln:dut", language_label => "ned&#601;rl&#593;ns", locale_label 
=> "Dutch",,},
-    {value => "ln:eng", language_label => "English", locale_label => "",,},
-    {value => "ln:fre", language_label => "Fran&ccedil;ais", locale_label => 
"French",,},
-    {value => "ln:ger", language_label => "Deutsch", locale_label => 
"German",,},
-    {value => "ln:gre", language_label => 
"&#949;&#955;&#955;&#951;&#957;&#953;&#954;&#940;", locale_label => "Greek, 
Modern [1453- ]",,},
-    {value => "ln:heb", language_label => 
"&#1506;&#1489;&#1512;&#1497;&#1514;", locale_label => "Hebrew",,},
-    {value => "ln:hin", language_label => 
"&#2361;&#2367;&#2344;&#2381;&#2342;&#2368;", locale_label => "Hindi",,},
-    {value => "ln:hun", language_label => "Magyar", locale_label => 
"Hungarian",,},
-    {value => "ln:ind", language_label => "", locale_label => "Indonesian",,},
-    {value => "ln:ita", language_label => "Italiano", locale_label => 
"Italian",,},
-    {value => "ln:jpn", language_label => "&#26085;&#26412;&#35486;", 
locale_label => "Japanese",,},
-    {value => "ln:kor", language_label => "&#54620;&#44397;&#50612;", 
locale_label => "Korean",,},
-    {value => "ln:lat", language_label => "Latina", locale_label => "Latin",,},
-    {value => "ln:nor", language_label => "Norsk", locale_label => 
"Norwegian",,},
-    {value => "ln:per", language_label => 
"&#1601;&#1575;&#1585;&#1587;&#1609;", locale_label => "Persian",,},
-    {value => "ln:pol", language_label => "Polski", locale_label => 
"Polish",,},
-    {value => "ln:por", language_label => "Portugu&ecirc;s", locale_label => 
"Portuguese",,},
-    {value => "ln:rum", language_label => "Rom&acirc;n&#259;", locale_label => 
"Romanian",,},
-    {value => "ln:rus", language_label => 
"&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;", locale_label => 
"Russian",,},
-    {value => "ln:spa", language_label => "Espa&ntilde;ol", locale_label => 
"Spanish",,},
-    {value => "ln:swe", language_label => "Svenska", locale_label => 
"Swedish",,},
-    {value => "ln:tha", language_label => 
"&#3616;&#3634;&#3625;&#3634;&#3652;&#3607;&#3618;", locale_label => "Thai",,},
-    {value => "ln:tur", language_label => "T&uuml;rk&ccedil;e", locale_label 
=> "Turkish",,},
-    {value => "ln:ukr", language_label => 
"&#1059;&#1082;&#1088;&#1072;&#1111;&#1085;&#1089;&#1100;&#1082;&#1072;", 
locale_label => "Ukrainian",,},
-
-];
-$template->param(search_languages_loop => $languages_loop,);
-
-# Yet another loop we can move to the DB when the scheme matures:
-my $outer_subtype_limits_loop = [
-
-            { # in MARC21, aud codes are stored in 008/22 (Target audience)
-                       name => "limit",
-                       inner_subtype_limits_loop => [
-                                       { value => '', label => 'Any Audience', 
selected => "selected" },
-                                       { value => 'aud:a', label => 'Easy',  },
-                    { value => 'aud:c', label => 'Juvenile',  },
-                    { value => 'aud:d', label => 'Young Adult',  },
-                    { value => 'aud:e', label => 'Adult',  },
-
-                               ],
-                       },
-                       { # in MARC21, fic is in 008/33, bio in 008/34, mus in 
LDR/06
-            name => "limit",
-            inner_subtype_limits_loop => [
-                    { value => '', label => 'Any Content', selected => 
"selected" },
-                    { value => 'fic:1', label => 'Fiction',  },
-                    { value => 'fic:0', label => 'Non Fiction',  },
-                    { value => 'bio:b', label => 'Biography',  },
-                    { value => 'mus:', label => 'Not working - Musical 
recording',  },
-                                       { value => 'mus:', label => 'Not 
working - Non-musical recording',  },
-
-                ],
-            },
-                       { # MARC21, these are codes stored in 007/00-01
-            name => "limit",
-            inner_subtype_limits_loop => [
-                    { value => '', label => 'Any Format', selected => 
"selected" },
-                                       { value => 'l-format:ta', label => 
'Regular print',  },
-                    { value => 'l-format:td', label => 'Large print',  },
-                                       { value => 'l-format:fk', label => 
'Braille',  },
-                                       { value => '', label => '-----------',  
},
-                                       { value => 'l-format:sd', label => 'CD 
audio',  },
-                    { value => 'l-format:ss', label => 'Cassette recording',  
},
-                    { value => 'l-format:vf', label => 'VHS tape / 
Videocassette',  },
-                                       { value => 'l-format:vd', label => 'DVD 
video / Videodisc',  },
-                                       { value => 'l-format:co', label => 'CD 
Software',  },
-
-                ],
-            },
-                       { # in MARC21, these are codes in 008/24-28
-            name => "limit",
-            inner_subtype_limits_loop => [
-                { value => '', label => 'Additional Content Types',  },
-                { value => 'ctype:a', label => 'Abstracts/summaries',  },
-                { value => 'ctype:b', label => 'Bibliographies',  },
-                { value => 'ctype:c', label => 'Catalogs',  },
-                { value => 'ctype:d', label => 'Dictionaries',  },
-                { value => 'ctype:e', label => 'Encyclopedias ',},
-                { value => 'ctype:f', label => 'Handbooks',  },
-                { value => 'ctype:g', label => 'Legal articles',},
-                { value => 'ctype:i', label => 'Indexes',  },
-                { value => 'ctype:j', label => 'Patent document',  },
-                { value => 'ctype:k', label => 'Discographies',  },            
    
-                               { value => 'ctype:l', label => 'Legislation',  
},                
-                               { value => 'ctype:m', label => 'Theses',},
-                               { value => 'ctype:n', label => 'Surveys', },
-                               { value => 'ctype:o', label => 'Reviews',},
-                               { value => 'ctype:p', label => 'Programmed 
texts',  },                
-                               { value => 'ctype:q', label => 'Filmographies', 
 },                
-                               { value => 'ctype:r', label => 'Directories',  
},                
-                               { value => 'ctype:s', label => 'Statistics',  
},                
-                               { value => 'ctype:t', label => 'Technical 
reports',  },                
-                               { value => 'ctype:v', label => 'Legal cases and 
case notes',  },                
-                               { value => 'ctype:w', label => 'Law reports and 
digests',  },                
-                               { value => 'ctype:z', label => 'Treaties ',  }, 
               
-                               ],            
-                       },
-];
-$template->param(outer_subtype_limits_loop => $outer_subtype_limits_loop,);
+       # 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);
+    warn "loading the template";
+    output_html_with_http_headers $cgi, $cookie, $template->output;
+    exit;
+}
 
-$template->param(branchloop => address@hidden,);
+### 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
@@ -324,7 +313,7 @@
 my @servers;
 @servers = split("\0",$params->{'server'}) if $params->{'server'};
 unless (@servers) {
-       #FIXME: this should be handled in Context.pm
+       #FIXME: this should be handled using Context.pm
        @servers = ("localhost:9900/biblios");
 }
 
@@ -340,31 +329,27 @@
 
 # an operand can be a single term, a phrase, or a complete ccl query
 my @operands;
address@hidden = split("\0",$params->{'qf'}) if $params->{'qf'};
address@hidden = 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;
 @limits = split("\0",$params->{'limit'}) if $params->{'limit'};
 push @limits, map "yr:".$_, split("\0",$params->{'limit-yr'}) if 
$params->{'limit-yr'};
 
+# Params that can only have one value
 # sort by is used to sort the query
 my @sort_by;
 @sort_by = split("\0",$params->{'sort_by'}) if $params->{'sort_by'};
-
-# Params that can only have one value
+# 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);
 my $query = $params->{'q'};
 my $scan = $params->{'scan'};
-my $expanded_options = $params->{'expanded_options'};
-my $count = $params->{'count'} || 20;
+my $results_per_page = $params->{'count'} || 20;
 my $offset = $params->{'offset'} || 0;
 my $hits;
-my $expanded_facet = $params->{'expand_facet'};
-$template->param(expanded_options => $expanded_options);
-unless ( (lc($do) =~/search/ )||($cgi->param("q")) ) {
-       warn "nothing to do, exiting";
-    output_html_with_http_headers $cgi, $cookie, $template->output;
-       exit;
-}
+my $expanded_facet = $params->{'expand'};
 
 # Define some global variables
 my $error; # used for error handling
@@ -379,12 +364,12 @@
 
 ## II. DO THE SEARCH AND GET THE RESULTS
 my $total; # the total results for the whole set
-my $facets;
+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,address@hidden,address@hidden,$count,$offset,$expanded_facet,$branches,$query_type,$scan);
+       ($error, $results_hashref, $facets) = 
getRecords($koha_query,$federated_query,address@hidden,address@hidden,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
 
 };
 if ($@ || $error) {
@@ -393,100 +378,37 @@
        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;
 for (my $i=0;$i<address@hidden;$i++) {
        my $server = $servers[$i];
        if ($server =~/localhost/) { # this is the local server
-               my @newresults = searchResults( 
$search_desc,$results_hashref->{$server}->{"hits"},$count,@{$results_hashref->{$server}->{"RECORDS"}});
-
-               $total = $total + $results_hashref->{$server}->{"hits"};
                $hits = $results_hashref->{$server}->{"hits"};
+               my @newresults = searchResults( 
$search_desc,$hits,$results_per_page,$offset,@{$results_hashref->{$server}->{"RECORDS"}});
+               $total = $total + $results_hashref->{$server}->{"hits"};
                if ($hits) {
-               # sorting out which results to display.
-               # the result number to start to show
-               $template->param(starting => $offset+1);
-               $template->param(ending => $offset+$count);
-               # the result number to end to show
-               ($offset+$hits<=$count) ? ($template->param(endat => 
$offset+$hits)) : ($template->param(endat => $count));
-               # the total results found
                $template->param(total => $hits);
                $template->param(searchdesc => $search_desc );
-               $template->param(results_per_page =>  $count);
+               $template->param(results_per_page =>  $results_per_page);
                $template->param(SEARCH_RESULTS => address@hidden);
 
-                       #this is to show the page numbers to navigate among the 
results, whether it has to show the number highlighted or not
-                       my $numbers;
-                       @$numbers = ();
-                       my $pg = 1;
-                       if (defined($cgi->param('pg'))) {
-                               $pg = $cgi->param('pg');
-                       }
-                       my $start = 0;
-                       $start = ($pg - 1) * $hits;
-                       my $pages = ceil($count / $hits);
-                       my $total_pages = ceil($count / $hits);
-                       my $url;
-                       if ($pg > 1) {
-                       $url = $pg - 1;
-                       push @$numbers, {
-                number => "&lt;&lt;",
-                highlight => 0 ,
-                startfrom => 0,
-                pg => '1' };
-
-                       push @$numbers, {
-                number => "&lt;",
-                highlight => 0 ,
-                startfrom => ($url-1)*$hits,
-                pg => $url };
-                       }
-    
-                       my $current_ten = $pg / 10;
-
-                       if ($current_ten == 0) {
-                       $current_ten = 0.1;           # In case it's in ten = 0
-                       }
-               my $from = $current_ten * 10; # Calculate the initial page
-               my $end_ten = $from + 9;
-               my $to;
-               if ($pages > $end_ten) {
-                       $to = $end_ten;
-               } else {
-                       $to = $pages;
-               }
-               for (my $i =$from; $i <= $to ; $i++) {
-                       if ($i == $pg) {
-                       if ($count > $hits) {
-                               push @$numbers, {
-                        number => $i,
-                        highlight => 1 ,
-                        startfrom => ($i-1)*$hits ,
-                        pg => $i };
-                       }
-                       } else {
-                       push @$numbers, {
-                        number => $i,
-                        highlight => 0 ,
-                        startfrom => ($i-1)*$hits ,
-                        pg => $i };
-                       }
-               }
-               if ($pg < $pages) {
-                       $url = $pg + 1;
-                       push @$numbers, {
-                        number => "&gt;",
-                        highlight => 0 ,
-                        startfrom => ($url-1)*$hits,
-                        pg => $url };
-
-                       push @$numbers, {
-                        number => "&gt;&gt;",
-                        highlight => 0 ,
-                        startfrom => ($total_pages-1)*$hits,
-                        pg => $total_pages};
-                       }
+                       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 " ",@sort_by 
};
+                       }
+                       $template->param(PAGE_NUMBERS => address@hidden,
+                                                       previous_page_offset => 
$previous_page_offset,
+                                                       next_page_offset => 
$next_page_offset) unless $pages < 2;
                }
        } # end of the if local
        else {
@@ -501,8 +423,8 @@
                                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,
+                                       'title' => $title,
+                                       'link' => $link,
                                };
                        }
                        my $servername = $server;
@@ -515,7 +437,6 @@
 #$template->param(FEDERATED_RESULTS => address@hidden);
 
 
$template->param('Disable_Dictionary'=>C4::Context->preference("Disable_Dictionary"))
 if (C4::Context->preference("Disable_Dictionary"));
-#my $scan_use = $cgi->param('use1');
 
 $template->param(
             #classlist => $classlist,
@@ -532,7 +453,7 @@
             opacsmallimage => C4::Context->preference("opacsmallimage"),
             opaclayoutstylesheet => 
C4::Context->preference("opaclayoutstylesheet"),
             opaccolorstylesheet => 
C4::Context->preference("opaccolorstylesheet"),
-            #scan_use => $scan_use,
+            scan_use => $scan,
             search_error => $error,
 );
 ## Now let's find out if we have any supplemental data to show the user
@@ -545,6 +466,7 @@
 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");
             };
@@ -565,7 +487,7 @@
 
                 # Now save the current query
                 
$koha_spsuggest_sth=$koha_spsuggest_dbh->prepare($koha_spsuggest_insert);
-                #$koha_spsuggest_sth->execute($phrases,$count,$ipaddress);
+                
#$koha_spsuggest_sth->execute($phrases,$results_per_page,$ipaddress);
                 $koha_spsuggest_sth->finish;
 
                 $template->param( koha_spsuggest => $koha_spsuggest ) unless 
$hits;
@@ -578,14 +500,5 @@
        }
 }
 
-
-
-# IV. GET THE QUERY HISTORY
-#($error,@query_history) = getQueryHistory($session);
-
-# V. GET SUGGESTIONS
-#($error,@spsuggest) = getSpellingSuggestions($simple_term);
-#($error,@rsuggest) = getRelatedSuggestions($simple_term);
-
 # VI. BUILD THE TEMPLATE
 output_html_with_http_headers $cgi, $cookie, $template->output;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]