Kumara - predecessor to Koha
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
3.4 KiB

  1. #!/usr/bin/perl
  2. #script to provide intranet (librarian) advanced search facility
  3. #modified 9/11/1999 by chris@katipo.co.nz
  4. use strict;
  5. #use DBI;
  6. use C4::Search;
  7. use CGI;
  8. use C4::Output;
  9. my $input = new CGI;
  10. print $input->header;
  11. #print $input->dump;
  12. my $blah;
  13. my %search;
  14. #build hash of users input
  15. my $title=$input->param('title');
  16. $search{'title'}=$title;
  17. my $keyword=$input->param('keyword');
  18. $search{'keyword'}=$keyword;
  19. my $author=$input->param('author');
  20. $search{'author'}=$author;
  21. my $subject=$input->param('subject');
  22. $search{'subject'}=$subject;
  23. my $itemnumber=$input->param('item');
  24. $search{'item'}=$itemnumber;
  25. my $isbn=$input->param('isbn');
  26. $search{'isbn'}=$isbn;
  27. my $datebefore=$input->param('date-before');
  28. $search{'date-before'};
  29. my @results;
  30. my $offset=$input->param('offset');
  31. if ($offset eq ''){
  32. $offset=0;
  33. }
  34. my $num=$input->param('num');
  35. if ($num eq ''){
  36. $num=10;
  37. }
  38. print startpage();
  39. print startmenu();
  40. print mkheadr(1,'Catalogue Search Results');
  41. print center();
  42. my $count;
  43. my @results;
  44. if ($itemnumber ne '' || $isbn ne ''){
  45. ($count,@results)=&CatSearch(\$blah,'precise',\%search,$num,$offset);
  46. } else {
  47. if ($subject ne ''){
  48. ($count,@results)=&CatSearch(\$blah,'subject',\%search,$num,$offset);
  49. } else {
  50. if ($keyword ne ''){
  51. ($count,@results)=&KeywordSearch(\$blah,'intra',\%search,$num,$offset);
  52. } else {
  53. ($count,@results)=&CatSearch(\$blah,'loose',\%search,$num,$offset);
  54. }
  55. }
  56. }
  57. print "You searched on ";
  58. while ( my ($key, $value) = each %search) {
  59. if ($value ne ''){
  60. print bold("$key $value,");
  61. }
  62. }
  63. print " $count results found";
  64. my $offset2=$num+$offset;
  65. print "<br> Results $offset to $offset2 displayed";
  66. print mktablehdr;
  67. if ($subject ne ''){
  68. print mktablerow(1,'#cccc99','<b>SUBJECT</b>');
  69. } else {
  70. print mktablerow(2,'#cccc99','<b>TITLE</b>','<b>AUTHOR</b>');
  71. }
  72. my $count2=@results;
  73. my $i=0;
  74. my $colour=1;
  75. while ($i < $count2){
  76. my @stuff=split('\t',$results[$i]);
  77. my $title2=$stuff[1];
  78. $title2=~ s/ /%20/g;
  79. if ($subject eq ''){
  80. $stuff[1]=mklink("/cgi-bin/kumara/detail.pl?bib=$stuff[0]&title=$title2",$stuff[1]);
  81. my $word=$stuff[2];
  82. $word=~ s/ //g;
  83. $word=~ s/\,/\,%20/g;
  84. $word=~ s/\n//g;
  85. my $url="/cgi-bin/kumara/search.pl?author=$word&type=a";
  86. $stuff[2]=mklink($url,$stuff[2]);
  87. } else {
  88. my $word=$stuff[1];
  89. $word=~ s/ /%20/;
  90. $stuff[1]=mklink("/cgi-bin/kumara/subjectsearch.pl?subject=$word",$stuff[1]);
  91. }
  92. if ($colour == 1){
  93. print mktablerow(2,'#ffffcc',$stuff[1],$stuff[2]);
  94. $colour=0;
  95. } else{
  96. print mktablerow(2,'white',$stuff[1],$stuff[2]);
  97. $colour=1;
  98. }
  99. $i++;
  100. }
  101. $offset=$num+$offset;
  102. print mktablerow(2,'#cccc99',' &nbsp; ',' &nbsp; ');
  103. print mktableft();
  104. if ($offset < $count){
  105. my $search="num=$num&offset=$offset";
  106. if ($subject ne ''){
  107. $subject=~ s/ /%20/g;
  108. $search=$search."&subject=$subject";
  109. }
  110. if ($title ne ''){
  111. $title=~ s/ /%20/g;
  112. $search=$search."&title=$title";
  113. }
  114. if ($author ne ''){
  115. $author=~ s/ /%20/g;
  116. $search=$search."&author=$author";
  117. }
  118. if ($keyword ne ''){
  119. $keyword=~ s/ /%20/g;
  120. $search=$search."&keyword=$keyword";
  121. }
  122. my $stuff=mklink("/cgi-bin/kumara/search.pl?$search",'More');
  123. print $stuff;
  124. }
  125. print endcenter();
  126. print endmenu();
  127. print endpage();