--- search/Search.cgi 2002/06/13 17:01:56 1.1 +++ search/Search.cgi 2002/07/02 17:18:43 1.22 @@ -1,17 +1,21 @@ #!/usr/bin/perl -w #***************************************************************************** -# Copyright (C) 1993-2000, FS Consulting Inc. All rights reserved * -# * -# * -# This notice is intended as a precaution against inadvertent publication * -# and does not constitute an admission or acknowledgement that publication * -# has occurred or constitute a waiver of confidentiality. * -# * -# This software is the proprietary and confidential property * -# of FS Consulting, Inc. * +# Copyright (C) 1993-2000, FS Consulting Inc. All rights reserved * +# * +# * +# This notice is intended as a precaution against inadvertent publication * +# and does not constitute an admission or acknowledgement that publication * +# has occurred or constitute a waiver of confidentiality. * +# * +# This software is the proprietary and confidential property * +# of FS Consulting, Inc. * #***************************************************************************** +#print "Content-type: text/plain\n\n"; + +#use Data::Dumper; + #-------------------------------------------------------------------------- # # Author: Francois Schiettecatte (FS Consulting, Inc.) @@ -179,53 +183,8 @@ # -# List of default configuration settings -%main::DefaultSettings = ( - 'lowest-year', '1990', - 'max-score', '1000', - 'allow-summary-displays','no', - 'allow-similiar-search','no', - 'allow-regular-searches','no', - 'deliver-empty-results-from-regular-search','no', -# 'allow-relevance-feedback-searches','no', - 'mailer-application','/usr/lib/sendmail', - 'server-log','mps.log', - 'output-colums','yes', -# 'show-past-date-list','yes', - 'database-for-SearchFieldDescriptions','ps', -); - -# DbP: Define which fields you have in normal and advanced search -# first define all available fields and then how many fields of that -# are visible. -@main::NormalSearchFieldNames = ( - '700+', - '200+', - '610', - '210', - '10', - -); -$main::NormalSearchDropdowns = 3 ; - -@main::AdvancedSearchFieldNames = ( - '700+', - '200+', - '610', - '210', - '225', - '300+', - '330', - '464', - '675', - '686', - '990', - '991', - '10', - '001', -); -$main::AdvancedSearchDropdowns = 4 ; - +# read configuration fields +require "config.pm"; # List of required configuration settings @main::RequiredSettings = ( @@ -273,25 +232,6 @@ $main::QueryReportMimeType = "application/x-wais-report"; - -# Hash of icon/images names that we use -%main::ImageNames = ( - 'banner', 'banner.gif', - 'collapse', 'collapse.gif', - 'expand', 'expand.gif', - 'inactive-search', 'inactive-search.gif', - 'active-search', 'active-search.gif', - 'inactive-search-history', 'inactive-search-history.gif', - 'active-search-history', 'active-search-history.gif', - 'inactive-saved-searches', 'inactive-saved-searches.gif', - 'active-saved-searches', 'active-saved-searches.gif', - 'inactive-document-folders','inactive-document-folders.gif', - 'active-document-folders', 'active-document-folders.gif', - 'inactive-settings', 'inactive-settings.gif', - 'active-settings', 'active-settings.gif', -); - - # Array of mime type names, we use this to map # mime types to mime type names (which are more readable) %main::MimeTypeNames = ( @@ -436,7 +376,7 @@ if ( ! $ENV{'GATEWAY_INTERFACE'} ) { return; } - + # Bail if we have already sent the header if ( $main::HeaderSent ) { return; @@ -452,7 +392,8 @@ print("$JavaScript\n"); } print ''; - print("\n\n"); + print ''; + print("\n\n"); # Send the header snippet file @@ -461,8 +402,11 @@ # Send the banner print("\n"); - print("\n"); - print("
\"Return
\n"); +# print(" \"Return \n"); + + print("

Katalozi knjižnica Filozofskog fakulteta

\n"); + + print("\n"); # Set the flag saying that the header has been sent @@ -559,43 +503,23 @@ } } - if ( %MenuBar && defined($MenuBar{'GetSearch'}) ) { - print("\"Search\""); - } - else { - print(""); + my $DISABLED; - - } + $DISABLED = ( %MenuBar && defined($MenuBar{'GetSearch'}) ) ? "DISABLED" : ""; + print(""); if ( defined($main::RemoteUser) ) { - if ( %MenuBar && defined($MenuBar{'ListSearchHistory'}) ) { - print("\"Search"); - } - else { - print(""); - } + $DISABLED = ( %MenuBar && defined($MenuBar{'ListSearchHistory'}) ) ? "DISABLED" : ""; + print""; - if ( %MenuBar && defined($MenuBar{'ListSavedSearch'}) ) { - print("\"Saved"); - } - else { - print(""); - } + $DISABLED = ( %MenuBar && defined($MenuBar{'ListSavedSearch'}) ) ? "DISABLED" : ""; + print""; - if ( %MenuBar && defined($MenuBar{'ListFolder'}) ) { - print("\"Doument"); - } - else { - print(""); - } - - if ( %MenuBar && defined($MenuBar{'GetUserSettings'}) ) { - print("\"My"); - } - else { - print(""); - } + $DISABLED = ( %MenuBar && defined($MenuBar{'ListFolder'}) ) ? "DISABLED" : ""; + print""; + + $DISABLED = ( %MenuBar && defined($MenuBar{'GetUserSettings'}) ) ? "DISABLED" : ""; + print""; } @@ -1585,9 +1509,17 @@ # Initialize the search string $SearchString = ""; +sub nuke_accents { + my $tmp = $_[0]; + $tmp =~ tr/ÇüéâäůćçłëŐőîŹÄĆÉĹĺôöĽľŚśÖÜŤťŁčáíóúĄąŽžĘęźČşÁÂĚŞŻżĂăđĐĎËďŇÍÎěŢŮÓÔŃńňŠšŔÚŕŰýÝţ´­˝˛ˇ˘¸¨˙Řř/CueaauccleOoiZACELlooLlSsOUTtLcaiouAaZzEezCsAAESZzAadDDEdNIIeTUOoNnnSsRUrUyYt'-".'',"'Rr/; + # convert search string to lower case -> make search case insensitive + $tmp =~ tr/A-Z/a-z/; + return $tmp; +} + # Add the search terms - $SearchString .= defined($Content{'Any'}) ? ((($SearchString ne "") ? " AND " : "") . $Content{'Any'}) : ""; + $SearchString .= defined($Content{'Any'}) ? ((($SearchString ne "") ? " AND " : "") . nuke_accents($Content{'Any'}) ) : ""; # Add the generic field names @@ -1595,20 +1527,22 @@ my ($FieldName) = "FieldName" . $Value; my ($FieldContent) = "FieldContent" . $Value; + + if ( defined($Content{$FieldName}) && defined($Content{$FieldContent}) ) { - if ( defined($Content{$FieldName}) ) { - $SearchString .= defined($Content{$FieldContent}) ? - (($SearchString ne "") ? " AND " : "") . "$Content{$FieldName}=(" . $Content{$FieldContent} . ")" : ""; + if ($Content{$FieldName} eq "ISBN") { + # fix stupid problem with dashes in data + $Content{$FieldContent} .= "*"; + } + + $SearchString .= ($SearchString ne "") ? " AND " : ""; + $SearchString .= "$Content{$FieldName}=(" . nuke_accents($Content{$FieldContent}) . ")"; } } - # nuke accented chars - $SearchString =~ tr/ÇüéâäůćçłëŐőîŹÄĆÉĹĺôöĽľŚśÖÜŤťŁčáíóúĄąŽžĘęźČşÁÂĚŞŻżĂăđĐĎËďŇÍÎěŢŮÓÔŃńňŠšŔÚŕŰýÝţ´­˝˛ˇ˘¸¨˙Řř/CueaauccleOoiZACELlooLlSsOUTtLcaiouAaZzEezCsAAESZzAadDDEdNIIeTUOoNnnSsRUrUyYt'-".'',"'Rr/; - # Add the internal search terms - # Add the date restriction on the load time if ( defined($Content{'LastRunTime'}) && ($Content{'LastRunTime'} > 0) ) { $SearchString .= (($SearchString ne "") ? " AND " : "") . "time_t>=$Content{'LastRunTime'}"; @@ -2028,10 +1962,12 @@ # Print the title if ( $HTML ) { printf("%s%s:\n", - defined($Title) ? $Title : "Document", (scalar(@Documents) > 1) ? "s" : ""); +# defined($Title) ? $Title : "Document", (scalar(@Documents) > 1) ? "s" : ""); + $Title); } else { - printf("%s%s:\n", defined($Title) ? $Title : "Document", (scalar(@Documents) > 1) ? "s" : ""); +# printf("%s%s:\n", defined($Title) ? $Title : "Document", (scalar(@Documents) > 1) ? "s" : ""); + print $Title; } @@ -2052,6 +1988,8 @@ $Headline =~ s/ //gs; $Headline =~ s/<.*?>//gs; $Headline =~ s/\s+/ /gs; + # decode some basic html from headline + $Headline =~ s/<(\/?[bi])>/<$1>/g; # Create a generic link for this document $Value = ""; @@ -2082,7 +2020,8 @@ # Put up the headline and the score, this one links to the document if ( $HTML ) { - print("$SelectorText $Headline ( $main::DatabaseDescriptions{$Value{'Database'}} )
\n"); +# print("$SelectorText $Headline ( $main::DatabaseDescriptions{$Value{'Database'}} )
\n"); + print("$SelectorText $Headline
\n"); # if ( defined($URL) && ($URL ne "") ) { # $Value = (length($URL) > $main::DefaultMaxVisibleUrlLength) ? substr($URL, 0, $main::DefaultMaxVisibleUrlLength) . "..." : $URL; @@ -2146,18 +2085,15 @@ my (@Words, $Word, @OffsetPairs, $OffsetPair, %Offsets, $Offset, $Start, $End, $OldStart, $OldEnd, $CurrentSummaryLength); my ($DatabaseSummaryFilterKey, $DatabaseSummaryFilterFunction); my ($Value, %Value, @Values, $ValueEntry); - - + + # Check input parameters if ( !defined($SearchResults) || !%Content ) { return (0); } - - # Split the search results text into a search results list @SearchResults = split(/\n/, $SearchResults); - # First we count up the number of results and scoop up @@ -2265,7 +2201,7 @@ print("\n"); # Print the selector - print("\n", + printf("\n", ($ResultCount > 0) ? $ResultCount : "no"); print("
Odabranima se smatraju svi rezultati ukoliko niste učinili nikakav dodatan odabir. \n"); + print("
Odabrani su svi rezultati ukoliko niste učinili nikakav dodatan odabir. \n"); if ( $ResultCount > 0 ) { @@ -2280,7 +2216,7 @@ if ( $main::ConfigurationData{'allow-relevance-feedback-searches'} eq "yes" ) { print("
Pronađeno: %s rezultata (Maksimalni broj podešen na: $Content{'Max'} )
Pronađeno: %s rezultata (Maksimalni broj podešen na: $Content{'Max'} )
\n"); @@ -2467,7 +2403,7 @@ } - +### FIX:: ADD SORT HERE if ( $ResultCount > 0 ) { # Loop over each entry in the hits list @@ -2724,12 +2660,16 @@ # Put up the headline and the score, this one links to the document if ( $HTML ) { print("\n"); - print(" $SelectorText $Score $Headline ( $main::DatabaseDescriptions{$Database} )
"); - } - else { - printf("%3d $Headline ($main::DatabaseDescriptions{$Database})\n", $Score); + #print(" $SelectorText $Score $Headline ( $main::DatabaseDescriptions{$Database} )
"); + # decode some basic html from headline + $Headline =~ s/<(\/?[bi])>/<$1>/g; + + print(" $SelectorText $Headline
 "); + } else { + printf("%3d $Headline \n", $Score); } +if (0) { ## don't display description # Put up the summary if ( defined($SummaryText) && ($SummaryText ne "") ) { @@ -2746,6 +2686,7 @@ if ( ! defined($Remainder) ) { if ( $HTML ) { print("Formatttt: $MimeTypeName, "); + } else { print(" Format: $MimeTypeName, "); @@ -2754,11 +2695,11 @@ # Put up the date if we got it - if ( defined($Date) && ($Date ne "") ) { + if ( defined($Date) && ($Date ne "") ) { print("Date: $Date"); # Put up the time if we got it - if ( defined($Time) && ($Time ne "") ) { + if ( defined($Time) && ($Time ne "") ) { print(" $Time"); } @@ -2889,6 +2830,7 @@ } print("\n"); +} #if # Finish off the entry if ( $HTML ) { print("\n"); @@ -3003,8 +2945,9 @@ # Make sure that we send the header - $Value = ($ENV{'PATH_INFO'} eq "/GetExpandedSearch") ? "Pretraživanje s više kriterija" : "Jednostavno pretraživanje"; - &vSendHTMLHeader($Value, undef); + $Value = ($ENV{'PATH_INFO'} eq "/GetExpandedSearch") ? "Složeno pretraživanje" : "Jednostavno pretraživanje"; + + &vSendHTMLHeader($Value, $main::JavaScript_SetChecked); undef(%Value); $Value{'GetSearch'} = "GetSearch"; @@ -3043,11 +2986,11 @@ if ( $ENV{'PATH_INFO'} eq "/GetExpandedSearch" ) { print("\n"); - print(" Kliknite na trokutić da biste suzili formu.\n"); + print(" Jednostavno pretraživanje (kliknite na trokutić)\n"); } else { print("\n"); - print(" Kliknite na trokutić da biste proširili formu.\n"); + print(" Složeno pretraživanje (kliknite na trokutić)\n"); } print("\n"); @@ -3055,7 +2998,7 @@ # Send the start of the form and the buttons print("\n"); - print("
\n"); + print(" \n"); print("\n"); print("
\n"); @@ -3075,20 +3018,31 @@ for (my $field=1; $field<= $nr_fields; $field++) { - print(""); + print ""; if ($field == 1 ) { - print ("Pretraži u određenom polju:"); + print ""; + print "Pretraži u odabranom polju:"; + print ""; } - print (""); + print (""); print (" \n"); + my $Value = ""; + if (defined($main::FormData{"FieldContent${field}"})) { + $Value = "VALUE='".$main::FormData{"FieldContent${field}"}."'"; + } + print(" \n"); } @@ -3110,7 +3064,9 @@ # Database selection if ( %main::DatabaseDescriptions ) { - print(" Odaberite bazu koju želite pretraživati: \n"); + print(" Odaberite knjižnicu čiji fond želite pretraživati: + + "); # Parse out the database names and put them into a # hash table, they should be separated with a '\0' @@ -3124,47 +3080,8 @@ @ItemList = split(",", $SelectedDatabases); } } - foreach $ItemEntry ( @ItemList ) { - $Value{$ItemEntry} = $ItemEntry; - } - - - - $Flag = 0; - print("\n"); - - my @html_database; - - foreach my $key ( sort keys %main::DatabaseSort ) { - $DatabaseName = $main::DatabaseSort{$key}; - $Value = ((defined($Value{$DatabaseName})) || (scalar(keys(%main::DatabaseDescriptions)) == 1) || !defined($main::RemoteUser) ) ? "CHECKED" : ""; - $ItemEntry = &lEncodeURLData($DatabaseName); - if ($main::DatabaseDescriptions{$DatabaseName}) { - push @html_database,"\n"; - } else { - push @html_database,"\n"; - } - } - - - if ($main::ConfigurationData{'output-colums'}) { - # create database names in columns - my $max = $#html_database+1 ; - - my $j=0; - for(my $i=0; $i < $max ; $i=$i+2) { - print("",$html_database[$j],$html_database[$j+int($max/2)],""); - $j++; - } - - } else { - for(my $i=0; $i <= $#html_database ; $i=$i+1) { - print("",$html_database[$i],""); - } - } - - print("
$main::DatabaseDescriptions{$DatabaseName} $main::DatabaseDescriptions{$DatabaseName}
\n"); + &ShowDatabaseCheckBoxes(@ItemList); print("\n"); @@ -3214,7 +3131,7 @@ # Send the end date - print(" Ograniči na knjige izdane prije godine:: \n"); $Value = (!defined($main::FormData{'Before'})) ? "SELECTED" : ""; print("