koha-cvs
[Top][All Lists]
Advanced

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

[Koha-cvs] CVS: koha/tmpl dosearch.pl,NONE,1.1.2.1 detail.pl,1.1.2.1,1.1


From: Finlay Thompson
Subject: [Koha-cvs] CVS: koha/tmpl dosearch.pl,NONE,1.1.2.1 detail.pl,1.1.2.1,1.1.2.2 search.pl,1.1.2.1,NONE
Date: Sun, 15 Sep 2002 22:42:25 -0700

Update of /cvsroot/koha/koha/tmpl
In directory usw-pr-cvs1:/tmp/cvs-serv10221

Modified Files:
      Tag: rel-1-2
        detail.pl 
Added Files:
      Tag: rel-1-2
        dosearch.pl 
Removed Files:
      Tag: rel-1-2
        search.pl 
Log Message:

dosearch.pl replaces search.pl for the new templated opac. I thought it should 
have another name because there are so many search.pl around! However 
dosearch.pl isnt actually that great a name :)

detail.pl now uses the new templating mechanism.


--- NEW FILE ---
#!/usr/bin/perl
use strict;
require Exporter;
use CGI;
use C4::Search;
use C4::Auth;
use C4::Output; # now contains picktemplate
  
my $query=new CGI;

my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 1);


my $template;
my $subject=$query->param('subject');
# if its a subject we need to use the subject.tmpl
if ($subject) {
    $template = gettemplate ("subject.tmpl", "opac");
} else {
    $template = gettemplate ("searchresults.tmpl", "opac");
}

# get all the search variables
# we assume that C4::Search will validate these values for us
my @fields = ('keyword', 'subject', 'author', 'illustrator', 'itemnumber', 
'isbn', 'date-before', 'date-after', 'class', 'dewey', 'branch', 'title', 
'abstract', 'publisher');



# collect all the fields ...
my %search;
my $forminputs;
my $searchdesc = '';
foreach my $field (@fields) {
    $search{$field} = $query->param($field);
    if ($search{$field}) {
        push @$forminputs, {field => $field, value => $search{$field}};
        $searchdesc .= "$field = $search{$field}, ";
    }
}
$search{'ttype'} = $query->param('ttype');
push @$forminputs, {field => 'ttype', value => $search{'ttype'}};

if (my $subjectitems=$query->param('subjectitems')){
    $search{'subject'} = $subjectitems;
    $searchdesc.="subject = $subjectitems, ";
}

@$forminputs=() unless $forminputs;
$template->param(FORMINPUTS => $forminputs);

# do the searchs ....
my $env;
$env->{itemcount}=1;
my $num=10;
my @results;
my $count;
my $startfrom = $query->param('startfrom');
my $subjectitems=$query->param('subjectitems');
if ($subjectitems) {
    my $blah;
    @results = subsearch(\$blah,$subjectitems, $num, $startfrom);
    $count = $#results+1;
} else {
    ($count, @results) = catalogsearch($env,'',\%search,$num,$startfrom);
}

my $startfrom=$query->param('startfrom');
($startfrom) || ($startfrom=0);

my address@hidden;
($resultsarray) || (@$resultsarray=());


# sorting out which results to display.
$template->param(startfrom => $startfrom+1);
($startfrom+$num<=$count) ? ($template->param(endat => $startfrom+$num)) : 
($template->param(endat => $count));
$template->param(numrecords => $count);
my $nextstartfrom=($startfrom+$num<$count) ? ($startfrom+$num) : (-1);
my $prevstartfrom=($startfrom-$num>=0) ? ($startfrom-$num) : (-1);
$template->param(nextstartfrom => $nextstartfrom);
my $displaynext=1;
my $displayprev=0;
($nextstartfrom==-1) ? ($displaynext=0) : ($displaynext=1);
($prevstartfrom==-1) ? ($displayprev=0) : ($displayprev=1);
$template->param(displaynext => $displaynext);
$template->param(displayprev => $displayprev);
$template->param(prevstartfrom => $prevstartfrom);

$template->param(searchdesc => $searchdesc);
$template->param(SEARCH_RESULTS => $resultsarray);
$template->param(loggedinuser => $loggedinuser);

my $numbers;
@$numbers = ();
if ($count>10) {
    for (my $i=1; $i<$count/10+1; $i++) {
        my $highlight=0;
        my $themelang = $template->param('themelang');
        ($startfrom==($i-1)*10) && ($highlight=1);
        push @$numbers, { number => $i, highlight => $highlight , startfrom => 
($i-1)*10 };
    }
}

$template->param(numbers => $numbers);


print $query->header(-cookie => $cookie), $template->output;


Index: detail.pl
===================================================================
RCS file: /cvsroot/koha/koha/tmpl/Attic/detail.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** detail.pl   11 Sep 2002 01:58:20 -0000      1.1.2.1
--- detail.pl   16 Sep 2002 05:42:23 -0000      1.1.2.2
***************
*** 1,33 ****
  #!/usr/bin/perl
- use HTML::Template;
  use strict;
  require Exporter;
- use C4::Database;
  use C4::Output;  # contains picktemplate
  use CGI;
  use C4::Search;
   
  my $query=new CGI;
  
  
! my $language='french';
! 
! 
! my %configfile;
! open (KC, "/etc/koha.conf");
! while (<KC>) {
!  chomp;
!  (next) if (/^\s*#/);
!  if (/(.*)\s*=\s*(.*)/) {
!    my $variable=$1;
!    my $value=$2;
!    # Clean up white space at beginning and end
!    $variable=~s/^\s*//g;
!    $variable=~s/\s*$//g;
!    $value=~s/^\s*//g;
!    $value=~s/\s*$//g;
!    $configfile{$variable}=$value;
!  }
! }
  
  my $biblionumber=$query->param('bib');
--- 1,15 ----
  #!/usr/bin/perl
  use strict;
  require Exporter;
  use C4::Output;  # contains picktemplate
  use CGI;
  use C4::Search;
+ use C4::Auth;
   
  my $query=new CGI;
  
+ my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 1);
  
! my $template = gettemplate ("detail.tmpl", "opac");
  
  my $biblionumber=$query->param('bib');
***************
*** 57,74 ****
  my address@hidden;
  
! my $includes=$configfile{'includes'};
! ($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
! my $templatebase="opac/detail.tmpl";
  my $startfrom=$query->param('startfrom');
  ($startfrom) || ($startfrom=0);
- my $theme=picktemplate($includes, $templatebase);
- 
- my $template = HTML::Template->new(filename => 
"$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => 
[$includes]);
  
  my $count=1;
  
  # now to get the items into a hash we can use and whack that thru
- 
- 
  $template->param(startfrom => $startfrom+1);
  $template->param(endat => $startfrom+20);
--- 39,49 ----
  my address@hidden;
  
! 
  my $startfrom=$query->param('startfrom');
  ($startfrom) || ($startfrom=0);
  
  my $count=1;
  
  # now to get the items into a hash we can use and whack that thru
  $template->param(startfrom => $startfrom+1);
  $template->param(endat => $startfrom+20);
***************
*** 78,88 ****
  $template->param(nextstartfrom => $nextstartfrom);
  $template->param(prevstartfrom => $prevstartfrom);
! # $template->param(template => $templatename);
! # $template->param(search => $search);
! $template->param(includesdir => $includes);
  $template->param(BIBLIO_RESULTS => $resultsarray);
  $template->param(ITEM_RESULTS => $itemsarray);
  $template->param(WEB_RESULTS => $webarray);
  $template->param(SITE_RESULTS => $sitearray);
  print "Content-Type: text/html\n\n", $template->output;
  
--- 53,62 ----
  $template->param(nextstartfrom => $nextstartfrom);
  $template->param(prevstartfrom => $prevstartfrom);
! 
  $template->param(BIBLIO_RESULTS => $resultsarray);
  $template->param(ITEM_RESULTS => $itemsarray);
  $template->param(WEB_RESULTS => $webarray);
  $template->param(SITE_RESULTS => $sitearray);
+ 
  print "Content-Type: text/html\n\n", $template->output;
  

--- search.pl DELETED ---




reply via email to

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