--- search/Search.cgi 2002/06/13 17:01:56 1.1.1.1 +++ search/Search.cgi 2002/06/25 19:31:07 1.20 @@ -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,6 +392,7 @@ print("$JavaScript\n"); } print ''; + print ''; print("\n\n"); @@ -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""; } @@ -1595,20 +1519,26 @@ my ($FieldName) = "FieldName" . $Value; my ($FieldContent) = "FieldContent" . $Value; + - - if ( defined($Content{$FieldName}) ) { - $SearchString .= defined($Content{$FieldContent}) ? - (($SearchString ne "") ? " AND " : "") . "$Content{$FieldName}=(" . $Content{$FieldContent} . ")" : ""; + if ( defined($Content{$FieldName}) && defined($Content{$FieldContent}) ) { + # nuke accented chars + $Content{$FieldContent} =~ tr/ÇüéâäůćçłëŐőîŹÄĆÉĹĺôöĽľŚśÖÜŤťŁčáíóúĄąŽžĘęźČşÁÂĚŞŻżĂăđĐĎËďŇÍÎěŢŮÓÔŃńňŠšŔÚŕŰýÝţ´­˝˛ˇ˘¸¨˙Řř/CueaauccleOoiZACELlooLlSsOUTtLcaiouAaZzEezCsAAESZzAadDDEdNIIeTUOoNnnSsRUrUyYt'-".'',"'Rr/; + # convert search string to lower case -> make search case insensitive + $Content{$FieldContent} =~ tr/A-Z/a-z/; + + if ($Content{$FieldName} eq "ISBN") { + # fix stupid problem with dashes in data + $Content{$FieldContent} .= "*"; + } + + $SearchString .= ($SearchString ne "") ? " AND " : ""; + $SearchString .= "$Content{$FieldName}=(" . $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 +1958,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; } @@ -2146,18 +2078,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 +2194,7 @@ print("\n"); # Print the selector - print("\n"); @@ -3003,8 +2938,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 +2979,11 @@ if ( $ENV{'PATH_INFO'} eq "/GetExpandedSearch" ) { print("\n"); - print(" Kliknite na trokutić da biste suzili formu.\n"); + print(" Jednostavo 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 +2991,7 @@ # Send the start of the form and the buttons print("\n"); print("\n"); @@ -3075,20 +3011,31 @@ for (my $field=1; $field<= $nr_fields; $field++) { - print(""; if ($field == 1 ) { - print ("Pretraži u određenom polju:"); + print ""; } - print ("\n"); + my $Value = ""; + if (defined($main::FormData{"FieldContent${field}"})) { + $Value = "VALUE='".$main::FormData{"FieldContent${field}"}."'"; + } + print("\n"); } @@ -3110,7 +3057,9 @@ # Database selection if ( %main::DatabaseDescriptions ) { - print(" + \n"); @@ -3252,6 +3162,9 @@ 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 +2209,7 @@ if ( $main::ConfigurationData{'allow-relevance-feedback-searches'} eq "yes" ) { print("
$SelectorText $Score $Headline ( $main::DatabaseDescriptions{$Database} )
"); - } - else { + #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 ($main::DatabaseDescriptions{$Database})\n", $Score); } +if (0) { ## don't display description # Put up the summary if ( defined($SummaryText) && ($SummaryText ne "") ) { @@ -2746,6 +2679,7 @@ if ( ! defined($Remainder) ) { if ( $HTML ) { print("Formatttt: $MimeTypeName, "); + } else { print(" Format: $MimeTypeName, "); @@ -2754,11 +2688,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 +2823,7 @@ } print("\n"); +} #if # Finish off the entry if ( $HTML ) { print("
\n"); - print("
\n"); + print(" \n"); print("

"); + print "
"; + print "Pretraži u odabranom polju:"; + print ""); + print (""); 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 +3073,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"); - print("\n"); + print("\n"); # Send the buttons print("\n"); @@ -4146,40 +4059,16 @@ print("\n"); - print("\n"); } @@ -4323,7 +4212,7 @@ $Value{'UserName'} = $main::FormData{'UserName'}; $Value{'EmailAddress'} = $main::FormData{'EmailAddress'}; $Value{'DefaultSearch'} = $main::FormData{'DefaultSearch'}; - $Value{'SelectedDatabases'} = $main::FormData{'SelectedDatabases'}; + $Value{'SelectedDatabases'} = $main::FormData{'Database'}; if ( defined($Value{'SelectedDatabases'}) ) { $Value{'SelectedDatabases'} =~ s/\0/,/g; } @@ -4751,7 +4640,7 @@ # Give the user a form to fill out - print("

Saving a search:

\n"); + print("

Čuvanje upita:

\n"); @@ -4804,9 +4693,9 @@ print("\n"); # Send the search name and search description fields - print("\n"); + print("\n"); - print("\n"); + print("\n"); if ( defined($main::FormData{'RfDocument'}) ) { print("\n"); @@ -4817,7 +4706,7 @@ print("\n"); - print("\n"); + print("\n"); @@ -4826,10 +4715,10 @@ print("\n"); - print("\n"); + print("\n"); # Send a pull-down which allows the user to select the automatic search frequency - print("\n"); # Send a pull-down which allows the user to select the automatic search delivery format - print("\n"); # Send a pull-down which allows the user to select the automatic search delivery method - print("\n"); @@ -5233,7 +5122,7 @@ } - print("\n"); + print("\n"); } print("
Odabrane baze:
Označite baze koje uvijek želite pretraživati: \n"); + print("
Označite baze koje uvijek želite pretraživati:
\n"); # Parse out the database names and put them into a # hash table, they should be separated with a '\n' - undef(%Value); if ( defined($SelectedDatabases) && ($SelectedDatabases ne "") ) { @ItemList = split(",", $SelectedDatabases); - foreach $ItemEntry ( @ItemList ) { - $Value{$ItemEntry} = $ItemEntry; - } - } - - $Flag = 0; - print(""); - } - - $Value = ((defined($Value{$DatabaseName})) || (scalar(keys(%main::DatabaseDescriptions)) == 1)) ? "CHECKED" : ""; - $ItemEntry = &lEncodeURLData($DatabaseName); - print("\n"); - - if ( $Flag == 1 ) { - print(""); - $Flag = 0; - } - else { - $Flag = 1; - } } - print("
$main::DatabaseDescriptions{$DatabaseName}
\n"); + + &ShowDatabaseCheckBoxes(@ItemList); + print("

Search Name (required):
Naziv (obavezno):
Search Description:
Opis:

Kliknite na ovaj kvadratić ako želite postojeći folder s istim imenom zamijeniti ovim novim:
Kliknite na ovaj kvadratić ako želite postojeći upit s istim imenom zamijeniti ovim novim:

Check to run this search on a regular basis:
Kliknite ovaj kvadratić ukoliko želite automatsko periodičko pretraživanje po ovom upitu:
Select the search frequency:
Odaberite frekvenciju automatskog pretraživanja:
Select the delivery format:
Odaberite format za isporuku rezultata pretraživanja:
Select the delivery method:
Odaberite metodu isporuke:
\n"); print("\n"); print("\n"); print("
[ Otvori formu za pretraživanje s upisanim ovim pretraživanjem ]
[ Otvori formu za pretraživanje s upisanim ovim upitom ]
\n"); @@ -5370,13 +5259,13 @@ # Set the title if ( $ENV{'PATH_INFO'} eq "/DeleteSavedSearch" ) { - $Title = "Obriši sačuvana pretraživanja"; + $Title = "Brisanje sačuvanih pretraživanja"; } elsif ( $ENV{'PATH_INFO'} eq "/ActivateSavedSearch" ) { - $Title = "Aktiviraj sačuvana pretraživanja"; + $Title = "Uključivanje automatskog periodičnog pretraživanja"; } elsif ( $ENV{'PATH_INFO'} eq "/SuspendSavedSearch" ) { - $Title = "Stavi u mirovanje sačuvana pretraživanja"; + $Title = "Isključivanje automatskog periodičnog pretraživanja"; } @@ -5391,9 +5280,9 @@ # Check to see if the saved search object is defined if ( ! defined($main::FormData{'SavedSearchObject'}) ) { # Could not find the saved search object - print("

Sorry, no searches were selected.

\n"); + print("

Niste odabrali niti jedan upit.

\n"); print("

\n"); - print("You need to select at least one saved search in order to be able to perform an action on it.\n"); + print("Potrebno je odabrati barem jedan sačuvani upit nad kojim će se izvršiti akcija.\n"); print("

\n"); goto bailFromProcessSavedSearch; } @@ -5422,10 +5311,10 @@ if ( $ENV{'PATH_INFO'} eq "/DeleteSavedSearch" ) { if ( unlink($SavedSearchFilePath) ) { - printf("

Successfully deleted: %s\n", $Value{'SearchName'}); + printf("

Uspješno pobrisano: %s\n", $Value{'SearchName'}); } else { - printf("

Failed to delete: %s\n", $Value{'SearchName'}); + printf("

Nije pobrisano: %s\n", $Value{'SearchName'}); } } elsif ( ($ENV{'PATH_INFO'} eq "/ActivateSavedSearch") || ($ENV{'PATH_INFO'} eq "/SuspendSavedSearch") ) { @@ -5439,12 +5328,12 @@ $Value{'SearchStatus'} = ($ENV{'PATH_INFO'} eq "/ActivateSavedSearch") ? "Active" : "Inactive" ; if ( &iSaveXMLFileFromHash($SavedSearchFilePath, "SavedSearch", %Value) ) { - printf("

Successfully %s: %s\n", - ($ENV{'PATH_INFO'} eq "/ActivateSavedSearch") ? "activated" : "suspended", $Value{'SearchName'}); + printf("

Uspješno %s: %s\n", + ($ENV{'PATH_INFO'} eq "/ActivateSavedSearch") ? "uključeno" : "isključeno", $Value{'SearchName'}); } else { - printf("

Failed to %s: %s\n", - ($ENV{'PATH_INFO'} eq "/ActivateSavedSearch") ? "activated" : "suspended", $Value{'SearchName'}); + printf("

Nije %s: %s\n", + ($ENV{'PATH_INFO'} eq "/ActivateSavedSearch") ? "uključeno" : "isključeno", $Value{'SearchName'}); } } } @@ -5546,7 +5435,7 @@ # Print up the title - print("

Snimanje foldera s dokumentima:

\n"); + print("

Kreiranje korisničkog foldera:

\n"); # Print up the form printf("
\n"); @@ -5595,7 +5484,7 @@ # Delete the old content delete($main::FormData{'Documents'}); - +###FIX if ( defined($main::FormData{'Document'}) ) { print("\n"); &bDisplayDocuments("Document", $main::FormData{'Document'}, "Document", undef, undef, 1); @@ -6006,7 +5895,7 @@ # Print out the document folders - print("

Folderi:

\n"); + print("

Korisnički folderi:

\n"); # Get the document folder hash @@ -7217,34 +7106,34 @@ } - if ( defined($main::FormData{'GetSearch.x'}) ) { + if ( defined($main::FormData{'GetSearch'}) ) { $ENV{'PATH_INFO'} = "/GetSearch"; - delete($main::FormData{'GetSearch.x'}); - delete($main::FormData{'GetSearch.y'}); + delete($main::FormData{'GetSearch'}); + delete($main::FormData{'GetSearch'}); } - if ( defined($main::FormData{'ListSearchHistory.x'}) ) { + if ( defined($main::FormData{'ListSearchHistory'}) ) { $ENV{'PATH_INFO'} = "/ListSearchHistory"; - delete($main::FormData{'ListSearchHistory.x'}); - delete($main::FormData{'ListSearchHistory.y'}); + delete($main::FormData{'ListSearchHistory'}); + delete($main::FormData{'ListSearchHistory'}); } - if ( defined($main::FormData{'ListSavedSearch.x'}) ) { + if ( defined($main::FormData{'ListSavedSearch'}) ) { $ENV{'PATH_INFO'} = "/ListSavedSearch"; - delete($main::FormData{'ListSavedSearch.x'}); - delete($main::FormData{'ListSavedSearch.y'}); + delete($main::FormData{'ListSavedSearch'}); + delete($main::FormData{'ListSavedSearch'}); } - if ( defined($main::FormData{'ListFolder.x'}) ) { + if ( defined($main::FormData{'ListFolder'}) ) { $ENV{'PATH_INFO'} = "/ListFolder"; - delete($main::FormData{'ListFolder.x'}); - delete($main::FormData{'ListFolder.y'}); + delete($main::FormData{'ListFolder'}); + delete($main::FormData{'ListFolder'}); } - if ( defined($main::FormData{'GetUserSettings.x'}) ) { + if ( defined($main::FormData{'GetUserSettings'}) ) { $ENV{'PATH_INFO'} = "/GetUserSettings"; - delete($main::FormData{'GetUserSettings.x'}); - delete($main::FormData{'GetUserSettings.y'}); + delete($main::FormData{'GetUserSettings'}); + delete($main::FormData{'GetUserSettings'}); } @@ -7486,3 +7375,62 @@ } } } + +#-------------------------------------------------------------------------- +# show list of all databases +# +# usage: ShowDatabaseCheckBoxes(@SelectedDatabases) + +sub ShowDatabaseCheckBoxes { + # Parse out the database names and put them into a + # hash table, they should be separated with a '\0' + my %Value; + + foreach my $ItemEntry ( @_ ) { + $Value{$ItemEntry} = $ItemEntry; + } + + print("\n"); + print ""; + + my @html_database; + + foreach my $key ( sort keys %main::DatabaseSort ) { + my $DatabaseName = $main::DatabaseSort{$key}; + my $Value = ((defined($Value{$DatabaseName})) || (scalar(keys(%main::DatabaseDescriptions)) == 1) || !defined($main::RemoteUser) ) ? "CHECKED" : ""; + my $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 $cols = $main::ConfigurationData{'show-nr-colums'}; + my $next = int($#html_database/$cols) ; + + for(my $i=0; $i <= $next ; $i++) { + print(""); + for(my $j=0; $j <= $cols; $j++) { + print($html_database[$i+$next*$j+$j] || ''); + } + print(""); + } + + } else { + for(my $i=0; $i <= $#html_database ; $i=$i+1) { + print("",$html_database[$i],""); + } + } + + print("
+ Označi + sve, + niti jednu. + +
$main::DatabaseDescriptions{$DatabaseName} $main::DatabaseDescriptions{$DatabaseName}
\n"); +}