1 |
#!/usr/bin/perl -w |
2 |
|
3 |
#***************************************************************************** |
4 |
# Copyright (C) 1993-2000, FS Consulting Inc. All rights reserved * |
5 |
# * |
6 |
# * |
7 |
# This notice is intended as a precaution against inadvertent publication * |
8 |
# and does not constitute an admission or acknowledgement that publication * |
9 |
# has occurred or constitute a waiver of confidentiality. * |
10 |
# * |
11 |
# This software is the proprietary and confidential property * |
12 |
# of FS Consulting, Inc. * |
13 |
#***************************************************************************** |
14 |
|
15 |
#print "Content-type: text/plain\n\n"; |
16 |
|
17 |
#use Data::Dumper; |
18 |
|
19 |
#-------------------------------------------------------------------------- |
20 |
# |
21 |
# Author: Francois Schiettecatte (FS Consulting, Inc.) |
22 |
# Creation Date: 8/9/96 |
23 |
|
24 |
|
25 |
#-------------------------------------------------------------------------- |
26 |
# |
27 |
# Description: |
28 |
# |
29 |
# This script implements the search interface into the search engine. We |
30 |
# interface with the search engine using the Direct protocol. |
31 |
# |
32 |
|
33 |
|
34 |
#-------------------------------------------------------------------------- |
35 |
# |
36 |
# Modification Log |
37 |
# |
38 |
# Date: |
39 |
# Author: |
40 |
# Organization: |
41 |
# Email: |
42 |
# Description: |
43 |
# |
44 |
# |
45 |
# Date: 8/9/96 |
46 |
# Author: Francois Schiettecatte |
47 |
# Organization: FS Consulting, Inc. |
48 |
# Email: francois@fsconsult.com |
49 |
# Description: First cut. |
50 |
|
51 |
|
52 |
#-------------------------------------------------------------------------- |
53 |
# |
54 |
# CGI-BIN mode usage |
55 |
# |
56 |
|
57 |
# We use the following environment variables from the cgi-bin environment: |
58 |
# |
59 |
# $PATH_INFO - action requested |
60 |
# $QUERY_STRING - contains the query |
61 |
# $REMOTE_USER - user account name |
62 |
# $REQUEST_METHOD - request method |
63 |
# $SCRIPT_NAME - script name |
64 |
# |
65 |
|
66 |
|
67 |
# We create the following variables as we go along, |
68 |
# these will both be empty if this is a guest user |
69 |
# |
70 |
# $main::RemoteUser - contains the remote user name |
71 |
# $main::UserAccountDirectoryPath - contains the path name to the user account directory |
72 |
# $main::UserSettingsFilePath - contains the path name to the user information file |
73 |
# |
74 |
|
75 |
|
76 |
# User directory structure |
77 |
# |
78 |
# /AccountName (user directory) |
79 |
# |
80 |
|
81 |
|
82 |
#-------------------------------------------------------------------------- |
83 |
# |
84 |
# Pragmatic modules |
85 |
# |
86 |
|
87 |
use strict; |
88 |
|
89 |
|
90 |
#-------------------------------------------------------------------------- |
91 |
# |
92 |
# Set the default configuration directories, files & parameters |
93 |
# |
94 |
|
95 |
|
96 |
# Root directory path |
97 |
$main::RootDirectoryPath = (($main::Index = rindex($0, "/")) >= 0) ? substr($0, 0, $main::Index) : "."; |
98 |
|
99 |
# Program name |
100 |
$main::ProgramName = (($main::Index = rindex($0, "/")) >= 0) ? substr($0, $main::Index + 1) : $0; |
101 |
|
102 |
# Program base name |
103 |
$main::ProgramBaseName = (($main::Index = rindex($main::ProgramName, ".")) >= 0) ? substr($main::ProgramName, 0, $main::Index) : $main::ProgramName; |
104 |
|
105 |
|
106 |
# Log directory path |
107 |
$main::LogDirectoryPath = $main::RootDirectoryPath . "/logs"; |
108 |
|
109 |
|
110 |
# Configuration file path |
111 |
$main::ConfigurationFilePath = $main::RootDirectoryPath . "/" . $main::ProgramBaseName . ".cf"; |
112 |
|
113 |
# Log file path |
114 |
$main::LogFilePath = $main::LogDirectoryPath . "/" . lc($main::ProgramBaseName) . ".log"; |
115 |
|
116 |
|
117 |
|
118 |
# Log file roll-over |
119 |
#$main::LogFileRollOver = 0; |
120 |
|
121 |
|
122 |
|
123 |
#-------------------------------------------------------------------------- |
124 |
# |
125 |
# Required packages |
126 |
# |
127 |
|
128 |
# Load the libraries |
129 |
push @INC, $main::RootDirectoryPath; |
130 |
require "Library.pl"; |
131 |
|
132 |
|
133 |
# Load the MPS Information Server library |
134 |
use MPS; |
135 |
|
136 |
#-------------------------------------------------------------------------- |
137 |
# |
138 |
# Environment variables |
139 |
# |
140 |
|
141 |
# Set up the environment so that we can find the external applications we need |
142 |
$ENV{'PATH'} = "/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/etc"; |
143 |
$ENV{'LD_LIBRARY_PATH'} = "/usr/lib"; |
144 |
|
145 |
|
146 |
#-------------------------------------------------------------------------- |
147 |
# |
148 |
# Global |
149 |
# |
150 |
|
151 |
# Configuration global (used to store the information read in from the configuration file) |
152 |
undef(%main::ConfigurationData); |
153 |
|
154 |
|
155 |
# Database descriptions global (used to store the information read in from the database description file) |
156 |
undef(%main::DatabaseDescriptions); |
157 |
undef(%main::DatabaseSort); |
158 |
|
159 |
|
160 |
# Database Filters global (used to store the information read in from the database description file) |
161 |
undef(%main::DatabaseFilters); |
162 |
|
163 |
|
164 |
# Global flags which are set after sending the html header and footer |
165 |
$main::HeaderSent = 0; |
166 |
$main::FooterSent = 0; |
167 |
|
168 |
# Form data global (this is used to store the information decoded from a form) |
169 |
undef(%main::FormData); |
170 |
|
171 |
|
172 |
# User account information |
173 |
undef($main::UserSettingsFilePath); |
174 |
undef($main::UserAccountDirectoryPath); |
175 |
undef($main::RemoteUser); |
176 |
|
177 |
|
178 |
$main::MPSSession = 0; |
179 |
|
180 |
#-------------------------------------------------------------------------- |
181 |
# |
182 |
# Configuration Constants |
183 |
# |
184 |
|
185 |
|
186 |
# read configuration fields |
187 |
require "config.pm"; |
188 |
|
189 |
# List of required configuration settings |
190 |
@main::RequiredSettings = ( |
191 |
'html-directory', |
192 |
'logs-directory', |
193 |
'image-base-path', |
194 |
'database-directory', |
195 |
'configuration-directory' |
196 |
); |
197 |
|
198 |
|
199 |
|
200 |
$main::DatabaseName = "database-name"; |
201 |
$main::DatabaseFiltersPackage = "database-filters-package"; |
202 |
$main::DatabaseDocumentFilter = "database-document-filter"; |
203 |
$main::DatabaseSummaryFilter = "database-summary-filter"; |
204 |
$main::DatabaseRelevanceFeedbackFilter = "database-relevance-feedback-filter"; |
205 |
|
206 |
|
207 |
#-------------------------------------------------------------------------- |
208 |
# |
209 |
# Application Constants |
210 |
# |
211 |
|
212 |
|
213 |
# XML file name extension |
214 |
$main::XMLFileNameExtension = ".xml"; |
215 |
|
216 |
|
217 |
# User Settings file |
218 |
$main::UserSettingsFileName = "UserSettings"; |
219 |
|
220 |
# Saved Search file preamble |
221 |
$main::SavedSearchFileNamePrefix = "SavedSearch"; |
222 |
|
223 |
# Search history file preamble |
224 |
$main::SearchHistoryFileNamePrefix = "SearchHistory"; |
225 |
|
226 |
# Document Folder file preamble |
227 |
$main::DocumentFolderFileNamePrefix = "DocumentFolder"; |
228 |
|
229 |
|
230 |
# Query report item name and mime type |
231 |
$main::QueryReportItemName = "document"; |
232 |
$main::QueryReportMimeType = "application/x-wais-report"; |
233 |
|
234 |
|
235 |
# Array of mime type names, we use this to map |
236 |
# mime types to mime type names (which are more readable) |
237 |
%main::MimeTypeNames = ( |
238 |
'text/plain', 'Text', |
239 |
'text/html', 'HTML', |
240 |
'text/http', 'HTML', |
241 |
'text/http', 'HTML', |
242 |
'image/gif', 'GIF Image', |
243 |
'image/tif', 'TIF Image', |
244 |
'image/jpeg', 'JPEG Image', |
245 |
'image/jfif', 'JPEG Image', |
246 |
); |
247 |
|
248 |
|
249 |
# Array of mime types that we can resonably use for relevance feedback |
250 |
%main::RFMimeTypes = ( |
251 |
'text/plain', 'text/plain', |
252 |
'text/html', 'text/html', |
253 |
'text/http', 'text/http', |
254 |
); |
255 |
|
256 |
|
257 |
# Array of mime types that are in HTML |
258 |
%main::HtmlMimeTypes = ( |
259 |
'text/html', 'text/html', |
260 |
'text/http', 'text/http', |
261 |
); |
262 |
|
263 |
|
264 |
# DbP: replaced by NormalSearchFieldNames and AdvancedSearchFieldNames |
265 |
# Search fields |
266 |
#@main::SearchFieldNames = ( |
267 |
# '200-ae', |
268 |
# '700,701,702,710,711', |
269 |
# '610' |
270 |
#); |
271 |
|
272 |
# DbP: this variable will be filled using MPS::GetDatabaseFieldInfo |
273 |
%main::SearchFieldDescriptions = ( |
274 |
# 'title', 'Title', |
275 |
# 'abstract', 'Abstract', |
276 |
# 'author', 'Author', |
277 |
# 'journal', 'Journal', |
278 |
); |
279 |
|
280 |
|
281 |
# Date list |
282 |
@main::PastDate = ( |
283 |
'Week', |
284 |
'Month', |
285 |
'3 Months', |
286 |
'6 Months', |
287 |
'9 Months', |
288 |
'Year' |
289 |
); |
290 |
|
291 |
# Default maximum number of documents |
292 |
$main::DefaultMaxDoc = 50; |
293 |
|
294 |
# Maximum docs list used for the search form pull-down |
295 |
@main::MaxDocs = ( '10', '25', '50', '100', '250', '500', '750'); |
296 |
|
297 |
|
298 |
# Default maximum search history |
299 |
$main::DefaultMaxSearchHistory = 15; |
300 |
|
301 |
|
302 |
# Summary type for the settings form pull-down |
303 |
%main::SummaryTypes = ( |
304 |
'none', 'None', |
305 |
'keyword', 'Keywords in Context', |
306 |
'default', 'Default summary', |
307 |
); |
308 |
|
309 |
|
310 |
# Summary length for the settings form pull-down |
311 |
@main::SummaryLengths = ( '20', '40', '60', '80', '100', '120' ); |
312 |
|
313 |
# Default summary length |
314 |
$main::DefaultSummaryLength = 40; |
315 |
|
316 |
# Default summary type |
317 |
$main::DefaultSummaryType = "default"; |
318 |
|
319 |
|
320 |
# Similar documents for the settings form pull-down |
321 |
@main::SimilarDocuments = ( '1', '3', '5', '10' ); |
322 |
|
323 |
# Default similar document |
324 |
$main::DefaultSimilarDocument = 5; |
325 |
|
326 |
# Token span on either side of the summary keyword |
327 |
$main::SummaryKeywordSpan = 9; |
328 |
|
329 |
|
330 |
# Delivery format |
331 |
%main::DeliveryFormats = ( |
332 |
'text/plain', 'Plain text', |
333 |
'text/html', 'HTML', |
334 |
); |
335 |
|
336 |
# Delivery methods |
337 |
%main::DeliveryMethods = ( |
338 |
'message', 'Email message', |
339 |
'attachement', 'Email attachement', |
340 |
); |
341 |
|
342 |
|
343 |
# Search frequency |
344 |
@main::SearchFrequencies = ( |
345 |
'Daily', |
346 |
'Weekly', |
347 |
'Monthly' |
348 |
); |
349 |
|
350 |
|
351 |
# Default maximum visible URL length |
352 |
$main::DefaultMaxVisibleUrlLength = 80; |
353 |
|
354 |
|
355 |
#-------------------------------------------------------------------------- |
356 |
# |
357 |
# Function: vSendHTMLHeader() |
358 |
# |
359 |
# Purpose: This function send the HTML header |
360 |
# |
361 |
# Called by: |
362 |
# |
363 |
# Parameters: $Title HTML page title |
364 |
# $JavaScript JavaScript to send |
365 |
# |
366 |
# Global Variables: $main::HeaderSent |
367 |
# |
368 |
# Returns: void |
369 |
# |
370 |
sub vSendHTMLHeader { |
371 |
|
372 |
my ($Title, $JavaScript) = @_; |
373 |
|
374 |
|
375 |
# Bail if we are not running as a CGI-BIN script |
376 |
if ( ! $ENV{'GATEWAY_INTERFACE'} ) { |
377 |
return; |
378 |
} |
379 |
|
380 |
# Bail if we have already sent the header |
381 |
if ( $main::HeaderSent ) { |
382 |
return; |
383 |
} |
384 |
|
385 |
|
386 |
# Send the CGI-BIN response header |
387 |
print("Content-type: text/html\n\n"); |
388 |
|
389 |
# Put out the html document header |
390 |
printf("<HTML>\n<HEAD>\n<TITLE>\n%s\n</TITLE>\n", defined($Title) ? $Title : "FS Consulting - MPS Direct Search Interface"); |
391 |
if ( defined($JavaScript) ) { |
392 |
print("$JavaScript\n"); |
393 |
} |
394 |
print '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-2">'; |
395 |
print '<link rel="STYLESHEET" type="text/css" href="'.$main::ConfigurationData{'image-base-path'}.'/stil.css">'; |
396 |
print("</HEAD>\n<BODY BGCOLOR=\"#FFFFFF\">\n"); |
397 |
|
398 |
|
399 |
# Send the header snippet file |
400 |
&vPrintFileContent($main::ConfigurationData{'html-header-snippet-file'}); |
401 |
|
402 |
|
403 |
# Send the banner |
404 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
405 |
# print("<TR><TD VALIGN=TOP ALIGN=RIGHT> <A HREF=\"/\" OnMouseOver=\"self.status='Return Home'; return true\"><IMG SRC=\"$main::ConfigurationData{'image-base-path'}/$main::ImageNames{'banner'}\" ALT=\"Return Home\" BORDER=0></A> </TD></TR>\n"); |
406 |
|
407 |
print("<TR><TD VALIGN=TOP ALIGN=RIGHT> <A HREF=\"/\" OnMouseOver=\"self.status='Return Home'; return true\"><H3>Katalozi knji¾nica Filozofskog fakulteta</H3> </A> </TD></TR>\n"); |
408 |
|
409 |
print("</TABLE>\n"); |
410 |
|
411 |
|
412 |
# Set the flag saying that the header has been sent |
413 |
$main::HeaderSent = 1; |
414 |
|
415 |
return; |
416 |
|
417 |
} |
418 |
|
419 |
|
420 |
|
421 |
#-------------------------------------------------------------------------- |
422 |
# |
423 |
# Function: vSendHTMLFooter() |
424 |
# |
425 |
# Purpose: This function send the HTML footer |
426 |
# |
427 |
# Called by: |
428 |
# |
429 |
# Parameters: void |
430 |
# |
431 |
# Global Variables: $main::FooterSent |
432 |
# |
433 |
# Returns: void |
434 |
# |
435 |
sub vSendHTMLFooter { |
436 |
|
437 |
|
438 |
# Bail if we are not running as a CGI-BIN script |
439 |
if ( ! $ENV{'GATEWAY_INTERFACE'} ) { |
440 |
return; |
441 |
} |
442 |
|
443 |
# Bail if we have already sent the footer |
444 |
if ( $main::FooterSent ) { |
445 |
return; |
446 |
} |
447 |
|
448 |
|
449 |
# Send the footer snippet file |
450 |
&vPrintFileContent($main::ConfigurationData{'html-footer-snippet-file'}); |
451 |
|
452 |
|
453 |
# Send the end of body tag and end of HTML tag |
454 |
print("</BODY>\n</HTML>\n"); |
455 |
|
456 |
|
457 |
# Set the flag saying that the footer has been sent |
458 |
$main::FooterSent = 1; |
459 |
|
460 |
return; |
461 |
|
462 |
} |
463 |
|
464 |
|
465 |
|
466 |
#-------------------------------------------------------------------------- |
467 |
# |
468 |
# Function: vSendMenuBar() |
469 |
# |
470 |
# Purpose: This function send the mneu bar |
471 |
# |
472 |
# Called by: |
473 |
# |
474 |
# Parameters: %MenuBar menu bar exclusion hash table |
475 |
# |
476 |
# Global Variables: |
477 |
# |
478 |
# Returns: void |
479 |
# |
480 |
sub vSendMenuBar { |
481 |
|
482 |
my (%MenuBar) = @_; |
483 |
|
484 |
my (%Value, $Value, $ValueEntry); |
485 |
|
486 |
|
487 |
# Start the table |
488 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
489 |
|
490 |
# Start the menu bar cell |
491 |
print("<TR><TD VALIGN=CENTER ALIGN=CENTER>\n"); |
492 |
|
493 |
# Start the form |
494 |
print("<FORM ACTION=\"$ENV{'SCRIPT_NAME'}\" METHOD=POST>\n"); |
495 |
|
496 |
|
497 |
|
498 |
# List the hidden fields |
499 |
%Value = &hParseURLIntoHashTable(&sMakeSearchAndRfDocumentURL(%main::FormData)); |
500 |
foreach $Value ( keys(%Value) ) { |
501 |
foreach $ValueEntry ( split(/\0/, $Value{$Value}) ) { |
502 |
print("<INPUT TYPE=HIDDEN NAME=\"$Value\" VALUE=\"$ValueEntry\">\n"); |
503 |
} |
504 |
} |
505 |
|
506 |
my $DISABLED; |
507 |
|
508 |
$DISABLED = ( %MenuBar && defined($MenuBar{'GetSearch'}) ) ? "DISABLED" : ""; |
509 |
print("<INPUT NAME=\"GetSearch\" TYPE=SUBMIT VALUE=\"Forma za pretra¾ivanje\" $DISABLED class=\"navigacija\">"); |
510 |
|
511 |
if ( defined($main::RemoteUser) ) { |
512 |
$DISABLED = ( %MenuBar && defined($MenuBar{'ListSearchHistory'}) ) ? "DISABLED" : ""; |
513 |
print"<INPUT NAME=\"ListSearchHistory\" TYPE=SUBMIT VALUE=\"Search History\" $DISABLED class=\"navigacija\">"; |
514 |
|
515 |
$DISABLED = ( %MenuBar && defined($MenuBar{'ListSavedSearch'}) ) ? "DISABLED" : ""; |
516 |
print"<INPUT NAME=\"ListSavedSearch\" TYPE=SUBMIT VALUE=\"List Saved Search\" $DISABLED class=\"navigacija\">"; |
517 |
|
518 |
$DISABLED = ( %MenuBar && defined($MenuBar{'ListFolder'}) ) ? "DISABLED" : ""; |
519 |
print"<INPUT NAME=\"ListFolder\" TYPE=SUBMIT VALUE=\"List Folder\" $DISABLED class=\"navigacija\">"; |
520 |
|
521 |
$DISABLED = ( %MenuBar && defined($MenuBar{'GetUserSettings'}) ) ? "DISABLED" : ""; |
522 |
print"<INPUT NAME=\"GetUserSettings\" TYPE=SUBMIT VALUE=\"Get User Settings\" $DISABLED class=\"navigacija\">"; |
523 |
} |
524 |
|
525 |
|
526 |
print("</FORM>\n"); |
527 |
|
528 |
# Close off the menu bar cell |
529 |
print("</TD></TR>\n"); |
530 |
|
531 |
print("</TABLE>\n"); |
532 |
|
533 |
|
534 |
return; |
535 |
} |
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
#-------------------------------------------------------------------------- |
543 |
# |
544 |
# Function: vHandleError() |
545 |
# |
546 |
# Purpose: This function handles any errors messages that need to be |
547 |
# reported when an error occurs |
548 |
# |
549 |
# This error handler also displays the header if needed |
550 |
# |
551 |
# Called by: |
552 |
# |
553 |
# Parameters: $Header header |
554 |
# $Message message |
555 |
# |
556 |
# Global Variables: |
557 |
# |
558 |
# Returns: void |
559 |
# |
560 |
sub vHandleError { |
561 |
|
562 |
my ($Header, $Message) = @_; |
563 |
|
564 |
my ($Package, $FileName, $Line); |
565 |
|
566 |
|
567 |
# Make sure we send the header |
568 |
&vSendHTMLHeader("Error", undef); |
569 |
|
570 |
|
571 |
printf("<H3> %s: </H3>\n", defined($Header) ? $Header : "No header supplied"); |
572 |
printf("<H3><CENTER> %s. </CENTER></H3>\n", defined($Message) ? $Message : "No error message supplied"); |
573 |
print("<P>\n"); |
574 |
if ( defined($main::ConfigurationData{'site-admin-url'}) ) { |
575 |
print("<CENTER> Please <A HREF=\"$main::ConfigurationData{'site-admin-url'}\"> contact the administrator </A> of this system to correct the problem. </CENTER>\n"); |
576 |
} |
577 |
else { |
578 |
print("<CENTER> Please contact the administrator of this system to correct the problem. </CENTER>\n"); |
579 |
} |
580 |
print("<P><HR WIDTH=50%><P>\n"); |
581 |
|
582 |
|
583 |
# Send package information |
584 |
# ($Package, $FileName, $Line) = caller; |
585 |
# print("Package = [$Package], FileName = [$FileName], Line = [$Line] <BR>\n"); |
586 |
|
587 |
return; |
588 |
} |
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
#-------------------------------------------------------------------------- |
595 |
# |
596 |
# Function: bCheckConfiguration() |
597 |
# |
598 |
# Purpose: This function checks that the configuration settings |
599 |
# specified are correct and that any directory paths and |
600 |
# files specified are there and can be accessed. |
601 |
# |
602 |
# We check both required settings and optional setting if |
603 |
# they have been set. |
604 |
# |
605 |
# An error here should be considered fatal. |
606 |
# |
607 |
# Called by: |
608 |
# |
609 |
# Parameters: void |
610 |
# |
611 |
# Global Variables: %main::ConfigurationData |
612 |
# |
613 |
# Returns: Boolean status |
614 |
# |
615 |
sub bCheckConfiguration { |
616 |
|
617 |
my ($Value, $Status); |
618 |
|
619 |
|
620 |
# Init the status |
621 |
$Status = 1; |
622 |
|
623 |
|
624 |
# Check 'user-accounts-directory' (optional) |
625 |
if ( defined($main::ConfigurationData{'user-accounts-directory'}) ) { |
626 |
|
627 |
$main::ConfigurationData{'user-accounts-directory'} = &sCleanSetting('user-accounts-directory', $main::ConfigurationData{'user-accounts-directory'}, $main::RootDirectoryPath); |
628 |
$Value = $main::ConfigurationData{'user-accounts-directory'}; |
629 |
|
630 |
# Check that the directory exists |
631 |
if ( ! (-d $Value) ) { |
632 |
&vLog("Error - configuration setting: 'user-accounts-directory', directory: '$Value' does not exist.\n"); |
633 |
$Status = 0; |
634 |
} |
635 |
else { |
636 |
|
637 |
# The directory exists, now check that it can be accessed |
638 |
if ( ! ((-r $Value) && (-w $Value) && (-x $Value)) ) { |
639 |
&vLog("Error - configuration setting: 'user-accounts-directory', directory: '$Value' cannot be accessed.\n"); |
640 |
$Status = 0; |
641 |
} |
642 |
} |
643 |
} |
644 |
|
645 |
|
646 |
|
647 |
# Check 'database-description-file' (optional) |
648 |
if ( defined($main::ConfigurationData{'database-description-file'}) ) { |
649 |
|
650 |
$main::ConfigurationData{'database-description-file'} = &sCleanSetting('database-description-file', $main::ConfigurationData{'database-description-file'}, $main::RootDirectoryPath); |
651 |
$Value = $main::ConfigurationData{'database-description-file'}; |
652 |
|
653 |
# Check that the file exists |
654 |
if ( ! ((-f $Value) && (-r $Value)) ) { |
655 |
&vLog("Error - configuration setting: 'database-description-file', file: '$Value' does not exist.\n"); |
656 |
$Status = 0; |
657 |
} |
658 |
} |
659 |
|
660 |
|
661 |
|
662 |
# Check 'allow-summary-displays' (optional) |
663 |
if ( defined($main::ConfigurationData{'allow-summary-displays'}) ) { |
664 |
|
665 |
# Clean the setting and convert to lower case |
666 |
$main::ConfigurationData{'allow-summary-displays'} = &sCleanSetting('allow-summary-displays', $main::ConfigurationData{'allow-summary-displays'}); |
667 |
$main::ConfigurationData{'allow-summary-displays'} = lc($main::ConfigurationData{'allow-summary-displays'}); |
668 |
|
669 |
# Check that the setting is valid |
670 |
if ( ($main::ConfigurationData{'allow-summary-displays'} ne "yes") && ($main::ConfigurationData{'allow-summary-displays'} ne "no")) { |
671 |
&vLog("Warning - configuration setting: 'allow-summary-displays', setting not recognized: $main::ConfigurationData{'allow-summary-displays'}.\n"); |
672 |
} |
673 |
} |
674 |
|
675 |
|
676 |
|
677 |
# Check 'allow-similiar-search' (optional) |
678 |
if ( defined($main::ConfigurationData{'allow-similiar-search'}) ) { |
679 |
|
680 |
# Clean the setting and convert to lower case |
681 |
$main::ConfigurationData{'allow-similiar-search'} = &sCleanSetting('allow-similiar-search', $main::ConfigurationData{'allow-similiar-search'}); |
682 |
$main::ConfigurationData{'allow-similiar-search'} = lc($main::ConfigurationData{'allow-similiar-search'}); |
683 |
|
684 |
# Check that the setting is valid |
685 |
if ( ($main::ConfigurationData{'allow-similiar-search'} ne "yes") && ($main::ConfigurationData{'allow-similiar-search'} ne "no")) { |
686 |
&vLog("Warning - configuration setting: 'allow-similiar-search', setting not recognized: $main::ConfigurationData{'allow-similiar-search'}.\n"); |
687 |
} |
688 |
} |
689 |
|
690 |
|
691 |
|
692 |
# Check 'allow-regular-searches' (optional) |
693 |
if ( defined($main::ConfigurationData{'allow-regular-searches'}) ) { |
694 |
|
695 |
# Clean the setting and convert to lower case |
696 |
$main::ConfigurationData{'allow-regular-searches'} = &sCleanSetting('allow-regular-searches', $main::ConfigurationData{'allow-regular-searches'}); |
697 |
$main::ConfigurationData{'allow-regular-searches'} = lc($main::ConfigurationData{'allow-regular-searches'}); |
698 |
|
699 |
# Check that the setting is valid |
700 |
if ( ($main::ConfigurationData{'allow-regular-searches'} ne "yes") && ($main::ConfigurationData{'allow-regular-searches'} ne "no")) { |
701 |
&vLog("Warning - configuration setting: 'allow-regular-searches', setting not recognized: $main::ConfigurationData{'allow-regular-searches'}.\n"); |
702 |
} |
703 |
} |
704 |
|
705 |
|
706 |
|
707 |
# Check 'deliver-empty-results-from-regular-search' (optional) |
708 |
if ( defined($main::ConfigurationData{'deliver-empty-results-from-regular-search'}) ) { |
709 |
|
710 |
# Clean the setting and convert to lower case |
711 |
$main::ConfigurationData{'deliver-empty-results-from-regular-search'} = &sCleanSetting('deliver-empty-results-from-regular-search', $main::ConfigurationData{'deliver-empty-results-from-regular-search'}); |
712 |
$main::ConfigurationData{'deliver-empty-results-from-regular-search'} = lc($main::ConfigurationData{'deliver-empty-results-from-regular-search'}); |
713 |
|
714 |
# Check that the setting is valid |
715 |
if ( ($main::ConfigurationData{'deliver-empty-results-from-regular-search'} ne "yes") && ($main::ConfigurationData{'deliver-empty-results-from-regular-search'} ne "no")) { |
716 |
&vLog("Warning - configuration setting: 'deliver-empty-results-from-regular-search', setting not recognized: $main::ConfigurationData{'deliver-empty-results-from-regular-search'}.\n"); |
717 |
} |
718 |
} |
719 |
|
720 |
|
721 |
|
722 |
# Check 'allow-relevance-feedback-searches' (optional) |
723 |
if ( defined($main::ConfigurationData{'allow-relevance-feedback-searches'}) ) { |
724 |
|
725 |
# Clean the setting and convert to lower case |
726 |
$main::ConfigurationData{'allow-relevance-feedback-searches'} = &sCleanSetting('allow-relevance-feedback-searches', $main::ConfigurationData{'allow-relevance-feedback-searches'}); |
727 |
$main::ConfigurationData{'allow-relevance-feedback-searches'} = lc($main::ConfigurationData{'allow-relevance-feedback-searches'}); |
728 |
|
729 |
# Check that the setting is valid |
730 |
if ( ($main::ConfigurationData{'allow-relevance-feedback-searches'} ne "yes") && ($main::ConfigurationData{'allow-relevance-feedback-searches'} ne "no")) { |
731 |
&vLog("Warning - configuration setting: 'allow-relevance-feedback-searches', setting not recognized: $main::ConfigurationData{'allow-relevance-feedback-searches'}.\n"); |
732 |
} |
733 |
} |
734 |
|
735 |
|
736 |
|
737 |
# Check 'html-directory' (required) |
738 |
$main::ConfigurationData{'html-directory'} = &sCleanSetting('html-directory', $main::ConfigurationData{'html-directory'}, $main::RootDirectoryPath); |
739 |
$Value = $main::ConfigurationData{'html-directory'}; |
740 |
|
741 |
# Check that the directory exists |
742 |
if ( ! (-d $Value) ) { |
743 |
&vLog("Error - configuration setting: 'html-directory', directory: '$Value' does not exist.\n"); |
744 |
$Status = 0; |
745 |
} |
746 |
else { |
747 |
|
748 |
# The directory exists, now check that it can be accessed |
749 |
if ( ! ((-r $Value) && (-x $Value)) ) { |
750 |
&vLog("Error - configuration setting: 'html-directory', directory: '$Value' cannot be accessed.\n"); |
751 |
$Status = 0; |
752 |
} |
753 |
} |
754 |
|
755 |
|
756 |
|
757 |
# Check 'image-base-path' (required) |
758 |
$main::ConfigurationData{'image-base-path'} = &sCleanSetting('image-base-path', $main::ConfigurationData{'image-base-path'}); |
759 |
$Value = $main::ConfigurationData{'html-directory'} . $main::ConfigurationData{'image-base-path'}; |
760 |
|
761 |
# Check that the directory exists |
762 |
if ( ! (-d $Value) ) { |
763 |
&vLog("Error - configuration setting: 'image-base-path', directory: '$Value' does not exist.\n"); |
764 |
$Status = 0; |
765 |
} |
766 |
else { |
767 |
|
768 |
my ($ImageName); |
769 |
|
770 |
# The directory exists, now check that it can be accessed |
771 |
if ( ! ((-r $Value) && (-x $Value)) ) { |
772 |
&vLog("Error - configuration setting: 'image-base-path', directory: '$Value' cannot be accessed.\n"); |
773 |
$Status = 0; |
774 |
} |
775 |
|
776 |
|
777 |
# Check the general icons |
778 |
foreach $ImageName ( values(%main::ImageNames) ) { |
779 |
|
780 |
$Value = $main::ConfigurationData{'html-directory'} . $main::ConfigurationData{'image-base-path'} . "/" . $ImageName; |
781 |
|
782 |
# Check that the file exists |
783 |
if ( ! ((-f $Value) && (-r $Value)) ) { |
784 |
&vLog("Error - configuration setting: 'image-base-path', file: '$Value' does not exist.\n"); |
785 |
$Status = 0; |
786 |
} |
787 |
} |
788 |
} |
789 |
|
790 |
|
791 |
|
792 |
# Check 'html-header-snippet-file' (optional) |
793 |
if ( defined($main::ConfigurationData{'html-header-snippet-file'}) ) { |
794 |
|
795 |
$main::ConfigurationData{'html-header-snippet-file'} = &sCleanSetting('html-header-snippet-file', $main::ConfigurationData{'html-header-snippet-file'}, $main::RootDirectoryPath); |
796 |
$Value = $main::ConfigurationData{'html-header-snippet-file'}; |
797 |
|
798 |
# Check that the file exists |
799 |
if ( ! ((-f $Value) && (-r $Value)) ) { |
800 |
&vLog("Error - configuration setting: 'html-header-snippet-file', file: '$Value' does not exist.\n"); |
801 |
$Status = 0; |
802 |
} |
803 |
} |
804 |
|
805 |
|
806 |
|
807 |
# Check 'html-footer-snippet-file' (optional) |
808 |
if ( defined($main::ConfigurationData{'html-footer-snippet-file'}) ) { |
809 |
|
810 |
$main::ConfigurationData{'html-footer-snippet-file'} = &sCleanSetting('html-footer-snippet-file', $main::ConfigurationData{'html-footer-snippet-file'}, $main::RootDirectoryPath); |
811 |
$Value = $main::ConfigurationData{'html-footer-snippet-file'}; |
812 |
|
813 |
# Check that the file exists |
814 |
if ( ! ((-f $Value) && (-r $Value)) ) { |
815 |
&vLog("Error - configuration setting: 'html-footer-snippet-file', file: '$Value' does not exist.\n"); |
816 |
$Status = 0; |
817 |
} |
818 |
} |
819 |
|
820 |
|
821 |
|
822 |
# Check 'logs-directory' (required) |
823 |
$main::ConfigurationData{'logs-directory'} = &sCleanSetting('logs-directory', $main::ConfigurationData{'logs-directory'}, $main::RootDirectoryPath); |
824 |
$Value = $main::ConfigurationData{'logs-directory'}; |
825 |
|
826 |
# Check that the directory exists |
827 |
if ( ! (-d $Value) ) { |
828 |
&vLog("Error - configuration setting: 'logs-directory', directory: '$Value' does not exist.\n"); |
829 |
$Status = 0; |
830 |
} |
831 |
else { |
832 |
|
833 |
# The directory exists, now check that it can be accessed |
834 |
if ( ! ((-r $Value) && (-w $Value) && (-x $Value)) ) { |
835 |
&vLog("Error - configuration setting: 'logs-directory', directory: '$Value' cannot be accessed.\n"); |
836 |
$Status = 0; |
837 |
} |
838 |
} |
839 |
|
840 |
|
841 |
|
842 |
# Check 'database-directory' (required) |
843 |
$main::ConfigurationData{'database-directory'} = &sCleanSetting('database-directory', $main::ConfigurationData{'database-directory'}, $main::RootDirectoryPath); |
844 |
$Value = $main::ConfigurationData{'database-directory'}; |
845 |
|
846 |
# Check that the directory exists |
847 |
if ( ! (-d $Value) ) { |
848 |
&vLog("Error - configuration setting: 'database-directory', directory: '$Value' does not exist.\n"); |
849 |
$Status = 0; |
850 |
} |
851 |
else { |
852 |
|
853 |
# The directory exists, now check that it can be accessed |
854 |
if ( ! ((-r $Value) && (-x $Value)) ) { |
855 |
&vLog("Error - configuration setting: 'database-directory, directory: '$Value' cannot be accessed.\n"); |
856 |
$Status = 0; |
857 |
} |
858 |
} |
859 |
|
860 |
|
861 |
|
862 |
# Check 'configuration-directory' (required) |
863 |
$main::ConfigurationData{'configuration-directory'} = &sCleanSetting('configuration-directory', $main::ConfigurationData{'configuration-directory'}, $main::RootDirectoryPath); |
864 |
$Value = $main::ConfigurationData{'configuration-directory'}; |
865 |
|
866 |
# Check that the directory exists |
867 |
if ( ! (-d $Value) ) { |
868 |
&vLog("Error - configuration setting: 'configuration-directory', directory: '$Value' does not exist.\n"); |
869 |
$Status = 0; |
870 |
} |
871 |
else { |
872 |
|
873 |
# The directory exists, now check that it can be accessed |
874 |
if ( ! ((-r $Value) && (-x $Value)) ) { |
875 |
&vLog("Error - configuration setting: 'configuration-directory, directory: '$Value' cannot be accessed.\n"); |
876 |
$Status = 0; |
877 |
} |
878 |
} |
879 |
|
880 |
|
881 |
|
882 |
# Check 'server-log' (optional with default) |
883 |
$main::ConfigurationData{'server-log'} = &sCleanSetting('server-log', $main::ConfigurationData{'server-log'}); |
884 |
$Value = $main::ConfigurationData{'logs-directory'} . "/" . $main::ConfigurationData{'server-log'}; |
885 |
|
886 |
# Check that we can write to the log file if it exists |
887 |
if ( -f $Value ) { |
888 |
|
889 |
# The file exists, now check that it can be accessed |
890 |
if ( ! -w $Value ) { |
891 |
&vLog("Error - configuration setting: 'server-log', directory: '$Value' cannot be accessed.\n"); |
892 |
$Status = 0; |
893 |
} |
894 |
} |
895 |
|
896 |
|
897 |
|
898 |
# Check 'mailer-application' (optional with default) |
899 |
if ( defined($main::ConfigurationData{'allow-regular-searches'}) && ($main::ConfigurationData{'allow-regular-searches'} eq "yes") ) { |
900 |
|
901 |
$main::ConfigurationData{'mailer-application'} = &sCleanSetting('mailer-application', $main::ConfigurationData{'mailer-application'}, $main::RootDirectoryPath); |
902 |
$Value = $main::ConfigurationData{'mailer-application'}; |
903 |
|
904 |
# Check that the application can be executed |
905 |
if ( ! (-x $Value) ) { |
906 |
&vLog("Error - configuration setting: 'mailer-application', application: '$Value' cannot be executed.\n"); |
907 |
$Status = 0; |
908 |
} |
909 |
} |
910 |
|
911 |
|
912 |
return ($Status); |
913 |
|
914 |
} |
915 |
|
916 |
|
917 |
|
918 |
|
919 |
|
920 |
#-------------------------------------------------------------------------- |
921 |
# |
922 |
# Function: bGetDatabaseDescriptions() |
923 |
# |
924 |
# Purpose: This function reads the database description file and places it in the |
925 |
# hash table global, note that the hash table is not cleared before |
926 |
# we start to add kay/value pairs to it. |
927 |
# |
928 |
# Any line which starts with a '#' or is empty will be skipped. |
929 |
# |
930 |
# An error will be generated if we try to redefine a value for a |
931 |
# key that has already been defined. |
932 |
# |
933 |
# An error here should be considered fatal. |
934 |
# |
935 |
# Called by: |
936 |
# |
937 |
# Parameters: void |
938 |
# |
939 |
# Global Variables: %main::ConfigurationData, %main::DatabaseDescriptions |
940 |
# |
941 |
# Returns: Boolean status |
942 |
# |
943 |
sub bGetDatabaseDescriptions { |
944 |
|
945 |
my ($Status, $Key, $KeyValue, $KeyBase, $KeyLeaf, $Database); |
946 |
|
947 |
|
948 |
# Init the status |
949 |
$Status = 1; |
950 |
|
951 |
|
952 |
# Only check the database description file if it is available |
953 |
if ( defined($main::ConfigurationData{'database-description-file'}) ) { |
954 |
|
955 |
# Open the database description file |
956 |
if ( ! open(FILE, "$main::ConfigurationData{'database-description-file'}") ) { |
957 |
&vLog("Error - could not open database description file: '$main::ConfigurationData{'database-description-file'}'.\n"); |
958 |
return (0); |
959 |
} |
960 |
|
961 |
# Read in each line in the file, ignore empty |
962 |
# lines and lines which start with a '#' |
963 |
while (<FILE>) { |
964 |
|
965 |
chop $_; |
966 |
|
967 |
# Check to see if this line is empty or is a comment, and skip them |
968 |
if ( (length($_) == 0) || ($_ =~ /^#/) ) { |
969 |
next; |
970 |
} |
971 |
|
972 |
# Split the configuration string into a set of key/value pairs |
973 |
($Key, $KeyValue) = split(/=/, $_); |
974 |
|
975 |
# Only add values which are defined |
976 |
if ( defined($KeyValue) && ($KeyValue ne "") ) { |
977 |
|
978 |
# Split the key into a key and a subkey |
979 |
($KeyBase, $KeyLeaf) = split(/:/, $Key, 2); |
980 |
|
981 |
if ( $KeyBase eq $main::DatabaseName ) { |
982 |
|
983 |
# Add the key/value pairs to the hash table |
984 |
if ( defined($main::DatabaseDescriptions{$KeyLeaf}) ) { |
985 |
# Fail if the value for this key is already defined |
986 |
&vLog("Error - value for: '$KeyLeaf', is already defined as: '$main::DatabaseDescriptions{$KeyLeaf}', tried to redefine it to: '$KeyValue'.\n"); |
987 |
$Status = 0; |
988 |
} |
989 |
else { |
990 |
# Add the value for this key |
991 |
if ($KeyValue =~ s/(##sort[^#]+##)//) { |
992 |
$main::DatabaseSort{$1} = $KeyLeaf; |
993 |
} else { |
994 |
$main::DatabaseSort{$KeyValue} = $KeyLeaf; |
995 |
} |
996 |
$main::DatabaseDescriptions{$KeyLeaf} = $KeyValue; |
997 |
} |
998 |
} |
999 |
elsif ( $KeyBase eq $main::DatabaseFiltersPackage ) { |
1000 |
|
1001 |
# Add the key/value pairs to the hash table |
1002 |
if ( defined($main::DatabaseFilters{$Key}) ) { |
1003 |
# Fail if the value for this key is already defined |
1004 |
&vLog("Error - value for: '$Key', is already defined as: '$main::DatabaseFilters{$Key}', tried to redefine it to: '$KeyValue'.\n"); |
1005 |
$Status = 0; |
1006 |
} |
1007 |
else { |
1008 |
|
1009 |
# Check that this filters package exists |
1010 |
if ( ! -x $KeyValue ) { |
1011 |
# Fail we cant find it |
1012 |
&vLog("Error - filter: '$KeyValue' for: '$Key' could not be found.\n"); |
1013 |
$Status = 0; |
1014 |
} |
1015 |
|
1016 |
# Add the value for this key |
1017 |
$main::DatabaseFilters{$Key} = $KeyValue; |
1018 |
} |
1019 |
} |
1020 |
else { |
1021 |
|
1022 |
($Database) = split(/:/, $KeyLeaf); |
1023 |
|
1024 |
# Add the key/value pairs to the hash table |
1025 |
if ( ! defined($main::DatabaseFilters{"$main::DatabaseFiltersPackage:$Database"}) ) { |
1026 |
# Fail if we dont have the package for this function |
1027 |
&vLog("Error - package file for function: '$KeyValue', defined for: '$Key', cound not be found.\n"); |
1028 |
$Status = 0; |
1029 |
} |
1030 |
elsif ( defined($main::DatabaseFilters{$Key}) ) { |
1031 |
# Fail if the value for this key is already defined |
1032 |
&vLog("Error - value for: '$Key', is already defined as: '$main::DatabaseFilters{$Key}', tried to redefine it to: '$KeyValue'.\n"); |
1033 |
$Status = 0; |
1034 |
} |
1035 |
else { |
1036 |
|
1037 |
# Add the value for this key |
1038 |
$main::DatabaseFilters{$Key} = $KeyValue; |
1039 |
} |
1040 |
} |
1041 |
} |
1042 |
} |
1043 |
close(FILE); |
1044 |
} |
1045 |
|
1046 |
# fill defaults for rest |
1047 |
$main::DatabaseFilters{$Key} = $main::DatabaseFilters{default} if (! defined($main::DatabaseFilters{$Key})); |
1048 |
|
1049 |
return ($Status); |
1050 |
|
1051 |
} |
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
#-------------------------------------------------------------------------- |
1058 |
# |
1059 |
# Function: bInitializeServer() |
1060 |
# |
1061 |
# Purpose: This function sets up the server |
1062 |
# |
1063 |
# An error here should be considered fatal. |
1064 |
# |
1065 |
# Called by: |
1066 |
# |
1067 |
# Parameters: void |
1068 |
# |
1069 |
# Global Variables: %main::ConfigurationData |
1070 |
# |
1071 |
# Returns: Boolean status |
1072 |
# |
1073 |
sub bInitializeServer { |
1074 |
|
1075 |
my ($Status, $Text); |
1076 |
my ($ErrorNumber, $ErrorMessage); |
1077 |
|
1078 |
|
1079 |
# Initialize the server |
1080 |
($Status, $Text) = MPS::InitializeServer($main::ConfigurationData{'database-directory'}, $main::ConfigurationData{'configuration-directory'}, $main::ConfigurationData{'logs-directory'} . "/". $main::ConfigurationData{'server-log'}, MPS_LOG_MEDIUM); |
1081 |
|
1082 |
# Check the return code |
1083 |
if ( ! $Status ) { |
1084 |
($ErrorNumber, $ErrorMessage) = split(/\t/, $Text, 2); |
1085 |
&vHandleError("Database Search", "Sorry, failed to initialize the server"); |
1086 |
print("The following error message was reported: <BR>\n"); |
1087 |
print("Error Message: $ErrorMessage <BR>\n"); |
1088 |
print("Error Number: $ErrorNumber <BR>\n"); |
1089 |
} |
1090 |
|
1091 |
$main::MPSSession = $Text; |
1092 |
|
1093 |
return ($Status); |
1094 |
} |
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
#-------------------------------------------------------------------------- |
1101 |
# |
1102 |
# Function: bShutdownServer() |
1103 |
# |
1104 |
# Purpose: This function shuts down the server |
1105 |
# |
1106 |
# An error here should be considered fatal. |
1107 |
# |
1108 |
# Called by: |
1109 |
# |
1110 |
# Parameters: void |
1111 |
# |
1112 |
# Global Variables: %main::ConfigurationData |
1113 |
# |
1114 |
# Returns: Boolean status |
1115 |
# |
1116 |
sub bShutdownServer { |
1117 |
|
1118 |
|
1119 |
# Shutdown the server |
1120 |
MPS::ShutdownServer($main::MPSSession); |
1121 |
|
1122 |
return (1); |
1123 |
|
1124 |
} |
1125 |
|
1126 |
|
1127 |
|
1128 |
|
1129 |
|
1130 |
#-------------------------------------------------------------------------- |
1131 |
# |
1132 |
# Function: bCheckCGIEnvironment() |
1133 |
# |
1134 |
# Purpose: This function checks that all the CGI environment variables we |
1135 |
# need are available. It will exit if any of the variables are |
1136 |
# not found, but it will first list all the variables that are |
1137 |
# not available. |
1138 |
# |
1139 |
# An error here should be considered fatal. |
1140 |
# |
1141 |
# Called by: |
1142 |
# |
1143 |
# Parameters: void |
1144 |
# |
1145 |
# Global Variables: $ENV{} |
1146 |
# |
1147 |
# Returns: Boolean status |
1148 |
# |
1149 |
sub bCheckCGIEnvironment { |
1150 |
|
1151 |
my ($Status); |
1152 |
|
1153 |
|
1154 |
# Init the status |
1155 |
$Status = 1; |
1156 |
|
1157 |
|
1158 |
# Check that REQUEST_METHOD is specified |
1159 |
if ( ! (defined($ENV{'REQUEST_METHOD'}) && ($ENV{'REQUEST_METHOD'} ne "")) ) { |
1160 |
&vLog("Error - missing 'REQUEST_METHOD' environment variable.\n"); |
1161 |
$Status = 0; |
1162 |
} |
1163 |
|
1164 |
|
1165 |
# Check that SCRIPT_NAME is specified |
1166 |
if ( ! (defined($ENV{'SCRIPT_NAME'}) && ($ENV{'SCRIPT_NAME'} ne "")) ) { |
1167 |
&vLog("Error - missing 'SCRIPT_NAME' environment variable.\n"); |
1168 |
$Status = 0; |
1169 |
} |
1170 |
|
1171 |
|
1172 |
# Force guest |
1173 |
#$ENV{'REMOTE_USER'} = "guest"; |
1174 |
|
1175 |
# Make sure that REMOTE_USER is defined, we set it to an empty string if it is not |
1176 |
if ( ! (defined($ENV{'REMOTE_USER'}) && ($ENV{'REMOTE_USER'} ne "")) ) { |
1177 |
$ENV{'REMOTE_USER'} = ""; |
1178 |
} |
1179 |
else { |
1180 |
# REMOTE_USER is defined, we check to see if the guest account name is defined |
1181 |
if ( defined($main::ConfigurationData{'guest-account-name'}) ) { |
1182 |
# Set the REMOTE_USER to an empty string if it is the same as the guest account |
1183 |
if ( $ENV{'REMOTE_USER'} eq $main::ConfigurationData{'guest-account-name'} ) { |
1184 |
$ENV{'REMOTE_USER'} = ""; |
1185 |
} |
1186 |
} |
1187 |
} |
1188 |
|
1189 |
|
1190 |
# Adjust the path info if needed |
1191 |
if ( defined($ENV{'PATH_INFO'}) && defined($ENV{'SCRIPT_NAME'}) && (length($ENV{'PATH_INFO'}) > length($ENV{'SCRIPT_NAME'})) ) { |
1192 |
if ( substr($ENV{'PATH_INFO'}, 0, length($ENV{'SCRIPT_NAME'})) eq $ENV{'SCRIPT_NAME'} ) { |
1193 |
$ENV{'PATH_INFO'} = substr($ENV{'PATH_INFO'}, length($ENV{'SCRIPT_NAME'})); |
1194 |
$ENV{'PATH_INFO'} = undef if ($ENV{'PATH_INFO'} eq ""); |
1195 |
} |
1196 |
} |
1197 |
|
1198 |
|
1199 |
return ($Status); |
1200 |
|
1201 |
} |
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 |
#-------------------------------------------------------------------------- |
1207 |
# |
1208 |
# Function: bSetupCGIEnvironment() |
1209 |
# |
1210 |
# Purpose: This function sets up the environment for the CGI mode, it will |
1211 |
# also check that all the globals are correct and that any |
1212 |
# required directories can be accessed and written to |
1213 |
# |
1214 |
# An error here should be considered fatal. |
1215 |
# |
1216 |
# Called by: |
1217 |
# |
1218 |
# Parameters: void |
1219 |
# |
1220 |
# Global Variables: $main::UserAccountDirectoryPath, $main::UserSettingsFilePath, $main::RemoteUser, |
1221 |
# %main::FormData, %main::ConfigurationData |
1222 |
# |
1223 |
# Returns: Boolean status |
1224 |
# |
1225 |
sub bSetupCGIEnvironment { |
1226 |
|
1227 |
my ($Status, $URLString); |
1228 |
|
1229 |
|
1230 |
# Init the status |
1231 |
$Status = 1; |
1232 |
|
1233 |
|
1234 |
# Get the query string from the environment |
1235 |
if ( $ENV{'REQUEST_METHOD'} eq "GET" ) { |
1236 |
$URLString = $ENV{'QUERY_STRING'}; |
1237 |
} |
1238 |
# Get the query string from stdin |
1239 |
elsif ( $ENV{'REQUEST_METHOD'} eq "POST" ) { |
1240 |
read("STDIN", $URLString, $ENV{'CONTENT_LENGTH'}); |
1241 |
|
1242 |
# Append the query string if it is defined |
1243 |
if ( defined($ENV{'QUERY_STRING'}) && ($ENV{'QUERY_STRING'} ne "") ) { |
1244 |
$URLString = $ENV{'QUERY_STRING'} . "&". $URLString; |
1245 |
} |
1246 |
} |
1247 |
|
1248 |
|
1249 |
# Parse the form data that was passed |
1250 |
if ( defined($URLString) && ($URLString ne "") ) { |
1251 |
%main::FormData = &hParseURLIntoHashTable($URLString); |
1252 |
} |
1253 |
|
1254 |
|
1255 |
# Get the REMOTE_USER from the CGI environment and set the user account directory path |
1256 |
if ( (defined($ENV{'REMOTE_USER'})) && ($ENV{'REMOTE_USER'} ne "") && defined($main::ConfigurationData{'user-accounts-directory'}) ) { |
1257 |
$main::RemoteUser = $ENV{'REMOTE_USER'}; |
1258 |
$main::UserAccountDirectoryPath = $main::ConfigurationData{'user-accounts-directory'} . "/". $main::RemoteUser; |
1259 |
$main::UserAccountDirectoryPath =~ tr/\+/ /; |
1260 |
$main::UserSettingsFilePath = $main::UserAccountDirectoryPath . "/". $main::UserSettingsFileName . $main::XMLFileNameExtension; |
1261 |
} |
1262 |
else { |
1263 |
undef($main::RemoteUser); |
1264 |
undef($main::UserAccountDirectoryPath); |
1265 |
undef($main::UserSettingsFilePath); |
1266 |
} |
1267 |
|
1268 |
|
1269 |
# Check that the user account directory exists if it is specified |
1270 |
if ( defined($main::UserAccountDirectoryPath) ) { |
1271 |
|
1272 |
# Try to create the user account directory if it does not exist |
1273 |
if ( ! -d $main::UserAccountDirectoryPath ) { |
1274 |
|
1275 |
if ( mkdir($main::UserAccountDirectoryPath, 0700) ) { |
1276 |
|
1277 |
# Set the user account directory so that it can be accessed by ourselves only |
1278 |
chmod(0700, $main::UserAccountDirectoryPath); |
1279 |
|
1280 |
} |
1281 |
else { |
1282 |
|
1283 |
# The directory could not be created, so we inform the user of the fact |
1284 |
&vHandleError("User Account Error", "Sorry, the account directory could not be created"); |
1285 |
$Status = 0; |
1286 |
} |
1287 |
} |
1288 |
|
1289 |
|
1290 |
# Check that we can access user account directory |
1291 |
if ( ! ((-r $main::UserAccountDirectoryPath) && (-w $main::UserAccountDirectoryPath) && (-x $main::UserAccountDirectoryPath)) ) { |
1292 |
|
1293 |
# The directory cannot be accessed, so we inform the user of the fact |
1294 |
&vHandleError("User Account Error", "Sorry, the account directory could not be accessed"); |
1295 |
$Status = 0; |
1296 |
} |
1297 |
} |
1298 |
|
1299 |
|
1300 |
return ($Status); |
1301 |
|
1302 |
} |
1303 |
|
1304 |
|
1305 |
|
1306 |
|
1307 |
#-------------------------------------------------------------------------- |
1308 |
# |
1309 |
# Function: sMakeSearchURL() |
1310 |
# |
1311 |
# Purpose: This function makes a search URL from the passed content hash. |
1312 |
# |
1313 |
# Called by: |
1314 |
# |
1315 |
# Parameters: %Content content hash |
1316 |
# |
1317 |
# Global Variables: none |
1318 |
# |
1319 |
# Returns: the URL search string, and an empty string if |
1320 |
# nothing relevant is defined in the content |
1321 |
# |
1322 |
sub sMakeSearchURL { |
1323 |
|
1324 |
my (%Content) = @_; |
1325 |
|
1326 |
my ($SearchURL, $Value); |
1327 |
my (@InternalFieldNames) = ('Any', 'Operator', 'Past', 'Since', 'Before', 'LastRunTime', 'Order', 'Max', 'Database'); |
1328 |
|
1329 |
|
1330 |
# Initialize the search URL |
1331 |
$SearchURL = ""; |
1332 |
|
1333 |
|
1334 |
# Add the generic field names |
1335 |
foreach $Value ( 1..100 ) { |
1336 |
|
1337 |
my ($FieldName) = "FieldName" . $Value; |
1338 |
my ($FieldContent) = "FieldContent" . $Value; |
1339 |
|
1340 |
if ( defined($Content{$FieldName}) ) { |
1341 |
$SearchURL .= "&$FieldName=" . &lEncodeURLData($Content{$FieldName}); |
1342 |
$SearchURL .= defined($Content{$FieldContent}) ? "&$FieldContent=" . &lEncodeURLData($Content{$FieldContent}) : ""; |
1343 |
} |
1344 |
} |
1345 |
|
1346 |
|
1347 |
# Add the internal search terms |
1348 |
foreach $Value ( @InternalFieldNames ) { |
1349 |
$SearchURL .= defined($Content{$Value}) ? "&$Value=" . join("&$Value=", &lEncodeURLData(split(/\0/, $Content{$Value}))) : ""; |
1350 |
} |
1351 |
|
1352 |
|
1353 |
# Return the URL, choping out the initial '&' |
1354 |
return (($SearchURL ne "") ? substr($SearchURL, 1) : ""); |
1355 |
|
1356 |
} |
1357 |
|
1358 |
|
1359 |
|
1360 |
|
1361 |
|
1362 |
#-------------------------------------------------------------------------- |
1363 |
# |
1364 |
# Function: sMakeDocumentURL() |
1365 |
# |
1366 |
# Purpose: This function makes a document URL from the passed content hash. |
1367 |
# |
1368 |
# Called by: |
1369 |
# |
1370 |
# Parameters: %Content content hash |
1371 |
# |
1372 |
# Global Variables: none |
1373 |
# |
1374 |
# Returns: the URL document string, and an empty string if |
1375 |
# nothing relevant is defined in the content |
1376 |
# |
1377 |
sub sMakeDocumentURL { |
1378 |
|
1379 |
my (%Content) = @_; |
1380 |
|
1381 |
my ($DocumentURL); |
1382 |
|
1383 |
|
1384 |
# Initialize the document URL |
1385 |
$DocumentURL = ""; |
1386 |
|
1387 |
|
1388 |
# Add the document URLs |
1389 |
if ( defined($Content{'Document'}) ) { |
1390 |
$DocumentURL .= "&Document=" . join("&Document=", &lEncodeURLData(split(/\0/, $Content{'Document'}))); |
1391 |
} |
1392 |
|
1393 |
|
1394 |
# Return the URL, choping out the initial '&' |
1395 |
return (($DocumentURL ne "") ? substr($DocumentURL, 1) : ""); |
1396 |
|
1397 |
} |
1398 |
|
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 |
#-------------------------------------------------------------------------- |
1404 |
# |
1405 |
# Function: sMakeRfDocumentURL() |
1406 |
# |
1407 |
# Purpose: This function makes an RF document URL from the passed content hash. |
1408 |
# |
1409 |
# Called by: |
1410 |
# |
1411 |
# Parameters: %Content content hash |
1412 |
# |
1413 |
# Global Variables: none |
1414 |
# |
1415 |
# Returns: the URL RF document string, and an empty string if |
1416 |
# nothing relevant is defined in the content |
1417 |
# |
1418 |
sub sMakeRfDocumentURL { |
1419 |
|
1420 |
my (%Content) = @_; |
1421 |
|
1422 |
my ($RfDocumentURL); |
1423 |
|
1424 |
|
1425 |
# Initialize the RF document URL |
1426 |
$RfDocumentURL = ""; |
1427 |
|
1428 |
|
1429 |
# Add the RF document URLs |
1430 |
if ( defined($Content{'RfDocument'}) ) { |
1431 |
$RfDocumentURL .= "&RfDocument=" . join("&RfDocument=", &lEncodeURLData(split(/\0/, $Content{'RfDocument'}))); |
1432 |
} |
1433 |
|
1434 |
|
1435 |
# Return the URL, choping out the initial '&' |
1436 |
return (($RfDocumentURL ne "") ? substr($RfDocumentURL, 1) : ""); |
1437 |
|
1438 |
} |
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
#-------------------------------------------------------------------------- |
1445 |
# |
1446 |
# Function: sMakeSearchAndRfDocumentURL() |
1447 |
# |
1448 |
# Purpose: This function makes a URL string from the search |
1449 |
# and RF document URLs |
1450 |
# |
1451 |
# Called by: |
1452 |
# |
1453 |
# Parameters: %Content content hash |
1454 |
# |
1455 |
# Global Variables: none |
1456 |
# |
1457 |
# Returns: the URL query string, and an empty string if |
1458 |
# nothing relevant is defined in %Content |
1459 |
# |
1460 |
sub sMakeSearchAndRfDocumentURL { |
1461 |
|
1462 |
my (%Content) = @_; |
1463 |
|
1464 |
my ($SearchURL, $RfDocumentURL, $SearchRfDocumentURL); |
1465 |
|
1466 |
|
1467 |
# Get the search URL and the RF document URL |
1468 |
$SearchURL = &sMakeSearchURL(%Content); |
1469 |
$RfDocumentURL = &sMakeRfDocumentURL(%Content); |
1470 |
|
1471 |
|
1472 |
# Concatenate them intelligently |
1473 |
$SearchRfDocumentURL = $SearchURL . ((($SearchURL ne "") && ($RfDocumentURL ne "")) ? "&" : "") . $RfDocumentURL; |
1474 |
|
1475 |
|
1476 |
# Return the URL |
1477 |
return ($SearchRfDocumentURL); |
1478 |
|
1479 |
} |
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
#-------------------------------------------------------------------------- |
1485 |
# |
1486 |
# Function: sMakeSearchString() |
1487 |
# |
1488 |
# Purpose: This function makes a search string from the search |
1489 |
# variables in the content hash |
1490 |
# |
1491 |
# Called by: |
1492 |
# |
1493 |
# Parameters: %Content content hash |
1494 |
# |
1495 |
# Global Variables: void |
1496 |
# |
1497 |
# Returns: the search string, and an empty string if |
1498 |
# nothing relevant is defined in the content hash |
1499 |
# |
1500 |
sub sMakeSearchString { |
1501 |
|
1502 |
my (%Content) = @_; |
1503 |
|
1504 |
my ($SearchString); |
1505 |
my ($FieldName, $Time, $Date); |
1506 |
my ($Value); |
1507 |
|
1508 |
|
1509 |
# Initialize the search string |
1510 |
$SearchString = ""; |
1511 |
|
1512 |
|
1513 |
# Add the search terms |
1514 |
$SearchString .= defined($Content{'Any'}) ? ((($SearchString ne "") ? " AND " : "") . $Content{'Any'}) : ""; |
1515 |
|
1516 |
|
1517 |
# Add the generic field names |
1518 |
foreach $Value ( 1..100 ) { |
1519 |
|
1520 |
my ($FieldName) = "FieldName" . $Value; |
1521 |
my ($FieldContent) = "FieldContent" . $Value; |
1522 |
|
1523 |
|
1524 |
if ( defined($Content{$FieldName}) ) { |
1525 |
$SearchString .= defined($Content{$FieldContent}) ? |
1526 |
(($SearchString ne "") ? " AND " : "") . "$Content{$FieldName}=(" . $Content{$FieldContent} . ")" : ""; |
1527 |
} |
1528 |
} |
1529 |
|
1530 |
# nuke accented chars |
1531 |
$SearchString =~ tr/Çüéâäùæç³ëÕõî¬ÄÆÉÅåôö¥µ¦¶ÖÜ«»£èáíóú¡±®¾Êê¼ÈºÁÂ̪¯¿ÃãðÐÏËïÒÍÎìÞÙÓÔÑñò©¹ÀÚàÛýÝþ´½²·¢¸¨ÿØø/CueaauccleOoiZACELlooLlSsOUTtLcaiouAaZzEezCsAAESZzAadDDEdNIIeTUOoNnnSsRUrUyYt'-".'',"'Rr/; |
1532 |
# convert search string to lower case -> make search case insensitive |
1533 |
$SearchString =~ tr/A-Z/a-z/; |
1534 |
|
1535 |
# Add the internal search terms |
1536 |
|
1537 |
|
1538 |
# Add the date restriction on the load time |
1539 |
if ( defined($Content{'LastRunTime'}) && ($Content{'LastRunTime'} > 0) ) { |
1540 |
$SearchString .= (($SearchString ne "") ? " AND " : "") . "time_t>=$Content{'LastRunTime'}"; |
1541 |
} |
1542 |
|
1543 |
|
1544 |
# Add the Past date restriction |
1545 |
if ( defined($Content{'Past'}) && ($Content{'Past'} ne "0") ) { |
1546 |
|
1547 |
$Time = time(); |
1548 |
if ( $Content{'Past'} eq "Day" ) { |
1549 |
$Time = &tSubstractFromTime($Time, undef, undef, 1); |
1550 |
} |
1551 |
elsif ( $Content{'Past'} eq "Week" ) { |
1552 |
$Time = &tSubstractFromTime($Time, undef, undef, 7); |
1553 |
} |
1554 |
elsif ( $Content{'Past'} eq "Month" ) { |
1555 |
$Time = &tSubstractFromTime($Time, undef, 1, undef); |
1556 |
} |
1557 |
elsif ( $Content{'Past'} eq "3 Months" ) { |
1558 |
$Time = &tSubstractFromTime($Time, undef, 3, undef); |
1559 |
} |
1560 |
elsif ( $Content{'Past'} eq "6 Months" ) { |
1561 |
$Time = &tSubstractFromTime($Time, undef, 6, undef); |
1562 |
} |
1563 |
elsif ( $Content{'Past'} eq "9 Months" ) { |
1564 |
$Time = &tSubstractFromTime($Time, undef, 9, undef); |
1565 |
} |
1566 |
elsif ( $Content{'Past'} eq "Year" ) { |
1567 |
$Time = &tSubstractFromTime($Time, 1, undef undef); |
1568 |
} |
1569 |
|
1570 |
# Create an ANSI format date/time field |
1571 |
$Date = &sGetAnsiDateFromTime($Time); |
1572 |
$SearchString .= " {DATE>=$Date}"; |
1573 |
} |
1574 |
|
1575 |
|
1576 |
# Add the Since date restriction |
1577 |
if ( defined($Content{'Since'}) && ($Content{'Since'} ne "0") ) { |
1578 |
$SearchString .= " {DATE>=$Content{'Since'}0000}"; |
1579 |
} |
1580 |
|
1581 |
|
1582 |
# Add the Before date restriction |
1583 |
if ( defined($Content{'Before'}) && ($Content{'Before'} ne "0") ) { |
1584 |
$SearchString .= " {DATE<$Content{'Before'}0000}"; |
1585 |
} |
1586 |
|
1587 |
|
1588 |
# Add the document sort order |
1589 |
$SearchString .= defined($Content{'Order'}) ? " {" . $Content{'Order'} . "}" : ""; |
1590 |
|
1591 |
# Add the operator |
1592 |
$SearchString .= defined($Content{'Operator'}) ? " {" . $Content{'Operator'} . "}" : ""; |
1593 |
|
1594 |
|
1595 |
return (($SearchString ne "") ? $SearchString : undef); |
1596 |
|
1597 |
} |
1598 |
|
1599 |
|
1600 |
|
1601 |
|
1602 |
|
1603 |
#-------------------------------------------------------------------------- |
1604 |
# |
1605 |
# Function: hGetSearchStringHash() |
1606 |
# |
1607 |
# Purpose: This function makes a search string hash table from the search |
1608 |
# variables in the content hash |
1609 |
# |
1610 |
# Called by: |
1611 |
# |
1612 |
# Parameters: %Content content hash |
1613 |
# |
1614 |
# Global Variables: void |
1615 |
# |
1616 |
# Returns: the search string hash table, and an empty string if |
1617 |
# nothing relevant is defined in the content hash |
1618 |
# |
1619 |
sub hGetSearchStringHash { |
1620 |
|
1621 |
my (%Content) = @_; |
1622 |
|
1623 |
my ($Content); |
1624 |
my (%Value, @Values, $Value); |
1625 |
|
1626 |
|
1627 |
@Values = split(/ /, defined($Content{'Any'}) ? $Content{'Any'} : ""); |
1628 |
foreach $Value ( @Values ) { $Value = lc($Value); $Value{$Value} = $Value }; |
1629 |
|
1630 |
|
1631 |
# Add the generic field names |
1632 |
foreach $Value ( 1..100 ) { |
1633 |
|
1634 |
my ($FieldName) = "FieldName" . $Value; |
1635 |
my ($FieldContent) = "FieldContent" . $Value; |
1636 |
|
1637 |
if ( defined($Content{$FieldName}) ) { |
1638 |
@Values = split(/ /, defined($Content{$FieldContent}) ? $Content{$FieldContent} : ""); |
1639 |
foreach $Value ( @Values ) { $Value = lc($Value); $Value{$Value} = $Value }; |
1640 |
} |
1641 |
} |
1642 |
|
1643 |
|
1644 |
return (%Value); |
1645 |
|
1646 |
} |
1647 |
|
1648 |
|
1649 |
|
1650 |
|
1651 |
|
1652 |
#-------------------------------------------------------------------------- |
1653 |
# |
1654 |
# Function: hGetDocumentFolders() |
1655 |
# |
1656 |
# Purpose: This function returns a hash table of all the document folders |
1657 |
# |
1658 |
# Called by: |
1659 |
# |
1660 |
# Parameters: void |
1661 |
# |
1662 |
# Global Variables: void |
1663 |
# |
1664 |
# Returns: a hash table of document folders, the key being the folder name |
1665 |
# and the content being the folder file name |
1666 |
# |
1667 |
sub hGetDocumentFolders { |
1668 |
|
1669 |
my (@DocumentFolderList, $DocumentFolderEntry, $HeaderName, $FolderName, %QualifiedDocumentFolders); |
1670 |
|
1671 |
# Read all the document folder files |
1672 |
opendir(USER_ACCOUNT_DIRECTORY, $main::UserAccountDirectoryPath); |
1673 |
@DocumentFolderList = map("$main::UserAccountDirectoryPath/$_", reverse(sort(grep(/$main::DocumentFolderFileNamePrefix/, readdir(USER_ACCOUNT_DIRECTORY))))); |
1674 |
closedir(USER_ACCOUNT_DIRECTORY); |
1675 |
|
1676 |
|
1677 |
# Loop over each document folder file checking that it is valid |
1678 |
for $DocumentFolderEntry ( @DocumentFolderList ) { |
1679 |
|
1680 |
# Get the header name from the XML document folder file |
1681 |
$HeaderName = &sGetObjectTagFromXMLFile($DocumentFolderEntry); |
1682 |
|
1683 |
# Check that the entry is valid and add it to the qualified list |
1684 |
if ( defined($HeaderName) && ($HeaderName eq "DocumentFolder") ) { |
1685 |
$FolderName = &sGetTagValueFromXMLFile($DocumentFolderEntry, "FolderName"); |
1686 |
$QualifiedDocumentFolders{$FolderName} = $DocumentFolderEntry; |
1687 |
} |
1688 |
else { |
1689 |
# Else we delete this invalid document folder file |
1690 |
unlink($DocumentFolderEntry); |
1691 |
} |
1692 |
} |
1693 |
|
1694 |
|
1695 |
return (%QualifiedDocumentFolders); |
1696 |
|
1697 |
} |
1698 |
|
1699 |
|
1700 |
|
1701 |
|
1702 |
|
1703 |
#-------------------------------------------------------------------------- |
1704 |
# |
1705 |
# Function: iSaveSearchHistory() |
1706 |
# |
1707 |
# Purpose: This function saves the passed search to a new |
1708 |
# search history XML file. |
1709 |
# |
1710 |
# Called by: |
1711 |
# |
1712 |
# Parameters: $FileName search history file name ('undef' means create a new file name) |
1713 |
# $SearchAndRfDocumentURL search and RF document URL |
1714 |
# $SearchResults search results |
1715 |
# $QueryReport query report |
1716 |
# |
1717 |
# Global Variables: $main::UserAccountDirectoryPath, $main::XMLFileNameExtension, |
1718 |
# $main::SearchHistoryFileNamePrefix |
1719 |
# |
1720 |
# Returns: 0 on error, 1 on success |
1721 |
# |
1722 |
sub iSaveSearchHistory { |
1723 |
|
1724 |
my ($FileName, $SearchAndRfDocumentURL, $SearchResults, $QueryReport) = @_; |
1725 |
my ($SearchHistoryFilePath, %Value); |
1726 |
my ($AnsiDateTime); |
1727 |
|
1728 |
|
1729 |
# Return an error if the user account directory is not defined |
1730 |
if ( !(defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
1731 |
return (0); |
1732 |
} |
1733 |
|
1734 |
# Create a file name if one was not passed |
1735 |
if ( !defined($FileName) ) { |
1736 |
$AnsiDateTime = &sGetAnsiDateFromTime() . &sGetAnsiTimeFromTime(); |
1737 |
$SearchHistoryFilePath = $main::UserAccountDirectoryPath . "/". $main::SearchHistoryFileNamePrefix . "-" . $AnsiDateTime . $main::XMLFileNameExtension; |
1738 |
} |
1739 |
else { |
1740 |
$SearchHistoryFilePath = $FileName; |
1741 |
} |
1742 |
|
1743 |
|
1744 |
# Set the hash from the history information |
1745 |
undef(%Value); |
1746 |
$Value{'CreationTime'} = time(); |
1747 |
$Value{'SearchAndRfDocumentURL'} = $SearchAndRfDocumentURL; |
1748 |
$Value{'QueryReport'} = $QueryReport; |
1749 |
$Value{'SearchResults'} = $SearchResults; |
1750 |
|
1751 |
|
1752 |
# Save the search information |
1753 |
if ( ! &iSaveXMLFileFromHash($SearchHistoryFilePath, "SearchHistory", %Value) ) { |
1754 |
# Failed to save the information, so we return an error |
1755 |
return (0); |
1756 |
} |
1757 |
|
1758 |
return (1); |
1759 |
|
1760 |
} |
1761 |
|
1762 |
|
1763 |
|
1764 |
|
1765 |
|
1766 |
#-------------------------------------------------------------------------- |
1767 |
# |
1768 |
# Function: iSaveSearch() |
1769 |
# |
1770 |
# Purpose: This function saves the passed search to a new |
1771 |
# search XML file. |
1772 |
# |
1773 |
# Called by: |
1774 |
# |
1775 |
# Parameters: $FileName saved search file name ('undef' means create a new file name) |
1776 |
# $SearchName search name |
1777 |
# $SearchDescription search description |
1778 |
# $SearchAndRfDocumentURL search and RF document URL |
1779 |
# $SearchFrequency search frequency |
1780 |
# $DeliveryFormat delivery format |
1781 |
# $DeliveryMethod delivery method |
1782 |
# $SearchStatus search status |
1783 |
# $CreationTime creation time |
1784 |
# $LastRunTime last run time |
1785 |
# |
1786 |
# Global Variables: $main::UserAccountDirectoryPath, $main::XMLFileNameExtension, |
1787 |
# $main::SavedSearchFileNamePrefix |
1788 |
# |
1789 |
# Returns: 0 on error, 1 on success |
1790 |
# |
1791 |
sub iSaveSearch { |
1792 |
|
1793 |
my ($FileName, $SearchName, $SearchDescription, $SearchAndRfDocumentURL, $SearchFrequency, $DeliveryFormat, $DeliveryMethod, $SearchStatus, $CreationTime, $LastRunTime) = @_; |
1794 |
my ($SavedSearchFilePath, %Value); |
1795 |
my ($AnsiDateTime); |
1796 |
|
1797 |
|
1798 |
# Return an error if the user account directory is not defined |
1799 |
if ( !(defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
1800 |
return (0); |
1801 |
} |
1802 |
|
1803 |
# Create a file name if one was not passed |
1804 |
if ( !defined($FileName) ) { |
1805 |
$AnsiDateTime = &sGetAnsiDateFromTime() . &sGetAnsiTimeFromTime(); |
1806 |
$SavedSearchFilePath = $main::UserAccountDirectoryPath . "/". $main::SavedSearchFileNamePrefix . "-" . $AnsiDateTime . $main::XMLFileNameExtension; |
1807 |
} |
1808 |
else { |
1809 |
$SavedSearchFilePath = $FileName; |
1810 |
} |
1811 |
|
1812 |
|
1813 |
|
1814 |
# Set the hash from the search information |
1815 |
undef(%Value); |
1816 |
$Value{'SearchName'} = $SearchName; |
1817 |
$Value{'SearchDescription'} = $SearchDescription; |
1818 |
$Value{'SearchAndRfDocumentURL'} = $SearchAndRfDocumentURL; |
1819 |
$Value{'SearchFrequency'} = $SearchFrequency; |
1820 |
$Value{'DeliveryFormat'} = $DeliveryFormat; |
1821 |
$Value{'DeliveryMethod'} = $DeliveryMethod; |
1822 |
$Value{'SearchStatus'} = $SearchStatus; |
1823 |
$Value{'CreationTime'} = $CreationTime; |
1824 |
$Value{'LastRunTime'} = $LastRunTime; |
1825 |
|
1826 |
|
1827 |
# Save the search information |
1828 |
if ( ! &iSaveXMLFileFromHash($SavedSearchFilePath, "SavedSearch", %Value) ) { |
1829 |
# Failed to save the information, so we return an error |
1830 |
return (0); |
1831 |
} |
1832 |
|
1833 |
return (1); |
1834 |
|
1835 |
} |
1836 |
|
1837 |
|
1838 |
|
1839 |
|
1840 |
|
1841 |
#-------------------------------------------------------------------------- |
1842 |
# |
1843 |
# Function: iSaveFolder() |
1844 |
# |
1845 |
# Purpose: This function saves the passed folder to a new |
1846 |
# document folder XML file. |
1847 |
# |
1848 |
# Called by: |
1849 |
# |
1850 |
# Parameters: $FileName document folder file name ('undef' means create a new file name) |
1851 |
# $FolderName folder name |
1852 |
# $FolderDescription folder description |
1853 |
# $FolderDocuments folder document |
1854 |
# $CreationTime creation time |
1855 |
# $UpdateTime update time |
1856 |
# |
1857 |
# Global Variables: $main::UserAccountDirectoryPath, $main::XMLFileNameExtension, |
1858 |
# $main::DocumentFolderFileNamePrefix |
1859 |
# |
1860 |
# Returns: 0 on error, 1 on success |
1861 |
# |
1862 |
sub iSaveFolder { |
1863 |
|
1864 |
my ($FileName, $FolderName, $FolderDescription, $FolderDocuments, $CreationTime, $UpdateTime) = @_; |
1865 |
my ($DocumentFolderFilePath, %Value); |
1866 |
my ($AnsiDateTime); |
1867 |
|
1868 |
|
1869 |
# Return an error if the user account directory is not defined |
1870 |
if ( !defined($main::RemoteUser) || !defined($main::UserAccountDirectoryPath) ) { |
1871 |
return (0); |
1872 |
} |
1873 |
|
1874 |
# Create a file name if one was not passed |
1875 |
if ( !defined($FileName) ) { |
1876 |
$AnsiDateTime = &sGetAnsiDateFromTime() . &sGetAnsiTimeFromTime(); |
1877 |
$DocumentFolderFilePath = $main::UserAccountDirectoryPath . "/". $main::DocumentFolderFileNamePrefix . "-" . $AnsiDateTime . $main::XMLFileNameExtension; |
1878 |
} |
1879 |
else { |
1880 |
$DocumentFolderFilePath = $FileName; |
1881 |
} |
1882 |
|
1883 |
|
1884 |
|
1885 |
# Set the hash from the folder information |
1886 |
undef(%Value); |
1887 |
$Value{'FolderName'} = $FolderName; |
1888 |
$Value{'FolderDescription'} = $FolderDescription; |
1889 |
$Value{'FolderDocuments'} = $FolderDocuments; |
1890 |
$Value{'CreationTime'} = $CreationTime; |
1891 |
$Value{'UpdateTime'} = $UpdateTime; |
1892 |
|
1893 |
|
1894 |
# Save the document folder information |
1895 |
if ( ! &iSaveXMLFileFromHash($DocumentFolderFilePath, "DocumentFolder", %Value) ) { |
1896 |
# Failed to save the information, so we return an error |
1897 |
return (0); |
1898 |
} |
1899 |
|
1900 |
return (1); |
1901 |
|
1902 |
} |
1903 |
|
1904 |
|
1905 |
|
1906 |
|
1907 |
|
1908 |
#-------------------------------------------------------------------------- |
1909 |
# |
1910 |
# Function: bDisplayDocuments() |
1911 |
# |
1912 |
# Purpose: This function displays the document |
1913 |
# |
1914 |
# Called by: |
1915 |
# |
1916 |
# Parameters: $Title title |
1917 |
# $Documents \0 separated document URL |
1918 |
# $FieldName field name |
1919 |
# $Selector true to display selector |
1920 |
# $Selected selector is selected |
1921 |
# $HTML true to display HTML |
1922 |
# |
1923 |
# |
1924 |
# Global Variables: void |
1925 |
# |
1926 |
# Returns: the status |
1927 |
# |
1928 |
sub bDisplayDocuments { |
1929 |
|
1930 |
my ($Title, $Documents, $FieldName, $Selector, $Selected, $HTML) = @_; |
1931 |
|
1932 |
my (@Documents, $Document, $Status, $DocumentInfo, $SelectorText, $SelectedText, $LinkText); |
1933 |
my ($Database, $Headline, $Score, $DocumentID, $Date, $Time, $ItemName, $MimeType, $URL, $Length, $Remainder); |
1934 |
my (%Value, $Value, @Values); |
1935 |
|
1936 |
|
1937 |
# Check input parameters |
1938 |
if ( !defined($Documents) ) { |
1939 |
return (0); |
1940 |
} |
1941 |
|
1942 |
|
1943 |
# Split the documents text into a documents list |
1944 |
@Documents = split(/\0/, $Documents); |
1945 |
|
1946 |
|
1947 |
# Set the field name |
1948 |
$FieldName = (defined($FieldName ) && ($FieldName ne "")) ? $FieldName : "Document"; |
1949 |
|
1950 |
# Set the selected text |
1951 |
$SelectedText = ((defined($Selector) && $Selector) && (defined($Selected) && $Selected)) ? "CHECKED" : ""; |
1952 |
|
1953 |
|
1954 |
# Print the title |
1955 |
if ( $HTML ) { |
1956 |
printf("<TD ALIGN=LEFT VALIGN=TOP>%s%s:</TD><TD ALIGN=LEFT VALIGN=TOP>\n", |
1957 |
defined($Title) ? $Title : "Document", (scalar(@Documents) > 1) ? "s" : ""); |
1958 |
} |
1959 |
else { |
1960 |
printf("%s%s:\n", defined($Title) ? $Title : "Document", (scalar(@Documents) > 1) ? "s" : ""); |
1961 |
} |
1962 |
|
1963 |
|
1964 |
# Loop over each entry in the documents list |
1965 |
foreach $Document ( @Documents ) { |
1966 |
|
1967 |
# Parse out the document entry |
1968 |
%Value = &hParseURLIntoHashTable($Document); |
1969 |
|
1970 |
# Get the document information |
1971 |
($Status, $DocumentInfo) = MPS::GetDocumentInfo($main::MPSSession, $Value{'Database'}, $Value{'DocumentID'}); |
1972 |
|
1973 |
if ( $Status ) { |
1974 |
($Headline, $Date, $Time, $ItemName, $MimeType, $URL, $Length, $Remainder) = split(/\t/, $DocumentInfo, 8); |
1975 |
|
1976 |
# Decode the headline and strip the HTML |
1977 |
$Headline = &lDecodeURLData($Headline); |
1978 |
$Headline =~ s/ //gs; |
1979 |
$Headline =~ s/<.*?>//gs; |
1980 |
$Headline =~ s/\s+/ /gs; |
1981 |
|
1982 |
# Create a generic link for this document |
1983 |
$Value = ""; |
1984 |
$Value .= (defined($Value{'Database'}) && ($Value{'Database'} ne "")) ? "&Database=" . &lEncodeURLData($Value{'Database'}) : ""; |
1985 |
$Value .= (defined($Value{'DocumentID'}) && ($Value{'DocumentID'} ne "")) ? "&DocumentID=" . &lEncodeURLData($Value{'DocumentID'}) : ""; |
1986 |
$Value .= (defined($ItemName) && ($ItemName ne "")) ? "&ItemName=" . &lEncodeURLData($ItemName) : ""; |
1987 |
$Value .= (defined($MimeType) && ($MimeType ne "")) ? "&MimeType=" . &lEncodeURLData($MimeType) : ""; |
1988 |
|
1989 |
|
1990 |
# Create the selector text |
1991 |
if ( defined($Selector) && $Selector ) { |
1992 |
$SelectorText = "<INPUT TYPE=\"checkbox\" NAME=\"$FieldName\" VALUE=\"" . substr($Value, 1) . "\" $SelectedText> "; |
1993 |
} |
1994 |
else { |
1995 |
$SelectorText = " - "; |
1996 |
} |
1997 |
|
1998 |
# Create the link text, we use the URL if it is there |
1999 |
if ( defined($URL) && ($URL ne "") ) { |
2000 |
$LinkText = $URL; |
2001 |
} |
2002 |
elsif ( defined($Value{'DocumentID'}) && ($Value{'DocumentID'} ne "") ) { |
2003 |
$LinkText = "$ENV{'SCRIPT_NAME'}/GetDocument?" . substr($Value, 1); |
2004 |
} |
2005 |
else { |
2006 |
$LinkText = ""; |
2007 |
} |
2008 |
|
2009 |
# Put up the headline and the score, this one links to the document |
2010 |
if ( $HTML ) { |
2011 |
print("$SelectorText <A HREF=\"$LinkText\" OnMouseOver=\"self.status='Retrieve this document'; return true\"> $Headline <I> ( $main::DatabaseDescriptions{$Value{'Database'}} ) </I> </A> <BR>\n"); |
2012 |
|
2013 |
# if ( defined($URL) && ($URL ne "") ) { |
2014 |
# $Value = (length($URL) > $main::DefaultMaxVisibleUrlLength) ? substr($URL, 0, $main::DefaultMaxVisibleUrlLength) . "..." : $URL; |
2015 |
# print("<FONT SIZE=-2><A HREF=\"$URL\"> $Value </A></FONT><BR>\n"); |
2016 |
# } |
2017 |
} |
2018 |
else { |
2019 |
print("- $Headline ($main::DatabaseDescriptions{$Value{'Database'}})\n URL: $LinkText\n"); |
2020 |
} |
2021 |
} |
2022 |
} |
2023 |
|
2024 |
if ( $HTML ) { |
2025 |
print("</TD>\n"); |
2026 |
} |
2027 |
|
2028 |
|
2029 |
return (1); |
2030 |
|
2031 |
} |
2032 |
|
2033 |
|
2034 |
|
2035 |
|
2036 |
|
2037 |
|
2038 |
#-------------------------------------------------------------------------- |
2039 |
# |
2040 |
# Function: bsDisplaySearchResults() |
2041 |
# |
2042 |
# Purpose: This function displays the search results |
2043 |
# |
2044 |
# Called by: |
2045 |
# |
2046 |
# Parameters: $Title title |
2047 |
# $SearchResults search results |
2048 |
# $SearchDate search date |
2049 |
# $SearchFrequency search frequency |
2050 |
# $SearchDescription search description |
2051 |
# $QueryReport query report |
2052 |
# $ScriptName script name |
2053 |
# $Header true to display header |
2054 |
# $Selector true to display selector |
2055 |
# $HTML true to display HTML |
2056 |
# %Content content hash table |
2057 |
# |
2058 |
# |
2059 |
# Global Variables: %main::ConfigurationData, $main::RemoteUser, |
2060 |
# $main::QueryReportItemName, $main::QueryReportMimeType |
2061 |
# |
2062 |
# Returns: the status and a the query report |
2063 |
# |
2064 |
sub bsDisplaySearchResults { |
2065 |
|
2066 |
my ($Title, $SearchDescription, $SearchDate, $SearchFrequency, $SearchResults, $QueryReport, $ScriptName, $Header, $Selector, $HTML, %Content) = @_; |
2067 |
|
2068 |
my ($SearchString, $SummaryType, $SummaryLength, @SearchResults, $SearchResult, $FinalQueryReport, $ResultCount, %SearchStringHash); |
2069 |
my ($Database, $Headline, $Score, $DocumentID, $Date, $Time, $ItemName, $MimeType, $URL, $Length, $Remainder); |
2070 |
my ($Status, $Text, $MimeTypeName, $SummaryText, $SelectorText, $LinkText, $RuleFlag, $LastItemName); |
2071 |
my (@DocumentFolderList, %QualifiedDocumentFolders, $DocumentFolderEntry, $HeaderName, $FolderName, $Index); |
2072 |
my (@Words, $Word, @OffsetPairs, $OffsetPair, %Offsets, $Offset, $Start, $End, $OldStart, $OldEnd, $CurrentSummaryLength); |
2073 |
my ($DatabaseSummaryFilterKey, $DatabaseSummaryFilterFunction); |
2074 |
my ($Value, %Value, @Values, $ValueEntry); |
2075 |
|
2076 |
|
2077 |
# Check input parameters |
2078 |
if ( !defined($SearchResults) || !%Content ) { |
2079 |
return (0); |
2080 |
} |
2081 |
|
2082 |
# Split the search results text into a search results list |
2083 |
@SearchResults = split(/\n/, $SearchResults); |
2084 |
|
2085 |
|
2086 |
# First we count up the number of results and scoop up |
2087 |
# any query reports if we need to |
2088 |
|
2089 |
# Initialize the final query report |
2090 |
if ( !defined($QueryReport) ) { |
2091 |
$FinalQueryReport = ""; |
2092 |
} |
2093 |
else { |
2094 |
$FinalQueryReport = $QueryReport; |
2095 |
} |
2096 |
|
2097 |
|
2098 |
# Loop over each entry in the search results list |
2099 |
$ResultCount = 0; |
2100 |
foreach $SearchResult ( @SearchResults ) { |
2101 |
|
2102 |
# Parse the headline, also get the first document item/type |
2103 |
($Database, $Headline, $Score, $DocumentID, $Date, $Time, $ItemName, $MimeType, $URL, $Length, $Remainder) = split(/\t/, $SearchResult, 11); |
2104 |
|
2105 |
# Is this a query report |
2106 |
if ( ($ItemName eq $main::QueryReportItemName) && ($MimeType eq $main::QueryReportMimeType) ) { |
2107 |
|
2108 |
# Retrieve the query report if it was not passed to us |
2109 |
if ( !defined($QueryReport) ) { |
2110 |
($Status, $Text) = MPS::GetDocument($main::MPSSession, $Database, $DocumentID, $ItemName, $MimeType); |
2111 |
|
2112 |
if ( $Status ) { |
2113 |
# Concatenate it to the query report text we have already got |
2114 |
$FinalQueryReport .= $Text; |
2115 |
} |
2116 |
} |
2117 |
} |
2118 |
else { |
2119 |
# Increment the result count |
2120 |
$ResultCount++; |
2121 |
} |
2122 |
} |
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 |
# Finally, we get information we are going to need later on |
2128 |
|
2129 |
# Get the search string |
2130 |
$SearchString = &sMakeSearchString(%Content); |
2131 |
if ( defined($SearchString) ) { |
2132 |
$SearchString =~ s/{.*?}//gs; |
2133 |
$SearchString = ($SearchString =~ /\S/) ? $SearchString : undef; |
2134 |
} |
2135 |
$SearchString = defined($SearchString) ? $SearchString : "(No search terms defined)"; |
2136 |
|
2137 |
# Get the search string hash |
2138 |
%SearchStringHash = &hGetSearchStringHash(%Content); |
2139 |
|
2140 |
# Do some very basic plural stemming |
2141 |
foreach $Value ( keys (%SearchStringHash) ) { |
2142 |
$Value =~ s/ies\Z/y/g; |
2143 |
$Value =~ s/s\Z//g; |
2144 |
$SearchStringHash{$Value} = $Value; |
2145 |
} |
2146 |
|
2147 |
|
2148 |
|
2149 |
# Get the summary information |
2150 |
if ( defined($main::RemoteUser) ) { |
2151 |
|
2152 |
$SummaryType = &sGetTagValueFromXMLFile($main::UserSettingsFilePath, "SummaryType"); |
2153 |
$SummaryLength = &sGetTagValueFromXMLFile($main::UserSettingsFilePath, "SummaryLength"); |
2154 |
|
2155 |
if ( !(defined($SummaryLength) && ($SummaryLength ne "")) ) { |
2156 |
$SummaryLength = $main::DefaultSummaryLength; |
2157 |
} |
2158 |
if ( !(defined($SummaryType) && ($SummaryType ne "")) ) { |
2159 |
$SummaryType = $main::DefaultSummaryType; |
2160 |
} |
2161 |
} |
2162 |
else { |
2163 |
$SummaryType = $main::DefaultSummaryType; |
2164 |
$SummaryLength = $main::DefaultSummaryLength; |
2165 |
} |
2166 |
|
2167 |
|
2168 |
# Print the header if needed |
2169 |
if ( $Header ) { |
2170 |
|
2171 |
if ( $HTML ) { |
2172 |
# Print the title and the start of the form |
2173 |
printf("<H3>%s</H3>\n", defined($Title) ? $Title : "Rezultati pretra¾ivanja:"); |
2174 |
|
2175 |
# Start the form |
2176 |
print("<FORM ACTION=\"$ScriptName\" METHOD=POST>\n"); |
2177 |
|
2178 |
|
2179 |
# List the hidden fields |
2180 |
%Value = &hParseURLIntoHashTable(&sMakeSearchURL(%Content)); |
2181 |
foreach $Value ( keys(%Value) ) { |
2182 |
foreach $ValueEntry ( split(/\0/, $Value{$Value}) ) { |
2183 |
print("<INPUT TYPE=HIDDEN NAME=\"$Value\" VALUE=\"$ValueEntry\">\n"); |
2184 |
} |
2185 |
} |
2186 |
|
2187 |
|
2188 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
2189 |
|
2190 |
# Print the selector |
2191 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP>Odabranima se smatraju svi rezultati ukoliko niste uèinili nikakav dodatan odabir.</TD><TD ALIGN=RIGHT VALIGN=TOP> \n"); |
2192 |
|
2193 |
if ( $ResultCount > 0 ) { |
2194 |
|
2195 |
if ( defined($main::RemoteUser) ) { |
2196 |
print("<SELECT NAME=\"Action\">\n"); |
2197 |
|
2198 |
print("<OPTION VALUE=\"GetDocument\">Prika¾i odabrane rezultate\n"); |
2199 |
if |
2200 |
( $main::ConfigurationData{'allow-similiar-search'} eq "yes" ) { |
2201 |
print("<OPTION VALUE=\"GetSimilarDocument\">Prika¾i rezultate sliène odabranim rezultatima\n"); |
2202 |
} |
2203 |
if ( $main::ConfigurationData{'allow-relevance-feedback-searches'} eq "yes" ) { |
2204 |
print("<OPTION VALUE=\"GetSearchResults\">Run search with selected documents as relevance feedback\n"); |
2205 |
} |
2206 |
print("<OPTION VALUE=\"GetSaveSearch\">Saèuvaj rezultate pretra¾ivanja\n"); |
2207 |
print("<OPTION VALUE=\"GetSaveFolder\">Saèuvaj odabrane rezultate u novi folder\n"); |
2208 |
|
2209 |
# Get the document folder hash |
2210 |
%QualifiedDocumentFolders = &hGetDocumentFolders; |
2211 |
|
2212 |
for $FolderName ( sort( keys(%QualifiedDocumentFolders)) ) { |
2213 |
|
2214 |
$DocumentFolderEntry = $QualifiedDocumentFolders{$FolderName}; |
2215 |
|
2216 |
# Get the document folder file name and encode it |
2217 |
$DocumentFolderEntry = ($DocumentFolderEntry =~ /^$main::UserAccountDirectoryPath\/(.*)/) ? $1 : $DocumentFolderEntry; |
2218 |
$DocumentFolderEntry = &lEncodeURLData($DocumentFolderEntry); |
2219 |
|
2220 |
print("<OPTION VALUE=\"SetSaveFolder&DocumentFolderObject=$DocumentFolderEntry\">Dodaj odabrane rezultate u '$FolderName' folder\n"); |
2221 |
} |
2222 |
print("</SELECT>\n"); |
2223 |
print("<INPUT TYPE=SUBMIT VALUE=\"Do It!\">\n"); |
2224 |
} |
2225 |
else { |
2226 |
print("<SELECT NAME=\"Action\">\n"); |
2227 |
print("<OPTION VALUE=\"GetDocument\">Prika¾i odabrane rezultate\n"); |
2228 |
if ( $main::ConfigurationData{'allow-similiar-search'} eq "yes" ) { |
2229 |
print("<OPTION VALUE=\"GetSimilarDocument\">Prika¾i rezultate sliène odabranim rezultatima\n"); |
2230 |
} |
2231 |
if ( $main::ConfigurationData{'allow-relevance-feedback-searches'} eq "yes" ) { |
2232 |
print("<OPTION VALUE=\"GetSearchResults\">Run search with selected documents as relevance feedback\n"); |
2233 |
} |
2234 |
print("</SELECT>\n"); |
2235 |
print("<INPUT TYPE=SUBMIT VALUE=\"Do It!\">\n"); |
2236 |
} |
2237 |
} |
2238 |
else { |
2239 |
if ( defined($main::RemoteUser) ) { |
2240 |
print("<INPUT TYPE=HIDDEN NAME=\"Action\" VALUE=\"GetSaveSearch\">\n"); |
2241 |
print("<INPUT TYPE=SUBMIT VALUE=\"Save this search\">\n"); |
2242 |
} |
2243 |
} |
2244 |
|
2245 |
print("</TD></TR>\n"); |
2246 |
print("</TABLE>\n"); |
2247 |
} |
2248 |
else { |
2249 |
printf("%s\n", defined($Title) ? $Title : "Rezultati pretra¾ivanja:"); |
2250 |
} |
2251 |
|
2252 |
|
2253 |
# Display the search string |
2254 |
if ( $HTML ) { |
2255 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
2256 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
2257 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Upit: </TD> <TD ALIGN=LEFT VALIGN=TOP> $SearchString </TD></TR>\n"); |
2258 |
} |
2259 |
else { |
2260 |
print("--------------------------------------------------------------\n"); |
2261 |
print(" - Search for : $SearchString\n"); |
2262 |
} |
2263 |
|
2264 |
|
2265 |
# Display the description |
2266 |
if ( defined($SearchDescription) ) { |
2267 |
if ( $HTML ) { |
2268 |
$SearchDescription =~ s/\n/<BR>/g; |
2269 |
$SearchDescription =~ s/\r/<BR>/g; |
2270 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Opis: </TD> <TD ALIGN=LEFT VALIGN=TOP> $SearchDescription </TD></TR>\n"); |
2271 |
} |
2272 |
else { |
2273 |
print(" - Description : $SearchDescription\n"); |
2274 |
} |
2275 |
} |
2276 |
|
2277 |
# Display the date |
2278 |
if ( defined($SearchDate) ) { |
2279 |
if ( $HTML ) { |
2280 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Run on: </TD> <TD ALIGN=LEFT VALIGN=TOP> $SearchDate </TD></TR>\n"); |
2281 |
} |
2282 |
else { |
2283 |
print(" - Run on : $SearchDate\n"); |
2284 |
} |
2285 |
} |
2286 |
|
2287 |
# Display the frequency |
2288 |
if ( defined($SearchFrequency) ) { |
2289 |
if ( $HTML ) { |
2290 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Frequency: </TD> <TD ALIGN=LEFT VALIGN=TOP> $SearchFrequency </TD></TR>\n"); |
2291 |
} |
2292 |
else { |
2293 |
print(" - Frequency : $SearchFrequency\n"); |
2294 |
} |
2295 |
} |
2296 |
|
2297 |
|
2298 |
|
2299 |
# Get the databases from the search and list their descriptions |
2300 |
if ( defined($Content{'Database'}) ) { |
2301 |
|
2302 |
# Initialize the temp list |
2303 |
undef(@Values); |
2304 |
|
2305 |
# Loop over each database |
2306 |
foreach $Database ( split(/\0/, $Content{'Database'}) ) { |
2307 |
$Value = &lEncodeURLData($Database); |
2308 |
if ( $HTML ) { |
2309 |
push @Values, sprintf("<A HREF=\"$ScriptName/GetDatabaseInfo?Database=$Value\" OnMouseOver=\"self.status='Get Information about the $main::DatabaseDescriptions{$Database} database'; return true\"> $main::DatabaseDescriptions{$Database} </A> "); |
2310 |
} |
2311 |
else { |
2312 |
push @Values, sprintf("$main::DatabaseDescriptions{$Database} "); |
2313 |
} |
2314 |
} |
2315 |
|
2316 |
# Print the list if there are any entries in it |
2317 |
if ( scalar(@Values) > 0 ) { |
2318 |
if ( $HTML ) { |
2319 |
printf("<TR><TD ALIGN=LEFT VALIGN=TOP> Database%s: </TD> <TD ALIGN=LEFT VALIGN=TOP> %s </TD></TR>\n", |
2320 |
(scalar(@Values) > 1) ? "s" : "", join(", ", @Values)); |
2321 |
} |
2322 |
else { |
2323 |
printf(" - Database%s : %s\n", (scalar(@Values) > 1) ? "s" : " ", join(", ", @Values)); |
2324 |
} |
2325 |
} |
2326 |
} |
2327 |
|
2328 |
|
2329 |
# Display any feedback documents |
2330 |
if ( defined($Content{'RfDocument'}) ) { |
2331 |
if ( $HTML ) { |
2332 |
print("<TR>\n"); |
2333 |
} |
2334 |
&bDisplayDocuments("Feedback Document", $Content{'RfDocument'}, "RfDocument", 1, 1, $HTML); |
2335 |
if ( $HTML ) { |
2336 |
print("</TR>\n"); |
2337 |
} |
2338 |
} |
2339 |
|
2340 |
|
2341 |
if ( $HTML ) { |
2342 |
printf("<TR><TD ALIGN=LEFT VALIGN=TOP> Pronaðeno: </TD> <TD ALIGN=LEFT VALIGN=TOP> %s rezultata (Maksimalni broj pode¹en na: $Content{'Max'} ) </TD></TR>\n", |
2343 |
($ResultCount > 0) ? $ResultCount : "no"); |
2344 |
|
2345 |
print("</TABLE>\n"); |
2346 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
2347 |
} |
2348 |
else { |
2349 |
printf(" - Results : %s\n", ($ResultCount > 0) ? $ResultCount : "no"); |
2350 |
print("--------------------------------------------------------------\n\n"); |
2351 |
} |
2352 |
} |
2353 |
|
2354 |
|
2355 |
# Start the table |
2356 |
if ( $HTML ) { |
2357 |
print("<!-- searchResults -->\n"); |
2358 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
2359 |
|
2360 |
# Display a button to select all the documents |
2361 |
if ( $ResultCount > 0 ) { |
2362 |
|
2363 |
if ( defined($Selector) && $Selector ) { |
2364 |
|
2365 |
$SelectorText = ""; |
2366 |
|
2367 |
# Loop over each entry in the hits list |
2368 |
foreach $SearchResult ( @SearchResults ) { |
2369 |
|
2370 |
# Parse the headline, also get the first document item/type |
2371 |
($Database, $Headline, $Score, $DocumentID, $Date, $Time, $ItemName, $MimeType, $URL, $Length, $Remainder) = split(/\t/, $SearchResult, 11); |
2372 |
|
2373 |
# Skip query reports |
2374 |
if ( ($ItemName eq $main::QueryReportItemName) && ($MimeType eq $main::QueryReportMimeType) ) { |
2375 |
next; |
2376 |
} |
2377 |
|
2378 |
$Value = ""; |
2379 |
$Value .= (defined($Database) && ($Database ne "")) ? "&Database=" . &lEncodeURLData($Database) : ""; |
2380 |
$Value .= (defined($DocumentID) && ($DocumentID ne "")) ? "&DocumentID=" . &lEncodeURLData($DocumentID) : ""; |
2381 |
$Value .= (defined($ItemName) && ($ItemName ne "")) ? "&ItemName=" . &lEncodeURLData($ItemName) : ""; |
2382 |
$Value .= (defined($MimeType) && ($MimeType ne "")) ? "&MimeType=" . &lEncodeURLData($MimeType) : ""; |
2383 |
$SelectorText .= (($SelectorText ne "") ? "|" : "") . substr($Value, 1); |
2384 |
} |
2385 |
|
2386 |
$SelectorText = "<INPUT TYPE=\"HIDDEN\" NAME=\"Documents\" VALUE=\"" . $SelectorText . "\"> "; |
2387 |
print("<TR><TD ALIGN=RIGHT VALIGN=TOP COLSPAN=3> $SelectorText </TD></TR>\n"); |
2388 |
} |
2389 |
} |
2390 |
} |
2391 |
|
2392 |
|
2393 |
### FIX:: ADD SORT HERE |
2394 |
if ( $ResultCount > 0 ) { |
2395 |
|
2396 |
# Loop over each entry in the hits list |
2397 |
foreach $SearchResult ( @SearchResults ) { |
2398 |
|
2399 |
# Parse the headline, also get the first document item/type |
2400 |
($Database, $Headline, $Score, $DocumentID, $Date, $Time, $ItemName, $MimeType, $URL, $Length, $Remainder) = split(/\t/, $SearchResult, 11); |
2401 |
|
2402 |
# Skip query reports |
2403 |
if ( ($ItemName eq $main::QueryReportItemName) && ($MimeType eq $main::QueryReportMimeType) ) { |
2404 |
next; |
2405 |
} |
2406 |
|
2407 |
|
2408 |
# Put a separator between each entry |
2409 |
if ( defined($Remainder) ) { |
2410 |
|
2411 |
if ( defined($RuleFlag) && ($RuleFlag) ) { |
2412 |
if ( $HTML ) { |
2413 |
print("<TR><TD COLSPAN=3><HR WIDTH=25%></TD></TR>\n"); |
2414 |
} |
2415 |
else { |
2416 |
print("--------------------------------------------------------------\n\n"); |
2417 |
} |
2418 |
} |
2419 |
|
2420 |
$RuleFlag = 1; |
2421 |
} |
2422 |
|
2423 |
|
2424 |
# Get the summary if needed |
2425 |
if ( defined($main::ConfigurationData{'allow-summary-displays'}) && ($main::ConfigurationData{'allow-summary-displays'} eq "yes") && |
2426 |
($SummaryType ne "none") ) { |
2427 |
|
2428 |
($Status, $Text) = MPS::GetDocument($main::MPSSession, $Database, $DocumentID, $ItemName, $MimeType); |
2429 |
|
2430 |
if ( $Status ) { |
2431 |
|
2432 |
# Then process for each summary type |
2433 |
if ( $SummaryType eq "default" ) { |
2434 |
|
2435 |
$DatabaseSummaryFilterKey = "$main::DatabaseSummaryFilter:$Database:$ItemName:$MimeType"; |
2436 |
|
2437 |
# Is a filter defined for this database summary filter key ? |
2438 |
if ( defined($main::DatabaseFilters{$DatabaseSummaryFilterKey}) ) { |
2439 |
|
2440 |
# Pull in the package |
2441 |
require $main::DatabaseFilters{"$main::DatabaseFiltersPackage:$Database"}; |
2442 |
|
2443 |
# Filter the document |
2444 |
$Value = $main::DatabaseFilters{$DatabaseSummaryFilterKey}; |
2445 |
$DatabaseSummaryFilterFunction = \&$Value; |
2446 |
$Text = $DatabaseSummaryFilterFunction->($Database, $DocumentID, $ItemName, $MimeType, $Text); |
2447 |
|
2448 |
} |
2449 |
|
2450 |
# Truncate the summary to the length requested |
2451 |
if ( defined ($Text) && ($Text ne "") ) { |
2452 |
|
2453 |
$CurrentSummaryLength = 0; |
2454 |
$SummaryText = ""; |
2455 |
|
2456 |
# Split the document text |
2457 |
@Words = split(/(\W)/, $Text); |
2458 |
|
2459 |
# Loop over each word |
2460 |
foreach $Offset ( 0..scalar(@Words) ) { |
2461 |
|
2462 |
# Skip undefined words |
2463 |
if ( !defined($Words[$Offset]) ) { |
2464 |
next; |
2465 |
} |
2466 |
|
2467 |
# Increment and check the summary length |
2468 |
if ( $Words[$Offset] ne " " ) { |
2469 |
|
2470 |
$CurrentSummaryLength++; |
2471 |
|
2472 |
if ( $CurrentSummaryLength > $SummaryLength ) { |
2473 |
# Append a diaresys at the end and bail |
2474 |
$SummaryText .= "..."; |
2475 |
last; |
2476 |
} |
2477 |
} |
2478 |
|
2479 |
# Append the current word to the end of the summary |
2480 |
$SummaryText .= $Words[$Offset]; |
2481 |
} |
2482 |
} |
2483 |
else { |
2484 |
$SummaryText = "(Document summary unavailable)"; |
2485 |
} |
2486 |
} |
2487 |
elsif ( $SummaryType eq "keyword" ) { |
2488 |
|
2489 |
# First clean up the text |
2490 |
if ( index($Text, "\r\n") >= 0 ) { |
2491 |
$Text =~ s/\r//gs; |
2492 |
} |
2493 |
elsif ( index($Text, "\r") >= 0 ) { |
2494 |
$Text =~ s/\r/\n/gs; |
2495 |
} |
2496 |
if ( defined($main::HtmlMimeTypes{$MimeType}) ) { |
2497 |
if ( ($Index = index($Text, "\n\n")) >= 0 ) { |
2498 |
$Text = substr($Text, $Index); |
2499 |
} |
2500 |
$Text =~ s/ //gs; |
2501 |
$Text =~ s/<.*?>//gs; |
2502 |
} |
2503 |
$Text =~ s/\n/ /gs; |
2504 |
$Text =~ s/\s+/ /gs; |
2505 |
$Text = ucfirst($Text); |
2506 |
|
2507 |
# Initialize our variables |
2508 |
$OldStart = -1; |
2509 |
$OldEnd = -1; |
2510 |
|
2511 |
$Start = -1; |
2512 |
$End = -1; |
2513 |
|
2514 |
$CurrentSummaryLength = 0; |
2515 |
|
2516 |
# Reset the offset pairs and offsets |
2517 |
undef(@OffsetPairs); |
2518 |
undef(%Offsets); |
2519 |
|
2520 |
|
2521 |
# Split the document text |
2522 |
@Words = split(/(\W)/, $Text); |
2523 |
|
2524 |
|
2525 |
# Loop over each word, checking to see if it is in the search string hash table |
2526 |
# and build the offset list as we go along, check with the previous offset to see |
2527 |
# if there is an overlap |
2528 |
foreach $Offset ( 0..scalar(@Words) ) { |
2529 |
|
2530 |
if ( !defined($Words[$Offset]) ) { |
2531 |
next; |
2532 |
} |
2533 |
|
2534 |
# Downcase the word |
2535 |
$Word = lc($Words[$Offset]); |
2536 |
|
2537 |
# Very basic plural stemming |
2538 |
$Word =~ s/ies\Z/y/g; |
2539 |
$Word =~ s/s\Z//g; |
2540 |
|
2541 |
if ( !defined($SearchStringHash{$Word}) ) { |
2542 |
next; |
2543 |
} |
2544 |
|
2545 |
$Start = ($Offset < $main::SummaryKeywordSpan) ? 0 : $Offset - $main::SummaryKeywordSpan; |
2546 |
$End = (($Offset + $main::SummaryKeywordSpan) > (scalar(@Words) - 1)) ? (scalar(@Words) - 1) : $Offset + $main::SummaryKeywordSpan; |
2547 |
|
2548 |
if ( @OffsetPairs ) { |
2549 |
($OldStart, $OldEnd) = split(/,/, $OffsetPairs[scalar(@OffsetPairs) - 1]); |
2550 |
} |
2551 |
|
2552 |
if ( $OldEnd >= $Start ) { |
2553 |
$OffsetPairs[scalar(@OffsetPairs) - 1] = "$OldStart,$End"; |
2554 |
} |
2555 |
else { |
2556 |
push @OffsetPairs, "$Start,$End"; |
2557 |
} |
2558 |
$Offsets{$Offset} = $Offset; |
2559 |
} |
2560 |
|
2561 |
|
2562 |
# Now we rebuild the sentence from the words |
2563 |
$SummaryText = ""; |
2564 |
foreach $OffsetPair ( @OffsetPairs ) { |
2565 |
|
2566 |
($Start, $End) = split(/,/, $OffsetPair); |
2567 |
|
2568 |
if ( $Start > 0 ) { |
2569 |
$SummaryText .= " ..."; |
2570 |
} |
2571 |
|
2572 |
foreach $Offset ( $Start..$End ) { |
2573 |
|
2574 |
if ( !defined($Words[$Offset]) ) { |
2575 |
next; |
2576 |
} |
2577 |
|
2578 |
if ( defined($Offsets{$Offset}) ) { |
2579 |
$SummaryText .= "<FONT COLOR=\"GREEN\">$Words[$Offset]</FONT> "; |
2580 |
} |
2581 |
else { |
2582 |
$SummaryText .= $Words[$Offset] . " "; |
2583 |
} |
2584 |
|
2585 |
# Increment the summary length |
2586 |
$CurrentSummaryLength++; |
2587 |
} |
2588 |
|
2589 |
# Append a diaresys at the end |
2590 |
if ( $End < scalar(@Words) ) { |
2591 |
$SummaryText .= "... "; |
2592 |
} |
2593 |
|
2594 |
# Bail if we have reached the max summary length |
2595 |
if ( $CurrentSummaryLength > $SummaryLength ) { |
2596 |
last; |
2597 |
} |
2598 |
} |
2599 |
} |
2600 |
} |
2601 |
else { |
2602 |
undef($SummaryText); |
2603 |
} |
2604 |
} |
2605 |
|
2606 |
|
2607 |
# Decode the headline and strip the HTML |
2608 |
$Headline = &lDecodeURLData($Headline); |
2609 |
$Headline =~ s/ //gs; |
2610 |
$Headline =~ s/<.*?>//gs; |
2611 |
$Headline =~ s/\s+/ /gs; |
2612 |
|
2613 |
|
2614 |
# Create the selector text |
2615 |
$SelectorText = ""; |
2616 |
if ( defined($Selector) && $Selector ) { |
2617 |
$SelectorText .= (defined($Database) && ($Database ne "")) ? "&Database=" . &lEncodeURLData($Database) : ""; |
2618 |
$SelectorText .= (defined($DocumentID) && ($DocumentID ne "")) ? "&DocumentID=" . &lEncodeURLData($DocumentID) : ""; |
2619 |
$SelectorText .= (defined($ItemName) && ($ItemName ne "")) ? "&ItemName=" . &lEncodeURLData($ItemName) : ""; |
2620 |
$SelectorText .= (defined($MimeType) && ($MimeType ne "")) ? "&MimeType=" . &lEncodeURLData($MimeType) : ""; |
2621 |
$SelectorText = "<INPUT TYPE=\"checkbox\" NAME=\"Document\" VALUE=\"" . substr($SelectorText, 1) . "\"> "; |
2622 |
} |
2623 |
|
2624 |
|
2625 |
# Put up the headline, the headline becomes the link to the document |
2626 |
|
2627 |
# Create the link, we use the URL if it is there, |
2628 |
# otherwise we create a link from the document ID |
2629 |
if ( defined($URL) && ($URL ne "") ) { |
2630 |
$LinkText = $URL; |
2631 |
} |
2632 |
elsif ( defined($DocumentID) && ($DocumentID ne "") ) { |
2633 |
$LinkText = ""; |
2634 |
$LinkText .= (defined($Database) && ($Database ne "")) ? "&Database=" . &lEncodeURLData($Database) : ""; |
2635 |
$LinkText .= (defined($DocumentID) && ($DocumentID ne "")) ? "&DocumentID=" . &lEncodeURLData($DocumentID) : ""; |
2636 |
$LinkText .= (defined($ItemName) && ($ItemName ne "")) ? "&ItemName=" . &lEncodeURLData($ItemName) : ""; |
2637 |
$LinkText .= (defined($MimeType) && ($MimeType ne "")) ? "&MimeType=" . &lEncodeURLData($MimeType) : ""; |
2638 |
$LinkText = "$ScriptName/GetDocument?" . substr($LinkText, 1); |
2639 |
} |
2640 |
else { |
2641 |
$LinkText = ""; |
2642 |
} |
2643 |
|
2644 |
# Get the mime type name |
2645 |
$MimeTypeName = (defined($main::MimeTypeNames{$MimeType})) ? $main::MimeTypeNames{$MimeType} : $MimeType; |
2646 |
|
2647 |
# Put up the headline and the score, this one links to the document |
2648 |
if ( $HTML ) { |
2649 |
print("<!-- resultItem -->\n"); |
2650 |
#print("<TR><TD ALIGN=LEFT VALIGN=TOP WIDTH=1%> $SelectorText </TD> <TD ALIGN=LEFT VALIGN=TOP WIDTH=1%> <!-- relevance --> <B> $Score </B> <!-- /relevance --> </TD> <TD ALIGN=LEFT VALIGN=TOP> <A HREF=\"$LinkText\" OnMouseOver=\"self.status='Retrieve this document'; return true\"> $Headline <I> ( $main::DatabaseDescriptions{$Database} ) </I> </A> <BR> <FONT SIZE=-2>"); |
2651 |
# decode some basic html from headline <b> <i> |
2652 |
$Headline =~ s/<(\/?[bi])>/<$1>/g; |
2653 |
|
2654 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP WIDTH=1%> $SelectorText </TD><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> <A HREF=\"$LinkText\" OnMouseOver=\"self.status='Retrieve this document'; return true\"> $Headline </A> <BR> <FONT SIZE=-2> "); |
2655 |
} else { |
2656 |
printf("%3d $Headline ($main::DatabaseDescriptions{$Database})\n", $Score); |
2657 |
} |
2658 |
|
2659 |
if (0) { ## don't display description |
2660 |
|
2661 |
# Put up the summary |
2662 |
if ( defined($SummaryText) && ($SummaryText ne "") ) { |
2663 |
if ( $HTML ) { |
2664 |
print(" <I> $SummaryText </I><BR>\n"); |
2665 |
} |
2666 |
else { |
2667 |
print(" $SummaryText\n"); |
2668 |
} |
2669 |
} |
2670 |
|
2671 |
|
2672 |
# Put up the mime type name |
2673 |
if ( ! defined($Remainder) ) { |
2674 |
if ( $HTML ) { |
2675 |
print("Formatttt: $MimeTypeName, "); |
2676 |
|
2677 |
} |
2678 |
else { |
2679 |
print(" Format: $MimeTypeName, "); |
2680 |
} |
2681 |
} |
2682 |
|
2683 |
|
2684 |
# Put up the date if we got it |
2685 |
if ( defined($Date) && ($Date ne "") ) { |
2686 |
print("Date: $Date"); |
2687 |
|
2688 |
# Put up the time if we got it |
2689 |
if ( defined($Time) && ($Time ne "") ) { |
2690 |
print(" $Time"); |
2691 |
} |
2692 |
|
2693 |
print(", "); |
2694 |
} |
2695 |
|
2696 |
|
2697 |
# Put up the document size, remember that there is only one |
2698 |
# item name/mime type for this document if the remainder is undefined |
2699 |
if ( ! defined($Remainder) ) { |
2700 |
# Put up the length if it is defined |
2701 |
if ( defined($Length) && ($Length ne "") ) { |
2702 |
print("Size: $Length, "); |
2703 |
} |
2704 |
|
2705 |
# Put up the link |
2706 |
if ( $HTML ) { |
2707 |
if ( defined($URL) && ($URL ne "") ) { |
2708 |
$Value = (length($URL) > $main::DefaultMaxVisibleUrlLength) ? substr($URL, 0, $main::DefaultMaxVisibleUrlLength) . "..." : $URL; |
2709 |
print("<A HREF=\"$URL\"> $Value </A>\n"); |
2710 |
} |
2711 |
} |
2712 |
else { |
2713 |
print(" URL: $LinkText\n"); |
2714 |
} |
2715 |
|
2716 |
# Finish off the entry |
2717 |
if ( $HTML ) { |
2718 |
print("</FONT></TD></TR>"); |
2719 |
print("<!-- /resultItem -->\n"); |
2720 |
} |
2721 |
print("\n"); |
2722 |
} |
2723 |
else { |
2724 |
|
2725 |
# There is a remainder, so there is more than one item name/mime type for this document, |
2726 |
# the item names/mime types are listed as an un-numbered list |
2727 |
if ( $HTML ) { |
2728 |
print("<UL>"); |
2729 |
} |
2730 |
print("\n"); |
2731 |
|
2732 |
# Set the last item to an empty string, this is also used as a flag |
2733 |
$LastItemName = ""; |
2734 |
|
2735 |
# Loop while there are item names/mime types to be parsed |
2736 |
do { |
2737 |
|
2738 |
# Get the next item name/mime type if the last item is set |
2739 |
if ( $LastItemName ne "" ) { |
2740 |
($ItemName, $MimeType, $URL, $Length, $Remainder) = split(/\t/, $Remainder, 5); |
2741 |
} |
2742 |
|
2743 |
|
2744 |
# If the item name has changed, so we close of the current list and start a new one |
2745 |
if ( $ItemName ne $LastItemName ) { |
2746 |
if ( $LastItemName ne "" ) { |
2747 |
if ( $HTML ) { |
2748 |
print("</UL>"); |
2749 |
} |
2750 |
print("\n"); |
2751 |
} |
2752 |
$Value = ucfirst($ItemName); |
2753 |
if ( $HTML ) { |
2754 |
print("<LI> $Value </LI>\n<UL>\n"); |
2755 |
} |
2756 |
else { |
2757 |
print("$Value\n"); |
2758 |
} |
2759 |
|
2760 |
# Set the last item name |
2761 |
$LastItemName = $ItemName; |
2762 |
} |
2763 |
|
2764 |
|
2765 |
# Create the link, we use the URL if it is there, |
2766 |
# otherwise we create a link from the document ID |
2767 |
if ( defined($URL) && ($URL ne "") ) { |
2768 |
$LinkText = $URL; |
2769 |
} |
2770 |
elsif ( defined($DocumentID) && ($DocumentID ne "") ) { |
2771 |
$LinkText = ""; |
2772 |
$LinkText .= (defined($Database) && ($Database ne "")) ? "&Database=" . &lEncodeURLData($Database) : ""; |
2773 |
$LinkText .= (defined($DocumentID) && ($DocumentID ne "")) ? "&DocumentID=" . &lEncodeURLData($DocumentID) : ""; |
2774 |
$LinkText .= (defined($ItemName) && ($ItemName ne "")) ? "&ItemName=" . &lEncodeURLData($ItemName) : ""; |
2775 |
$LinkText .= (defined($MimeType) && ($MimeType ne "")) ? "&MimeType=" . &lEncodeURLData($MimeType) : ""; |
2776 |
$LinkText = "$ScriptName/GetDocument?" . substr($LinkText, 1); |
2777 |
} |
2778 |
else { |
2779 |
$LinkText = ""; |
2780 |
} |
2781 |
|
2782 |
|
2783 |
# Get the mime type name |
2784 |
$MimeTypeName = defined($main::MimeTypeNames{$MimeType}) ? $main::MimeTypeNames{$MimeType} : $MimeType; |
2785 |
|
2786 |
|
2787 |
# Put up the mime type, this one links to the document |
2788 |
if ( $HTML ) { |
2789 |
print("<LI><A HREF=\"$LinkText\" OnMouseOver=\"self.status='Retrieve this document'; return true\"> $MimeTypeName </A>"); |
2790 |
} |
2791 |
else { |
2792 |
print("$MimeTypeName "); |
2793 |
} |
2794 |
|
2795 |
# Put up the length if it is defined |
2796 |
if ( defined($Length) && ($Length ne "") ) { |
2797 |
print("Size: $Length, "); |
2798 |
} |
2799 |
|
2800 |
if ( $HTML ) { |
2801 |
if ( defined($URL) && ($URL ne "") ) { |
2802 |
$Value = (length($URL) > $main::DefaultMaxVisibleUrlLength) ? substr($URL, 0, $main::DefaultMaxVisibleUrlLength) . "..." : $URL; |
2803 |
print("<A HREF=\"$URL\"> $Value </A>\n"); |
2804 |
} |
2805 |
print("</LI>\n"); |
2806 |
} |
2807 |
else { |
2808 |
print("URL: $LinkText\n"); |
2809 |
} |
2810 |
|
2811 |
|
2812 |
} while ( defined($Remainder) ); # Keep looping while there are item names/mime types to process |
2813 |
|
2814 |
# Close off both un-numbered lists |
2815 |
if ( $HTML ) { |
2816 |
print("</UL></UL>"); |
2817 |
} |
2818 |
print("\n"); |
2819 |
|
2820 |
} #if |
2821 |
# Finish off the entry |
2822 |
if ( $HTML ) { |
2823 |
print("</FONT></TD></TR>\n"); |
2824 |
print("<!-- /resultItem -->\n"); |
2825 |
} |
2826 |
} |
2827 |
} |
2828 |
} |
2829 |
|
2830 |
|
2831 |
# Print up the query report if it is defined |
2832 |
if ( defined($FinalQueryReport) && ($FinalQueryReport ne "") ) { |
2833 |
|
2834 |
if ( $ResultCount > 0 ) { |
2835 |
if ( $HTML ) { |
2836 |
print("<TR><TD COLSPAN=3><HR WIDTH=50%></TD></TR>\n"); |
2837 |
} |
2838 |
else { |
2839 |
print("--------------------------------------------------------------\n\n"); |
2840 |
} |
2841 |
} |
2842 |
|
2843 |
if ( $HTML ) { |
2844 |
print("<TR><TD COLSPAN=2></TD><TD ALIGN=LEFT VALIGN=TOP>\n"); |
2845 |
} |
2846 |
|
2847 |
$Value = $FinalQueryReport; |
2848 |
if ( $HTML ) { |
2849 |
$Value =~ s/\n/\<BR\>\n/g; |
2850 |
} |
2851 |
|
2852 |
if ( $HTML ) { |
2853 |
print("<SMALL>\n"); |
2854 |
} |
2855 |
|
2856 |
print("$Value"); |
2857 |
|
2858 |
if ( $HTML ) { |
2859 |
print("</SMALL>\n"); |
2860 |
print("</TD></TR>\n"); |
2861 |
} |
2862 |
} |
2863 |
|
2864 |
|
2865 |
if ( $HTML ) { |
2866 |
|
2867 |
# Close off the table |
2868 |
print("<!-- /searchResults -->\n"); |
2869 |
print("</TABLE>\n"); |
2870 |
|
2871 |
if ( $Header ) { |
2872 |
# Close off the form |
2873 |
print("</FORM>\n"); |
2874 |
} |
2875 |
} |
2876 |
|
2877 |
# Return the status and the query report |
2878 |
return (1, $FinalQueryReport); |
2879 |
|
2880 |
} |
2881 |
|
2882 |
|
2883 |
|
2884 |
#-------------------------------------------------------------------------- |
2885 |
# |
2886 |
# Function: vGetSearch() |
2887 |
# |
2888 |
# Purpose: This function displays a search form to the user |
2889 |
# |
2890 |
# Called by: |
2891 |
# |
2892 |
# Parameters: void |
2893 |
# |
2894 |
# Global Variables: %main::ConfigurationData, %main::FormData, $main::RemoteUser |
2895 |
# |
2896 |
# Returns: void |
2897 |
# |
2898 |
sub vGetSearch { |
2899 |
|
2900 |
my (@ItemList, $ItemEntry, $Flag); |
2901 |
my ($DatabaseName, $SelectedDatabases, $Year); |
2902 |
my ($Value, %Value); |
2903 |
|
2904 |
|
2905 |
# If we are getting the default search, we check to see if there is a |
2906 |
# user name defined and if they chose to have a default search |
2907 |
if ( $ENV{'PATH_INFO'} eq "/GetSearch" ) { |
2908 |
|
2909 |
if ( defined($main::RemoteUser) && defined($main::UserSettingsFilePath) ) { |
2910 |
|
2911 |
# Get the default search symbol |
2912 |
$Value = &sGetTagValueFromXMLFile($main::UserSettingsFilePath, "DefaultSearch"); |
2913 |
|
2914 |
# Set the default search |
2915 |
if ( defined($Value) && ($Value eq "Simple") ) { |
2916 |
$ENV{'PATH_INFO'} = "/GetSimpleSearch"; |
2917 |
} |
2918 |
elsif ( defined($Value) && ($Value eq "Expanded") ) { |
2919 |
$ENV{'PATH_INFO'} = "/GetExpandedSearch"; |
2920 |
} |
2921 |
} |
2922 |
|
2923 |
# Override the default search if there is field from the expanded form defined |
2924 |
foreach $Value ('FieldContent3', 'Past', 'Since', 'Before') { |
2925 |
if ( defined($main::FormData{$Value}) ) { |
2926 |
$ENV{'PATH_INFO'} = "/GetExpandedSearch"; |
2927 |
last; |
2928 |
} |
2929 |
} |
2930 |
} |
2931 |
|
2932 |
|
2933 |
|
2934 |
# Make sure that we send the header |
2935 |
$Value = ($ENV{'PATH_INFO'} eq "/GetExpandedSearch") ? "Pretra¾ivanje s vi¹e kriterija" : "Jednostavno pretra¾ivanje"; |
2936 |
|
2937 |
&vSendHTMLHeader($Value, $main::JavaScript_SetChecked); |
2938 |
|
2939 |
undef(%Value); |
2940 |
$Value{'GetSearch'} = "GetSearch"; |
2941 |
&vSendMenuBar(%Value); |
2942 |
undef(%Value); |
2943 |
|
2944 |
|
2945 |
# Print the header ($Value is reused from the header) |
2946 |
print("<H3>$Value:</H3>\n"); |
2947 |
|
2948 |
|
2949 |
# We now have a list of valid databases, at least we think so, |
2950 |
# we check that there is at least one and put up an error message if there are none |
2951 |
if ( scalar(keys(%main::DatabaseDescriptions)) <= 0 ) { |
2952 |
&vHandleError("Database Search", "Sorry, there were no valid databases available for searching"); |
2953 |
goto bailFromGetSearch; |
2954 |
} |
2955 |
|
2956 |
|
2957 |
|
2958 |
# Start the search form table |
2959 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
2960 |
|
2961 |
# Display the collapse and expand buttons |
2962 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2>\n"); |
2963 |
print("<FORM ACTION=\"$ENV{'SCRIPT_NAME'}\" METHOD=POST>\n"); |
2964 |
|
2965 |
# List the hidden fields |
2966 |
%Value = &hParseURLIntoHashTable(&sMakeSearchAndRfDocumentURL(%main::FormData)); |
2967 |
foreach $Value ( keys(%Value) ) { |
2968 |
@ItemList = split(/\0/, $Value{$Value}); |
2969 |
foreach $ItemEntry ( @ItemList ) { |
2970 |
print("<INPUT TYPE=HIDDEN NAME=\"$Value\" VALUE=\"$ItemEntry\">\n"); |
2971 |
} |
2972 |
} |
2973 |
|
2974 |
if ( $ENV{'PATH_INFO'} eq "/GetExpandedSearch" ) { |
2975 |
print("<INPUT TYPE=HIDDEN NAME=\"Action\" VALUE=\"GetSimpleSearch\">\n"); |
2976 |
print("<INPUT SRC=\"$main::ConfigurationData{'image-base-path'}/$main::ImageNames{'collapse'}\" BORDER=0 TYPE=IMAGE> Kliknite na trokutiæ da biste suzili formu.\n"); |
2977 |
} |
2978 |
else { |
2979 |
print("<INPUT TYPE=HIDDEN NAME=\"Action\" VALUE=\"GetExpandedSearch\">\n"); |
2980 |
print("<INPUT SRC=\"$main::ConfigurationData{'image-base-path'}/$main::ImageNames{'expand'}\" BORDER=0 TYPE=IMAGE> Kliknite na trokutiæ da biste pro¹irili formu.\n"); |
2981 |
} |
2982 |
print("</FORM></TD>\n"); |
2983 |
|
2984 |
|
2985 |
|
2986 |
# Send the start of the form and the buttons |
2987 |
print("<TD ALIGN=RIGHT VALIGN=TOP>\n"); |
2988 |
print("<FORM ACTION=\"$ENV{'SCRIPT_NAME'}/GetSearchResults\" NAME=\"Search\" METHOD=POST> <INPUT TYPE=SUBMIT VALUE=\"Pretra¾i bazu\"> <INPUT TYPE=RESET VALUE=\"Pobri¹i polja\">\n"); |
2989 |
print("</TD></TR>\n"); |
2990 |
|
2991 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=3><BR></TD></TR>\n"); |
2992 |
|
2993 |
# Send the standard fields |
2994 |
$Value = defined($main::FormData{'Any'}) ? "VALUE='$main::FormData{'Any'}'" : ""; |
2995 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> Pretra¾i u bilo kojem polju: </TD> <TD ALIGN=LEFT VALIGN=TOP> <INPUT NAME=\"Any\" TYPE=TEXT $Value SIZE=45> </TD></TR>\n"); |
2996 |
|
2997 |
|
2998 |
my $nr_fields = $main::NormalSearchDropdowns; |
2999 |
my @SearchFieldNames = @main::NormalSearchFieldNames; |
3000 |
|
3001 |
if ( $ENV{'PATH_INFO'} eq "/GetExpandedSearch" ) { |
3002 |
$nr_fields = $main::AdvancedSearchDropdowns; |
3003 |
@SearchFieldNames = @main::AdvancedSearchFieldNames; |
3004 |
} |
3005 |
|
3006 |
for (my $field=1; $field<= $nr_fields; $field++) { |
3007 |
|
3008 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP>"); |
3009 |
if ($field == 1 ) { |
3010 |
print ("Pretra¾i u odreðenom polju:"); |
3011 |
} |
3012 |
print ("</TD><TD ALIGN=RIGHT VALIGN=TOP>"); |
3013 |
|
3014 |
print ("<SELECT NAME=\"FieldName${field}\">"); |
3015 |
for (my $i=0; $i<=$#SearchFieldNames; $i++) { |
3016 |
my $ItemEntry = $SearchFieldNames[$i]; |
3017 |
my $Selected = ""; |
3018 |
if ($main::FormData{"FieldName${field}"} && $main::FormData{"FieldName${field}"} eq $ItemEntry) { |
3019 |
$Selected = "SELECTED"; |
3020 |
} elsif ($i == ($field - 1)) { |
3021 |
$Selected = "SELECTED"; |
3022 |
} |
3023 |
|
3024 |
print("<OPTION VALUE=\"$ItemEntry\" $Selected> $main::SearchFieldDescriptions{$ItemEntry}\n"); |
3025 |
} |
3026 |
my $Value = ""; |
3027 |
if (defined($main::FormData{"FieldContent${field}"})) { |
3028 |
$Value = "VALUE='".$main::FormData{"FieldContent${field}"}."'"; |
3029 |
} |
3030 |
print("</SELECT></TD><TD ALIGN=LEFT><INPUT NAME=\"FieldContent${field}\" TYPE=TEXT $Value SIZE=45> </TD></TR>\n"); |
3031 |
} |
3032 |
|
3033 |
|
3034 |
# Send a pull-down which allows the user to select what to search for |
3035 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> Tra¾eni zapis mora sadr¾avati: </TD> <TD ALIGN=LEFT VALIGN=TOP> <SELECT NAME=\"Operator\">\n"); |
3036 |
$Value = (defined($main::FormData{'Operator'}) && ($main::FormData{'Operator'} eq "ADJ")) ? "SELECTED" : ""; |
3037 |
print("<OPTION VALUE=\"ADJ\"> Toènu frazu\n"); |
3038 |
$Value = ((defined($main::FormData{'Operator'}) && ($main::FormData{'Operator'} eq "AND")) || !defined($main::FormData{'Operator'})) ? "SELECTED" : ""; |
3039 |
print("<OPTION VALUE=\"AND\" $Value> Sve rijeèi (AND)\n"); |
3040 |
$Value = (defined($main::FormData{'Operator'}) && ($main::FormData{'Operator'} eq "OR")) ? "SELECTED" : ""; |
3041 |
print("<OPTION VALUE=\"OR\" $Value> Bilo koju rijeè (OR)\n"); |
3042 |
print("</SELECT> </TD></TR>\n"); |
3043 |
|
3044 |
|
3045 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=3><HR WIDTH=50%></TD></TR>\n"); |
3046 |
|
3047 |
|
3048 |
|
3049 |
# Database selection |
3050 |
if ( %main::DatabaseDescriptions ) { |
3051 |
|
3052 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> Odaberite bazu koju ¾elite pretra¾ivati:</TD></TR> |
3053 |
<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=4> |
3054 |
"); |
3055 |
|
3056 |
# Parse out the database names and put them into a |
3057 |
# hash table, they should be separated with a '\0' |
3058 |
undef(%Value); |
3059 |
if ( defined($main::FormData{'Database'}) ) { |
3060 |
@ItemList = split(/\0/, $main::FormData{'Database'}); |
3061 |
} |
3062 |
else { |
3063 |
$SelectedDatabases = &sGetTagValueFromXMLFile($main::UserSettingsFilePath, "SelectedDatabases"); |
3064 |
if ( defined($SelectedDatabases) ) { |
3065 |
@ItemList = split(",", $SelectedDatabases); |
3066 |
} |
3067 |
} |
3068 |
|
3069 |
&ShowDatabaseCheckBoxes(@ItemList); |
3070 |
|
3071 |
print("</TD></TR>\n"); |
3072 |
|
3073 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=3><HR WIDTH=50%></TD></TR>\n"); |
3074 |
} |
3075 |
|
3076 |
|
3077 |
# Print out the RF documents |
3078 |
if ( defined($main::FormData{'RfDocument'}) ) { |
3079 |
print("<TR>\n"); |
3080 |
&bDisplayDocuments("Feedback Document", $main::FormData{'RfDocument'}, "RfDocument", 1, 1, 1); |
3081 |
print("</TR>\n"); |
3082 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=3><HR WIDTH=50%></TD></TR>\n"); |
3083 |
} |
3084 |
|
3085 |
|
3086 |
# Send complex search pull-downs |
3087 |
if ( $ENV{'PATH_INFO'} eq "/GetExpandedSearch" ) { |
3088 |
|
3089 |
if ($main::ConfigurationData{'show-past-date-list'} eq 'yes') { |
3090 |
|
3091 |
# Send the past date list |
3092 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> Ogranièi na knjige koje su izdane u zadnjih : </TD> <TD ALIGN=LEFT VALIGN=TOP> <SELECT NAME=\"Past\">\n"); |
3093 |
$Value = (!defined($main::FormData{'Past'})) ? "SELECTED" : ""; |
3094 |
print("<OPTION VALUE=\"\" $Value>Bez ogranièenja...\n"); |
3095 |
foreach $ItemEntry ( @main::PastDate ) { |
3096 |
$Value = (defined($main::FormData{'Past'}) && ($main::FormData{'Past'} eq $ItemEntry)) ? "SELECTED" : ""; |
3097 |
print("<OPTION VALUE=\"$ItemEntry\" $Value> $ItemEntry\n"); |
3098 |
} |
3099 |
print("</SELECT> </TD></TR>\n"); |
3100 |
} |
3101 |
|
3102 |
|
3103 |
# Send the start date |
3104 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> Ogranièi na knjige izdane od godine: </TD> <TD ALIGN=LEFT VALIGN=TOP> <SELECT NAME=\"Since\">\n"); |
3105 |
$Value = (!defined($main::FormData{'Since'})) ? "SELECTED" : ""; |
3106 |
print("<OPTION VALUE=\"\" $Value>Bez ogranièenja...\n"); |
3107 |
|
3108 |
$Year = (localtime)[5] + 1900; |
3109 |
|
3110 |
while ( $Year >= $main::ConfigurationData{'lowest-year'} ) { |
3111 |
$Value = (defined($main::FormData{'Since'}) && ($main::FormData{'Since'} eq $Year)) ? "SELECTED" : ""; |
3112 |
print("<OPTION VALUE=\"$Year\" $Value> $Year \n"); |
3113 |
$Year--; |
3114 |
} |
3115 |
print("</SELECT> </TD></TR>\n"); |
3116 |
|
3117 |
|
3118 |
# Send the end date |
3119 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> Ogranièi na knjige izdane prije godine:: </TD> <TD ALIGN=LEFT VALIGN=TOP> <SELECT NAME=\"Before\">\n"); |
3120 |
$Value = (!defined($main::FormData{'Before'})) ? "SELECTED" : ""; |
3121 |
print("<OPTION VALUE=\"\" $Value>Bez ogranièenja...\n"); |
3122 |
|
3123 |
$Year = (localtime)[5] + 1900; |
3124 |
|
3125 |
while ( $Year >= $main::ConfigurationData{'lowest-year'} ) { |
3126 |
$Value = (defined($main::FormData{'Before'}) && ($main::FormData{'Before'} eq $Year)) ? "SELECTED" : ""; |
3127 |
print("<OPTION VALUE=\"$Year\" $Value> $Year \n"); |
3128 |
$Year--; |
3129 |
} |
3130 |
print("</SELECT> </TD></TR>\n"); |
3131 |
|
3132 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=3><HR WIDTH=50%></TD></TR>\n"); |
3133 |
} |
3134 |
|
3135 |
|
3136 |
# Send a pull-down which allows the user to select the max number of documents |
3137 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> Maksimalan broj rezultata pretra¾ivanja: </TD> <TD ALIGN=LEFT VALIGN=TOP> <SELECT NAME=\"Max\">\n"); |
3138 |
|
3139 |
foreach $ItemEntry ( @main::MaxDocs ) { |
3140 |
$Value = ((defined($main::FormData{'Max'}) && ($main::FormData{'Max'} eq $ItemEntry)) || (!defined($main::FormData{'Max'}) && ($ItemEntry eq $main::DefaultMaxDoc)) ) ? "SELECTED" : ""; |
3141 |
if ( ($ItemEntry >= 500) && $ENV{'PATH_INFO'} ne "/GetExpandedSearch" ) { |
3142 |
next; |
3143 |
} |
3144 |
print("<OPTION VALUE=\"$ItemEntry\" $Value> $ItemEntry\n"); |
3145 |
} |
3146 |
|
3147 |
print("</SELECT> </TD></TR>\n"); |
3148 |
|
3149 |
|
3150 |
# Send a pull-down which allows the user to select the sort order |
3151 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> Sortiranje rezultata: </TD> <TD ALIGN=LEFT VALIGN=TOP> <SELECT NAME=\"Order\">\n"); |
3152 |
# print("<OPTION VALUE=\"\"> Relevance\n"); |
3153 |
$Value = (defined($main::FormData{'Order'}) && ($main::FormData{'Order'} eq "SORT:DATE:DESC")) ? "SELECTED" : ""; |
3154 |
print("<OPTION VALUE=\"SORT:DATE:DESC\" $Value> Datum - najprije novije\n"); |
3155 |
$Value = (defined($main::FormData{'Order'}) && ($main::FormData{'Order'} eq "DATEASCSORT")) ? "SELECTED" : ""; |
3156 |
print("<OPTION VALUE=\"SORT:DATE:ASC\" $Value> Datum - najprije starije\n"); |
3157 |
### FIX:: SORT |
3158 |
# print("<OPTION VALUE=\"SORT:700+:DESC\"> autor\n"); |
3159 |
# print("<OPTION VALUE=\"SORT:200+:DESC\"> naslov\n"); |
3160 |
print("</SELECT> </TD></TR>\n"); |
3161 |
|
3162 |
|
3163 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=3><HR WIDTH=50%></TD></TR>\n"); |
3164 |
print("<TR><TD ALIGN=RIGHT COLSPAN=3><INPUT TYPE=SUBMIT VALUE=\"Pretra¾i bazu\"> <INPUT TYPE=RESET VALUE=\"Pobri¹i polja\"></TD></TR>\n"); |
3165 |
|
3166 |
print("</FORM>\n"); |
3167 |
print("</TABLE>\n"); |
3168 |
|
3169 |
|
3170 |
# Bail from the search |
3171 |
bailFromGetSearch: |
3172 |
|
3173 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
3174 |
undef(%Value); |
3175 |
$Value{'GetSearch'} = "GetSearch"; |
3176 |
&vSendMenuBar(%Value); |
3177 |
undef(%Value); |
3178 |
|
3179 |
&vSendHTMLFooter; |
3180 |
|
3181 |
return; |
3182 |
|
3183 |
} |
3184 |
|
3185 |
|
3186 |
|
3187 |
|
3188 |
|
3189 |
|
3190 |
#-------------------------------------------------------------------------- |
3191 |
# |
3192 |
# Function: vGetSearchResults() |
3193 |
# |
3194 |
# Purpose: This function run the search and displays the results to the user |
3195 |
# |
3196 |
# Called by: |
3197 |
# |
3198 |
# Parameters: void |
3199 |
# |
3200 |
# Global Variables: %main::ConfigurationData, %main::FormData, $main::RemoteUser |
3201 |
# |
3202 |
# Returns: void |
3203 |
# |
3204 |
sub vGetSearchResults { |
3205 |
|
3206 |
my (%Databases, $Databases, $SearchString, $SearchAndRfDocumentURL, $RfText); |
3207 |
my ($Status, $DocumentText, $SearchResults, $QueryReport, $ErrorNumber, $ErrorMessage); |
3208 |
my ($DatabaseRelevanceFeedbackFilterKey, $DatabaseRelevanceFeedbackFilterFunction); |
3209 |
my (@Values, %Value, $Value); |
3210 |
|
3211 |
|
3212 |
|
3213 |
# Check to see if there are any documents selected, if there are, they need |
3214 |
# to be converted to RF documents before we put up the header, this is because |
3215 |
# the header creates a search link from existing search fields, we also deduplicate |
3216 |
# documents along the way |
3217 |
if ( defined($main::FormData{'RfDocument'}) || defined($main::FormData{'Document'}) || defined($main::FormData{'Documents'})) { |
3218 |
|
3219 |
# Undefine the hash table in preparation |
3220 |
undef(%Value); |
3221 |
|
3222 |
# Make a hash table from the documents already selected for feedback |
3223 |
if ( defined($main::FormData{'RfDocument'}) ) { |
3224 |
foreach $Value ( split(/\0/, $main::FormData{'RfDocument'}) ) { |
3225 |
$Value{$Value} = $Value; |
3226 |
} |
3227 |
} |
3228 |
|
3229 |
# Add document that were specifically selected |
3230 |
if ( defined($main::FormData{'Document'}) ) { |
3231 |
foreach $Value ( split(/\0/, $main::FormData{'Document'}) ) { |
3232 |
$Value{$Value} = $Value; |
3233 |
} |
3234 |
} |
3235 |
# Otherwise add documents that were selected by default |
3236 |
elsif ( defined($main::FormData{'Documents'}) ) { |
3237 |
foreach $Value ( split(/\|/, $main::FormData{'Documents'}) ) { |
3238 |
$Value{$Value} = $Value; |
3239 |
} |
3240 |
} |
3241 |
|
3242 |
# Assemble the new content |
3243 |
$main::FormData{'RfDocument'} = join("\0", keys(%Value)); |
3244 |
|
3245 |
# Delete the old content |
3246 |
delete($main::FormData{'Document'}); |
3247 |
delete($main::FormData{'Documents'}); |
3248 |
} |
3249 |
|
3250 |
|
3251 |
# Set the database names if needed |
3252 |
if ( !defined($main::FormData{'Database'}) && defined($main::FormData{'RfDocument'}) ) { |
3253 |
|
3254 |
# Loop over each entry in the documents list |
3255 |
foreach $Value ( split(/\0/, $main::FormData{'RfDocument'}) ) { |
3256 |
|
3257 |
# Parse out the document entry |
3258 |
%Value = &hParseURLIntoHashTable($Value); |
3259 |
|
3260 |
# Add the database name to the hash table |
3261 |
$Databases{$Value{'Database'}} = $Value{'Database'}; |
3262 |
} |
3263 |
|
3264 |
$main::FormData{'Database'} = join("\0", keys(%Databases)); |
3265 |
} |
3266 |
|
3267 |
|
3268 |
|
3269 |
# Make sure that we send the header |
3270 |
&vSendHTMLHeader("Rezultati pretra¾ivanja", undef); |
3271 |
undef(%Value); |
3272 |
&vSendMenuBar(%Value); |
3273 |
|
3274 |
|
3275 |
# Check that at least one database was selected |
3276 |
if ( !defined($main::FormData{'Database'}) ) { |
3277 |
print("<H3>Database Search:</H3>\n"); |
3278 |
print("<H3><CENTER>Sorry, no database(s) were selected for searching.</CENTER></H3>\n"); |
3279 |
print("<P>\n"); |
3280 |
print("There needs to be a least one database selected in order to perform the search.\n"); |
3281 |
print("Click <B>'back'</B> on your browser, select at least one database and try again.\n"); |
3282 |
goto bailFromGetSearchResults; |
3283 |
} |
3284 |
|
3285 |
|
3286 |
|
3287 |
# Extract the search information |
3288 |
foreach $Value ( 1..100 ) { |
3289 |
|
3290 |
my ($FieldName) = "FieldName" . $Value; |
3291 |
my ($FieldContent) = "FieldContent" . $Value; |
3292 |
|
3293 |
if ( defined($main::FormData{$FieldName}) ) { |
3294 |
if ( defined($main::FormData{$FieldContent}) && ($main::FormData{$FieldContent} ne "") ) { |
3295 |
$main::FormData{$main::FormData{$FieldName}} = $main::FormData{$FieldContent}; |
3296 |
} |
3297 |
} |
3298 |
} |
3299 |
|
3300 |
|
3301 |
|
3302 |
# Set the local database names |
3303 |
if ( defined($main::FormData{'Database'}) ) { |
3304 |
$Databases = $main::FormData{'Database'}; |
3305 |
} |
3306 |
|
3307 |
|
3308 |
# Convert all the '\0' to ',' |
3309 |
$Databases =~ tr/\0/,/; |
3310 |
|
3311 |
|
3312 |
# Add the max doc restriction |
3313 |
if ( !defined($main::FormData{'Max'}) ) { |
3314 |
$main::FormData{'Max'} = $main::DefaultMaxDoc; |
3315 |
} |
3316 |
|
3317 |
|
3318 |
# Generate the search string |
3319 |
$SearchString = &sMakeSearchString(%main::FormData); |
3320 |
|
3321 |
# Retrieve the relevance feedback documents |
3322 |
if ( defined($main::FormData{'RfDocument'}) ) { |
3323 |
|
3324 |
$RfText = ""; |
3325 |
|
3326 |
# Loop over each entry in the documents list |
3327 |
foreach $Value ( split(/\0/, $main::FormData{'RfDocument'}) ) { |
3328 |
|
3329 |
# Parse out the document entry |
3330 |
%Value = &hParseURLIntoHashTable($Value); |
3331 |
|
3332 |
# Check this document can be used for relevance feedback |
3333 |
if ( !defined($main::RFMimeTypes{$Value{'MimeType'}}) ) { |
3334 |
next; |
3335 |
} |
3336 |
|
3337 |
# Get the document |
3338 |
($Status, $DocumentText) = MPS::GetDocument($main::MPSSession, $Value{'Database'}, $Value{'DocumentID'}, $Value{'ItemName'}, $Value{'MimeType'}); |
3339 |
|
3340 |
if ( $Status ) { |
3341 |
|
3342 |
$DatabaseRelevanceFeedbackFilterKey = "$main::DatabaseRelevanceFeedbackFilter:$Value{'Database'}:$Value{'ItemName'}:$Value{'MimeType'}"; |
3343 |
|
3344 |
# Is a filter defined for this database relevance feedback filter key ? |
3345 |
if ( defined($main::DatabaseFilters{$DatabaseRelevanceFeedbackFilterKey}) ) { |
3346 |
|
3347 |
# Pull in the package |
3348 |
require $main::DatabaseFilters{"$main::DatabaseFiltersPackage:$Value{'Database'}"}; |
3349 |
|
3350 |
# Filter the document |
3351 |
$Value = $main::DatabaseFilters{$DatabaseRelevanceFeedbackFilterKey}; |
3352 |
$DatabaseRelevanceFeedbackFilterFunction = \&$Value; |
3353 |
$DocumentText = $DatabaseRelevanceFeedbackFilterFunction->($Value{'Database'}, $Value{'DocumentID'}, $Value{'ItemName'}, $Value{'MimeType'}, $DocumentText); |
3354 |
|
3355 |
} |
3356 |
else { |
3357 |
|
3358 |
# Strip the HTML from the text (this is only really useful on HTML documents) |
3359 |
if ( defined($main::HtmlMimeTypes{$Value{'MimeType'}}) ) { |
3360 |
$DocumentText =~ s/ //gs; |
3361 |
$DocumentText =~ s/<.*?>//gs; |
3362 |
} |
3363 |
} |
3364 |
|
3365 |
$RfText .= $DocumentText . " "; |
3366 |
} |
3367 |
} |
3368 |
} |
3369 |
|
3370 |
|
3371 |
# Run the search |
3372 |
($Status, $SearchResults) = MPS::SearchDatabase($main::MPSSession, $Databases, $SearchString, $RfText, 0, $main::FormData{'Max'} - 1, $main::ConfigurationData{'max-score'}); |
3373 |
|
3374 |
if ( $Status ) { |
3375 |
|
3376 |
# Display the search results and get the query report text |
3377 |
($Status, $QueryReport) = &bsDisplaySearchResults("Rezultati pretra¾ivanja:", undef, undef, undef, $SearchResults, undef, $ENV{'SCRIPT_NAME'}, 1, 1, 1, %main::FormData); |
3378 |
|
3379 |
# Save the search history |
3380 |
if ( defined($main::RemoteUser) ) { |
3381 |
|
3382 |
# Generate the search string |
3383 |
$SearchAndRfDocumentURL = &sMakeSearchAndRfDocumentURL(%main::FormData); |
3384 |
|
3385 |
# Save the search history |
3386 |
&iSaveSearchHistory(undef, $SearchAndRfDocumentURL, $SearchResults, $QueryReport); |
3387 |
|
3388 |
# Purge the search history files |
3389 |
&vPurgeSearchHistory; |
3390 |
} |
3391 |
} |
3392 |
else { |
3393 |
($ErrorNumber, $ErrorMessage) = split(/\t/, $SearchResults, 2); |
3394 |
&vHandleError("Database Search", "Sorry, failed to search the database(s)"); |
3395 |
print("The following error message was reported: <BR>\n"); |
3396 |
print("Error Message: $ErrorMessage <BR>\n"); |
3397 |
print("Error Number: $ErrorNumber <BR>\n"); |
3398 |
goto bailFromGetSearchResults; |
3399 |
} |
3400 |
|
3401 |
|
3402 |
# Bail from the search |
3403 |
bailFromGetSearchResults: |
3404 |
|
3405 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
3406 |
undef(%Value); |
3407 |
&vSendMenuBar(%Value); |
3408 |
|
3409 |
&vSendHTMLFooter; |
3410 |
|
3411 |
return; |
3412 |
|
3413 |
} |
3414 |
|
3415 |
|
3416 |
|
3417 |
|
3418 |
|
3419 |
|
3420 |
#-------------------------------------------------------------------------- |
3421 |
# |
3422 |
# Function: vGetDatabaseInfo() |
3423 |
# |
3424 |
# Purpose: This function allows the user to get some database information |
3425 |
# such as the description, the contents and the time period spanned |
3426 |
# by the content. |
3427 |
# |
3428 |
# Called by: |
3429 |
# |
3430 |
# Parameters: void |
3431 |
# |
3432 |
# Global Variables: %main::ConfigurationData, %main::FormData |
3433 |
# |
3434 |
# Returns: void |
3435 |
# |
3436 |
sub vGetDatabaseInfo { |
3437 |
|
3438 |
my ($DatabaseDescription, $DatabaseLanguage, $DatabaseTokenizer, $DocumentCount, $TotalWordCount, $UniqueWordCount, $StopWordCount, $AccessControl, $UpdateFrequency, $LastUpdateDate, $LastUpdateTime, $CaseSensitive); |
3439 |
my ($FieldInformation, $FieldName, $FieldDescription); |
3440 |
my ($Status, $Text, $Time, $Title); |
3441 |
my ($ErrorNumber, $ErrorMessage); |
3442 |
my ($Value, %Value); |
3443 |
|
3444 |
|
3445 |
|
3446 |
# Check we that we got a database name |
3447 |
if ( !defined($main::FormData{'Database'}) ) { |
3448 |
&vHandleError("Database information", "Sorry, the database content description could not be obtained"); |
3449 |
goto bailFromGetDatabaseInfo; |
3450 |
} |
3451 |
|
3452 |
|
3453 |
# Make sure that we send the header |
3454 |
$Title = "Database Information: " . (defined($main::DatabaseDescriptions{$main::FormData{'Database'}}) |
3455 |
? $main::DatabaseDescriptions{$main::FormData{'Database'}} : ""); |
3456 |
&vSendHTMLHeader($Title, undef); |
3457 |
undef(%Value); |
3458 |
&vSendMenuBar(%Value); |
3459 |
|
3460 |
|
3461 |
# Get the database information |
3462 |
($Status, $Text) = MPS::GetDatabaseInfo($main::MPSSession, $main::FormData{'Database'}); |
3463 |
|
3464 |
if ( $Status ) { |
3465 |
|
3466 |
# Display the database information |
3467 |
print("<H3>Database information:</H3>\n"); |
3468 |
|
3469 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
3470 |
|
3471 |
|
3472 |
# Send the database description |
3473 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Database description: </TD> <TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> $main::DatabaseDescriptions{$main::FormData{'Database'}} </TD></TR>\n"); |
3474 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=3><HR WIDTH=50%></TD></TR>\n"); |
3475 |
|
3476 |
# Truncate the line |
3477 |
chop ($Text); |
3478 |
|
3479 |
# Parse the database information |
3480 |
($DatabaseDescription, $DatabaseLanguage, $DatabaseTokenizer, $DocumentCount, $TotalWordCount, $UniqueWordCount, $StopWordCount, $AccessControl, $UpdateFrequency, $LastUpdateDate, $LastUpdateTime, $CaseSensitive) = split(/\t/, $Text); |
3481 |
|
3482 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Database information: </TD><TD ALIGN=LEFT VALIGN=TOP> Broj rezultata: </TD> <TD ALIGN=LEFT VALIGN=TOP> $DocumentCount </TD></TR>\n"); |
3483 |
print("<TR><TD></TD><TD ALIGN=LEFT VALIGN=TOP> Total number of words: </TD> <TD ALIGN=LEFT VALIGN=TOP> $TotalWordCount </TD></TR>\n"); |
3484 |
print("<TR><TD></TD><TD ALIGN=LEFT VALIGN=TOP> Number of unique words: </TD> <TD ALIGN=LEFT VALIGN=TOP> $UniqueWordCount </TD></TR>\n"); |
3485 |
print("<TR><TD></TD><TD ALIGN=LEFT VALIGN=TOP> Number of stop words: </TD> <TD ALIGN=LEFT VALIGN=TOP> $StopWordCount </TD></TR>\n"); |
3486 |
|
3487 |
# Get the time of last update of the data directory |
3488 |
# $Time = (stat("$main::ConfigurationData{'data-directory'}/$main::FormData{'Database'}/"))[9]; |
3489 |
# $Value = &sGetPrintableDateFromTime($Time); |
3490 |
# print("<TR><TD ALIGN=LEFT VALIGN=TOP> Data last updated on: </TD> <TD ALIGN=LEFT VALIGN=TOP> $Value </TD></TR>\n"); |
3491 |
|
3492 |
print("<TR><TD></TD><TD ALIGN=LEFT VALIGN=TOP> Index last updated on: </TD> <TD ALIGN=LEFT VALIGN=TOP> $LastUpdateDate ($LastUpdateTime) </TD></TR>\n"); |
3493 |
|
3494 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=3><HR WIDTH=50%></TD></TR>\n"); |
3495 |
|
3496 |
# Get the database field information |
3497 |
($Status, $Text) = MPS::GetDatabaseFieldInfo($main::MPSSession, $main::FormData{'Database'}); |
3498 |
|
3499 |
if ( $Status ) { |
3500 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Database Field Information: </TD> <TD ALIGN=LEFT VALIGN=TOP> Field Name: </TD> <TD ALIGN=LEFT VALIGN=TOP> Field Description: </TD></TR> \n"); |
3501 |
|
3502 |
foreach $FieldInformation ( split(/\n/, $Text) ) { |
3503 |
($FieldName, $FieldDescription, $Value) = split(/\t/, $FieldInformation, 3); |
3504 |
print("<TR><TD></TD><TD ALIGN=LEFT VALIGN=TOP> $FieldName </TD> <TD ALIGN=LEFT VALIGN=TOP> $FieldDescription </TD></TR>\n"); |
3505 |
} |
3506 |
} |
3507 |
|
3508 |
print("</TABLE>\n"); |
3509 |
|
3510 |
} |
3511 |
else { |
3512 |
($ErrorNumber, $ErrorMessage) = split(/\t/, $Text, 2); |
3513 |
&vHandleError("Database information", "Sorry, failed to get the database information"); |
3514 |
print("The following error message was reported: <BR>\n"); |
3515 |
print("Error Message: $ErrorMessage <BR>\n"); |
3516 |
print("Error Number: $ErrorNumber <BR>\n"); |
3517 |
goto bailFromGetDatabaseInfo; |
3518 |
} |
3519 |
|
3520 |
|
3521 |
|
3522 |
# Bail from the database info |
3523 |
bailFromGetDatabaseInfo: |
3524 |
|
3525 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
3526 |
undef(%Value); |
3527 |
&vSendMenuBar(%Value); |
3528 |
|
3529 |
&vSendHTMLFooter; |
3530 |
|
3531 |
return; |
3532 |
|
3533 |
} |
3534 |
|
3535 |
|
3536 |
|
3537 |
|
3538 |
|
3539 |
|
3540 |
#-------------------------------------------------------------------------- |
3541 |
# |
3542 |
# Function: vGetDocument() |
3543 |
# |
3544 |
# Purpose: This function get a document from the database. |
3545 |
# |
3546 |
# Called by: |
3547 |
# |
3548 |
# Parameters: void |
3549 |
# |
3550 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
3551 |
# $main::FooterSent |
3552 |
# |
3553 |
# Returns: void |
3554 |
# |
3555 |
sub vGetDocument { |
3556 |
|
3557 |
my (@DocumentList, %Document, $Document, $TextDocumentFlag); |
3558 |
my ($Status, $Data, $ErrorNumber, $ErrorMessage); |
3559 |
my (%QualifiedDocumentFolders, $QualifiedDocumentFolders, $FolderName, $DocumentFolderEntry); |
3560 |
my ($DatabaseDocumentFilterFunction, $DatabaseDocumentFilterKey); |
3561 |
my ($SelectorText, $FilteredData, $SimilarDocuments, $SearchResults); |
3562 |
my (%Value, $Value); |
3563 |
|
3564 |
|
3565 |
|
3566 |
# Assemble the documents selected into a list do that we keep their order |
3567 |
if ( defined($main::FormData{'Document'}) || defined($main::FormData{'Documents'}) || defined($main::FormData{'DocumentID'}) ) { |
3568 |
|
3569 |
# Undefine the hash table in preparation |
3570 |
undef(%Value); |
3571 |
|
3572 |
# Add document that were specifically selected |
3573 |
if ( defined($main::FormData{'Document'}) ) { |
3574 |
foreach $Value ( split(/\0/, $main::FormData{'Document'}) ) { |
3575 |
if ( !defined($Value{$Value}) ) { |
3576 |
push @DocumentList, $Value; |
3577 |
$Value{$Value} = $Value; |
3578 |
} |
3579 |
} |
3580 |
} |
3581 |
# Otherwise add documents that were selected by default |
3582 |
elsif ( defined($main::FormData{'Documents'}) ) { |
3583 |
foreach $Value ( split(/\|/, $main::FormData{'Documents'}) ) { |
3584 |
if ( !defined($Value{$Value}) ) { |
3585 |
push @DocumentList, $Value; |
3586 |
$Value{$Value} = $Value; |
3587 |
} |
3588 |
} |
3589 |
} |
3590 |
|
3591 |
# Add document from the URL |
3592 |
if ( defined($main::FormData{'DocumentID'}) ) { |
3593 |
$Value = ""; |
3594 |
$Value .= (defined($main::FormData{'Database'}) && ($main::FormData{'Database'} ne "")) ? "&Database=" . &lEncodeURLData($main::FormData{'Database'}) : ""; |
3595 |
$Value .= (defined($main::FormData{'DocumentID'}) && ($main::FormData{'DocumentID'} ne "")) ? "&DocumentID=" . &lEncodeURLData($main::FormData{'DocumentID'}) : ""; |
3596 |
$Value .= (defined($main::FormData{'ItemName'}) && ($main::FormData{'ItemName'} ne "")) ? "&ItemName=" . &lEncodeURLData($main::FormData{'ItemName'}) : ""; |
3597 |
$Value .= (defined($main::FormData{'MimeType'}) && ($main::FormData{'MimeType'} ne "")) ? "&MimeType=" . &lEncodeURLData($main::FormData{'MimeType'}) : ""; |
3598 |
if ( !defined($Value{$Value}) ) { |
3599 |
push @DocumentList, $Value; |
3600 |
$Value{$Value} = $Value; |
3601 |
} |
3602 |
} |
3603 |
} |
3604 |
|
3605 |
|
3606 |
|
3607 |
# Catch no document selection |
3608 |
if ( !@DocumentList || (scalar(@DocumentList) == 0) ) { |
3609 |
|
3610 |
# Make sure that we send the header |
3611 |
if ( $ENV{'PATH_INFO'} eq "/GetSimilarDocument" ) { |
3612 |
&vSendHTMLHeader("Similar Documents", undef); |
3613 |
} |
3614 |
else { |
3615 |
&vSendHTMLHeader("Documents", undef); |
3616 |
} |
3617 |
undef(%Value); |
3618 |
&vSendMenuBar(%Value); |
3619 |
|
3620 |
print("<H3>Document retrieval:</H3>\n"); |
3621 |
print("<H3><CENTER>Sorry, no document(s) were selected for retrieval.</CENTER></H3>\n"); |
3622 |
print("<P>\n"); |
3623 |
print("There needs to be a least one document selected in order to perform the retrieval.\n"); |
3624 |
print("Click <B>'back'</B> on your browser, select at least one document and try again.\n"); |
3625 |
goto bailFromGetDocument; |
3626 |
} |
3627 |
|
3628 |
|
3629 |
|
3630 |
# Set the text document flag |
3631 |
$TextDocumentFlag = 0; |
3632 |
|
3633 |
# Check the documents for text based documents |
3634 |
foreach $Document ( @DocumentList ) { |
3635 |
|
3636 |
# Parse out the document entry |
3637 |
%Document = &hParseURLIntoHashTable($Document); |
3638 |
|
3639 |
# Set the text flag if there are any text documents in the list |
3640 |
if ( $Document{'MimeType'} =~ /^text\// ) { |
3641 |
$TextDocumentFlag = 1; |
3642 |
} |
3643 |
} |
3644 |
|
3645 |
|
3646 |
|
3647 |
# If there were no text documents in our list, we display the first document in the |
3648 |
# list, this is to handle cases where got one or more non-text documents (such as |
3649 |
# images, pdf files, etc) |
3650 |
if ( ! $TextDocumentFlag ) { |
3651 |
|
3652 |
%Document = &hParseURLIntoHashTable($DocumentList[0]); |
3653 |
|
3654 |
# Get the document |
3655 |
($Status, $Data) = MPS::GetDocument($main::MPSSession, $Document{'Database'}, $Document{'DocumentID'}, $Document{'ItemName'}, $Document{'MimeType'}); |
3656 |
|
3657 |
if ( !$Status ) { |
3658 |
|
3659 |
# Make sure that we send the header |
3660 |
if ( $ENV{'PATH_INFO'} eq "/GetSimilarDocument" ) { |
3661 |
&vSendHTMLHeader("Similar Documents", undef); |
3662 |
} |
3663 |
else { |
3664 |
&vSendHTMLHeader("Documents", undef); |
3665 |
} |
3666 |
undef(%Value); |
3667 |
&vSendMenuBar(%Value); |
3668 |
|
3669 |
($ErrorNumber, $ErrorMessage) = split(/\t/, $Data, 2); |
3670 |
# The database document could not be gotten, so we inform the user of the fact |
3671 |
&vHandleError("Document retrieval", "Sorry, the database document could not be obtained"); |
3672 |
print("The following error message was reported: <BR>\n"); |
3673 |
print("Error Message: $ErrorMessage <BR>\n"); |
3674 |
print("Error Number: $ErrorNumber <BR>\n"); |
3675 |
goto bailFromGetDocument; |
3676 |
} |
3677 |
|
3678 |
# Send the content type |
3679 |
print("Content-type: $Document{'MimeType'}\n\n"); |
3680 |
|
3681 |
# Send the document |
3682 |
print("$Data"); |
3683 |
|
3684 |
return; |
3685 |
} |
3686 |
|
3687 |
|
3688 |
|
3689 |
# Make sure that we send the header |
3690 |
if ( $ENV{'PATH_INFO'} eq "/GetSimilarDocument" ) { |
3691 |
&vSendHTMLHeader("Similar Documents", undef); |
3692 |
} |
3693 |
else { |
3694 |
&vSendHTMLHeader("Documents", undef); |
3695 |
} |
3696 |
undef(%Value); |
3697 |
&vSendMenuBar(%Value); |
3698 |
|
3699 |
|
3700 |
|
3701 |
# Print the header |
3702 |
if ( $ENV{'PATH_INFO'} eq "/GetSimilarDocument" ) { |
3703 |
print("<H3>Similar Documents:</H3>\n"); |
3704 |
} |
3705 |
else { |
3706 |
print("<H3>Dokumenti:</H3>\n"); |
3707 |
} |
3708 |
|
3709 |
|
3710 |
# Start the form |
3711 |
print("<FORM ACTION=\"$ENV{'SCRIPT_NAME'}\" METHOD=POST>\n"); |
3712 |
|
3713 |
# Send the pull-down |
3714 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
3715 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP>Odabranima se smatraju svi rezultati ukoliko niste uèinili nikakav dodatan odabir.</TD><TD ALIGN=RIGHT VALIGN=TOP> \n"); |
3716 |
|
3717 |
if ( defined($main::RemoteUser) ) { |
3718 |
print("<SELECT NAME=\"Action\">\n"); |
3719 |
if ( $ENV{'PATH_INFO'} eq "/GetSimilarDocument" ) { |
3720 |
print("<OPTION VALUE=\"GetDocument\">Prika¾i odabrane rezultate\n"); |
3721 |
} |
3722 |
if ( $main::ConfigurationData{'allow-similiar-search'} eq "yes" ) { |
3723 |
print("<OPTION VALUE=\"GetSimilarDocument\">Prika¾i rezultate sliène odabranim rezultatima\n"); |
3724 |
} |
3725 |
if ( $main::ConfigurationData{'allow-relevance-feedback-searches'} eq "yes" ) { |
3726 |
print("<OPTION VALUE=\"GetSearchResults\">Run search with selected documents as relevance feedback\n"); |
3727 |
} |
3728 |
print("<OPTION VALUE=\"GetSaveFolder\">Save selected documents to a new document folder\n"); |
3729 |
|
3730 |
# Get the document folder hash |
3731 |
%QualifiedDocumentFolders = &hGetDocumentFolders; |
3732 |
|
3733 |
for $FolderName ( sort( keys(%QualifiedDocumentFolders)) ) { |
3734 |
|
3735 |
$DocumentFolderEntry = $QualifiedDocumentFolders{$FolderName}; |
3736 |
|
3737 |
# Get the document folder file name and encode it |
3738 |
$DocumentFolderEntry = ($DocumentFolderEntry =~ /^$main::UserAccountDirectoryPath\/(.*)/) ? $1 : $DocumentFolderEntry; |
3739 |
$DocumentFolderEntry = &lEncodeURLData($DocumentFolderEntry); |
3740 |
|
3741 |
print("<OPTION VALUE=\"SetSaveFolder&DocumentFolderObject=$DocumentFolderEntry\">Add selected documents to the '$FolderName' document folder\n"); |
3742 |
} |
3743 |
|
3744 |
print("</SELECT>\n"); |
3745 |
print("<INPUT TYPE=SUBMIT VALUE=\"Do It!\">\n"); |
3746 |
} |
3747 |
else { |
3748 |
if ( $main::ConfigurationData{'allow-relevance-feedback-searches'} eq "yes" ) { |
3749 |
print("<INPUT TYPE=HIDDEN NAME=\"Action\" VALUE=\"GetSearchResults\">\n"); |
3750 |
print("<INPUT TYPE=SUBMIT VALUE=\"Run search with documents as relevance feedback\">\n"); |
3751 |
} |
3752 |
} |
3753 |
|
3754 |
print("</TD></TR>\n"); |
3755 |
print("</TABLE>\n"); |
3756 |
|
3757 |
|
3758 |
# Display the documents |
3759 |
|
3760 |
print("<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 WIDTH=100%>\n"); |
3761 |
|
3762 |
|
3763 |
# Display the selector for all the documents |
3764 |
$SelectorText = ""; |
3765 |
|
3766 |
foreach $Document ( @DocumentList ) { |
3767 |
|
3768 |
# Parse out the document entry |
3769 |
%Document = &hParseURLIntoHashTable($Document); |
3770 |
|
3771 |
# Skip non-text documents |
3772 |
if ( !($Document{'MimeType'} =~ /^text\//) ) { |
3773 |
next; |
3774 |
} |
3775 |
|
3776 |
$Value = ""; |
3777 |
$Value .= (defined($Document{'Database'}) && ($Document{'Database'} ne "")) ? "&Database=" . &lEncodeURLData($Document{'Database'}) : ""; |
3778 |
$Value .= (defined($Document{'DocumentID'}) && ($Document{'DocumentID'} ne "")) ? "&DocumentID=" . &lEncodeURLData($Document{'DocumentID'}) : ""; |
3779 |
$Value .= (defined($Document{'ItemName'}) && ($Document{'ItemName'} ne "")) ? "&ItemName=" . &lEncodeURLData($Document{'ItemName'}) : ""; |
3780 |
$Value .= (defined($Document{'MimeType'}) && ($Document{'MimeType'} ne "")) ? "&MimeType=" . &lEncodeURLData($Document{'MimeType'}) : ""; |
3781 |
$SelectorText .= (($SelectorText ne "") ? "|" : "") . substr($Value, 1); |
3782 |
} |
3783 |
|
3784 |
$SelectorText = "<INPUT TYPE=\"HIDDEN\" NAME=\"Documents\" VALUE=\"" . $SelectorText . "\"> "; |
3785 |
print("<TR><TD ALIGN=RIGHT VALIGN=TOP COLSPAN=3> $SelectorText </TD></TR>\n"); |
3786 |
|
3787 |
|
3788 |
|
3789 |
# Get the similar documents value |
3790 |
if ( defined($main::RemoteUser) ) { |
3791 |
$SimilarDocuments = &sGetTagValueFromXMLFile($main::UserSettingsFilePath, "SimilarDocuments"); |
3792 |
} |
3793 |
else { |
3794 |
$SimilarDocuments = $main::DefaultSimilarDocument; |
3795 |
} |
3796 |
|
3797 |
|
3798 |
|
3799 |
foreach $Document ( @DocumentList ) { |
3800 |
|
3801 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=3> <HR WIDTH=50%> </TD></TR>\n"); |
3802 |
|
3803 |
|
3804 |
# Parse out the document entry |
3805 |
%Document = &hParseURLIntoHashTable($Document); |
3806 |
|
3807 |
# Skip non-text documents |
3808 |
if ( !($Document{'MimeType'} =~ /^text\//) ) { |
3809 |
next; |
3810 |
} |
3811 |
|
3812 |
|
3813 |
# Get the document |
3814 |
($Status, $Data) = MPS::GetDocument($main::MPSSession, $Document{'Database'}, $Document{'DocumentID'}, $Document{'ItemName'}, $Document{'MimeType'}); |
3815 |
|
3816 |
if ( !$Status ) { |
3817 |
($ErrorNumber, $ErrorMessage) = split(/\t/, $Data, 2); |
3818 |
# The database document could not be gotten, so we inform the user of the fact |
3819 |
&vHandleError("Document retrieval", "Sorry, the database document could not be obtained"); |
3820 |
print("The following error message was reported: <BR>\n"); |
3821 |
print("Error Message: $ErrorMessage <BR>\n"); |
3822 |
print("Error Number: $ErrorNumber <BR>\n"); |
3823 |
goto bailFromGetDocument; |
3824 |
} |
3825 |
|
3826 |
|
3827 |
# Create the database document filter key |
3828 |
$DatabaseDocumentFilterKey = "$main::DatabaseDocumentFilter:$Document{'Database'}:$Document{'ItemName'}:$Document{'MimeType'}"; |
3829 |
|
3830 |
# Is a filter defined for this database document filter key ? |
3831 |
if ( defined($main::DatabaseFilters{$DatabaseDocumentFilterKey}) ) { |
3832 |
|
3833 |
# Pull in the package |
3834 |
require $main::DatabaseFilters{"$main::DatabaseFiltersPackage:$Document{'Database'}"}; |
3835 |
|
3836 |
# Filter the document |
3837 |
$Value = $main::DatabaseFilters{$DatabaseDocumentFilterKey}; |
3838 |
$DatabaseDocumentFilterFunction = \&$Value; |
3839 |
$FilteredData = $DatabaseDocumentFilterFunction->($Document{'Database'}, $Document{'DocumentID'}, $Document{'ItemName'}, $Document{'MimeType'}, $Data); |
3840 |
} else { |
3841 |
# use default filter key |
3842 |
|
3843 |
# Pull in the package |
3844 |
require $main::DatabaseFilters{"$main::DatabaseFiltersPackage:default"}; |
3845 |
|
3846 |
# Filter the document |
3847 |
$Value = $main::DatabaseFilters{"$main::DatabaseDocumentFilter:default:$Document{'ItemName'}:$Document{'MimeType'}"}; |
3848 |
$DatabaseDocumentFilterFunction = \&$Value; |
3849 |
$FilteredData = $DatabaseDocumentFilterFunction->($Document{'Database'}, $Document{'DocumentID'}, $Document{'ItemName'}, $Document{'MimeType'}, $Data); |
3850 |
} |
3851 |
|
3852 |
|
3853 |
|
3854 |
# Create the document selector button text |
3855 |
$SelectorText = ""; |
3856 |
$SelectorText .= (defined($Document{'Database'}) && ($Document{'Database'} ne "")) ? "&Database=" . &lEncodeURLData($Document{'Database'}) : ""; |
3857 |
$SelectorText .= (defined($Document{'DocumentID'}) && ($Document{'DocumentID'} ne "")) ? "&DocumentID=" . &lEncodeURLData($Document{'DocumentID'}) : ""; |
3858 |
$SelectorText .= (defined($Document{'ItemName'}) && ($Document{'ItemName'} ne "")) ? "&ItemName=" . &lEncodeURLData($Document{'ItemName'}) : ""; |
3859 |
$SelectorText .= (defined($Document{'MimeType'}) && ($Document{'MimeType'} ne "")) ? "&MimeType=" . &lEncodeURLData($Document{'MimeType'}) : ""; |
3860 |
$SelectorText = "<INPUT TYPE=\"checkbox\" NAME=\"Document\" VALUE=\"" . substr($SelectorText, 1) . "\"> "; |
3861 |
|
3862 |
|
3863 |
# Send the document text |
3864 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> $SelectorText </TD> <TD ALIGN=LEFT VALIGN=TOP>$FilteredData</TD></TR>"); |
3865 |
if ( $ENV{'PATH_INFO'} eq "/GetSimilarDocument" ) { |
3866 |
|
3867 |
# Get the similar documents if needed |
3868 |
if ( defined($main::ConfigurationData{'allow-similiar-search'}) && ($main::ConfigurationData{'allow-similiar-search'} eq "yes") && |
3869 |
defined($SimilarDocuments) ) { |
3870 |
|
3871 |
# Run the search, discard the query report |
3872 |
($Status, $SearchResults) = MPS::SearchDatabase($main::MPSSession, $Document{'Database'}, "{NOREPORT}", $Data, 0, $SimilarDocuments - 1, $main::ConfigurationData{'max-score'}); |
3873 |
|
3874 |
if ( $Status ) { |
3875 |
|
3876 |
# Display the search result |
3877 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=3> <HR WIDTH=25%> </TD></TR>\n"); |
3878 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP></TD> <TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> \n"); |
3879 |
print("<B>Similar Documents:</B>\n"); |
3880 |
($Status, undef) = &bsDisplaySearchResults("Similar Documents:", undef, undef, undef, $SearchResults, undef, $ENV{'SCRIPT_NAME'}, 0, 1, 1, %main::FormData); |
3881 |
print("</TD></TR>\n"); |
3882 |
} |
3883 |
else { |
3884 |
($ErrorNumber, $ErrorMessage) = split(/\t/, $SearchResults, 2); |
3885 |
&vHandleError("Database Search", "Sorry, failed to search the database(s)"); |
3886 |
print("The following error message was reported: <BR>\n"); |
3887 |
print("Error Message: $ErrorMessage <BR>\n"); |
3888 |
print("Error Number: $ErrorNumber <BR>\n"); |
3889 |
goto bailFromGetDocument; |
3890 |
} |
3891 |
} |
3892 |
} |
3893 |
} |
3894 |
|
3895 |
|
3896 |
# Close off the form |
3897 |
print("</FORM>\n"); |
3898 |
|
3899 |
# Close off the table |
3900 |
print("</TABLE>\n"); |
3901 |
|
3902 |
|
3903 |
# Bail from getting the document |
3904 |
bailFromGetDocument: |
3905 |
|
3906 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
3907 |
undef(%Value); |
3908 |
&vSendMenuBar(%Value); |
3909 |
|
3910 |
&vSendHTMLFooter; |
3911 |
|
3912 |
return; |
3913 |
|
3914 |
} |
3915 |
|
3916 |
|
3917 |
|
3918 |
|
3919 |
|
3920 |
|
3921 |
#-------------------------------------------------------------------------- |
3922 |
# |
3923 |
# Function: vGetUserSettings() |
3924 |
# |
3925 |
# Purpose: This function displays a user settings form to the user |
3926 |
# |
3927 |
# Called by: |
3928 |
# |
3929 |
# Parameters: void |
3930 |
# |
3931 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
3932 |
# $main::UserSettingsFilePath, $main::RemoteUser, |
3933 |
# |
3934 |
# Returns: void |
3935 |
# |
3936 |
sub vGetUserSettings { |
3937 |
|
3938 |
my ($UserName, $SearchHistory, $DefaultSearch, $SelectedDatabases, $EmailAddress, $SearchFrequency, $DeliveryFormat, $DeliveryMethod, $SummaryType, $SummaryLength, $SimilarDocuments); |
3939 |
my ($SearchHistoryCount, $HeaderName); |
3940 |
my ($DatabaseName, @ItemList, $ItemEntry, $Flag); |
3941 |
my ($Value, %Value); |
3942 |
|
3943 |
|
3944 |
# Return an error if the remote user name/account directory is not defined |
3945 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
3946 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
3947 |
&vSendHTMLFooter; |
3948 |
return; |
3949 |
} |
3950 |
|
3951 |
|
3952 |
|
3953 |
# Make sure that we send the header |
3954 |
&vSendHTMLHeader("My Settings", $main::JavaScript_SetChecked); |
3955 |
undef(%Value); |
3956 |
$Value{'GetUserSettings'} = "GetUserSettings"; |
3957 |
&vSendMenuBar(%Value); |
3958 |
undef(%Value); |
3959 |
|
3960 |
|
3961 |
|
3962 |
# Get information from the XML saved search file |
3963 |
($HeaderName, %Value) = &shGetHashFromXMLFile($main::UserSettingsFilePath); |
3964 |
|
3965 |
# Check the header if it is defines, delete the file if it is not valid, |
3966 |
# else set the variables from the hash table contents |
3967 |
if ( defined($HeaderName) ) { |
3968 |
if ( $HeaderName ne "UserSettings" ) { |
3969 |
unlink($main::UserSettingsFilePath); |
3970 |
} |
3971 |
else { |
3972 |
$UserName = $Value{'UserName'}; |
3973 |
$SearchHistory = $Value{'SearchHistory'}; |
3974 |
$DefaultSearch = $Value{'DefaultSearch'}; |
3975 |
$SelectedDatabases = $Value{'SelectedDatabases'}; |
3976 |
$EmailAddress = $Value{'EmailAddress'}; |
3977 |
$SearchFrequency = $Value{'SearchFrequency'}; |
3978 |
$DeliveryFormat = $Value{'DeliveryFormat'}; |
3979 |
$DeliveryMethod = $Value{'DeliveryMethod'}; |
3980 |
$SummaryType = $Value{'SummaryType'}; |
3981 |
$SummaryLength = $Value{'SummaryLength'}; |
3982 |
$SimilarDocuments = $Value{'SimilarDocuments'}; |
3983 |
} |
3984 |
} |
3985 |
|
3986 |
|
3987 |
# Give the user a form to fill out |
3988 |
|
3989 |
print("<H3> Postavke: </H3>\n"); |
3990 |
|
3991 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
3992 |
print("<FORM ACTION=\"$ENV{'SCRIPT_NAME'}/SetUserSettings\" NAME=\"Search\" METHOD=POST>\n"); |
3993 |
|
3994 |
# Send the buttons |
3995 |
print("<TR><TD ALIGN=RIGHT VALIGN=TOP COLSPAN=2> <INPUT TYPE=RESET VALUE=\"Pobri¹i polja\"> <INPUT TYPE=SUBMIT VALUE=\"Saèuvaj postavke\"> </TD></TR>\n"); |
3996 |
|
3997 |
|
3998 |
|
3999 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2><HR WIDTH=50%></TD></TR>\n"); |
4000 |
|
4001 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> <B> Informacije o korisniku: </B> </TR>\n"); |
4002 |
|
4003 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Login: </TD><TD ALIGN=LEFT VALIGN=TOP> $ENV{'REMOTE_USER'} </TD></TR>\n"); |
4004 |
|
4005 |
$Value = (defined($UserName)) ? "VALUE=\"$UserName\"" : ""; |
4006 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Ime korisnika: </TD> <TD ALIGN=LEFT VALIGN=TOP> <INPUT NAME=\"UserName\" TYPE=TEXT $Value SIZE=45> </TD></TR>\n"); |
4007 |
|
4008 |
# Are regular searches enabled? |
4009 |
if ( defined($main::ConfigurationData{'allow-regular-searches'}) && ($main::ConfigurationData{'allow-regular-searches'} eq "yes") ) { |
4010 |
|
4011 |
# Get the email address |
4012 |
$Value = (defined($EmailAddress)) ? "VALUE=\"$EmailAddress\"" : ""; |
4013 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> E-mail adresa:"); |
4014 |
if ( !defined($EmailAddress) && defined($main::ConfigurationData{'allow-regular-searches'}) && ($main::ConfigurationData{'allow-regular-searches'} eq "yes") ) { |
4015 |
print(" (*) "); |
4016 |
} |
4017 |
print(": </TD> <TD ALIGN=LEFT VALIGN=TOP> <INPUT NAME=\"EmailAddress\" TYPE=TEXT $Value SIZE=45> </TD></TR>\n"); |
4018 |
|
4019 |
if ( !defined($EmailAddress) && defined($main::ConfigurationData{'allow-regular-searches'}) && ($main::ConfigurationData{'allow-regular-searches'} eq "yes") ) { |
4020 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> (*) Please fill in the email address if you are going to want to have your automatic searches delivered to you. </TD></TR>\n"); |
4021 |
} |
4022 |
} |
4023 |
|
4024 |
|
4025 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2><HR WIDTH=50%></TD></TR>\n"); |
4026 |
|
4027 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> <B> Search Preferences: </B> </TD></TR>\n"); |
4028 |
|
4029 |
# Send a pull-down which allows the user to select which search form to default to |
4030 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Forma za pretra¾ivanje: </TD> <TD ALIGN=LEFT VALIGN=TOP> <SELECT NAME=\"DefaultSearch\">\n"); |
4031 |
$Value = (defined($DefaultSearch) && ($DefaultSearch eq "Simple")) ? "SELECTED" : ""; |
4032 |
print("<OPTION VALUE=\"Simple\" $Value> Jednostavna forma za pretra¾ivanje\n"); |
4033 |
$Value = (defined($DefaultSearch) && ($DefaultSearch eq "Expanded")) ? "SELECTED" : ""; |
4034 |
print("<OPTION VALUE=\"Expanded\" $Value>Forma za pretra¾ivanje s vi¹e kriterija\n"); |
4035 |
print("</SELECT> </TD></TR>\n"); |
4036 |
|
4037 |
# Send a pull-down which allows the user to select how many previous searches to store |
4038 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Broj pretra¾ivanja koja ostaju zapamæena (maksimalno): </TD> <TD ALIGN=LEFT VALIGN=TOP> <SELECT NAME=\"SearchHistory\">\n"); |
4039 |
|
4040 |
for ( $SearchHistoryCount = 5; $SearchHistoryCount <= 20; $SearchHistoryCount += 5 ) { |
4041 |
$Value = (defined($SearchHistory) && ($SearchHistory == $SearchHistoryCount)) ? "SELECTED" : ""; |
4042 |
print("<OPTION VALUE=\"$SearchHistoryCount\" $Value> $SearchHistoryCount \n"); |
4043 |
} |
4044 |
print("</SELECT> </TD></TR>\n"); |
4045 |
|
4046 |
|
4047 |
# Database selection preferences |
4048 |
if ( %main::DatabaseDescriptions ) { |
4049 |
|
4050 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2><HR WIDTH=50%></TD></TR>\n"); |
4051 |
|
4052 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> <B> Odabrane baze: </B> </TD></TR>\n"); |
4053 |
|
4054 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> Oznaèite baze koje uvijek ¾elite pretra¾ivati:</TD></TR><TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2>\n"); |
4055 |
|
4056 |
# Parse out the database names and put them into a |
4057 |
# hash table, they should be separated with a '\n' |
4058 |
if ( defined($SelectedDatabases) && ($SelectedDatabases ne "") ) { |
4059 |
@ItemList = split(",", $SelectedDatabases); |
4060 |
} |
4061 |
|
4062 |
&ShowDatabaseCheckBoxes(@ItemList); |
4063 |
|
4064 |
print("</TD></TR>\n"); |
4065 |
} |
4066 |
|
4067 |
|
4068 |
|
4069 |
# Send a pull-down which allows the user to select whether to display summaries or not, and how long we want them |
4070 |
if ( defined($main::ConfigurationData{'allow-summary-displays'}) && ($main::ConfigurationData{'allow-summary-displays'} eq "yes") ) { |
4071 |
|
4072 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2><HR WIDTH=50%></TD></TR>\n"); |
4073 |
|
4074 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> <B> Document Summary Preferences: </B> </TD></TR>\n"); |
4075 |
|
4076 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Document summary type: </TD> <TD ALIGN=LEFT VALIGN=TOP><SELECT NAME=\"SummaryType\">\n"); |
4077 |
foreach $ItemEntry ( keys (%main::SummaryTypes) ) { |
4078 |
$Value = (defined($SummaryType) && ($SummaryType eq $ItemEntry)) ? "SELECTED" : ""; |
4079 |
print("<OPTION VALUE=\"$ItemEntry\" $Value> $main::SummaryTypes{$ItemEntry}\n"); |
4080 |
} |
4081 |
print("</SELECT></TD></TR>\n"); |
4082 |
|
4083 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Document summary length in words (max): </TD> <TD ALIGN=LEFT VALIGN=TOP><SELECT NAME=\"SummaryLength\">\n"); |
4084 |
foreach $ItemEntry ( @main::SummaryLengths ) { |
4085 |
$Value = (defined($SummaryLength) && ($SummaryLength eq $ItemEntry)) ? "SELECTED" : ""; |
4086 |
print("<OPTION VALUE=\"$ItemEntry\" $Value> $ItemEntry\n"); |
4087 |
} |
4088 |
print("</SELECT></TD></TR>\n"); |
4089 |
} |
4090 |
|
4091 |
|
4092 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2><HR WIDTH=50%></TD></TR>\n"); |
4093 |
|
4094 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> <B> Document Retrieval Preferences: </B> </TD></TR>\n"); |
4095 |
|
4096 |
# Send a pull-down which allows the user to select whether to display summaries or not, and how long we want them |
4097 |
if ( defined($main::ConfigurationData{'allow-similiar-search'}) && ($main::ConfigurationData{'allow-similiar-search'} eq "yes") ) { |
4098 |
|
4099 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Number of similar documents retrieved (max): </TD> <TD ALIGN=LEFT VALIGN=TOP><SELECT NAME=\"SimilarDocuments\">\n"); |
4100 |
foreach $ItemEntry ( @main::SimilarDocuments ) { |
4101 |
$Value = (defined($SimilarDocuments) && ($SimilarDocuments eq $ItemEntry)) ? "SELECTED" : ""; |
4102 |
print("<OPTION VALUE=\"$ItemEntry\" $Value> $ItemEntry\n"); |
4103 |
} |
4104 |
print("</SELECT></TD></TR>\n"); |
4105 |
} |
4106 |
|
4107 |
|
4108 |
|
4109 |
|
4110 |
# Are regular searches enabled? |
4111 |
if ( defined($main::ConfigurationData{'allow-regular-searches'}) && ($main::ConfigurationData{'allow-regular-searches'} eq "yes") ) { |
4112 |
|
4113 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2><HR WIDTH=50%></TD></TR>\n"); |
4114 |
|
4115 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> <B> Saved Searches Defaults: </B> </TD></TR>\n"); |
4116 |
|
4117 |
# Send a pull-down which allows the user to select the automatic search frequency (default to weekly) |
4118 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Saved search frequency: </TD> <TD ALIGN=LEFT VALIGN=TOP> <SELECT NAME=\"SearchFrequency\">\n"); |
4119 |
foreach $ItemEntry ( @main::SearchFrequencies ) { |
4120 |
$Value = (defined($SearchFrequency) && ($SearchFrequency eq $ItemEntry)) ? "SELECTED" : ""; |
4121 |
print("<OPTION VALUE=\"$ItemEntry\" $Value> $ItemEntry \n"); |
4122 |
} |
4123 |
print("</SELECT> </TD></TR>\n"); |
4124 |
|
4125 |
# Send a pull-down which allows the user to select the automatic search delivery format |
4126 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Saved search delivery format: </TD> <TD ALIGN=LEFT VALIGN=TOP> <SELECT NAME=\"DeliveryFormat\">\n"); |
4127 |
foreach $ItemEntry ( sort(keys(%main::DeliveryFormats)) ) { |
4128 |
$Value = (defined($DeliveryFormat) && ($DeliveryFormat eq $ItemEntry)) ? "SELECTED" : ""; |
4129 |
print("<OPTION VALUE=\"$ItemEntry\" $Value> $main::DeliveryFormats{$ItemEntry}\n"); |
4130 |
} |
4131 |
print("</SELECT> </TD></TR>\n"); |
4132 |
|
4133 |
# Send a pull-down which allows the user to select the automatic delivery method |
4134 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Saved search delivery method: </TD> <TD ALIGN=LEFT VALIGN=TOP> <SELECT NAME=\"DeliveryMethod\">\n"); |
4135 |
foreach $ItemEntry ( sort(keys(%main::DeliveryMethods)) ) { |
4136 |
$Value = (defined($DeliveryMethod) && ($DeliveryMethod eq $ItemEntry)) ? "SELECTED" : ""; |
4137 |
print("<OPTION VALUE=\"$ItemEntry\" $Value> $main::DeliveryMethods{$ItemEntry}\n"); |
4138 |
} |
4139 |
print("</SELECT> </TD></TR>\n"); |
4140 |
} |
4141 |
|
4142 |
|
4143 |
print("</FORM>\n"); |
4144 |
print("</TABLE>\n"); |
4145 |
|
4146 |
|
4147 |
|
4148 |
# Bail from the settings |
4149 |
bailFromGetUserSettings: |
4150 |
|
4151 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
4152 |
undef(%Value); |
4153 |
$Value{'GetUserSettings'} = "GetUserSettings"; |
4154 |
&vSendMenuBar(%Value); |
4155 |
undef(%Value); |
4156 |
|
4157 |
&vSendHTMLFooter; |
4158 |
|
4159 |
return; |
4160 |
|
4161 |
} |
4162 |
|
4163 |
|
4164 |
|
4165 |
|
4166 |
|
4167 |
|
4168 |
#-------------------------------------------------------------------------- |
4169 |
# |
4170 |
# Function: vSetUserSettings() |
4171 |
# |
4172 |
# Purpose: This function saves the user setting |
4173 |
# |
4174 |
# Called by: |
4175 |
# |
4176 |
# Parameters: void |
4177 |
# |
4178 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
4179 |
# $main::UserSettingsFilePath, $main::RemoteUser, |
4180 |
# |
4181 |
# Returns: void |
4182 |
# |
4183 |
sub vSetUserSettings { |
4184 |
|
4185 |
my (%Value); |
4186 |
|
4187 |
|
4188 |
# Return an error if the remote user name/account directory is not defined |
4189 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
4190 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
4191 |
&vSendHTMLFooter; |
4192 |
return; |
4193 |
} |
4194 |
|
4195 |
|
4196 |
# Make sure that we send the header |
4197 |
&vSendHTMLHeader("My Settings", undef); |
4198 |
undef(%Value); |
4199 |
&vSendMenuBar(%Value); |
4200 |
|
4201 |
|
4202 |
# Save the user settings |
4203 |
undef(%Value); |
4204 |
$Value{'UserName'} = $main::FormData{'UserName'}; |
4205 |
$Value{'EmailAddress'} = $main::FormData{'EmailAddress'}; |
4206 |
$Value{'DefaultSearch'} = $main::FormData{'DefaultSearch'}; |
4207 |
$Value{'SelectedDatabases'} = $main::FormData{'Database'}; |
4208 |
if ( defined($Value{'SelectedDatabases'}) ) { |
4209 |
$Value{'SelectedDatabases'} =~ s/\0/,/g; |
4210 |
} |
4211 |
$Value{'SearchHistory'} = $main::FormData{'SearchHistory'}; |
4212 |
$Value{'SearchFrequency'} = $main::FormData{'SearchFrequency'}; |
4213 |
$Value{'DeliveryFormat'} = $main::FormData{'DeliveryFormat'}; |
4214 |
$Value{'DeliveryMethod'} = $main::FormData{'DeliveryMethod'}; |
4215 |
$Value{'SummaryType'} = $main::FormData{'SummaryType'}; |
4216 |
$Value{'SummaryLength'} = $main::FormData{'SummaryLength'}; |
4217 |
$Value{'SimilarDocuments'} = $main::FormData{'SimilarDocuments'}; |
4218 |
|
4219 |
|
4220 |
# Save the user settings file |
4221 |
if ( &iSaveXMLFileFromHash($main::UserSettingsFilePath, "UserSettings", %Value) ) { |
4222 |
|
4223 |
print("<H3> Postavke: </H3>\n"); |
4224 |
print("<H3><CENTER> Postavke su uspje¹no snimljene! </CENTER></H3>\n"); |
4225 |
print("<P>\n"); |
4226 |
} |
4227 |
else { |
4228 |
|
4229 |
# The settings could not be saved, so we inform the user of the fact |
4230 |
&vHandleError("User Settings", "Sorry, we failed to saved your settings"); |
4231 |
} |
4232 |
|
4233 |
|
4234 |
|
4235 |
# Bail from the settings |
4236 |
bailFromSetUserSettings: |
4237 |
|
4238 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
4239 |
undef(%Value); |
4240 |
&vSendMenuBar(%Value); |
4241 |
|
4242 |
&vSendHTMLFooter; |
4243 |
|
4244 |
return; |
4245 |
|
4246 |
} |
4247 |
|
4248 |
|
4249 |
|
4250 |
|
4251 |
|
4252 |
|
4253 |
#-------------------------------------------------------------------------- |
4254 |
# |
4255 |
# Function: vPurgeSearchHistory() |
4256 |
# |
4257 |
# Purpose: This function purges the search history files. |
4258 |
# |
4259 |
# Called by: |
4260 |
# |
4261 |
# Parameters: void |
4262 |
# |
4263 |
# Global Variables: $main::DefaultMaxSearchHistory, $main::UserSettingsFilePath, |
4264 |
# $main::SearchHistoryFileNamePrefix, $main::UserAccountDirectoryPath |
4265 |
# |
4266 |
# Returns: void |
4267 |
# |
4268 |
sub vPurgeSearchHistory { |
4269 |
|
4270 |
my ($MaxSearchHistory, @SearchHistoryList, $SearchHistoryEntry); |
4271 |
|
4272 |
|
4273 |
# Return if the remote user name/account directory is not defined |
4274 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
4275 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
4276 |
&vSendHTMLFooter; |
4277 |
return; |
4278 |
} |
4279 |
|
4280 |
|
4281 |
# Get the max number of entries in the search history |
4282 |
$MaxSearchHistory = &sGetTagValueFromXMLFile($main::UserSettingsFilePath, "SearchHistory"); |
4283 |
|
4284 |
# Set the detault max number of entries if it was not gotten from the user settings |
4285 |
if ( !defined($MaxSearchHistory) ) { |
4286 |
$MaxSearchHistory = $main::DefaultMaxSearchHistory; |
4287 |
} |
4288 |
|
4289 |
|
4290 |
# Read all the search history files |
4291 |
opendir(USER_ACCOUNT_DIRECTORY, $main::UserAccountDirectoryPath); |
4292 |
@SearchHistoryList = map("$main::UserAccountDirectoryPath/$_" , |
4293 |
reverse(sort(grep(/$main::SearchHistoryFileNamePrefix/, readdir(USER_ACCOUNT_DIRECTORY))))); |
4294 |
closedir(USER_ACCOUNT_DIRECTORY); |
4295 |
|
4296 |
|
4297 |
# Purge the excess search history files |
4298 |
if ( scalar(@SearchHistoryList) > $MaxSearchHistory ) { |
4299 |
|
4300 |
# Splice out the old stuff, and loop over it deleting the files |
4301 |
for $SearchHistoryEntry ( splice(@SearchHistoryList, $MaxSearchHistory) ) { |
4302 |
unlink($SearchHistoryEntry); |
4303 |
} |
4304 |
} |
4305 |
|
4306 |
return; |
4307 |
|
4308 |
} |
4309 |
|
4310 |
|
4311 |
|
4312 |
|
4313 |
#-------------------------------------------------------------------------- |
4314 |
# |
4315 |
# Function: vListSearchHistory() |
4316 |
# |
4317 |
# Purpose: This function lists the search history for the user, the |
4318 |
# entries are listed in reverse chronological order (most |
4319 |
# recent first). |
4320 |
# |
4321 |
# In addition, the search history will be scanned and excess |
4322 |
# searches will be purged. |
4323 |
# |
4324 |
# Called by: |
4325 |
# |
4326 |
# Parameters: void |
4327 |
# |
4328 |
# Global Variables: %main::ConfigurationData, $main::UserAccountDirectoryPath, |
4329 |
# $main::XMLFileNameExtension, $main::SearchHistoryFileNamePrefix, |
4330 |
# $main::RemoteUser |
4331 |
# |
4332 |
# Returns: void |
4333 |
# |
4334 |
sub vListSearchHistory { |
4335 |
|
4336 |
my (@SearchHistoryList, @QualifiedSearchHistoryList, $SearchHistoryEntry); |
4337 |
my ($SearchString, $CreationTime, $SearchAndRfDocumentURL, $HeaderName, $Database); |
4338 |
my ($Value, %Value, @Values); |
4339 |
|
4340 |
|
4341 |
# Return an error if the remote user name/account directory is not defined |
4342 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
4343 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
4344 |
&vSendHTMLFooter; |
4345 |
return; |
4346 |
} |
4347 |
|
4348 |
|
4349 |
|
4350 |
# Make sure that we send the header |
4351 |
&vSendHTMLHeader("Prija¹nja pretra¾ivanja", undef); |
4352 |
undef(%Value); |
4353 |
$Value{'ListSearchHistory'} = "ListSearchHistory"; |
4354 |
&vSendMenuBar(%Value); |
4355 |
undef(%Value); |
4356 |
|
4357 |
|
4358 |
# Purge the search history files |
4359 |
&vPurgeSearchHistory; |
4360 |
|
4361 |
|
4362 |
# Read all the search history files |
4363 |
opendir(USER_ACCOUNT_DIRECTORY, $main::UserAccountDirectoryPath); |
4364 |
@SearchHistoryList = map("$main::UserAccountDirectoryPath/$_", reverse(sort(grep(/$main::SearchHistoryFileNamePrefix/, readdir(USER_ACCOUNT_DIRECTORY))))); |
4365 |
closedir(USER_ACCOUNT_DIRECTORY); |
4366 |
|
4367 |
|
4368 |
# Loop over each search history file checking that it is valid |
4369 |
for $SearchHistoryEntry ( @SearchHistoryList ) { |
4370 |
|
4371 |
# Get the header name from the XML search history file |
4372 |
$HeaderName = &sGetObjectTagFromXMLFile($SearchHistoryEntry); |
4373 |
|
4374 |
# Check that the entry is valid and add it to the qualified list |
4375 |
if ( defined($HeaderName) && ($HeaderName eq "SearchHistory") ) { |
4376 |
push @QualifiedSearchHistoryList, $SearchHistoryEntry; |
4377 |
} |
4378 |
else { |
4379 |
# Else we delete this invalid search history file |
4380 |
unlink($SearchHistoryEntry); |
4381 |
} |
4382 |
} |
4383 |
|
4384 |
|
4385 |
|
4386 |
# Display the search history |
4387 |
print("<H3> Prija¹nja pretra¾ivanja: </H3>\n"); |
4388 |
|
4389 |
# Print up the search history, if there is none, we put up a nice message |
4390 |
if ( scalar(@QualifiedSearchHistoryList) > 0 ) { |
4391 |
|
4392 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
4393 |
|
4394 |
|
4395 |
for $SearchHistoryEntry ( @QualifiedSearchHistoryList ) { |
4396 |
|
4397 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=3><HR WIDTH=50%></TD></TR>\n"); |
4398 |
|
4399 |
# Get information from the XML search history file |
4400 |
($HeaderName, %Value) = &shGetHashFromXMLFile($SearchHistoryEntry); |
4401 |
|
4402 |
# Get the search file name and encode it |
4403 |
$SearchHistoryEntry = ($SearchHistoryEntry =~ /^$main::UserAccountDirectoryPath\/(.*)/) ? $1 : $SearchHistoryEntry; |
4404 |
$SearchHistoryEntry = &lEncodeURLData($SearchHistoryEntry); |
4405 |
|
4406 |
$CreationTime = $Value{'CreationTime'}; |
4407 |
$SearchAndRfDocumentURL = $Value{'SearchAndRfDocumentURL'}; |
4408 |
%Value = &hParseURLIntoHashTable($SearchAndRfDocumentURL); |
4409 |
$SearchString = &sMakeSearchString(%Value); |
4410 |
if ( defined($SearchString) ) { |
4411 |
$SearchString =~ s/{.*?}//gs; |
4412 |
$SearchString = ($SearchString =~ /\S/) ? $SearchString : undef; |
4413 |
} |
4414 |
$SearchString = defined($SearchString) ? $SearchString : "(No search terms defined)"; |
4415 |
|
4416 |
|
4417 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Upit: </TD><TD ALIGN=LEFT VALIGN=TOP> $SearchString </TD></TR>\n"); |
4418 |
|
4419 |
# Get the local databases from the search and list their descriptions |
4420 |
if ( defined($Value{'Database'}) ) { |
4421 |
|
4422 |
# Initialize the temp list |
4423 |
undef(@Values); |
4424 |
|
4425 |
# Loop over each database |
4426 |
foreach $Database ( split(/\0/, $Value{'Database'}) ) { |
4427 |
$Value = &lEncodeURLData($Database); |
4428 |
push @Values, sprintf("<A HREF=\"$ENV{'SCRIPT_NAME'}/GetDatabaseInfo?Database=$Value\" OnMouseOver=\"self.status='Informacije o bazi $main::DatabaseDescriptions{$Database}'; return true\"> $main::DatabaseDescriptions{$Database} </A> "); |
4429 |
} |
4430 |
|
4431 |
# Print the list if there are any entries in it |
4432 |
if ( scalar(@Values) > 0 ) { |
4433 |
printf("<TR><TD ALIGN=LEFT VALIGN=TOP> Database%s: </TD><TD ALIGN=LEFT VALIGN=TOP> %s </TD></TR>\n", |
4434 |
scalar(@Values) > 1 ? "s" : "", join(", ", @Values)); |
4435 |
} |
4436 |
} |
4437 |
|
4438 |
if ( defined($Value{'RfDocument'}) ) { |
4439 |
print("<TR>"); |
4440 |
&bDisplayDocuments("Feedback Document", $Value{'RfDocument'}, "RfDocument", undef, undef, 1); |
4441 |
print("</TR>"); |
4442 |
} |
4443 |
|
4444 |
$Value = &sGetPrintableDateFromTime($CreationTime); |
4445 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Datum kreiranja: </TD><TD ALIGN=LEFT VALIGN=TOP> $Value </TD></TR>\n"); |
4446 |
|
4447 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> </TD><TD ALIGN=LEFT VALIGN=TOP> <A HREF=\"$ENV{'SCRIPT_NAME'}/GetSearchHistory?SearchHistoryObject=$SearchHistoryEntry\" > [ Prika¾i rezultate pretra¾ivanja ] </A> </TD></TR>\n"); |
4448 |
|
4449 |
} |
4450 |
|
4451 |
print("</TABLE>\n"); |
4452 |
} |
4453 |
else { |
4454 |
print("<H3><CENTER> Sorry, currently there is no search history. </CENTER></H3>\n"); |
4455 |
} |
4456 |
|
4457 |
|
4458 |
|
4459 |
# Bail from the search history |
4460 |
bailFromListSearchHistory: |
4461 |
|
4462 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
4463 |
undef(%Value); |
4464 |
$Value{'ListSearchHistory'} = "ListSearchHistory"; |
4465 |
&vSendMenuBar(%Value); |
4466 |
undef(%Value); |
4467 |
|
4468 |
&vSendHTMLFooter; |
4469 |
|
4470 |
return; |
4471 |
|
4472 |
} |
4473 |
|
4474 |
|
4475 |
|
4476 |
|
4477 |
|
4478 |
#-------------------------------------------------------------------------- |
4479 |
# |
4480 |
# Function: vGetSearchHistory() |
4481 |
# |
4482 |
# Purpose: This function displays a search history file to the user. |
4483 |
# |
4484 |
# Called by: |
4485 |
# |
4486 |
# Parameters: void |
4487 |
# |
4488 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
4489 |
# $main::UserAccountDirectoryPath, $main::XMLFileNameExtension, |
4490 |
# $main::SearchHistoryFileNamePrefix, $main::RemoteUser |
4491 |
# |
4492 |
# Returns: void |
4493 |
# |
4494 |
sub vGetSearchHistory { |
4495 |
|
4496 |
my ($SearchAndRfDocumentURL, $SearchResults, $QueryReport, $CreationTime); |
4497 |
my ($SearchHistoryEntry, $HeaderName, $Status); |
4498 |
my ($Value, %Value); |
4499 |
|
4500 |
|
4501 |
|
4502 |
# Return an error if the remote user name/account directory is not defined |
4503 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
4504 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
4505 |
&vSendHTMLFooter; |
4506 |
return; |
4507 |
} |
4508 |
|
4509 |
|
4510 |
# Create the search history file name |
4511 |
$SearchHistoryEntry = $main::UserAccountDirectoryPath . "/" . $main::FormData{'SearchHistoryObject'}; |
4512 |
|
4513 |
|
4514 |
# Check to see if the XML search history file requested is there |
4515 |
if ( ! -f $SearchHistoryEntry ) { |
4516 |
# Could not find the search history file |
4517 |
&vHandleError("Display Search History", "Sorry, we cant to access this search history object because it is not there"); |
4518 |
goto bailFromGetSearchHistory; |
4519 |
} |
4520 |
|
4521 |
|
4522 |
# Get information from the XML search history file |
4523 |
($HeaderName, %Value) = &shGetHashFromXMLFile($SearchHistoryEntry); |
4524 |
|
4525 |
# Check that the entry is valid |
4526 |
if ( !(defined($HeaderName) && ($HeaderName eq "SearchHistory")) ) { |
4527 |
&vHandleError("Display Search History", "Sorry, this search history object is invalid"); |
4528 |
goto bailFromGetSearchHistory; |
4529 |
} |
4530 |
|
4531 |
|
4532 |
|
4533 |
# At this point, the XML search history file is there and is valid, |
4534 |
# so we can go ahead and display it |
4535 |
$SearchAndRfDocumentURL = $Value{'SearchAndRfDocumentURL'}; |
4536 |
$SearchResults = $Value{'SearchResults'}; |
4537 |
$QueryReport = $Value{'QueryReport'}; |
4538 |
$CreationTime = $Value{'CreationTime'}; |
4539 |
|
4540 |
%main::FormData = &hParseURLIntoHashTable($SearchAndRfDocumentURL); |
4541 |
|
4542 |
# Make sure that we send the header |
4543 |
&vSendHTMLHeader("Display Search History", undef); |
4544 |
undef(%Value); |
4545 |
&vSendMenuBar(%Value); |
4546 |
|
4547 |
|
4548 |
($Status, $QueryReport) = &bsDisplaySearchResults("Rezultati prija¹njih pretra¾ivanja:", undef, undef, undef, $SearchResults, $QueryReport, $ENV{'SCRIPT_NAME'}, 1, 1, 1, %main::FormData); |
4549 |
|
4550 |
|
4551 |
# Bail from displaying the search history |
4552 |
bailFromGetSearchHistory: |
4553 |
|
4554 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
4555 |
undef(%Value); |
4556 |
&vSendMenuBar(%Value); |
4557 |
|
4558 |
&vSendHTMLFooter; |
4559 |
|
4560 |
return; |
4561 |
|
4562 |
} |
4563 |
|
4564 |
|
4565 |
|
4566 |
|
4567 |
|
4568 |
|
4569 |
#-------------------------------------------------------------------------- |
4570 |
# |
4571 |
# Function: vGetSaveSearch() |
4572 |
# |
4573 |
# Purpose: This function displays a form to the user allowing them to save a search |
4574 |
# |
4575 |
# Called by: |
4576 |
# |
4577 |
# Parameters: void |
4578 |
# |
4579 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
4580 |
# $main::UserSettingsFilePath, $main::RemoteUser, |
4581 |
# |
4582 |
# Returns: void |
4583 |
# |
4584 |
sub vGetSaveSearch { |
4585 |
|
4586 |
|
4587 |
my ($SearchString, $Database); |
4588 |
my ($HeaderName, $SearchFrequency, $DeliveryFormat, $DeliveryMethod); |
4589 |
my ($JavaScript, $EmailAddress); |
4590 |
my ($Value, @Values, %Value, $ValueEntry); |
4591 |
|
4592 |
|
4593 |
# Return an error if the remote user name/account directory is not defined |
4594 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
4595 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
4596 |
&vSendHTMLFooter; |
4597 |
return; |
4598 |
} |
4599 |
|
4600 |
|
4601 |
$JavaScript = '<SCRIPT LANGUAGE="JavaScript"> |
4602 |
<!-- hide |
4603 |
function checkForm( Form ) { |
4604 |
if ( !checkField( Form.SearchName, "Search name" ) ) |
4605 |
return false |
4606 |
return true |
4607 |
} |
4608 |
function checkField( Field, Name ) { |
4609 |
if ( Field.value == "" ) { |
4610 |
errMsg( Field, "Niste ispunili polje \'"+Name+"\' ." ) |
4611 |
return false |
4612 |
} |
4613 |
else { |
4614 |
return true |
4615 |
} |
4616 |
} |
4617 |
function errMsg( Field, Msg ) { |
4618 |
alert( Msg ) |
4619 |
Field.focus() |
4620 |
return |
4621 |
} |
4622 |
// --> |
4623 |
</SCRIPT> |
4624 |
'; |
4625 |
|
4626 |
|
4627 |
|
4628 |
# Make sure that we send the header |
4629 |
&vSendHTMLHeader("Save this Search", $JavaScript); |
4630 |
undef(%Value); |
4631 |
&vSendMenuBar(%Value); |
4632 |
|
4633 |
|
4634 |
# Give the user a form to fill out |
4635 |
print("<H3> Saving a search: </H3>\n"); |
4636 |
|
4637 |
|
4638 |
|
4639 |
# Get information from the XML saved search file |
4640 |
($HeaderName, %Value) = &shGetHashFromXMLFile($main::UserSettingsFilePath); |
4641 |
|
4642 |
$SearchFrequency = $Value{'SearchFrequency'}; |
4643 |
$DeliveryFormat = $Value{'DeliveryFormat'}; |
4644 |
$DeliveryMethod = $Value{'DeliveryMethod'}; |
4645 |
$EmailAddress = $Value{'EmailAddress'}; |
4646 |
|
4647 |
|
4648 |
# Print up the table start |
4649 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
4650 |
|
4651 |
# Start the form |
4652 |
print("<FORM ACTION=\"$ENV{'SCRIPT_NAME'}/SetSaveSearch\" onSubmit=\"return checkForm(this)\" METHOD=POST>\n"); |
4653 |
|
4654 |
# Send the buttons |
4655 |
print("<TR><TD ALIGN=RIGHT VALIGN=TOP COLSPAN=2> <INPUT TYPE=RESET VALUE=\"Pobri¹i polja\"> <INPUT TYPE=SUBMIT VALUE=\"Save this Search\"> </TD></TR>\n"); |
4656 |
|
4657 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2><HR WIDTH=50%></TD></TR>\n"); |
4658 |
|
4659 |
# Print up the search string |
4660 |
$SearchString = &sMakeSearchString(%main::FormData); |
4661 |
if ( defined($SearchString) ) { |
4662 |
$SearchString =~ s/{.*?}//gs; |
4663 |
$SearchString = ($SearchString =~ /\S/) ? $SearchString : undef; |
4664 |
} |
4665 |
$SearchString = defined($SearchString) ? $SearchString : "(No search terms defined)"; |
4666 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Upit: </TD> <TD ALIGN=LEFT VALIGN=TOP> $SearchString </TD></TR>\n"); |
4667 |
|
4668 |
# Get the local databases from the search and list their descriptions |
4669 |
if ( defined($main::FormData{'Database'}) ) { |
4670 |
|
4671 |
# Initialize the temp list |
4672 |
undef(@Values); |
4673 |
|
4674 |
foreach $Database ( sort(split(/\0/, $main::FormData{'Database'})) ) { |
4675 |
$Value = &lEncodeURLData($Database); |
4676 |
push @Values, sprintf("<A HREF=\"$ENV{'SCRIPT_NAME'}/GetDatabaseInfo?Database=$Value\" OnMouseOver=\"self.status='Get Information about the $main::DatabaseDescriptions{$Database} database'; return true\"> $main::DatabaseDescriptions{$Database} </A> "); |
4677 |
} |
4678 |
|
4679 |
# Print the list if there are any entries in it |
4680 |
if ( scalar(@Values) > 0 ) { |
4681 |
printf("<TR><TD ALIGN=LEFT VALIGN=TOP> Database%s: </TD> <TD ALIGN=LEFT VALIGN=TOP> %s </TD></TR>\n", (scalar(@Values) > 1) ? "s" : "", join(", ", @Values)); |
4682 |
} |
4683 |
} |
4684 |
|
4685 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2><HR WIDTH=50%></TD></TR>\n"); |
4686 |
|
4687 |
# Send the search name and search description fields |
4688 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Search Name (required): </TD> <TD ALIGN=LEFT VALIGN=TOP> <INPUT NAME=\"SearchName\" TYPE=TEXT SIZE=45> </TD></TR>\n"); |
4689 |
|
4690 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Search Description: </TD> <TD ALIGN=LEFT VALIGN=TOP> <TEXTAREA INPUT NAME=\"SearchDescription\" COLS=45 ROWS=6 WRAP=VIRTUAL></TEXTAREA> </TD></TR>\n"); |
4691 |
|
4692 |
if ( defined($main::FormData{'RfDocument'}) ) { |
4693 |
print("<TR>\n"); |
4694 |
&bDisplayDocuments("Feedback Document", $main::FormData{'RfDocument'}, "RfDocument", undef, undef, 1); |
4695 |
print("</TR>\n"); |
4696 |
} |
4697 |
|
4698 |
|
4699 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2><HR WIDTH=50%></TD></TR>\n"); |
4700 |
|
4701 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Kliknite na ovaj kvadratiæ ako ¾elite postojeæi folder s istim imenom zamijeniti ovim novim: </TD> <TD ALIGN=LEFT VALIGN=TOP><INPUT TYPE=\"checkbox\" NAME=\"OverWrite\" VALUE=\"yes\"> </TD></TR>\n"); |
4702 |
|
4703 |
|
4704 |
|
4705 |
# Are regular searches enabled? |
4706 |
if ( defined($main::ConfigurationData{'allow-regular-searches'}) && ($main::ConfigurationData{'allow-regular-searches'} eq "yes") ) { |
4707 |
|
4708 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2><HR WIDTH=50%></TD></TR>\n"); |
4709 |
|
4710 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Check to run this search on a regular basis: </TD> <TD ALIGN=LEFT VALIGN=TOP> <INPUT TYPE=CHECKBOX VALUE=\"yes\" NAME=\"Regular\"> </TD></TR>\n"); |
4711 |
|
4712 |
# Send a pull-down which allows the user to select the automatic search frequency |
4713 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Select the search frequency: </TD> <TD ALIGN=LEFT VALIGN=TOP> <SELECT NAME=\"SearchFrequency\">\n"); |
4714 |
foreach $ValueEntry ( @main::SearchFrequencies ) { |
4715 |
$Value = (defined($SearchFrequency) && ($SearchFrequency eq $ValueEntry)) ? "SELECTED" : ""; |
4716 |
print("<OPTION VALUE=\"$ValueEntry\" $Value> $ValueEntry \n"); |
4717 |
} |
4718 |
print("</SELECT> </TD></TR>\n"); |
4719 |
|
4720 |
# Send a pull-down which allows the user to select the automatic search delivery format |
4721 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Select the delivery format: </TD> <TD ALIGN=LEFT VALIGN=TOP> <SELECT NAME=\"DeliveryFormat\">\n"); |
4722 |
foreach $ValueEntry ( sort(keys(%main::DeliveryFormats)) ) { |
4723 |
$Value = (defined($DeliveryFormat) && ($DeliveryFormat eq $ValueEntry)) ? "SELECTED" : ""; |
4724 |
print("<OPTION VALUE=\"$ValueEntry\" $Value> $main::DeliveryFormats{$ValueEntry}\n"); |
4725 |
} |
4726 |
print("</SELECT> </TD></TR>\n"); |
4727 |
|
4728 |
# Send a pull-down which allows the user to select the automatic search delivery method |
4729 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Select the delivery method: </TD> <TD ALIGN=LEFT VALIGN=TOP> <SELECT NAME=\"DeliveryMethod\">\n"); |
4730 |
foreach $ValueEntry ( sort(keys(%main::DeliveryMethods)) ) { |
4731 |
$Value = (defined($DeliveryMethod) && ($DeliveryMethod eq $ValueEntry)) ? "SELECTED" : ""; |
4732 |
print("<OPTION VALUE=\"$ValueEntry\" $Value> $main::DeliveryMethods{$ValueEntry}\n"); |
4733 |
} |
4734 |
print("</SELECT> </TD></TR>\n"); |
4735 |
} |
4736 |
|
4737 |
|
4738 |
# List the hidden fields |
4739 |
%Value = &hParseURLIntoHashTable(&sMakeSearchAndRfDocumentURL(%main::FormData)); |
4740 |
foreach $Value ( keys(%Value) ) { |
4741 |
foreach $ValueEntry ( split(/\0/, $Value{$Value}) ) { |
4742 |
print("<INPUT TYPE=HIDDEN NAME=\"$Value\" VALUE=\"$ValueEntry\">\n"); |
4743 |
} |
4744 |
} |
4745 |
|
4746 |
print("</FORM>\n"); |
4747 |
print("</TABLE>\n"); |
4748 |
|
4749 |
if ( !defined($EmailAddress) && |
4750 |
(defined($main::ConfigurationData{'allow-regular-searches'}) && ($main::ConfigurationData{'allow-regular-searches'} eq "yes")) ) { |
4751 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
4752 |
print("<B>Note: </B> You have not specified an email address in your settings, you will need to specify it if you want to run this search on a regular basis. <P>\n"); |
4753 |
} |
4754 |
|
4755 |
|
4756 |
# Bail from saving the search |
4757 |
bailFromGetSaveSearch: |
4758 |
|
4759 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
4760 |
undef(%Value); |
4761 |
&vSendMenuBar(%Value); |
4762 |
|
4763 |
&vSendHTMLFooter; |
4764 |
|
4765 |
return; |
4766 |
|
4767 |
} |
4768 |
|
4769 |
|
4770 |
|
4771 |
|
4772 |
|
4773 |
|
4774 |
#-------------------------------------------------------------------------- |
4775 |
# |
4776 |
# Function: vSetSaveSearch() |
4777 |
# |
4778 |
# Purpose: This function saves that search and search name in a search file |
4779 |
# |
4780 |
# Called by: |
4781 |
# |
4782 |
# Parameters: void |
4783 |
# |
4784 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
4785 |
# $main::UserSettingsFilePath, $main::RemoteUser, |
4786 |
# |
4787 |
# Returns: void |
4788 |
# |
4789 |
sub vSetSaveSearch { |
4790 |
|
4791 |
|
4792 |
my ($SearchAndRfDocumentURL, $SearchString); |
4793 |
my (@SavedSearchList, $SavedSearchEntry, $SavedSearchFilePath); |
4794 |
my ($EmailAddress, $SearchName, $CreationTime, $LastRunTime); |
4795 |
my ($Value, %Value); |
4796 |
|
4797 |
|
4798 |
# Return an error if the remote user name/account directory is not defined |
4799 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
4800 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
4801 |
&vSendHTMLFooter; |
4802 |
return; |
4803 |
} |
4804 |
|
4805 |
|
4806 |
# Make sure that we send the header |
4807 |
&vSendHTMLHeader("Saèuvana pretra¾ivanja", undef); |
4808 |
undef(%Value); |
4809 |
&vSendMenuBar(%Value); |
4810 |
|
4811 |
|
4812 |
# Check that the required fields are filled in |
4813 |
if ( !defined($main::FormData{'SearchName'}) ) { |
4814 |
|
4815 |
# A required field is missing, so we suggest corrective action to the user. |
4816 |
print("<H3> Snimanje pretra¾ivanja: </H3>\n"); |
4817 |
print("<H3><CENTER> Oprostite, nedostaju neke informacije. </CENTER></H3>\n"); |
4818 |
print("<P>\n"); |
4819 |
print("Polje <B>'search name'</B> mora biti ispunjeno da bi se moglo saèuvati pretra¾ivanje.<P>\n"); |
4820 |
print("Kliknite na <B>'Back'</B> u svom browseru, popunite polje koje nedostaje i poku¹ajte ponovo.\n"); |
4821 |
print("<P>\n"); |
4822 |
|
4823 |
goto bailFromSetSaveSearch; |
4824 |
|
4825 |
} |
4826 |
|
4827 |
|
4828 |
# Read all the saved search files |
4829 |
opendir(USER_ACCOUNT_DIRECTORY, $main::UserAccountDirectoryPath); |
4830 |
@SavedSearchList = map("$main::UserAccountDirectoryPath/$_", grep(/$main::SavedSearchFileNamePrefix/, readdir(USER_ACCOUNT_DIRECTORY))); |
4831 |
closedir(USER_ACCOUNT_DIRECTORY); |
4832 |
|
4833 |
|
4834 |
# Loop over each saved search file checking that it is valid |
4835 |
for $SavedSearchEntry ( @SavedSearchList ) { |
4836 |
|
4837 |
$SearchName = &sGetTagValueFromXMLFile($SavedSearchEntry, "SearchName"); |
4838 |
|
4839 |
if ( $SearchName eq $main::FormData{'SearchName'} ) { |
4840 |
$SavedSearchFilePath = $SavedSearchEntry; |
4841 |
last; |
4842 |
} |
4843 |
} |
4844 |
|
4845 |
# Check that the saved search file does not already exist |
4846 |
if ( defined($SavedSearchFilePath) && ($SavedSearchFilePath ne "") |
4847 |
&& !(defined($main::FormData{'OverWrite'}) && ($main::FormData{'OverWrite'} eq "yes")) ) { |
4848 |
|
4849 |
# There is already a saved search with this name, so we suggest corrective action to the user. |
4850 |
print("<H3> Saving a Search: </H3>\n"); |
4851 |
print("<H3><CENTER> Sorry, there is already a saved search with this name. </CENTER></H3>\n"); |
4852 |
print("<P>\n"); |
4853 |
print("Click <B>'back'</B> on your browser, change the <B>'search name'</B> and try again, \n"); |
4854 |
print("alternatively you can check the box which allows you to automatically over-write a saved search with the same name.\n"); |
4855 |
print("<P>\n"); |
4856 |
|
4857 |
goto bailFromSetSaveSearch; |
4858 |
} |
4859 |
|
4860 |
|
4861 |
# Get the email address of this user |
4862 |
$Value = &sGetTagValueFromXMLFile($main::UserSettingsFilePath, "EmailAddress"); |
4863 |
|
4864 |
# Check this user has an email address defined if they want to run the search on a regular basis |
4865 |
if ( !defined($Value) && (defined($main::FormData{'Regular'}) && ($main::FormData{'Regular'} eq "yes")) ) { |
4866 |
|
4867 |
# Regular delivery was requested, but the email address was not specified in the settings |
4868 |
print("<H3> Saving a Search: </H3>\n"); |
4869 |
print("<H3><CENTER> Sorry, your email address is not specified in your settings. </CENTER></H3>\n"); |
4870 |
print("<P>\n"); |
4871 |
print("You need to specify your email address in your settings if you want this search to run on a regular basis, \n"); |
4872 |
print("without your email address, we are not able to send you the search result. <P>\n"); |
4873 |
print("Click the <B>'Settings'</B> option from the menu sidebar, fill in your email address and save the settings, \n"); |
4874 |
print("then click <B>'back'</B> on your browser three times to go back to the form which allows you to save a search.\n"); |
4875 |
print("<P>\n"); |
4876 |
|
4877 |
goto bailFromSetSaveSearch; |
4878 |
} |
4879 |
|
4880 |
|
4881 |
# All the checks have been passed, so we can go ahead and save the search |
4882 |
|
4883 |
$CreationTime = time(); |
4884 |
$LastRunTime = $CreationTime; |
4885 |
|
4886 |
# Erase the search frequency and the delivery method if this is not a regular search |
4887 |
if ( !(defined($main::FormData{'Regular'}) && ($main::FormData{'Regular'} eq "yes")) ) { |
4888 |
$main::FormData{'SearchFrequency'} = ""; |
4889 |
$main::FormData{'DeliveryFormat'} = ""; |
4890 |
$main::FormData{'DeliveryMethod'} = ""; |
4891 |
$LastRunTime = ""; |
4892 |
} |
4893 |
|
4894 |
|
4895 |
# Get the URL search string |
4896 |
$SearchAndRfDocumentURL = &sMakeSearchAndRfDocumentURL(%main::FormData); |
4897 |
|
4898 |
# Save the search |
4899 |
if ( &iSaveSearch(undef, $main::FormData{'SearchName'}, $main::FormData{'SearchDescription'}, $SearchAndRfDocumentURL, $main::FormData{'SearchFrequency'}, $main::FormData{'DeliveryFormat'}, $main::FormData{'DeliveryMethod'}, "Active", $CreationTime, $LastRunTime) ) { |
4900 |
|
4901 |
print("<H3> Saving a Search: </H3>\n"); |
4902 |
print("<P>\n"); |
4903 |
print("<H3><CENTER> Your search was successfully saved. </CENTER></H3>\n"); |
4904 |
|
4905 |
# Delete the overwritten search file |
4906 |
if ( defined($SavedSearchFilePath) && ($SavedSearchFilePath ne "") ) { |
4907 |
unlink($SavedSearchFilePath); |
4908 |
} |
4909 |
} |
4910 |
else { |
4911 |
|
4912 |
# The search could not be saved, so we inform the user of the fact |
4913 |
&vHandleError("Saving a Search", "Sorry, we failed to save this search"); |
4914 |
goto bailFromSetSaveSearch; |
4915 |
} |
4916 |
|
4917 |
|
4918 |
# Bail from saving the search |
4919 |
bailFromSetSaveSearch: |
4920 |
|
4921 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
4922 |
undef(%Value); |
4923 |
&vSendMenuBar(%Value); |
4924 |
|
4925 |
&vSendHTMLFooter; |
4926 |
|
4927 |
return; |
4928 |
|
4929 |
} |
4930 |
|
4931 |
|
4932 |
|
4933 |
|
4934 |
|
4935 |
|
4936 |
#-------------------------------------------------------------------------- |
4937 |
# |
4938 |
# Function: vListSavedSearch() |
4939 |
# |
4940 |
# Purpose: This function allows the user list the saved searches and |
4941 |
# sets up the links allowing the user to get a search form |
4942 |
# filled with the search |
4943 |
# |
4944 |
# Called by: |
4945 |
# |
4946 |
# Parameters: void |
4947 |
# |
4948 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
4949 |
# $main::UserAccountDirectoryPath, $main::XMLFileNameExtension, |
4950 |
# $main::SavedSearchFileNamePrefix, $main::RemoteUser |
4951 |
# |
4952 |
# Returns: void |
4953 |
# |
4954 |
sub vListSavedSearch { |
4955 |
|
4956 |
my (@SavedSearchList, @QualifiedSavedSearchList, $SavedSearchEntry, $HeaderName, $SearchString, $Database); |
4957 |
my ($SearchName, $SearchDescription, $SearchAndRfDocumentURL, $SearchFrequency, $DeliveryFormat, $DeliveryMethod, $SearchStatus, $CreationTime, $LastRunTime); |
4958 |
my (@Values, $Value, %Value); |
4959 |
|
4960 |
|
4961 |
# Return an error if the remote user name/account directory is not defined |
4962 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
4963 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
4964 |
&vSendHTMLFooter; |
4965 |
return; |
4966 |
} |
4967 |
|
4968 |
|
4969 |
# Make sure that we send the header |
4970 |
&vSendHTMLHeader("Saèuvana pretra¾ivanja", undef); |
4971 |
undef(%Value); |
4972 |
$Value{'ListSavedSearch'} = "ListSavedSearch"; |
4973 |
&vSendMenuBar(%Value); |
4974 |
undef(%Value); |
4975 |
|
4976 |
|
4977 |
# Read all the saved search files |
4978 |
opendir(USER_ACCOUNT_DIRECTORY, $main::UserAccountDirectoryPath); |
4979 |
@SavedSearchList = map("$main::UserAccountDirectoryPath/$_", reverse(sort(grep(/$main::SavedSearchFileNamePrefix/, readdir(USER_ACCOUNT_DIRECTORY))))); |
4980 |
closedir(USER_ACCOUNT_DIRECTORY); |
4981 |
|
4982 |
|
4983 |
# Loop over each search history file checking that it is valid |
4984 |
for $SavedSearchEntry ( @SavedSearchList ) { |
4985 |
|
4986 |
# Get the header name from the XML saved search file |
4987 |
$HeaderName = &sGetObjectTagFromXMLFile($SavedSearchEntry); |
4988 |
|
4989 |
# Check that the entry is valid and add it to the qualified list |
4990 |
if ( defined($HeaderName) && ($HeaderName eq "SavedSearch") ) { |
4991 |
push @QualifiedSavedSearchList, $SavedSearchEntry; |
4992 |
} |
4993 |
else { |
4994 |
# Else we delete this invalid saved search file |
4995 |
unlink($SavedSearchEntry); |
4996 |
} |
4997 |
} |
4998 |
|
4999 |
|
5000 |
# Print out the saved searches |
5001 |
print("<H3> Saèuvana pretra¾ivanja: </H3>\n"); |
5002 |
|
5003 |
|
5004 |
|
5005 |
# Print up the saved searches, if there is none, we put up a nice message |
5006 |
if ( scalar(@QualifiedSavedSearchList) > 0 ) { |
5007 |
|
5008 |
# Start the table |
5009 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
5010 |
|
5011 |
# Start the form |
5012 |
print("<FORM ACTION=\"$ENV{'SCRIPT_NAME'}\" METHOD=POST>\n"); |
5013 |
|
5014 |
|
5015 |
print("<TR><TD ALIGN=RIGHT VALIGN=TOP COLSPAN=3> \n"); |
5016 |
print("<SELECT NAME=\"Action\">\n"); |
5017 |
print("<OPTION VALUE=\"ActivateSavedSearch\">Aktiviraj oznaèena saèuvana pretra¾ivanja\n"); |
5018 |
print("<OPTION VALUE=\"SuspendSavedSearch\">Stavi u mirovanje oznaèena saèuvana pretra¾ivanja\n"); |
5019 |
print("<OPTION VALUE=\"DeleteSavedSearch\">Obri¹i oznaèena saèuvana pretra¾ivanja\n"); |
5020 |
print("</SELECT>\n"); |
5021 |
print("<INPUT TYPE=SUBMIT VALUE=\"Do It!\">\n"); |
5022 |
print("</TD></TR>\n"); |
5023 |
|
5024 |
for $SavedSearchEntry ( @QualifiedSavedSearchList ) { |
5025 |
|
5026 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=3><HR WIDTH=50%></TD></TR>\n"); |
5027 |
|
5028 |
# Get information from the XML saved search file |
5029 |
($HeaderName, %Value) = &shGetHashFromXMLFile($SavedSearchEntry); |
5030 |
|
5031 |
# Get the saved search file name and encode it |
5032 |
$SavedSearchEntry = ($SavedSearchEntry =~ /^$main::UserAccountDirectoryPath\/(.*)/) ? $1 : $SavedSearchEntry; |
5033 |
$SavedSearchEntry = &lEncodeURLData($SavedSearchEntry); |
5034 |
|
5035 |
|
5036 |
$SearchName = $Value{'SearchName'}; |
5037 |
$SearchDescription = $Value{'SearchDescription'}; |
5038 |
$SearchAndRfDocumentURL = $Value{'SearchAndRfDocumentURL'}; |
5039 |
$SearchFrequency = $Value{'SearchFrequency'}; |
5040 |
$SearchStatus = $Value{'SearchStatus'}; |
5041 |
$DeliveryFormat = $Value{'DeliveryFormat'}; |
5042 |
$DeliveryMethod = $Value{'DeliveryMethod'}; |
5043 |
$CreationTime = $Value{'CreationTime'}; |
5044 |
$LastRunTime = $Value{'LastRunTime'}; |
5045 |
|
5046 |
# Parse the URL Search string into a hash so that we can get at it's components |
5047 |
%Value = &hParseURLIntoHashTable($SearchAndRfDocumentURL); |
5048 |
|
5049 |
$SearchString = &sMakeSearchString(%Value); |
5050 |
if ( defined($SearchString) ) { |
5051 |
$SearchString =~ s/{.*?}//gs; |
5052 |
$SearchString = ($SearchString =~ /\S/) ? $SearchString : undef; |
5053 |
} |
5054 |
$SearchString = defined($SearchString) ? $SearchString : "(No search terms defined)"; |
5055 |
|
5056 |
# Print the link |
5057 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP><INPUT TYPE=\"checkbox\" NAME=\"SavedSearchObject\" VALUE=\"$SavedSearchEntry\"> </TD><TD ALIGN=LEFT VALIGN=TOP> Naziv: </TD> <TD ALIGN=LEFT VALIGN=TOP> $SearchName </TD></TR>\n"); |
5058 |
|
5059 |
# Print the search description |
5060 |
$SearchDescription = defined($SearchDescription) ? $SearchDescription : "(Nije naveden)"; |
5061 |
$SearchDescription =~ s/\n/<BR>/g; |
5062 |
$SearchDescription =~ s/\r/<BR>/g; |
5063 |
print("<TR><TD></TD><TD ALIGN=LEFT VALIGN=TOP> Opis: </TD> <TD ALIGN=LEFT VALIGN=TOP> $SearchDescription </TD></TR>\n"); |
5064 |
|
5065 |
print("<TR><TD></TD><TD ALIGN=LEFT VALIGN=TOP> Upit: </TD> <TD ALIGN=LEFT VALIGN=TOP> $SearchString </TD></TR>\n"); |
5066 |
|
5067 |
# Get the local databases from the search and list their descriptions |
5068 |
if ( defined($Value{'Database'}) ) { |
5069 |
|
5070 |
# Initialize the temp list |
5071 |
undef(@Values); |
5072 |
|
5073 |
# Loop over each database |
5074 |
foreach $Database ( split(/\0/, $Value{'Database'}) ) { |
5075 |
$Value = &lEncodeURLData($Database); |
5076 |
push @Values, sprintf("<A HREF=\"$ENV{'SCRIPT_NAME'}/GetDatabaseInfo?Database=$Value\" OnMouseOver=\"self.status='Get Information about the $main::DatabaseDescriptions{$Database} database'; return true\"> $main::DatabaseDescriptions{$Database} </A> "); |
5077 |
} |
5078 |
|
5079 |
# Print the list if there are any entries in it |
5080 |
if ( scalar(@Values) > 0 ) { |
5081 |
printf("<TR><TD></TD><TD ALIGN=LEFT VALIGN=TOP> Database%s: </TD> <TD ALIGN=LEFT VALIGN=TOP> %s </TD></TR>\n", (scalar(@Values) > 1) ? "s" : "", join(", ", @Values)); |
5082 |
} |
5083 |
} |
5084 |
|
5085 |
|
5086 |
if ( defined($Value{'RfDocument'}) ) { |
5087 |
print("<TR><TD></TD>\n"); |
5088 |
&bDisplayDocuments("Feedback Document", $Value{'RfDocument'}, "RfDocument", undef, undef, 1); |
5089 |
print("</TR>\n"); |
5090 |
} |
5091 |
|
5092 |
undef(%Value); |
5093 |
|
5094 |
|
5095 |
if ( defined($SearchFrequency) || defined($DeliveryFormat) || defined($DeliveryMethod) ) { |
5096 |
print("<TR><TD></TD><TD ALIGN=LEFT VALIGN=TOP> Run: </TD> <TD ALIGN=LEFT VALIGN=TOP> $SearchFrequency </TD></TR>\n"); |
5097 |
print("<TR><TD></TD><TD ALIGN=LEFT VALIGN=TOP> Delivery format: </TD> <TD ALIGN=LEFT VALIGN=TOP> $main::DeliveryFormats{$DeliveryFormat} </TD></TR>\n"); |
5098 |
print("<TR><TD></TD><TD ALIGN=LEFT VALIGN=TOP> Delivery method : </TD> <TD ALIGN=LEFT VALIGN=TOP> $main::DeliveryMethods{$DeliveryMethod} </TD></TR>\n"); |
5099 |
} |
5100 |
|
5101 |
$Value = &sGetPrintableDateFromTime($CreationTime); |
5102 |
print("<TR><TD></TD><TD ALIGN=LEFT VALIGN=TOP> Datum kreiranja: </TD> <TD ALIGN=LEFT VALIGN=TOP> $Value </TD></TR>\n"); |
5103 |
|
5104 |
|
5105 |
if ( defined($SearchFrequency) || defined($DeliveryFormat) || defined($DeliveryMethod) ) { |
5106 |
|
5107 |
if ( defined($LastRunTime) ) { |
5108 |
$Value = &sGetPrintableDateFromTime($LastRunTime); |
5109 |
print("<TR><TD></TD><TD ALIGN=LEFT VALIGN=TOP> Last Run: </TD> <TD ALIGN=LEFT VALIGN=TOP> $Value </TD></TR>\n"); |
5110 |
} |
5111 |
|
5112 |
printf("<TR><TD></TD><TD ALIGN=LEFT VALIGN=TOP> Status: </TD> <TD ALIGN=LEFT VALIGN=TOP> %s </TD></TR>", |
5113 |
(defined($SearchStatus) && ($SearchStatus eq "Active")) ? "Active" : "Suspended"); |
5114 |
|
5115 |
} |
5116 |
|
5117 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP></TD><TD ALIGN=LEFT VALIGN=TOP></TD> <TD ALIGN=LEFT VALIGN=TOP> <A HREF=\"$ENV{'SCRIPT_NAME'}/GetSavedSearch?SavedSearchObject=$SavedSearchEntry\" OnMouseOver=\"self.status='Display the search form with this search'; return true\"> [ Otvori formu za pretra¾ivanje s upisanim ovim pretra¾ivanjem ] </A> </TD></TR>\n"); |
5118 |
} |
5119 |
|
5120 |
print("</FORM></TABLE>\n"); |
5121 |
} |
5122 |
else { |
5123 |
print("<H3><CENTER> Sorry, currently, there are no saved searches. </CENTER></H3>\n"); |
5124 |
} |
5125 |
|
5126 |
|
5127 |
|
5128 |
|
5129 |
# Bail from displaying saved searches |
5130 |
bailFromDisplaySavedSearch: |
5131 |
|
5132 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
5133 |
undef(%Value); |
5134 |
$Value{'ListSavedSearch'} = "ListSavedSearch"; |
5135 |
&vSendMenuBar(%Value); |
5136 |
undef(%Value); |
5137 |
|
5138 |
&vSendHTMLFooter; |
5139 |
|
5140 |
|
5141 |
return; |
5142 |
|
5143 |
} |
5144 |
|
5145 |
|
5146 |
|
5147 |
|
5148 |
|
5149 |
|
5150 |
#-------------------------------------------------------------------------- |
5151 |
# |
5152 |
# Function: vGetSavedSearch() |
5153 |
# |
5154 |
# Purpose: This function gets a saved search. |
5155 |
# |
5156 |
# Called by: |
5157 |
# |
5158 |
# Parameters: void |
5159 |
# |
5160 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
5161 |
# $main::UserAccountDirectoryPath, $main::XMLFileNameExtension, |
5162 |
# $main::SavedSearchFileNamePrefix, $main::RemoteUser |
5163 |
# |
5164 |
# Returns: void |
5165 |
# |
5166 |
sub vGetSavedSearch { |
5167 |
|
5168 |
my ($HeaderName, $SavedSearchFilePath, $SearchAndRfDocumentURL, $DefaultSearch); |
5169 |
my ($Value, %Value); |
5170 |
|
5171 |
|
5172 |
# Return an error if the remote user name/account directory is not defined |
5173 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
5174 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
5175 |
&vSendHTMLFooter; |
5176 |
return; |
5177 |
} |
5178 |
|
5179 |
|
5180 |
# Set the saved search file path |
5181 |
$SavedSearchFilePath = $main::UserAccountDirectoryPath . "/" . $main::FormData{'SavedSearchObject'}; |
5182 |
|
5183 |
|
5184 |
# Check to see if the XML saved search file requested is there |
5185 |
if ( ! -f $SavedSearchFilePath ) { |
5186 |
# Could not find the saved search file |
5187 |
&vHandleError("Prikaz saèuvaniog pretra¾ivanja", "Sorry, we cant to access this saved search object because it is not there"); |
5188 |
&vSendHTMLFooter; |
5189 |
return; |
5190 |
} |
5191 |
|
5192 |
|
5193 |
|
5194 |
# Get the data from the XML saved search file |
5195 |
$HeaderName = &sGetObjectTagFromXMLFile($SavedSearchFilePath); |
5196 |
|
5197 |
# Check that the entry is valid |
5198 |
if ( !(defined($HeaderName) && ($HeaderName eq "SavedSearch")) ) { |
5199 |
&vHandleError("Prikaz saèuvaniog pretra¾ivanja", "Sorry, this saved search object is invalid"); |
5200 |
&vSendHTMLFooter; |
5201 |
return; |
5202 |
} |
5203 |
|
5204 |
|
5205 |
# All is fine, so we hand over the hash and get the search |
5206 |
%main::FormData = &hParseURLIntoHashTable(&sGetTagValueFromXMLFile($SavedSearchFilePath, 'SearchAndRfDocumentURL')); |
5207 |
|
5208 |
$ENV{'PATH_INFO'} = "/GetSearch"; |
5209 |
|
5210 |
# Display the search form, it will autoset itself from %main::FormData |
5211 |
&vGetSearch; |
5212 |
|
5213 |
return; |
5214 |
|
5215 |
} |
5216 |
|
5217 |
|
5218 |
|
5219 |
|
5220 |
|
5221 |
|
5222 |
#-------------------------------------------------------------------------- |
5223 |
# |
5224 |
# Function: vProcessSavedSearch() |
5225 |
# |
5226 |
# Purpose: This function processes a saved search. |
5227 |
# |
5228 |
# Called by: |
5229 |
# |
5230 |
# Parameters: void |
5231 |
# |
5232 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
5233 |
# $main::UserAccountDirectoryPath, $main::XMLFileNameExtension, |
5234 |
# $main::SavedSearchFileNamePrefix, $main::RemoteUser |
5235 |
# |
5236 |
# Returns: void |
5237 |
# |
5238 |
sub vProcessSavedSearch { |
5239 |
|
5240 |
my ($Title, $HeaderName, $SavedSearchFilePath, $SavedSearchObject); |
5241 |
my ($Value, %Value); |
5242 |
|
5243 |
|
5244 |
# Return an error if the remote user name/account directory is not defined |
5245 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
5246 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
5247 |
&vSendHTMLFooter; |
5248 |
return; |
5249 |
} |
5250 |
|
5251 |
|
5252 |
# Set the title |
5253 |
if ( $ENV{'PATH_INFO'} eq "/DeleteSavedSearch" ) { |
5254 |
$Title = "Obri¹i saèuvana pretra¾ivanja"; |
5255 |
} |
5256 |
elsif ( $ENV{'PATH_INFO'} eq "/ActivateSavedSearch" ) { |
5257 |
$Title = "Aktiviraj saèuvana pretra¾ivanja"; |
5258 |
} |
5259 |
elsif ( $ENV{'PATH_INFO'} eq "/SuspendSavedSearch" ) { |
5260 |
$Title = "Stavi u mirovanje saèuvana pretra¾ivanja"; |
5261 |
} |
5262 |
|
5263 |
|
5264 |
# Make sure that we send the header |
5265 |
&vSendHTMLHeader($Title, undef); |
5266 |
undef(%Value); |
5267 |
&vSendMenuBar(%Value); |
5268 |
|
5269 |
|
5270 |
print("<H3> $Title: </H3>\n"); |
5271 |
|
5272 |
# Check to see if the saved search object is defined |
5273 |
if ( ! defined($main::FormData{'SavedSearchObject'}) ) { |
5274 |
# Could not find the saved search object |
5275 |
print("<H3><CENTER> Sorry, no searches were selected. </CENTER></H3>\n"); |
5276 |
print("<P>\n"); |
5277 |
print("You need to select at least one saved search in order to be able to perform an action on it.\n"); |
5278 |
print("<P>\n"); |
5279 |
goto bailFromProcessSavedSearch; |
5280 |
} |
5281 |
|
5282 |
|
5283 |
|
5284 |
# Loop over each saved search |
5285 |
foreach $SavedSearchObject ( split(/\0/, $main::FormData{'SavedSearchObject'}) ) { |
5286 |
|
5287 |
# Set the saved search file path |
5288 |
$SavedSearchFilePath = $main::UserAccountDirectoryPath . "/" . $SavedSearchObject; |
5289 |
|
5290 |
# Check to see if the XML saved search file requested is there |
5291 |
if ( ! -f $SavedSearchFilePath ) { |
5292 |
next; |
5293 |
} |
5294 |
|
5295 |
# Get information from the XML saved search file |
5296 |
($HeaderName, %Value) = &shGetHashFromXMLFile($SavedSearchFilePath); |
5297 |
|
5298 |
# Check that the entry is valid |
5299 |
if ( !(defined($HeaderName) && ($HeaderName eq "SavedSearch")) ) { |
5300 |
next; |
5301 |
} |
5302 |
|
5303 |
|
5304 |
if ( $ENV{'PATH_INFO'} eq "/DeleteSavedSearch" ) { |
5305 |
if ( unlink($SavedSearchFilePath) ) { |
5306 |
printf("<P>Successfully deleted: %s\n", $Value{'SearchName'}); |
5307 |
} |
5308 |
else { |
5309 |
printf("<P>Failed to delete: %s\n", $Value{'SearchName'}); |
5310 |
} |
5311 |
} |
5312 |
elsif ( ($ENV{'PATH_INFO'} eq "/ActivateSavedSearch") || ($ENV{'PATH_INFO'} eq "/SuspendSavedSearch") ) { |
5313 |
|
5314 |
if ( !defined($Value{'SearchStatus'}) ) { |
5315 |
printf("<P>Could not %s: %s, as it is not a regular search\n", |
5316 |
($ENV{'PATH_INFO'} eq "/ActivateSavedSearch") ? "activate" : "suspend", $Value{'SearchName'}); |
5317 |
} |
5318 |
else { |
5319 |
|
5320 |
$Value{'SearchStatus'} = ($ENV{'PATH_INFO'} eq "/ActivateSavedSearch") ? "Active" : "Inactive" ; |
5321 |
|
5322 |
if ( &iSaveXMLFileFromHash($SavedSearchFilePath, "SavedSearch", %Value) ) { |
5323 |
printf("<P>Successfully %s: %s\n", |
5324 |
($ENV{'PATH_INFO'} eq "/ActivateSavedSearch") ? "activated" : "suspended", $Value{'SearchName'}); |
5325 |
} |
5326 |
else { |
5327 |
printf("<P>Failed to %s: %s\n", |
5328 |
($ENV{'PATH_INFO'} eq "/ActivateSavedSearch") ? "activated" : "suspended", $Value{'SearchName'}); |
5329 |
} |
5330 |
} |
5331 |
} |
5332 |
} |
5333 |
|
5334 |
print("<P>\n"); |
5335 |
|
5336 |
# Bail from processing the saved search |
5337 |
bailFromProcessSavedSearch: |
5338 |
|
5339 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
5340 |
undef(%Value); |
5341 |
&vSendMenuBar(%Value); |
5342 |
|
5343 |
&vSendHTMLFooter; |
5344 |
|
5345 |
return; |
5346 |
|
5347 |
} |
5348 |
|
5349 |
|
5350 |
|
5351 |
|
5352 |
|
5353 |
|
5354 |
#-------------------------------------------------------------------------- |
5355 |
# |
5356 |
# Function: vGetSaveFolder() |
5357 |
# |
5358 |
# Purpose: This function displays a form to the user allowing them to |
5359 |
# save documents to a folder |
5360 |
# |
5361 |
# Called by: |
5362 |
# |
5363 |
# Parameters: void |
5364 |
# |
5365 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
5366 |
# $main::UserSettingsFilePath, $main::RemoteUser, |
5367 |
# |
5368 |
# Returns: void |
5369 |
# |
5370 |
sub vGetSaveFolder { |
5371 |
|
5372 |
|
5373 |
my ($JavaScript); |
5374 |
my ($Value, @Values, %Value, $ValueEntry); |
5375 |
|
5376 |
|
5377 |
|
5378 |
# Return an error if the remote user name/account directory is not defined |
5379 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
5380 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
5381 |
&vSendHTMLFooter; |
5382 |
return; |
5383 |
} |
5384 |
|
5385 |
|
5386 |
$JavaScript = '<SCRIPT LANGUAGE="JavaScript"> |
5387 |
<!-- hide |
5388 |
function checkForm( Form ) { |
5389 |
if ( !checkField( Form.FolderName, "Folder name" ) ) |
5390 |
return false |
5391 |
return true |
5392 |
} |
5393 |
function checkField( Field, Name ) { |
5394 |
if ( Field.value == "" ) { |
5395 |
errMsg( Field, "Niste ispunili polje \'"+Name+"\'." ) |
5396 |
return false |
5397 |
} |
5398 |
else { |
5399 |
return true |
5400 |
} |
5401 |
} |
5402 |
function errMsg( Field, Msg ) { |
5403 |
alert( Msg ) |
5404 |
Field.focus() |
5405 |
return |
5406 |
} |
5407 |
// --> |
5408 |
</SCRIPT> |
5409 |
'; |
5410 |
|
5411 |
|
5412 |
# Make sure that we send the header |
5413 |
&vSendHTMLHeader("Saving a Document Folder", $JavaScript); |
5414 |
undef(%Value); |
5415 |
&vSendMenuBar(%Value); |
5416 |
|
5417 |
|
5418 |
# Check that at least one document was selected |
5419 |
if ( !defined($main::FormData{'Document'}) && !defined($main::FormData{'Documents'}) ) { |
5420 |
print("<H3>Saving a Document Folder:</H3>\n"); |
5421 |
print("<H3><CENTER>Sorry, no document(s) were selected for saving.</CENTER></H3>\n"); |
5422 |
print("<P>\n"); |
5423 |
print("There needs to be a least one document selected in order to save it.\n"); |
5424 |
print("Click <B>'back'</B> on your browser, select at least one document and try again.\n"); |
5425 |
goto bailFromGetSaveFolder; |
5426 |
} |
5427 |
|
5428 |
|
5429 |
# Print up the title |
5430 |
print("<H3> Snimanje foldera s dokumentima: </H3>\n"); |
5431 |
|
5432 |
# Print up the form |
5433 |
printf("<FORM ACTION=\"$ENV{'SCRIPT_NAME'}/SetSaveFolder\" onSubmit=\"return checkForm(this)\" METHOD=POST>\n"); |
5434 |
|
5435 |
# Print up the table start |
5436 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
5437 |
|
5438 |
# Send the buttons |
5439 |
print("<TR><TD ALIGN=RIGHT VALIGN=TOP COLSPAN=2> <INPUT TYPE=RESET VALUE=\"Pobri¹i polja\"> <INPUT TYPE=SUBMIT VALUE=\"Save this Folder\"> </TD></TR>\n"); |
5440 |
|
5441 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2><HR WIDTH=50%></TD></TR>\n"); |
5442 |
|
5443 |
# Send the fields |
5444 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Ime foldera: </TD> <TD ALIGN=LEFT VALIGN=TOP> <INPUT NAME=\"FolderName\" TYPE=TEXT SIZE=45> </TD></TR>\n"); |
5445 |
|
5446 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Opis foldera: </TD> <TD ALIGN=LEFT VALIGN=TOP> <TEXTAREA INPUT NAME=\"FolderDescription\" COLS=45 ROWS=6 WRAP=VIRTUAL></TEXTAREA> </TD></TR>\n"); |
5447 |
|
5448 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2><HR WIDTH=50%></TD></TR>\n"); |
5449 |
|
5450 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Kliknite na ovaj kvadratiæ ako ¾elite postojeæi folder s istim imenom zamijeniti ovim novim: </TD> <TD ALIGN=LEFT VALIGN=TOP><INPUT TYPE=\"checkbox\" NAME=\"OverWrite\" VALUE=\"yes\"> </TD></TR>\n"); |
5451 |
|
5452 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2><HR WIDTH=50%></TD></TR>\n"); |
5453 |
|
5454 |
# List the documents |
5455 |
if ( defined($main::FormData{'Document'}) || defined($main::FormData{'Documents'}) ) { |
5456 |
|
5457 |
# Undefine the hash table in preparation |
5458 |
undef(%Value); |
5459 |
|
5460 |
# Add document that were specifically selected |
5461 |
if ( defined($main::FormData{'Document'}) ) { |
5462 |
foreach $Value ( split(/\0/, $main::FormData{'Document'}) ) { |
5463 |
$Value{$Value} = $Value; |
5464 |
} |
5465 |
} |
5466 |
# Otherwise add documents that were selected by default |
5467 |
elsif ( defined($main::FormData{'Documents'}) ) { |
5468 |
foreach $Value ( split(/\|/, $main::FormData{'Documents'}) ) { |
5469 |
$Value{$Value} = $Value; |
5470 |
} |
5471 |
} |
5472 |
|
5473 |
# Assemble the new content |
5474 |
$main::FormData{'Document'} = join("\0", keys(%Value)); |
5475 |
|
5476 |
# Delete the old content |
5477 |
delete($main::FormData{'Documents'}); |
5478 |
|
5479 |
|
5480 |
if ( defined($main::FormData{'Document'}) ) { |
5481 |
print("<TR>\n"); |
5482 |
&bDisplayDocuments("Document", $main::FormData{'Document'}, "Document", undef, undef, 1); |
5483 |
print("</TR>\n"); |
5484 |
} |
5485 |
} |
5486 |
|
5487 |
|
5488 |
|
5489 |
# List the hidden fields |
5490 |
%Value = &hParseURLIntoHashTable(&sMakeDocumentURL(%main::FormData)); |
5491 |
foreach $Value ( keys(%Value) ) { |
5492 |
foreach $ValueEntry ( split(/\0/, $Value{$Value}) ) { |
5493 |
print("<INPUT TYPE=HIDDEN NAME=\"$Value\" VALUE=\"$ValueEntry\">\n"); |
5494 |
} |
5495 |
} |
5496 |
|
5497 |
|
5498 |
# Retain the 'from' folder name if it is defined as these documents are coming from it |
5499 |
if ( defined($main::FormData{'FromDocumentFolderObject'}) ) { |
5500 |
print("<INPUT TYPE=HIDDEN NAME=\"FromDocumentFolderObject\" VALUE=\"$main::FormData{'FromDocumentFolderObject'}\">\n"); |
5501 |
} |
5502 |
|
5503 |
|
5504 |
# Retain the 'merge' folder name if it is defined as these documents are coming from them |
5505 |
if ( defined($main::FormData{'MergeDocumentFolderObject'}) ) { |
5506 |
foreach $Value ( split(/\0/, $main::FormData{'MergeDocumentFolderObject'}) ) { |
5507 |
print("<INPUT TYPE=HIDDEN NAME=\"MergeDocumentFolderObject\" VALUE=\"$Value\">\n"); |
5508 |
} |
5509 |
} |
5510 |
|
5511 |
print("</TABLE>\n"); |
5512 |
print("</FORM>\n"); |
5513 |
|
5514 |
|
5515 |
# Bail from saving the document folder |
5516 |
bailFromGetSaveFolder: |
5517 |
|
5518 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
5519 |
undef(%Value); |
5520 |
&vSendMenuBar(%Value); |
5521 |
|
5522 |
&vSendHTMLFooter; |
5523 |
|
5524 |
return; |
5525 |
|
5526 |
} |
5527 |
|
5528 |
|
5529 |
|
5530 |
|
5531 |
|
5532 |
|
5533 |
#-------------------------------------------------------------------------- |
5534 |
# |
5535 |
# Function: vSetSaveFolder() |
5536 |
# |
5537 |
# Purpose: This function saves that search and search name in a search file |
5538 |
# |
5539 |
# Called by: |
5540 |
# |
5541 |
# Parameters: void |
5542 |
# |
5543 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
5544 |
# $main::UserSettingsFilePath, $main::RemoteUser, |
5545 |
# |
5546 |
# Returns: void |
5547 |
# |
5548 |
sub vSetSaveFolder { |
5549 |
|
5550 |
my ($DocumentFolderFilePath, $HeaderName); |
5551 |
my ($FolderName, $FolderDescription, $FolderDocuments, $CreationTime, $UpdateTime); |
5552 |
my (@DocumentFolderList, $DocumentFolderEntry); |
5553 |
my ($Document, %Document); |
5554 |
my (%Value, @Values, $Value); |
5555 |
|
5556 |
|
5557 |
|
5558 |
# Return an error if the remote user name/account directory is not defined |
5559 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
5560 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
5561 |
&vSendHTMLFooter; |
5562 |
return; |
5563 |
} |
5564 |
|
5565 |
|
5566 |
|
5567 |
# Make sure that we send the header |
5568 |
&vSendHTMLHeader("Saving a Document Folder", undef); |
5569 |
undef($Value); |
5570 |
&vSendMenuBar(%Value); |
5571 |
|
5572 |
|
5573 |
# Check that at least one document was selected |
5574 |
if ( !defined($main::FormData{'Document'}) && !defined($main::FormData{'Documents'}) ) { |
5575 |
|
5576 |
print("<H3>Saving a Document Folder:</H3>\n"); |
5577 |
print("<H3><CENTER>Sorry, no document(s) were selected for saving.</CENTER></H3>\n"); |
5578 |
print("<P>\n"); |
5579 |
print("There needs to be a least one document selected in order to save it.\n"); |
5580 |
print("Click <B>'back'</B> on your browser, select at least one document and try again.\n"); |
5581 |
|
5582 |
goto bailFromSetSaveFolder; |
5583 |
} |
5584 |
|
5585 |
|
5586 |
# Check that the required fields are filled in |
5587 |
if ( !(defined($main::FormData{'FolderName'}) || defined($main::FormData{'DocumentFolderObject'})) ) { |
5588 |
|
5589 |
# A required field is missing, so we suggest corrective action to the user. |
5590 |
print("<H3> Spremanje foldera s dokumentima: </H3>\n"); |
5591 |
print("<H3><CENTER> Oprostite, nedostaju neke informacije. </CENTER></H3>\n"); |
5592 |
print("<P>\n"); |
5593 |
print("Polje <B>'folder name'</B> mora biti ispunjeno da bi se mogao kreirati folder s dokumentima.<P>\n"); |
5594 |
print("Kliknite na <B>'Back'</B> u svom browseru, ispunite polje koje nedostaje i poku¹ajtwe ponovo.\n"); |
5595 |
print("<P>\n"); |
5596 |
|
5597 |
goto bailFromSetSaveFolder; |
5598 |
} |
5599 |
|
5600 |
|
5601 |
|
5602 |
# Check that the folder is there if we are saving to an existing folder |
5603 |
if ( defined($main::FormData{'DocumentFolderObject'}) ) { |
5604 |
|
5605 |
# Check the old document folder if it is defined |
5606 |
if ( defined($main::FormData{'FromDocumentFolderObject'}) ) { |
5607 |
|
5608 |
# Set the document folder file path |
5609 |
$DocumentFolderFilePath = $main::UserAccountDirectoryPath . "/" . $main::FormData{'FromDocumentFolderObject'}; |
5610 |
|
5611 |
# Check to see if the old XML saved search file requested is there |
5612 |
if ( ! -f $DocumentFolderFilePath ) { |
5613 |
# Could not find the old saved search file |
5614 |
&vHandleError("Saving a Document Folder", "Sorry, we cant to access this document folder object because it is not there"); |
5615 |
goto bailFromSetSaveFolder; |
5616 |
} |
5617 |
|
5618 |
# Get information from the XML document folder file |
5619 |
$HeaderName = &sGetObjectTagFromXMLFile($DocumentFolderFilePath); |
5620 |
|
5621 |
# Check that the entry is valid |
5622 |
if ( !(defined($HeaderName) && ($HeaderName eq "DocumentFolder")) ) { |
5623 |
&vHandleError("Saving a Document Folder", "Sorry, this document folder object is invalid"); |
5624 |
goto bailFromSetSaveFolder; |
5625 |
} |
5626 |
} |
5627 |
|
5628 |
|
5629 |
# Set the document folder file path |
5630 |
$DocumentFolderFilePath = $main::UserAccountDirectoryPath . "/" . $main::FormData{'DocumentFolderObject'}; |
5631 |
|
5632 |
# Check to see if the XML saved search file requested is there |
5633 |
if ( ! -f $DocumentFolderFilePath ) { |
5634 |
# Could not find the saved search file |
5635 |
&vHandleError("Saving a Document Folder", "Sorry, we cant to access this document folder object because it is not there"); |
5636 |
goto bailFromSetSaveFolder; |
5637 |
} |
5638 |
|
5639 |
# Get information from the XML document folder file |
5640 |
$HeaderName = &sGetObjectTagFromXMLFile($DocumentFolderFilePath); |
5641 |
|
5642 |
# Check that the entry is valid |
5643 |
if ( !(defined($HeaderName) && ($HeaderName eq "DocumentFolder")) ) { |
5644 |
&vHandleError("Saving a Document Folder", "Sorry, this document folder object is invalid"); |
5645 |
goto bailFromSetSaveFolder; |
5646 |
} |
5647 |
} |
5648 |
elsif ( defined($main::FormData{'FolderName'}) ) { |
5649 |
|
5650 |
# Get the document folder hash |
5651 |
%Value = &hGetDocumentFolders; |
5652 |
|
5653 |
# Set the path/flag |
5654 |
$DocumentFolderFilePath = $Value{$main::FormData{'FolderName'}}; |
5655 |
|
5656 |
# Check that the document folder file does not already exist |
5657 |
if ( defined($DocumentFolderFilePath) && !(defined($main::FormData{'OverWrite'}) && ($main::FormData{'OverWrite'} eq "yes")) ) { |
5658 |
|
5659 |
# There is already a document folder with this name, so we suggest corrective action to the user. |
5660 |
print("<H3> Snimanje foldera s dokumentima: </H3>\n"); |
5661 |
print("<H3><CENTER> Oprostite, veæ postoji folder s tim imenom. </CENTER></H3>\n"); |
5662 |
print("<P>\n"); |
5663 |
print("Kliknite na <B>'Back'</B> u svom browseru, promijenite <B>'ime foldera'</B> i poku¹ate ponovo. \n"); |
5664 |
print("Alternativno, klikom na kvadratiæ, mo¾ete odabrati da ¾elite postojeæi folder zamijeniti ovim.\n"); |
5665 |
print("<P>\n"); |
5666 |
|
5667 |
goto bailFromSetSaveFolder; |
5668 |
} |
5669 |
} |
5670 |
|
5671 |
|
5672 |
# Save information in the folder |
5673 |
if ( defined($main::FormData{'DocumentFolderObject'}) ) { |
5674 |
|
5675 |
# Get the data from the XML document folder file |
5676 |
($HeaderName, %Value) = &shGetHashFromXMLFile($DocumentFolderFilePath); |
5677 |
|
5678 |
# Check that the entry is valid |
5679 |
if ( !(defined($HeaderName) && ($HeaderName eq "DocumentFolder")) ) { |
5680 |
&vHandleError("Saving a Document Folder", "Sorry, this document folder object is invalid"); |
5681 |
goto bailFromGetSavedSearch; |
5682 |
} |
5683 |
|
5684 |
$FolderName = $Value{'FolderName'}; |
5685 |
$FolderDescription = $Value{'FolderDescription'}; |
5686 |
$FolderDocuments = $Value{'FolderDocuments'}; |
5687 |
$CreationTime = $Value{'CreationTime'}; |
5688 |
$UpdateTime = time(); |
5689 |
|
5690 |
|
5691 |
# Merge the documents |
5692 |
if ( defined($FolderDocuments) || defined($main::FormData{'Document'}) || defined($main::FormData{'Documents'}) ) { |
5693 |
|
5694 |
# Undefine the hash table in preparation |
5695 |
undef(%Value); |
5696 |
|
5697 |
# Make a hash table from the documents already in the document folder |
5698 |
if ( defined($FolderDocuments) ) { |
5699 |
foreach $Value ( split(/\0/, $FolderDocuments) ) { |
5700 |
$Value{$Value} = $Value; |
5701 |
} |
5702 |
} |
5703 |
|
5704 |
# Add document that were specifically selected |
5705 |
if ( defined($main::FormData{'Document'}) ) { |
5706 |
foreach $Value ( split(/\0/, $main::FormData{'Document'}) ) { |
5707 |
$Value{$Value} = $Value; |
5708 |
} |
5709 |
} |
5710 |
# Otherwise add documents that were selected by default |
5711 |
elsif ( defined($main::FormData{'Documents'}) ) { |
5712 |
foreach $Value ( split(/\|/, $main::FormData{'Documents'}) ) { |
5713 |
$Value{$Value} = $Value; |
5714 |
} |
5715 |
} |
5716 |
|
5717 |
# Assemble the new content |
5718 |
$FolderDocuments = join("\0", keys(%Value)); |
5719 |
|
5720 |
# Delete the old content |
5721 |
delete($main::FormData{'Document'}); |
5722 |
delete($main::FormData{'Documents'}); |
5723 |
} |
5724 |
|
5725 |
} |
5726 |
elsif ( defined($main::FormData{'FolderName'}) ) { |
5727 |
|
5728 |
$FolderName = $main::FormData{'FolderName'}; |
5729 |
$FolderDescription = $main::FormData{'FolderDescription'}; |
5730 |
|
5731 |
# Merge the documents |
5732 |
if ( defined($main::FormData{'Document'}) || defined($main::FormData{'Documents'})) { |
5733 |
|
5734 |
# Undefine the hash table in preparation |
5735 |
undef(%Value); |
5736 |
|
5737 |
# Add document that were specifically selected |
5738 |
if ( defined($main::FormData{'Document'}) ) { |
5739 |
foreach $Value ( split(/\0/, $main::FormData{'Document'}) ) { |
5740 |
$Value{$Value} = $Value; |
5741 |
} |
5742 |
} |
5743 |
# Otherwise add documents that were selected by default |
5744 |
elsif ( defined($main::FormData{'Documents'}) ) { |
5745 |
foreach $Value ( split(/\|/, $main::FormData{'Documents'}) ) { |
5746 |
$Value{$Value} = $Value; |
5747 |
} |
5748 |
} |
5749 |
|
5750 |
# Assemble the new content |
5751 |
$main::FormData{'Document'} = join("\0", keys(%Value)); |
5752 |
|
5753 |
# Delete the old content |
5754 |
delete($main::FormData{'Documents'}); |
5755 |
} |
5756 |
|
5757 |
$FolderDocuments = $main::FormData{'Document'}; |
5758 |
$CreationTime = time(); |
5759 |
$UpdateTime = time(); |
5760 |
} |
5761 |
|
5762 |
|
5763 |
# Save the document folder to a new file |
5764 |
if ( &iSaveFolder($DocumentFolderFilePath, $FolderName, $FolderDescription, $FolderDocuments, $CreationTime, $UpdateTime) ) { |
5765 |
|
5766 |
# Are we pulling these documents from an existing folder? |
5767 |
if ( defined($main::FormData{'FromDocumentFolderObject'}) ) { |
5768 |
|
5769 |
# Set the document folder file path |
5770 |
$DocumentFolderFilePath = $main::UserAccountDirectoryPath . "/" . $main::FormData{'FromDocumentFolderObject'}; |
5771 |
|
5772 |
# Get information from the XML document folder file |
5773 |
($HeaderName, %Value) = &shGetHashFromXMLFile($DocumentFolderFilePath); |
5774 |
|
5775 |
|
5776 |
$FolderName = $Value{'FolderName'}; |
5777 |
$FolderDescription = $Value{'FolderDescription'}; |
5778 |
$FolderDocuments = $Value{'FolderDocuments'}; |
5779 |
$CreationTime = $Value{'CreationTime'}; |
5780 |
$UpdateTime = time(); |
5781 |
|
5782 |
|
5783 |
# Make a hash table from the documents selected for deletion, this serves as |
5784 |
# a lookup table when we loop through the existing documents |
5785 |
undef(%Value); |
5786 |
foreach $Value ( split(/\0/, $main::FormData{'Document'}) ) { |
5787 |
$Value{$Value} = 1; |
5788 |
} |
5789 |
|
5790 |
# Parse out of the existing documents into a list |
5791 |
foreach $Value ( split(/\0/, $FolderDocuments) ) { |
5792 |
# Add the document if it is not on the deletion list |
5793 |
if ( !defined($Value{$Value}) ) { |
5794 |
push @Values, $Value; |
5795 |
} |
5796 |
} |
5797 |
$FolderDocuments = join("\0", @Values); |
5798 |
|
5799 |
|
5800 |
# Save the document folder |
5801 |
&iSaveFolder($DocumentFolderFilePath, $FolderName, $FolderDescription, $FolderDocuments, $CreationTime, $UpdateTime); |
5802 |
|
5803 |
} |
5804 |
|
5805 |
if ( defined($main::FormData{'MergeDocumentFolderObject'}) ) { |
5806 |
@Values = split(/\0/, $main::FormData{'MergeDocumentFolderObject'}); |
5807 |
foreach $Value ( @Values ) { |
5808 |
# Set the document folder file path |
5809 |
if ( !(defined($main::FormData{'DocumentFolderObject'}) && ($main::FormData{'DocumentFolderObject'} eq $Value))) { |
5810 |
$DocumentFolderFilePath = $main::UserAccountDirectoryPath . "/" . $Value; |
5811 |
unlink($DocumentFolderFilePath); |
5812 |
} |
5813 |
} |
5814 |
} |
5815 |
|
5816 |
print("<H3> Saving a Document Folder: </H3>\n"); |
5817 |
print("<P>\n"); |
5818 |
print("<H3><CENTER> Your document folder was successfully saved. </CENTER></H3>\n"); |
5819 |
|
5820 |
|
5821 |
} |
5822 |
else { |
5823 |
|
5824 |
# The document folder could not be saved, so we inform the user of the fact |
5825 |
&vHandleError("Saving a Document Folder", "Sorry, we failed to save this document folder"); |
5826 |
goto bailFromSetSaveFolder; |
5827 |
} |
5828 |
|
5829 |
|
5830 |
# Bail from saving the document folder |
5831 |
bailFromSetSaveFolder: |
5832 |
|
5833 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
5834 |
undef(%Value); |
5835 |
&vSendMenuBar(%Value); |
5836 |
|
5837 |
&vSendHTMLFooter; |
5838 |
|
5839 |
return; |
5840 |
|
5841 |
} |
5842 |
|
5843 |
|
5844 |
|
5845 |
|
5846 |
|
5847 |
|
5848 |
#-------------------------------------------------------------------------- |
5849 |
# |
5850 |
# Function: vListFolder() |
5851 |
# |
5852 |
# Purpose: This function allows the user list the document folders and |
5853 |
# sets up the links allowing the user to get a list of the documents |
5854 |
# |
5855 |
# Called by: |
5856 |
# |
5857 |
# Parameters: void |
5858 |
# |
5859 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
5860 |
# $main::UserAccountDirectoryPath, $main::XMLFileNameExtension, |
5861 |
# $main::DocumentFolderFileNamePrefix, $main::RemoteUser |
5862 |
# |
5863 |
# Returns: void |
5864 |
# |
5865 |
sub vListFolder { |
5866 |
|
5867 |
my (@DocumentFolderList, %QualifiedDocumentFolders, $DocumentFolderEntry, $HeaderName); |
5868 |
my ($FolderName, $FolderDescription, $FolderDocuments, $CreationTime, $UpdateTime); |
5869 |
my (@Values, $Value, %Value); |
5870 |
|
5871 |
|
5872 |
# Return an error if the remote user name/account directory is not defined |
5873 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
5874 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
5875 |
&vSendHTMLFooter; |
5876 |
return; |
5877 |
} |
5878 |
|
5879 |
|
5880 |
# Make sure that we send the header |
5881 |
&vSendHTMLHeader("Document Folders", undef); |
5882 |
undef(%Value); |
5883 |
$Value{'ListFolder'} = "ListFolder"; |
5884 |
&vSendMenuBar(%Value); |
5885 |
undef(%Value); |
5886 |
|
5887 |
|
5888 |
|
5889 |
# Print out the document folders |
5890 |
print("<H3> Folderi: </H3>\n"); |
5891 |
|
5892 |
|
5893 |
# Get the document folder hash |
5894 |
%QualifiedDocumentFolders = &hGetDocumentFolders; |
5895 |
|
5896 |
|
5897 |
# Print up the document folders, if there is none, we put up a nice message |
5898 |
if ( scalar(keys(%QualifiedDocumentFolders)) > 0 ) { |
5899 |
|
5900 |
# Start the table |
5901 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
5902 |
|
5903 |
# Start the form |
5904 |
print("<FORM ACTION=\"$ENV{'SCRIPT_NAME'}\" METHOD=POST>\n"); |
5905 |
|
5906 |
|
5907 |
# Print the selector |
5908 |
print("<TR><TD ALIGN=RIGHT VALIGN=TOP COLSPAN=3>\n"); |
5909 |
print("<SELECT NAME=\"Action\">\n"); |
5910 |
print("<OPTION VALUE=\"DeleteFolder\">Obri¹i oznaèene foldere\n"); |
5911 |
print("<OPTION VALUE=\"GetMergeFolder\">Spoji oznaèene foldere u novi folder\n"); |
5912 |
|
5913 |
for $FolderName ( sort( keys(%QualifiedDocumentFolders)) ) { |
5914 |
|
5915 |
$DocumentFolderEntry = $QualifiedDocumentFolders{$FolderName}; |
5916 |
|
5917 |
# Get the document folder file name and encode it |
5918 |
$DocumentFolderEntry = ($DocumentFolderEntry =~ /^$main::UserAccountDirectoryPath\/(.*)/) ? $1 : $DocumentFolderEntry; |
5919 |
$DocumentFolderEntry = &lEncodeURLData($DocumentFolderEntry); |
5920 |
|
5921 |
print("<OPTION VALUE=\"SetMergeFolder&ToDocumentFolderObject=$DocumentFolderEntry\">Spoji oznaèene foldere u '$FolderName' folder\n"); |
5922 |
} |
5923 |
|
5924 |
print("</SELECT>\n"); |
5925 |
print("<INPUT TYPE=SUBMIT VALUE=\"Do It!\">\n"); |
5926 |
print("</TD></TR>\n"); |
5927 |
|
5928 |
|
5929 |
|
5930 |
# List the folders |
5931 |
for $FolderName ( sort( keys(%QualifiedDocumentFolders)) ) { |
5932 |
|
5933 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=3><HR WIDTH=50%></TD></TR>\n"); |
5934 |
|
5935 |
$DocumentFolderEntry = $QualifiedDocumentFolders{$FolderName}; |
5936 |
|
5937 |
# Get information from the XML document folder file |
5938 |
($HeaderName, %Value) = &shGetHashFromXMLFile($DocumentFolderEntry); |
5939 |
|
5940 |
# Get the saved search file name and encode it |
5941 |
$DocumentFolderEntry = ($DocumentFolderEntry =~ /^$main::UserAccountDirectoryPath\/(.*)/) ? $1 : $DocumentFolderEntry; |
5942 |
$DocumentFolderEntry = &lEncodeURLData($DocumentFolderEntry); |
5943 |
|
5944 |
|
5945 |
$FolderName = $Value{'FolderName'}; |
5946 |
$FolderDescription = $Value{'FolderDescription'}; |
5947 |
$FolderDocuments = $Value{'FolderDocuments'}; |
5948 |
$CreationTime = $Value{'CreationTime'}; |
5949 |
$UpdateTime = $Value{'UpdateTime'}; |
5950 |
|
5951 |
|
5952 |
# Print the link |
5953 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP WIDTH=1%><INPUT TYPE=\"checkbox\" NAME=\"DocumentFolderObject\" VALUE=\"$DocumentFolderEntry\"> </TD><TD ALIGN=LEFT VALIGN=TOP> Naziv: </TD> <TD ALIGN=LEFT VALIGN=TOP> $FolderName </TD></TR>\n"); |
5954 |
|
5955 |
# Print the folder description |
5956 |
$FolderDescription = defined($FolderDescription) ? $FolderDescription : "(Nije naveden)"; |
5957 |
$FolderDescription =~ s/\n/<BR>/g; |
5958 |
$FolderDescription =~ s/\r/<BR>/g; |
5959 |
print("<TR><TD WIDTH=1%></TD><TD ALIGN=LEFT VALIGN=TOP> Opis: </TD> <TD ALIGN=LEFT VALIGN=TOP> $FolderDescription </TD></TR>\n"); |
5960 |
|
5961 |
if ( defined($FolderDocuments) ) { |
5962 |
@Values = split(/\0/, $FolderDocuments); |
5963 |
$Value = scalar( @Values ); |
5964 |
} |
5965 |
else { |
5966 |
$Value = 0; |
5967 |
} |
5968 |
print("<TR><TD WIDTH=1%></TD><TD ALIGN=LEFT VALIGN=TOP> Broj rezultata: </TD> <TD ALIGN=LEFT VALIGN=TOP> $Value </TD></TR>\n"); |
5969 |
|
5970 |
|
5971 |
$Value = &sGetPrintableDateFromTime($CreationTime); |
5972 |
print("<TR><TD WIDTH=1%></TD><TD ALIGN=LEFT VALIGN=TOP> Datum kreiranja: </TD> <TD ALIGN=LEFT VALIGN=TOP> $Value </TD></TR>\n"); |
5973 |
|
5974 |
$Value = &sGetPrintableDateFromTime($UpdateTime); |
5975 |
print("<TR><TD WIDTH=1%></TD><TD ALIGN=LEFT VALIGN=TOP> Datum zadnje promijene: </TD> <TD ALIGN=LEFT VALIGN=TOP> $Value </TD></TR>\n"); |
5976 |
|
5977 |
print("<TR><TD WIDTH=1%> </TD><TD ALIGN=LEFT VALIGN=TOP> </TD> <TD ALIGN=LEFT VALIGN=TOP> <A HREF=\"$ENV{'SCRIPT_NAME'}/GetFolder?DocumentFolderObject=$DocumentFolderEntry\" OnMouseOver=\"self.status='Display the documents in this document folder'; return true\">[ Otvori ovaj folder ] </A> </TD></TR>\n"); |
5978 |
} |
5979 |
|
5980 |
print("</FORM></TABLE>\n"); |
5981 |
} |
5982 |
else { |
5983 |
print("<H3><CENTER> Nema foldera! </CENTER></H3>\n"); |
5984 |
} |
5985 |
|
5986 |
|
5987 |
|
5988 |
|
5989 |
# Bail from displaying document folders |
5990 |
bailFromListFolder: |
5991 |
|
5992 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
5993 |
undef(%Value); |
5994 |
$Value{'ListFolder'} = "ListFolder"; |
5995 |
&vSendMenuBar(%Value); |
5996 |
undef(%Value); |
5997 |
|
5998 |
&vSendHTMLFooter; |
5999 |
|
6000 |
|
6001 |
return; |
6002 |
|
6003 |
} |
6004 |
|
6005 |
|
6006 |
|
6007 |
|
6008 |
|
6009 |
|
6010 |
#-------------------------------------------------------------------------- |
6011 |
# |
6012 |
# Function: vMergeFolder() |
6013 |
# |
6014 |
# Purpose: This function deletes a folder. |
6015 |
# |
6016 |
# Called by: |
6017 |
# |
6018 |
# Parameters: void |
6019 |
# |
6020 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
6021 |
# $main::UserAccountDirectoryPath, $main::XMLFileNameExtension, |
6022 |
# $main::DocumentFolderFileNamePrefix, $main::RemoteUser |
6023 |
# |
6024 |
# Returns: void |
6025 |
# |
6026 |
sub vMergeFolder { |
6027 |
|
6028 |
my ($Title, $HeaderName, $DocumentFolderFilePath, $DocumentFolderObject, $FolderDocuments); |
6029 |
my ($Value, %Value); |
6030 |
|
6031 |
|
6032 |
|
6033 |
# Return an error if the remote user name/account directory is not defined |
6034 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
6035 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
6036 |
&vSendHTMLFooter; |
6037 |
return; |
6038 |
} |
6039 |
|
6040 |
|
6041 |
|
6042 |
# Check to see if the document folder object is defined |
6043 |
if ( ! defined($main::FormData{'DocumentFolderObject'}) ) { |
6044 |
|
6045 |
# Could not find the document folder file |
6046 |
&vSendHTMLHeader("Merge Document Folders", undef); |
6047 |
undef(%Value); |
6048 |
&vSendMenuBar(%Value); |
6049 |
print("<H3> Merge Document Folders: </H3>\n"); |
6050 |
print("<H3><CENTER> Sorry, no document folders were selected. </CENTER></H3>\n"); |
6051 |
print("<P>\n"); |
6052 |
print("You need to select at least one document folder in order to be able to perform an action on it.\n"); |
6053 |
print("<P>\n"); |
6054 |
return; |
6055 |
} |
6056 |
|
6057 |
|
6058 |
# Init the value hash |
6059 |
undef(%Value); |
6060 |
|
6061 |
# Loop over document folder object |
6062 |
$Value = $main::FormData{'DocumentFolderObject'} . |
6063 |
((defined($main::FormData{'ToDocumentFolderObject'})) ? "\0" . $main::FormData{'ToDocumentFolderObject'} : ""); |
6064 |
|
6065 |
foreach $DocumentFolderObject ( split(/\0/, $Value) ) { |
6066 |
|
6067 |
# Set the document folder file path |
6068 |
$DocumentFolderFilePath = $main::UserAccountDirectoryPath . "/" . $DocumentFolderObject; |
6069 |
|
6070 |
# Check to see if the XML saved search file requested is there |
6071 |
if ( ! -f $DocumentFolderFilePath ) { |
6072 |
next; |
6073 |
} |
6074 |
|
6075 |
# Get information from the XML saved search file |
6076 |
$HeaderName = &sGetObjectTagFromXMLFile($DocumentFolderFilePath); |
6077 |
|
6078 |
# Check that the entry is valid |
6079 |
if ( !(defined($HeaderName) && ($HeaderName eq "DocumentFolder")) ) { |
6080 |
next; |
6081 |
} |
6082 |
|
6083 |
# Get the FolderDocuments symbol |
6084 |
$FolderDocuments = &sGetTagValueFromXMLFile($DocumentFolderFilePath, "FolderDocuments"); |
6085 |
|
6086 |
# Add each document to the hash |
6087 |
foreach $Value ( split(/\0/, $FolderDocuments) ) { |
6088 |
$Value{$Value} = $Value; |
6089 |
} |
6090 |
} |
6091 |
|
6092 |
# Set the document URL from the hash |
6093 |
$main::FormData{'Document'} = join("\0", keys(%Value)); |
6094 |
|
6095 |
|
6096 |
if ( defined($main::FormData{'DocumentFolderObject'}) ) { |
6097 |
$main::FormData{'MergeDocumentFolderObject'} = $main::FormData{'DocumentFolderObject'}; |
6098 |
delete($main::FormData{'DocumentFolderObject'}); |
6099 |
} |
6100 |
|
6101 |
if ( defined($main::FormData{'ToDocumentFolderObject'}) ) { |
6102 |
$main::FormData{'DocumentFolderObject'} = $main::FormData{'ToDocumentFolderObject'}; |
6103 |
delete($main::FormData{'ToDocumentFolderObject'}); |
6104 |
} |
6105 |
|
6106 |
|
6107 |
if ( $ENV{'PATH_INFO'} eq "/GetMergeFolder" ) { |
6108 |
&vGetSaveFolder; |
6109 |
} |
6110 |
elsif ( $ENV{'PATH_INFO'} eq "/SetMergeFolder" ) { |
6111 |
&vSetSaveFolder; |
6112 |
} |
6113 |
|
6114 |
|
6115 |
return; |
6116 |
|
6117 |
} |
6118 |
|
6119 |
|
6120 |
|
6121 |
|
6122 |
|
6123 |
|
6124 |
#-------------------------------------------------------------------------- |
6125 |
# |
6126 |
# Function: vProcessFolder() |
6127 |
# |
6128 |
# Purpose: This function deletes a folder. |
6129 |
# |
6130 |
# Called by: |
6131 |
# |
6132 |
# Parameters: void |
6133 |
# |
6134 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
6135 |
# $main::UserAccountDirectoryPath, $main::XMLFileNameExtension, |
6136 |
# $main::DocumentFolderFileNamePrefix, $main::RemoteUser |
6137 |
# |
6138 |
# Returns: void |
6139 |
# |
6140 |
sub vProcessFolder { |
6141 |
|
6142 |
my ($Title, $HeaderName, $DocumentFolderFilePath, $DocumentFolderObject); |
6143 |
my ($Value, %Value); |
6144 |
|
6145 |
|
6146 |
|
6147 |
# Return an error if the remote user name/account directory is not defined |
6148 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
6149 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
6150 |
&vSendHTMLFooter; |
6151 |
return; |
6152 |
} |
6153 |
|
6154 |
|
6155 |
|
6156 |
if ( $ENV{'PATH_INFO'} eq "/DeleteFolder" ) { |
6157 |
$Title = "Delete Document Folders"; |
6158 |
} |
6159 |
|
6160 |
|
6161 |
# Make sure that we send the header |
6162 |
&vSendHTMLHeader($Title, undef); |
6163 |
undef(%Value); |
6164 |
&vSendMenuBar(%Value); |
6165 |
|
6166 |
print("<H3> $Title: </H3>\n"); |
6167 |
|
6168 |
# Check to see if the document folder object is defined |
6169 |
if ( ! defined($main::FormData{'DocumentFolderObject'}) ) { |
6170 |
|
6171 |
# Could not find the document folder file |
6172 |
print("<H3><CENTER> Sorry, no document folders were selected. </CENTER></H3>\n"); |
6173 |
print("<P>\n"); |
6174 |
print("You need to select at least one document folder in order to be able to perform an action on it.\n"); |
6175 |
print("<P>\n"); |
6176 |
|
6177 |
goto bailFromProcessFolder; |
6178 |
} |
6179 |
|
6180 |
|
6181 |
# Loop over document folder object |
6182 |
foreach $DocumentFolderObject ( split(/\0/, $main::FormData{'DocumentFolderObject'}) ) { |
6183 |
|
6184 |
# Set the document folder file path |
6185 |
$DocumentFolderFilePath = $main::UserAccountDirectoryPath . "/" . $DocumentFolderObject; |
6186 |
|
6187 |
# Check to see if the XML saved search file requested is there |
6188 |
if ( ! -f $DocumentFolderFilePath ) { |
6189 |
printf("<P>Failed to delete: %s\n", $Value{'FolderName'}); |
6190 |
next; |
6191 |
} |
6192 |
|
6193 |
# Get information from the XML saved search file |
6194 |
($HeaderName, %Value) = &shGetHashFromXMLFile($DocumentFolderFilePath); |
6195 |
|
6196 |
# Check that the entry is valid |
6197 |
if ( !(defined($HeaderName) && ($HeaderName eq "DocumentFolder")) ) { |
6198 |
printf("<P>Failed to delete: %s\n", $Value{'FolderName'}); |
6199 |
} |
6200 |
|
6201 |
|
6202 |
if ( unlink($DocumentFolderFilePath) ) { |
6203 |
printf("<P>Successfully deleted: %s\n", $Value{'FolderName'}); |
6204 |
} |
6205 |
else { |
6206 |
printf("<P>Failed to delete: %s\n", $Value{'FolderName'}); |
6207 |
} |
6208 |
} |
6209 |
|
6210 |
print("<P>\n"); |
6211 |
|
6212 |
# Bail from processing the document folder |
6213 |
bailFromProcessFolder: |
6214 |
|
6215 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
6216 |
undef(%Value); |
6217 |
&vSendMenuBar(%Value); |
6218 |
|
6219 |
&vSendHTMLFooter; |
6220 |
|
6221 |
return; |
6222 |
|
6223 |
} |
6224 |
|
6225 |
|
6226 |
|
6227 |
|
6228 |
|
6229 |
|
6230 |
#-------------------------------------------------------------------------- |
6231 |
# |
6232 |
# Function: vGetFolder() |
6233 |
# |
6234 |
# Purpose: This function displays a document folder to the user. |
6235 |
# |
6236 |
# Called by: |
6237 |
# |
6238 |
# Parameters: void |
6239 |
# |
6240 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
6241 |
# $main::UserAccountDirectoryPath, $main::XMLFileNameExtension, |
6242 |
# $main::DocumentFolderFileNamePrefix, $main::RemoteUser |
6243 |
# |
6244 |
# Returns: void |
6245 |
# |
6246 |
sub vGetFolder { |
6247 |
|
6248 |
my ($HeaderName, $FolderName, $SelectorText, %ArticleFolder); |
6249 |
my (@DocumentFolderList, $DocumentFolderEntry, %QualifiedDocumentFolders); |
6250 |
my ($Value, %Value); |
6251 |
|
6252 |
|
6253 |
# Return an error if the remote user name/account directory is not defined |
6254 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
6255 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
6256 |
&vSendHTMLFooter; |
6257 |
return; |
6258 |
} |
6259 |
|
6260 |
|
6261 |
|
6262 |
# Make the document folder file name |
6263 |
$DocumentFolderEntry = $main::UserAccountDirectoryPath . "/" . $main::FormData{'DocumentFolderObject'}; |
6264 |
|
6265 |
# Check to see if the XML document folder file requested is there |
6266 |
if ( ! -f $DocumentFolderEntry ) { |
6267 |
# Could not find the document folders file |
6268 |
&vHandleError("Document Folder", "Sorry, we cant to access this document folder object because it is not there"); |
6269 |
goto bailFromGetFolder; |
6270 |
} |
6271 |
|
6272 |
# Get information from the XML document folder file |
6273 |
($HeaderName, %ArticleFolder) = &shGetHashFromXMLFile($DocumentFolderEntry); |
6274 |
|
6275 |
# Check that the entry is valid |
6276 |
if ( !(defined($HeaderName) && ($HeaderName eq "DocumentFolder")) ) { |
6277 |
&vHandleError("Document Folder", "Sorry, this document folder object is invalid"); |
6278 |
goto bailFromGetFolder; |
6279 |
} |
6280 |
|
6281 |
|
6282 |
# Make su re we send the header |
6283 |
&vSendHTMLHeader("Document Folder", undef); |
6284 |
undef(%Value); |
6285 |
&vSendMenuBar(%Value); |
6286 |
|
6287 |
print("<H3> Document Folder: </H3>\n"); |
6288 |
|
6289 |
|
6290 |
# Start the form |
6291 |
print("<FORM ACTION=\"$ENV{'SCRIPT_NAME'}\" METHOD=POST>\n"); |
6292 |
|
6293 |
|
6294 |
# Print the selector if there are any documents |
6295 |
if ( defined($ArticleFolder{'FolderDocuments'}) ) { |
6296 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
6297 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP>Odabranima se smatraju svi rezultati ukoliko niste uèinili nikakav dodatan odabir.</TD><TD ALIGN=RIGHT VALIGN=TOP> \n"); |
6298 |
print("<SELECT NAME=\"Action\">\n"); |
6299 |
print("<OPTION VALUE=\"GetDocument\">Prika¾i odabrane rezultates\n"); |
6300 |
if ( $main::ConfigurationData{'allow-similiar-search'} eq "yes" ) { |
6301 |
print("<OPTION VALUE=\"GetSimilarDocument\">Prika¾i rezultate sliène odabranim rezultatima\n"); |
6302 |
} |
6303 |
if ( $main::ConfigurationData{'allow-relevance-feedback-searches'} eq "yes" ) { |
6304 |
print("<OPTION VALUE=\"GetSearchResults\">Run search with selected documents as relevance feedback\n"); |
6305 |
} |
6306 |
print("<OPTION VALUE=\"DeleteDocument&DocumentFolderObject=$main::FormData{'DocumentFolderObject'}\">Delete selected documents from this document folder\n"); |
6307 |
print("<OPTION VALUE=\"GetSaveFolder&FromDocumentFolderObject=$main::FormData{'DocumentFolderObject'}\">Move selected documents to a new document folder\n"); |
6308 |
|
6309 |
|
6310 |
# Get the document folder hash |
6311 |
%QualifiedDocumentFolders = &hGetDocumentFolders; |
6312 |
|
6313 |
for $FolderName ( sort( keys(%QualifiedDocumentFolders)) ) { |
6314 |
|
6315 |
# Skip this folder |
6316 |
if ( $FolderName eq $ArticleFolder{'FolderName'} ) { |
6317 |
next; |
6318 |
} |
6319 |
|
6320 |
$DocumentFolderEntry = $QualifiedDocumentFolders{$FolderName}; |
6321 |
|
6322 |
# Get the document folder file name and encode it |
6323 |
$DocumentFolderEntry = ($DocumentFolderEntry =~ /^$main::UserAccountDirectoryPath\/(.*)/) ? $1 : $DocumentFolderEntry; |
6324 |
$DocumentFolderEntry = &lEncodeURLData($DocumentFolderEntry); |
6325 |
|
6326 |
print("<OPTION VALUE=\"SetSaveFolder&DocumentFolderObject=$DocumentFolderEntry&FromDocumentFolderObject=$main::FormData{'DocumentFolderObject'}\">Move selected documents to the '$FolderName' document folder\n"); |
6327 |
} |
6328 |
|
6329 |
print("</SELECT>\n"); |
6330 |
print("<INPUT TYPE=SUBMIT VALUE=\"Do It!\">\n"); |
6331 |
print("</TD></TR>\n"); |
6332 |
print("</TABLE>\n"); |
6333 |
} |
6334 |
|
6335 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
6336 |
|
6337 |
|
6338 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>\n"); |
6339 |
|
6340 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Naziv: </TD> <TD ALIGN=LEFT VALIGN=TOP> $ArticleFolder{'FolderName'} </TD></TR>\n"); |
6341 |
|
6342 |
# Print the folder description |
6343 |
$ArticleFolder{'FolderDescription'} = defined($ArticleFolder{'FolderDescription'}) ? $ArticleFolder{'FolderDescription'} : "(No description defined)"; |
6344 |
$ArticleFolder{'FolderDescription'} =~ s/\n/<BR>/g; |
6345 |
$ArticleFolder{'FolderDescription'} =~ s/\r/<BR>/g; |
6346 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Opis: </TD> <TD ALIGN=LEFT VALIGN=TOP> $ArticleFolder{'FolderDescription'} </TD></TR>\n"); |
6347 |
|
6348 |
|
6349 |
$Value = &sGetPrintableDateFromTime($ArticleFolder{'CreationTime'}); |
6350 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Datum kreiranja: </TD> <TD ALIGN=LEFT VALIGN=TOP> $Value </TD></TR>\n"); |
6351 |
|
6352 |
$Value = &sGetPrintableDateFromTime($ArticleFolder{'UpdateTime'}); |
6353 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP> Datum zadnje promijene: </TD> <TD ALIGN=LEFT VALIGN=TOP> $Value </TD></TR>\n"); |
6354 |
|
6355 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2><HR WIDTH=50%></TD></TR>\n"); |
6356 |
|
6357 |
|
6358 |
# Display a button to select all the documents if there are any |
6359 |
if ( defined($ArticleFolder{'FolderDocuments'}) ) { |
6360 |
|
6361 |
$SelectorText = ""; |
6362 |
|
6363 |
# Loop over each entry folder documents |
6364 |
foreach $Value ( split(/\0/, $ArticleFolder{'FolderDocuments'}) ) { |
6365 |
$SelectorText .= (($SelectorText ne "") ? "|" : "") . $Value; |
6366 |
} |
6367 |
|
6368 |
$SelectorText = "<INPUT TYPE=\"HIDDEN\" NAME=\"Documents\" VALUE=\"" . $SelectorText . "\"> "; |
6369 |
print("<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2> $SelectorText </TD></TR>\n"); |
6370 |
} |
6371 |
|
6372 |
if ( defined($ArticleFolder{'FolderDocuments'}) ) { |
6373 |
print("<TR>\n"); |
6374 |
&bDisplayDocuments("Document", $ArticleFolder{'FolderDocuments'}, "Document", 1, undef, 1); |
6375 |
print("</TR>\n"); |
6376 |
} |
6377 |
else { |
6378 |
print("<TR><TD ALIGN=CENTER VALIGN=TOP COLSPAN=2> This document folder does not contain any documents. </TD></TR>\n"); |
6379 |
} |
6380 |
|
6381 |
print("</FORM></TABLE>\n"); |
6382 |
|
6383 |
# Bail from displaying the document folder |
6384 |
bailFromGetFolder: |
6385 |
|
6386 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
6387 |
undef(%Value); |
6388 |
&vSendMenuBar(%Value); |
6389 |
|
6390 |
&vSendHTMLFooter; |
6391 |
|
6392 |
return; |
6393 |
|
6394 |
} |
6395 |
|
6396 |
|
6397 |
|
6398 |
|
6399 |
|
6400 |
|
6401 |
#-------------------------------------------------------------------------- |
6402 |
# |
6403 |
# Function: vProcessDocument() |
6404 |
# |
6405 |
# Purpose: This function deletes folder documents |
6406 |
# |
6407 |
# Called by: |
6408 |
# |
6409 |
# Parameters: void |
6410 |
# |
6411 |
# Global Variables: %main::ConfigurationData, %main::FormData, |
6412 |
# $main::UserSettingsFilePath, $main::RemoteUser, |
6413 |
# |
6414 |
# Returns: void |
6415 |
# |
6416 |
sub vProcessDocument { |
6417 |
|
6418 |
my ($Title, $DocumentFolderFilePath, $HeaderName); |
6419 |
my ($FolderName, $FolderDescription, $FolderDocuments, $CreationTime, $UpdateTime); |
6420 |
my (%Value, @Values, $Value); |
6421 |
|
6422 |
|
6423 |
|
6424 |
# Return an error if the remote user name/account directory is not defined |
6425 |
if ( ! (defined($main::RemoteUser) && defined($main::UserAccountDirectoryPath)) ) { |
6426 |
&vHandleError("Undefined User Account", "Sorry, there is no user account defined"); |
6427 |
&vSendHTMLFooter; |
6428 |
return; |
6429 |
} |
6430 |
|
6431 |
|
6432 |
# Check to see if the XML document fol der is there |
6433 |
if ( !defined($main::FormData{'DocumentFolderObject'}) ) { |
6434 |
# Could not find the document folders file |
6435 |
&vHandleError($Title, "Sorry, the document folder object was not defined"); |
6436 |
goto bailFromProcessDocument; |
6437 |
} |
6438 |
|
6439 |
|
6440 |
# Set the title |
6441 |
if ( $ENV{'PATH_INFO'} eq "/DeleteDocument" ) { |
6442 |
$Title = "Delete Folder Documents"; |
6443 |
} |
6444 |
|
6445 |
|
6446 |
# Make sure that we send the header |
6447 |
&vSendHTMLHeader($Title, undef); |
6448 |
undef(%Value); |
6449 |
&vSendMenuBar(%Value); |
6450 |
|
6451 |
|
6452 |
|
6453 |
# Check to see if the document folder object is defined |
6454 |
if ( ! (defined($main::FormData{'Document'}) || defined($main::FormData{'Documents'})) ) { |
6455 |
|
6456 |
# No documents were defined |
6457 |
print("<H3><CENTER> Sorry, no documents were selected. </CENTER></H3>\n"); |
6458 |
print("<P>\n"); |
6459 |
print("You need to select at least one document in order to be able to perform an action on it.\n"); |
6460 |
print("<P>\n"); |
6461 |
|
6462 |
goto bailFromProcessDocument; |
6463 |
} |
6464 |
|
6465 |
|
6466 |
# Set the document folder file path |
6467 |
$DocumentFolderFilePath = $main::UserAccountDirectoryPath . "/" . $main::FormData{'DocumentFolderObject'}; |
6468 |
|
6469 |
|
6470 |
# Check to see if the XML document folder file requested is there |
6471 |
if ( ! -f $DocumentFolderFilePath ) { |
6472 |
# Could not find the document folders file |
6473 |
&vHandleError($Title, "Sorry, we cant to access this document folder object because it is not there"); |
6474 |
goto bailFromProcessDocument; |
6475 |
} |
6476 |
|
6477 |
|
6478 |
# Get information from the XML document folder file |
6479 |
($HeaderName, %Value) = &shGetHashFromXMLFile($DocumentFolderFilePath); |
6480 |
|
6481 |
# Check that the entry is valid |
6482 |
if ( !(defined($HeaderName) && ($HeaderName eq "DocumentFolder")) ) { |
6483 |
&vHandleError($Title, "Sorry, this document folder object is invalid"); |
6484 |
goto bailFromProcessDocument; |
6485 |
} |
6486 |
|
6487 |
|
6488 |
|
6489 |
$FolderName = $Value{'FolderName'}; |
6490 |
$FolderDescription = $Value{'FolderDescription'}; |
6491 |
$FolderDocuments = $Value{'FolderDocuments'}; |
6492 |
$CreationTime = $Value{'CreationTime'}; |
6493 |
$UpdateTime = time(); |
6494 |
|
6495 |
|
6496 |
# Make a hash table from the documents selected for deletion, this serves as |
6497 |
# a lookup table when we loop through the existing documents |
6498 |
# List the documents |
6499 |
if ( defined($main::FormData{'Document'}) || defined($main::FormData{'Documents'}) ) { |
6500 |
|
6501 |
# Undefine the hash table in preparation |
6502 |
undef(%Value); |
6503 |
|
6504 |
# Add document that were specifically selected |
6505 |
if ( defined($main::FormData{'Document'}) ) { |
6506 |
foreach $Value ( split(/\0/, $main::FormData{'Document'}) ) { |
6507 |
$Value{$Value} = $Value; |
6508 |
} |
6509 |
} |
6510 |
# Otherwise add documents that were selected by default |
6511 |
elsif ( defined($main::FormData{'Documents'}) ) { |
6512 |
foreach $Value ( split(/\|/, $main::FormData{'Documents'}) ) { |
6513 |
$Value{$Value} = $Value; |
6514 |
} |
6515 |
} |
6516 |
} |
6517 |
|
6518 |
|
6519 |
# Parse out of the existing documents into a list |
6520 |
foreach $Value ( split(/\0/, $FolderDocuments) ) { |
6521 |
# Add the document if it is not on the deletion list |
6522 |
if ( !defined($Value{$Value}) ) { |
6523 |
push @Values, $Value; |
6524 |
} |
6525 |
} |
6526 |
$FolderDocuments = join("\0", @Values); |
6527 |
|
6528 |
|
6529 |
# Save the document folder (now missing the selected documents) |
6530 |
if ( &iSaveFolder($DocumentFolderFilePath, $FolderName, $FolderDescription, $FolderDocuments, $CreationTime, $UpdateTime) ) { |
6531 |
|
6532 |
print("<H3> $Title: </H3>\n"); |
6533 |
print("<P>\n"); |
6534 |
print("<H3><CENTER> The folder documents were successfully deleted. </CENTER></H3>\n"); |
6535 |
|
6536 |
} |
6537 |
else { |
6538 |
|
6539 |
# The documents coudl not be deleted, so we inform the user of the fact |
6540 |
&vHandleError($Title, "Sorry, we failed to delete the selected folder documents"); |
6541 |
goto bailFromProcessDocument; |
6542 |
} |
6543 |
|
6544 |
|
6545 |
# Bail from deleting the documents |
6546 |
bailFromProcessDocument: |
6547 |
|
6548 |
print("<CENTER><HR WIDTH=50%></CENTER>\n"); |
6549 |
undef(%Value); |
6550 |
&vSendMenuBar(%Value); |
6551 |
|
6552 |
&vSendHTMLFooter; |
6553 |
|
6554 |
return; |
6555 |
|
6556 |
} |
6557 |
|
6558 |
|
6559 |
|
6560 |
|
6561 |
|
6562 |
|
6563 |
#-------------------------------------------------------------------------- |
6564 |
# |
6565 |
# Function: vRunSavedSearches() |
6566 |
# |
6567 |
# Purpose: Run the saved searches which are due |
6568 |
# |
6569 |
# Called by: |
6570 |
# |
6571 |
# Parameters: $PassedFrequency search frequency |
6572 |
# |
6573 |
# Global Variables: |
6574 |
# |
6575 |
# Returns: void |
6576 |
# |
6577 |
sub vRunSavedSearches { |
6578 |
|
6579 |
my ($PassedFrequency) = @_; |
6580 |
my (@UserAccountsDirectoryList, $UserAccountsDirectory, @UserSavedSearchList, $UserSavedSearch); |
6581 |
my (@SavedSearchFilePathList, @QualifiedSaveSearchFilePathList, $SavedSearchFilePath); |
6582 |
my ($SearchName, $SearchDescription, $SearchAndRfDocumentURL, $SearchString, $DeliveryFormat, $DeliveryMethod, $SearchFrequency, $SearchStatus, $CreationTime, $LastRunTime); |
6583 |
my ($EmailAddress, $NewLastRunTime, $Databases, $HeaderName); |
6584 |
my ($Status, $SearchResults, $FinalSearchString, $SearchResult, $ResultCount, $QueryReport, $ErrorNumber, $ErrorMessage); |
6585 |
my ($ItemName, $MimeType, $HTML, $SavedFileHandle); |
6586 |
my ($Value, %Value, $ValueEntry); |
6587 |
|
6588 |
|
6589 |
# Check that we can actually run saved searches |
6590 |
if ( !(defined($main::ConfigurationData{'allow-regular-searches'}) && ($main::ConfigurationData{'allow-regular-searches'} eq "yes")) ) { |
6591 |
print("Execution error - configuration setting: 'allow-regular-searches', setting not set or disabled.\n"); |
6592 |
return; |
6593 |
} |
6594 |
|
6595 |
|
6596 |
# Check that we have a user account directory |
6597 |
if ( !defined($main::ConfigurationData{'user-accounts-directory'}) ) { |
6598 |
print("Execution error - configuration setting: 'user-accounts-directory', setting not set.\n"); |
6599 |
} |
6600 |
|
6601 |
|
6602 |
# Check that we have a script URL |
6603 |
if ( !(defined($main::ConfigurationData{'script-url'}) && ($main::ConfigurationData{'script-url'} ne "yes")) ) { |
6604 |
print("Execution error - configuration setting: 'script-url', setting not set.\n"); |
6605 |
} |
6606 |
|
6607 |
|
6608 |
# Scoop up all the directories in the user accounts directory |
6609 |
opendir(ACCOUNTS_DIRECTORY, $main::ConfigurationData{'user-accounts-directory'}); |
6610 |
@UserAccountsDirectoryList = grep(!/^\.\.?$/, readdir(ACCOUNTS_DIRECTORY)); |
6611 |
closedir(ACCOUNTS_DIRECTORY); |
6612 |
|
6613 |
# Loop over each user account |
6614 |
foreach $UserAccountsDirectory ( @UserAccountsDirectoryList ) { |
6615 |
|
6616 |
# Read all the saved searches |
6617 |
opendir(USER_ACCOUNT_DIRECTORY, $main::ConfigurationData{'user-accounts-directory'} . "/" . $UserAccountsDirectory); |
6618 |
@UserSavedSearchList = grep(/$main::SavedSearchFileNamePrefix/, readdir(USER_ACCOUNT_DIRECTORY)); |
6619 |
closedir(USER_ACCOUNT_DIRECTORY); |
6620 |
|
6621 |
# And add each to the saved searches list |
6622 |
foreach $UserSavedSearch ( @UserSavedSearchList ) { |
6623 |
push @SavedSearchFilePathList, $main::ConfigurationData{'user-accounts-directory'} . "/" . $UserAccountsDirectory . "/" . $UserSavedSearch; |
6624 |
} |
6625 |
} |
6626 |
|
6627 |
|
6628 |
# Return here if there are no saved search to process |
6629 |
if ( ! @SavedSearchFilePathList ) { |
6630 |
print("Execution warning - no saved searches to process.\n"); |
6631 |
return; |
6632 |
} |
6633 |
|
6634 |
|
6635 |
# Loop over each file in the list, checking to see if it is time to |
6636 |
# process this one, if so we add it to the qualified saved search list |
6637 |
foreach $SavedSearchFilePath ( @SavedSearchFilePathList ) { |
6638 |
|
6639 |
# Get the header name from the saved search file |
6640 |
$HeaderName = &sGetObjectTagFromXMLFile($SavedSearchFilePath); |
6641 |
|
6642 |
# Skip this saved search file entry if it is not valid |
6643 |
if ( !(defined($HeaderName) && ($HeaderName eq "SavedSearch")) ) { |
6644 |
print("Execution error - invalid saved search object: '$SavedSearchFilePath'.\n"); |
6645 |
next; |
6646 |
} |
6647 |
|
6648 |
|
6649 |
# Get the delivery format from the saved search file |
6650 |
$DeliveryFormat = &sGetTagValueFromXMLFile($SavedSearchFilePath, "DeliveryFormat"); |
6651 |
|
6652 |
# Check the delivery format, it is undefined if the search is not a regular search |
6653 |
if ( ! defined($DeliveryFormat) ) { |
6654 |
next; |
6655 |
} |
6656 |
|
6657 |
# Check the validity of the delivery format |
6658 |
if ( ! defined($main::DeliveryFormats{$DeliveryFormat}) ) { |
6659 |
print("Execution error - invalid delivery method: '$DeliveryFormat' in saved search: '$SavedSearchFilePath'.\n"); |
6660 |
next; |
6661 |
} |
6662 |
|
6663 |
|
6664 |
|
6665 |
# Set the user settings file path name |
6666 |
$main::UserSettingsFilePath = substr($SavedSearchFilePath, 0, rindex($SavedSearchFilePath,"/") + 1) . $main::UserSettingsFileName . $main::XMLFileNameExtension; |
6667 |
|
6668 |
# Check that this preference file is valid |
6669 |
$HeaderName = &sGetObjectTagFromXMLFile($main::UserSettingsFilePath); |
6670 |
|
6671 |
# Skip this entry if it is not valid |
6672 |
if ( !(defined($HeaderName) && ($HeaderName eq "UserSettings")) ) { |
6673 |
print("Execution error - invalid user settings object: '$main::UserSettingsFilePath'.\n"); |
6674 |
next; |
6675 |
} |
6676 |
|
6677 |
|
6678 |
# Get the email address from the user settings file |
6679 |
$EmailAddress = &sGetTagValueFromXMLFile($main::UserSettingsFilePath, "EmailAddress"); |
6680 |
|
6681 |
# Skip this entry if it is not valid |
6682 |
if ( !defined($EmailAddress) ) { |
6683 |
print("Execution error - invalid email address in user settings object: '$main::UserSettingsFilePath'.\n"); |
6684 |
next; |
6685 |
} |
6686 |
|
6687 |
|
6688 |
# Get the frequency requested for this saved search |
6689 |
$SearchFrequency = &sGetTagValueFromXMLFile($SavedSearchFilePath, "SearchFrequency"); |
6690 |
|
6691 |
# Check the search frequency, skip if it is undefined |
6692 |
if ( !defined($SearchFrequency)) { |
6693 |
print("Execution error - undefined search frequency in user settings object: '$main::UserSettingsFilePath'.\n"); |
6694 |
next; |
6695 |
} |
6696 |
|
6697 |
# Check the search frequency, skip if it is invalid |
6698 |
$Value = 0; |
6699 |
foreach $ValueEntry ( @main::SearchFrequencies ) { |
6700 |
if ( $ValueEntry eq $SearchFrequency ) { |
6701 |
$Value = 1; |
6702 |
last; |
6703 |
} |
6704 |
} |
6705 |
if ( !$Value ) { |
6706 |
print("Execution error - invalid search frequency: '$SearchFrequency', in user settings object: '$main::UserSettingsFilePath'.\n"); |
6707 |
next; |
6708 |
} |
6709 |
|
6710 |
|
6711 |
# Is this the frequency we are currently working on? |
6712 |
if ( index($PassedFrequency, $SearchFrequency) < 0 ) { |
6713 |
next; |
6714 |
} |
6715 |
|
6716 |
|
6717 |
# It is, so we concatenate the saved search file name to the list of |
6718 |
# qualified saved search file names |
6719 |
push @QualifiedSaveSearchFilePathList, $SavedSearchFilePath; |
6720 |
} |
6721 |
|
6722 |
|
6723 |
|
6724 |
# Return here if there are no qualified saved search to process |
6725 |
if ( ! @QualifiedSaveSearchFilePathList ) { |
6726 |
return; |
6727 |
} |
6728 |
|
6729 |
|
6730 |
# Get the current time, this will be used as the new last run time |
6731 |
$NewLastRunTime = time(); |
6732 |
|
6733 |
|
6734 |
# Loop each saved search in the qualified saved search list, processing each of them |
6735 |
foreach $SavedSearchFilePath ( @QualifiedSaveSearchFilePathList ) { |
6736 |
|
6737 |
# Get information from the XML saved search file |
6738 |
($HeaderName, %Value) = &shGetHashFromXMLFile($SavedSearchFilePath); |
6739 |
|
6740 |
$SearchName = $Value{'SearchName'}; |
6741 |
$SearchDescription = $Value{'SearchDescription'}; |
6742 |
$SearchString = $Value{'SearchString'}; |
6743 |
$SearchAndRfDocumentURL = $Value{'SearchAndRfDocumentURL'}; |
6744 |
$SearchFrequency = $Value{'SearchFrequency'}; |
6745 |
$SearchStatus = $Value{'SearchStatus'}; |
6746 |
$DeliveryFormat = $Value{'DeliveryFormat'}; |
6747 |
$DeliveryMethod = $Value{'DeliveryMethod'}; |
6748 |
$CreationTime = $Value{'CreationTime'}; |
6749 |
$LastRunTime = $Value{'LastRunTime'}; |
6750 |
|
6751 |
|
6752 |
# Check the search status, run the search if it is active |
6753 |
if ( defined($SearchStatus) && ($SearchStatus eq "Active") ) { |
6754 |
|
6755 |
# Get the last run time from the XML saved search file |
6756 |
if ( !defined($LastRunTime) ) { |
6757 |
$LastRunTime = "0"; |
6758 |
} |
6759 |
|
6760 |
|
6761 |
# Set the remote user name |
6762 |
$main::RemoteUser = substr($SavedSearchFilePath, 0, rindex($SavedSearchFilePath,"/")); |
6763 |
$main::RemoteUser = substr($main::RemoteUser, rindex($main::RemoteUser,"/") + 1); |
6764 |
|
6765 |
# Set the user directory path |
6766 |
$main::UserAccountDirectoryPath = substr($SavedSearchFilePath, 0, rindex($SavedSearchFilePath,"/") + 1); |
6767 |
|
6768 |
# Set the user settings file path name |
6769 |
$main::UserSettingsFilePath = $main::UserAccountDirectoryPath . $main::UserSettingsFileName . $main::XMLFileNameExtension; |
6770 |
|
6771 |
# Get the email address from the user settings file |
6772 |
$EmailAddress = &sGetTagValueFromXMLFile($main::UserSettingsFilePath, "EmailAddress"); |
6773 |
|
6774 |
# Parse the URL search string into the form data global |
6775 |
%main::FormData = &hParseURLIntoHashTable($SearchAndRfDocumentURL); |
6776 |
|
6777 |
|
6778 |
########################## |
6779 |
# Uncomment this to force a check over the complete database rather than |
6780 |
# just getting the documents which changed since the last run |
6781 |
# $LastRunTime = 0; |
6782 |
########################## |
6783 |
|
6784 |
|
6785 |
# Clear the date restriction fields, they are meaningless in this context |
6786 |
delete($main::FormData{'Since'}); |
6787 |
delete($main::FormData{'Before'}); |
6788 |
|
6789 |
# Set the last run time restriction |
6790 |
$main::FormData{'LastRunTime'} = $LastRunTime; |
6791 |
|
6792 |
|
6793 |
# Generate the search string |
6794 |
$FinalSearchString = &sMakeSearchString(%main::FormData); |
6795 |
|
6796 |
|
6797 |
# Set the local database names |
6798 |
if ( defined($main::FormData{'Database'}) ) { |
6799 |
|
6800 |
# Set the database variable and convert all the '\0' to ',' |
6801 |
$Databases = $main::FormData{'Database'}; |
6802 |
$Databases =~ tr/\0/,/; |
6803 |
} |
6804 |
|
6805 |
|
6806 |
|
6807 |
print("Execution - saved search: '$SavedSearchFilePath', database: '$Databases', search: '$FinalSearchString', time: '$LastRunTime'.\n"); |
6808 |
|
6809 |
# Run the search |
6810 |
($Status, $SearchResults) = MPS::SearchDatabase($main::MPSSession, $Databases, $FinalSearchString, "", 0, $main::DefaultMaxDoc - 1, $main::ConfigurationData{'max-score'}); |
6811 |
|
6812 |
if ( ! $Status ) { |
6813 |
($ErrorNumber, $ErrorMessage) = split(/\t/, $SearchResults, 2); |
6814 |
print("Execution error - failed to run the search.\n"); |
6815 |
print("The following error message was reported: <BR>\n"); |
6816 |
print("Error Message: $ErrorMessage <BR>\n"); |
6817 |
print("Error Number: $ErrorNumber <BR>\n"); |
6818 |
next; |
6819 |
} |
6820 |
|
6821 |
|
6822 |
# Get the number of results we got from the search |
6823 |
$ResultCount = 0; |
6824 |
foreach $SearchResult ( split(/\n/, $SearchResults) ) { |
6825 |
|
6826 |
# Parse the headline, also get the first document item/type |
6827 |
(undef, undef, undef, undef, undef undef, $ItemName, $MimeType, undef) = split(/\t/, $SearchResult, 9); |
6828 |
|
6829 |
# Is this a query report |
6830 |
if ( !(($ItemName eq $main::QueryReportItemName) && ($MimeType eq $main::QueryReportMimeType)) ) { |
6831 |
# Increment the result count |
6832 |
$ResultCount++; |
6833 |
} |
6834 |
} |
6835 |
|
6836 |
|
6837 |
# Do we want to deliver email messages with no new results? |
6838 |
if ( defined($main::ConfigurationData{'deliver-empty-results-from-regular-search'}) && ($main::ConfigurationData{'deliver-empty-results-from-regular-search'} eq "no") ) { |
6839 |
if ( $ResultCount == 0 ) { |
6840 |
next; |
6841 |
} |
6842 |
} |
6843 |
|
6844 |
|
6845 |
# Open the mail application, put put an error message if we cant open it and loop to the next saved search |
6846 |
if ( ! open(RESULT_FILE, "| $main::ConfigurationData{'mailer-application'} $EmailAddress ") ) { |
6847 |
print("Execution error - failed to launch mail application: '$main::ConfigurationData{'mailer-application'}', system error: $!.\n"); |
6848 |
next; |
6849 |
} |
6850 |
|
6851 |
|
6852 |
# Save the file handle for stdout and select the result file handle as the default handle |
6853 |
$SavedFileHandle = select; |
6854 |
select RESULT_FILE; |
6855 |
|
6856 |
|
6857 |
# Print out the message header (To:) |
6858 |
print ("To: $EmailAddress\n"); |
6859 |
|
6860 |
# Print out the message header (From:) |
6861 |
if ( defined($main::ConfigurationData{'site-admin-email'}) && ($main::ConfigurationData{'site-admin-email'} ne "") ) { |
6862 |
print ("From: $main::ConfigurationData{'site-admin-email'}\n"); |
6863 |
} |
6864 |
|
6865 |
# Print out the message header (Subject:) |
6866 |
print ("Subject: Results for saved search: $SearchName\n"); |
6867 |
|
6868 |
|
6869 |
# Print out the message header (Content-Type) |
6870 |
if ( $DeliveryMethod eq "attachement" ) { |
6871 |
print("Mime-Version: 1.0\n"); |
6872 |
print("Content-Type: multipart/mixed; boundary=\"============_-1234567890==_============\"\n"); |
6873 |
} |
6874 |
else { |
6875 |
print("Mime-Version: 1.0\n"); |
6876 |
printf("Content-Type: %s\n\n", ($DeliveryFormat eq "text/html") ? "text/html" : "text/plain"); |
6877 |
} |
6878 |
|
6879 |
# Print out the separating new line between message header and message body |
6880 |
print("\n"); |
6881 |
|
6882 |
|
6883 |
|
6884 |
# Print out mime part separator and mime header for the message header |
6885 |
if ( $DeliveryMethod eq "attachement" ) { |
6886 |
print("--============_-1234567890==_============\n"); |
6887 |
printf("Content-Type: text/plain; charset=\"us-ascii\"\n\n\n"); |
6888 |
|
6889 |
if ( $DeliveryFormat eq "text/plain" ) { |
6890 |
print("The search results are attached to this email message as a plain text\n"); |
6891 |
print("file. This file can be opened with a any word processor or text editor.\n"); |
6892 |
} |
6893 |
elsif ( $DeliveryFormat eq "text/html" ) { |
6894 |
print("The search results are attached to this email message as an HTML\n"); |
6895 |
print("file. This file can be opened with Netscape or Internet Explorer.\n"); |
6896 |
} |
6897 |
|
6898 |
print("--============_-1234567890==_============\n"); |
6899 |
$Value = "citations." . (($DeliveryFormat eq "text/html") ? "html" : "txt"); |
6900 |
print("Content-Type: $DeliveryFormat; name=\"$Value\"\n"); |
6901 |
print("Content-Disposition: attachment; filename=\"$Value\"\n\n"); |
6902 |
} |
6903 |
|
6904 |
|
6905 |
# Get the current date |
6906 |
$Value = &sGetPrintableDateFromTime(); |
6907 |
|
6908 |
# Set the HTML flag |
6909 |
$HTML = ( $DeliveryFormat eq "text/html" ) ? 1 : 0; |
6910 |
|
6911 |
# Write out the search result header |
6912 |
($Status, $QueryReport) = &bsDisplaySearchResults("Search Results for: $SearchName:", $SearchDescription, $Value, $SearchFrequency, $SearchResults, undef, $main::ConfigurationData{'script-url'}, 1, 1, $HTML, %main::FormData); |
6913 |
|
6914 |
|
6915 |
|
6916 |
# Print out mime part separator and mime header for the message footer |
6917 |
if ( $DeliveryMethod eq "attachement" ) { |
6918 |
print("--============_-1234567890==_============\n"); |
6919 |
printf("Content-Type: %s; charset=\"us-ascii\"\n\n\n", ($DeliveryFormat eq "text/html") ? "text/html" : "text/plain"); |
6920 |
} |
6921 |
|
6922 |
|
6923 |
# Print out the profile result footer |
6924 |
if ( $DeliveryFormat eq "text/html" ) { |
6925 |
print("<BR><HR>\n"); |
6926 |
print("Saved search by the <A HREF=\"$main::ConfigurationData{'script-url'}\">MPS Information Server </A><BR>\n"); |
6927 |
print("Created by <A HREF=\"http://www.fsconsult.com/\">FS Consulting, Inc.</A><BR>\n"); |
6928 |
print("<HR><BR>\n"); |
6929 |
print("</BODY>\n"); |
6930 |
} |
6931 |
elsif ( ($DeliveryFormat eq "text/plain") || ($DeliveryFormat eq "text/medline-citation") ) { |
6932 |
print("----------------------------------------------------------------------\n"); |
6933 |
print("Saved search by the MPS Information Server [URL: $main::ConfigurationData{'script-url'}].\n"); |
6934 |
print("Created by FS Consulting, Inc. [URL: http://www.fsconsult.com/].\n"); |
6935 |
print("----------------------------------------------------------------------\n"); |
6936 |
|
6937 |
} |
6938 |
|
6939 |
# Print out mime part separator for the end of the message |
6940 |
if ( $DeliveryMethod eq "attachement" ) { |
6941 |
print("--============_-1234567890==_============--\n"); |
6942 |
} |
6943 |
|
6944 |
|
6945 |
# Restore the saved file handle |
6946 |
select $SavedFileHandle; |
6947 |
|
6948 |
# Close the result file |
6949 |
close(RESULT_FILE); |
6950 |
|
6951 |
} |
6952 |
else { |
6953 |
print("Execution - saved search: '$SavedSearchFilePath' is currently inactive.\n"); |
6954 |
} |
6955 |
|
6956 |
# Save the search object |
6957 |
if ( ! &iSaveSearch($SavedSearchFilePath, $SearchName, $SearchDescription, $SearchAndRfDocumentURL, $SearchFrequency, $DeliveryFormat, $DeliveryMethod, $SearchStatus, $CreationTime, $NewLastRunTime) ) { |
6958 |
print("Execution error - failed to save search object: '$SavedSearchFilePath'.\n"); |
6959 |
} |
6960 |
|
6961 |
} # foreach () |
6962 |
|
6963 |
return; |
6964 |
|
6965 |
} |
6966 |
|
6967 |
|
6968 |
|
6969 |
|
6970 |
#-------------------------------------------------------------------------- |
6971 |
# |
6972 |
# Function: vLog() |
6973 |
# |
6974 |
# Purpose: This a logging function which logs any passed printf() |
6975 |
# formatted string to STDOUT and the log file if it is defined. |
6976 |
# |
6977 |
# If the log file cannot be opened for appending, nothing will |
6978 |
# be written to it. |
6979 |
# |
6980 |
# Called by: |
6981 |
# |
6982 |
# Parameters: @_ |
6983 |
# |
6984 |
# Global Variables: $main::LogFilePath |
6985 |
# |
6986 |
# Returns: void |
6987 |
# |
6988 |
sub vLog { |
6989 |
|
6990 |
# Log to defined log file |
6991 |
if ( defined($main::LogFilePath) && ($main::LogFilePath ne "") && open(LOG_FILE, ">>$main::LogFilePath") ) { |
6992 |
print(LOG_FILE @_); |
6993 |
close(LOG_FILE); |
6994 |
} |
6995 |
|
6996 |
return; |
6997 |
|
6998 |
} |
6999 |
|
7000 |
|
7001 |
|
7002 |
|
7003 |
|
7004 |
|
7005 |
#-------------------------------------------------------------------------- |
7006 |
# |
7007 |
# Function: main() |
7008 |
# |
7009 |
# Purpose: main |
7010 |
# |
7011 |
# Called by: |
7012 |
# |
7013 |
# Parameters: |
7014 |
# |
7015 |
# Global Variables: |
7016 |
# |
7017 |
# Returns: void |
7018 |
# |
7019 |
|
7020 |
my ($Status); |
7021 |
my (%Value, $Value); |
7022 |
|
7023 |
|
7024 |
|
7025 |
# Roll over the log file (ignore the status) |
7026 |
# &iRolloverLog($main::LogFilePath, $main::LogFileRollOver); |
7027 |
|
7028 |
|
7029 |
# Verify that we are running the correct perl version, assume upward compatibility |
7030 |
if ( $] < 5.004 ) { |
7031 |
&vLog("Error - this script needs to be run with Perl version 5.004 or better.\n"); |
7032 |
&vSendHTMLFooter; |
7033 |
exit (-1); |
7034 |
} |
7035 |
|
7036 |
|
7037 |
# Load up the configuration file |
7038 |
($Status, %main::ConfigurationData) = &bhReadConfigurationFile($main::ConfigurationFilePath); |
7039 |
if ( ! $Status ) { |
7040 |
&vSendHTMLFooter; |
7041 |
exit (-1); |
7042 |
} |
7043 |
|
7044 |
|
7045 |
|
7046 |
# Set any defaults in the configuration |
7047 |
if ( ! &bSetConfigurationDefaults(\%main::ConfigurationData, \%main::DefaultSettings) ) { |
7048 |
&vSendHTMLFooter; |
7049 |
exit (-1); |
7050 |
} |
7051 |
|
7052 |
|
7053 |
# Check for a minimal configuration |
7054 |
if ( ! &bCheckMinimalConfiguration(\%main::ConfigurationData, \@main::RequiredSettings) ) { |
7055 |
&vSendHTMLFooter; |
7056 |
exit (-1); |
7057 |
} |
7058 |
|
7059 |
|
7060 |
# Check that the configuration paths specified is correct and can be accessed |
7061 |
if ( ! &bCheckConfiguration ) { |
7062 |
&vSendHTMLFooter; |
7063 |
exit (-1); |
7064 |
} |
7065 |
|
7066 |
|
7067 |
# Get the database descriptions |
7068 |
if ( ! &bGetDatabaseDescriptions ) { |
7069 |
&vSendHTMLFooter; |
7070 |
exit (-1); |
7071 |
} |
7072 |
|
7073 |
|
7074 |
# Set up the server |
7075 |
if ( ! &bInitializeServer ) { |
7076 |
&vSendHTMLFooter; |
7077 |
exit (-1); |
7078 |
} |
7079 |
|
7080 |
# fill filed descriptions |
7081 |
&fill_SearchFieldDescriptions_fromDB('ps'); |
7082 |
|
7083 |
# Are we running as a CGI-BIN script |
7084 |
if ( $ENV{'GATEWAY_INTERFACE'} ) { |
7085 |
|
7086 |
|
7087 |
# Check the CGI environment |
7088 |
if ( ! &bCheckCGIEnvironment ) { |
7089 |
&vSendHTMLFooter; |
7090 |
exit (-1); |
7091 |
} |
7092 |
|
7093 |
|
7094 |
# Set and verify the environment (dont comment this out). |
7095 |
if ( ! &bSetupCGIEnvironment ) { |
7096 |
&vSendHTMLFooter; |
7097 |
exit (-1); |
7098 |
} |
7099 |
|
7100 |
|
7101 |
if ( defined($main::FormData{'GetSearch'}) ) { |
7102 |
$ENV{'PATH_INFO'} = "/GetSearch"; |
7103 |
delete($main::FormData{'GetSearch'}); |
7104 |
delete($main::FormData{'GetSearch'}); |
7105 |
} |
7106 |
|
7107 |
if ( defined($main::FormData{'ListSearchHistory'}) ) { |
7108 |
$ENV{'PATH_INFO'} = "/ListSearchHistory"; |
7109 |
delete($main::FormData{'ListSearchHistory'}); |
7110 |
delete($main::FormData{'ListSearchHistory'}); |
7111 |
} |
7112 |
|
7113 |
if ( defined($main::FormData{'ListSavedSearch'}) ) { |
7114 |
$ENV{'PATH_INFO'} = "/ListSavedSearch"; |
7115 |
delete($main::FormData{'ListSavedSearch'}); |
7116 |
delete($main::FormData{'ListSavedSearch'}); |
7117 |
} |
7118 |
|
7119 |
if ( defined($main::FormData{'ListFolder'}) ) { |
7120 |
$ENV{'PATH_INFO'} = "/ListFolder"; |
7121 |
delete($main::FormData{'ListFolder'}); |
7122 |
delete($main::FormData{'ListFolder'}); |
7123 |
} |
7124 |
|
7125 |
if ( defined($main::FormData{'GetUserSettings'}) ) { |
7126 |
$ENV{'PATH_INFO'} = "/GetUserSettings"; |
7127 |
delete($main::FormData{'GetUserSettings'}); |
7128 |
delete($main::FormData{'GetUserSettings'}); |
7129 |
} |
7130 |
|
7131 |
|
7132 |
|
7133 |
# foreach $Value ( keys (%main::FormData) ) { |
7134 |
# $Status = defined($main::FormData{$Value}) ? $main::FormData{$Value} : "(undefined)"; |
7135 |
# &vLog("[\$main::FormData{'$Value'} = '$Status']\n"); |
7136 |
# } |
7137 |
|
7138 |
# Check for 'Action', set the PATH_INFO from it if it is set |
7139 |
if ( defined($main::FormData{'Action'}) ) { |
7140 |
|
7141 |
if ( ($Value = index($main::FormData{'Action'}, "&")) > 0 ) { |
7142 |
%Value = &hParseURLIntoHashTable(&lDecodeURLData(substr($main::FormData{'Action'}, $Value))); |
7143 |
$main::FormData{'Action'} = substr($main::FormData{'Action'}, 0, $Value); |
7144 |
foreach $Value ( keys(%Value) ) { |
7145 |
$main::FormData{$Value} = $Value{$Value}; |
7146 |
} |
7147 |
} |
7148 |
|
7149 |
$ENV{'PATH_INFO'} = "/" . $main::FormData{'Action'}; |
7150 |
delete($main::FormData{'Action'}); |
7151 |
} |
7152 |
|
7153 |
|
7154 |
# Default to search if PATH_INFO is not defined |
7155 |
if ( !defined($ENV{'PATH_INFO'}) || ($ENV{'PATH_INFO'} eq "") ) { |
7156 |
$ENV{'PATH_INFO'} = "/GetSearch"; |
7157 |
} |
7158 |
|
7159 |
|
7160 |
# Check what was requested and take action appropriately |
7161 |
if ( ($ENV{'PATH_INFO'} eq "/GetSearch") || ($ENV{'PATH_INFO'} eq "/GetSimpleSearch") || ($ENV{'PATH_INFO'} eq "/GetExpandedSearch") ) { |
7162 |
&vGetSearch; |
7163 |
} |
7164 |
elsif ( $ENV{'PATH_INFO'} eq "/GetSearchResults" ) { |
7165 |
&vGetSearchResults; |
7166 |
} |
7167 |
elsif ( $ENV{'PATH_INFO'} eq "/GetDatabaseInfo" ) { |
7168 |
&vGetDatabaseInfo; |
7169 |
} |
7170 |
elsif ( $ENV{'PATH_INFO'} eq "/GetDocument" ) { |
7171 |
&vGetDocument; |
7172 |
} |
7173 |
elsif ( $ENV{'PATH_INFO'} eq "/GetSimilarDocument" ) { |
7174 |
&vGetDocument; |
7175 |
} |
7176 |
elsif ( $ENV{'PATH_INFO'} eq "/GetUserSettings" ) { |
7177 |
&vGetUserSettings; |
7178 |
} |
7179 |
elsif ( $ENV{'PATH_INFO'} eq "/SetUserSettings" ) { |
7180 |
&vSetUserSettings; |
7181 |
} |
7182 |
elsif ( $ENV{'PATH_INFO'} eq "/ListSearchHistory" ) { |
7183 |
&vListSearchHistory; |
7184 |
} |
7185 |
elsif ( $ENV{'PATH_INFO'} eq "/GetSearchHistory" ) { |
7186 |
&vGetSearchHistory; |
7187 |
} |
7188 |
elsif ( $ENV{'PATH_INFO'} eq "/GetSaveSearch" ) { |
7189 |
&vGetSaveSearch; |
7190 |
} |
7191 |
elsif ( $ENV{'PATH_INFO'} eq "/SetSaveSearch" ) { |
7192 |
&vSetSaveSearch; |
7193 |
} |
7194 |
elsif ( $ENV{'PATH_INFO'} eq "/ListSavedSearch" ) { |
7195 |
&vListSavedSearch; |
7196 |
} |
7197 |
elsif ( $ENV{'PATH_INFO'} eq "/GetSavedSearch" ) { |
7198 |
&vGetSavedSearch; |
7199 |
} |
7200 |
elsif ( $ENV{'PATH_INFO'} eq "/DeleteSavedSearch" ) { |
7201 |
&vProcessSavedSearch; |
7202 |
} |
7203 |
elsif ( $ENV{'PATH_INFO'} eq "/ActivateSavedSearch" ) { |
7204 |
&vProcessSavedSearch; |
7205 |
} |
7206 |
elsif ( $ENV{'PATH_INFO'} eq "/SuspendSavedSearch" ) { |
7207 |
&vProcessSavedSearch; |
7208 |
} |
7209 |
elsif ( $ENV{'PATH_INFO'} eq "/GetSaveFolder" ) { |
7210 |
&vGetSaveFolder; |
7211 |
} |
7212 |
elsif ( $ENV{'PATH_INFO'} eq "/SetSaveFolder" ) { |
7213 |
&vSetSaveFolder; |
7214 |
} |
7215 |
elsif ( $ENV{'PATH_INFO'} eq "/ListFolder" ) { |
7216 |
&vListFolder; |
7217 |
} |
7218 |
elsif ( $ENV{'PATH_INFO'} eq "/SetMergeFolder" ) { |
7219 |
&vMergeFolder; |
7220 |
} |
7221 |
elsif ( $ENV{'PATH_INFO'} eq "/GetMergeFolder" ) { |
7222 |
&vMergeFolder; |
7223 |
} |
7224 |
elsif ( $ENV{'PATH_INFO'} eq "/DeleteFolder" ) { |
7225 |
&vProcessFolder; |
7226 |
} |
7227 |
elsif ( $ENV{'PATH_INFO'} eq "/GetFolder" ) { |
7228 |
&vGetFolder; |
7229 |
} |
7230 |
elsif ( $ENV{'PATH_INFO'} eq "/DeleteDocument" ) { |
7231 |
&vProcessDocument; |
7232 |
} |
7233 |
else { |
7234 |
$ENV{'PATH_INFO'} = "/GetSearch"; |
7235 |
&vGetSearch; |
7236 |
} |
7237 |
|
7238 |
} |
7239 |
else { |
7240 |
|
7241 |
my ($RunSearches, $Param, $Frequency, $Mday, $Wday); |
7242 |
|
7243 |
|
7244 |
# We are running as a stand alone script |
7245 |
|
7246 |
|
7247 |
# |
7248 |
# Initialize the variables |
7249 |
# |
7250 |
|
7251 |
# Run Searches? |
7252 |
# 0 - dont run searches |
7253 |
# 1 - run searches |
7254 |
$RunSearches = 1; |
7255 |
|
7256 |
|
7257 |
# Init the frequency |
7258 |
$Frequency = ""; |
7259 |
|
7260 |
# Check for command parameters |
7261 |
foreach $Param ( @ARGV ) { |
7262 |
|
7263 |
if ( $Param =~ /^-nos/i ) { |
7264 |
# Dont run searches |
7265 |
$RunSearches = 0; |
7266 |
} |
7267 |
elsif ( $Param =~ /^-s/i ) { |
7268 |
# Run searches |
7269 |
$RunSearches = 1; |
7270 |
} |
7271 |
elsif ( $Param =~ /^-d/i ) { |
7272 |
# Want to run the daily |
7273 |
$Frequency .= "|Daily|"; |
7274 |
} |
7275 |
elsif ( $Param =~ /^-w/i ) { |
7276 |
# Want to run the weekly |
7277 |
$Frequency .= "|Weekly|"; |
7278 |
} |
7279 |
elsif ( $Param =~ /^-m/i ) { |
7280 |
# Want to run the monthly |
7281 |
$Frequency .= "|Monthly|"; |
7282 |
} |
7283 |
elsif ( $Param =~ /^-h/i ) { |
7284 |
# help |
7285 |
print("Usage: Search.cgi [-nosearch|-search] [-daily][-weekly][-monthly][-help]\n"); |
7286 |
print("\n"); |
7287 |
print(" [-nosearch|-search] whether to run or not run searches (default = -search).\n"); |
7288 |
print(" [-daily] run daily crawls/searches (overrides default).\n"); |
7289 |
print(" [-weekly] run weekly crawls/searches (overrides default).\n"); |
7290 |
print(" [-monthly] run monthly crawls/searches (overrides default).\n"); |
7291 |
print(" [-help] print the usage and exit.\n"); |
7292 |
exit (0); |
7293 |
} |
7294 |
else { |
7295 |
# Invalid param |
7296 |
print("\tError - invalid parameter: '$Param', run 'Search.cgi -help' to get parameter information.\n"); |
7297 |
exit (-2); |
7298 |
} |
7299 |
} |
7300 |
|
7301 |
|
7302 |
|
7303 |
# Did we set a frequency usign a command line parameter? |
7304 |
if ( $Frequency eq "" ) { |
7305 |
|
7306 |
# We did not, so we set it based on the following rules |
7307 |
# |
7308 |
# monday-sunday run the daily |
7309 |
# sunday run the weekly |
7310 |
# 1st of the month run the monthly |
7311 |
# |
7312 |
|
7313 |
# Create an ANSI format date/time field |
7314 |
(undef, undef, undef, $Mday, undef, undef, $Wday, undef, undef) = localtime(); |
7315 |
|
7316 |
# Always do the daily |
7317 |
$Frequency = "|Daily|"; |
7318 |
|
7319 |
# Check for sunday, append the weekly |
7320 |
if ( $Wday == 0 ) { |
7321 |
$Frequency .= "|Weekly|"; |
7322 |
} |
7323 |
|
7324 |
# Check for the 1st of the month, append the monthly |
7325 |
if ( $Mday == 1 ) { |
7326 |
$Frequency .= "|Monthly|"; |
7327 |
} |
7328 |
} |
7329 |
|
7330 |
|
7331 |
# Log stuff |
7332 |
print("Execution - Frequency: $Frequency\n"); |
7333 |
|
7334 |
|
7335 |
# Run the searches |
7336 |
if ( $RunSearches == 1 ) { |
7337 |
&vRunSavedSearches($Frequency); |
7338 |
} |
7339 |
} |
7340 |
|
7341 |
|
7342 |
# Shutdown the server |
7343 |
&bShutdownServer; |
7344 |
|
7345 |
|
7346 |
exit (0); |
7347 |
|
7348 |
|
7349 |
|
7350 |
#-------------------------------------------------------------------------- |
7351 |
|
7352 |
# fill SearchFieldDescriptions from one database |
7353 |
|
7354 |
# 2002-06-08 Dobrica Pavlinusic <dpavlin@rot13.org> |
7355 |
|
7356 |
sub fill_SearchFieldDescriptions_fromDB { |
7357 |
|
7358 |
my ($Database) = @_; |
7359 |
|
7360 |
# Get the database field information |
7361 |
my ($Status, $Text) = MPS::GetDatabaseFieldInfo($main::MPSSession, $Database); |
7362 |
|
7363 |
if ( $Status ) { |
7364 |
foreach my $FieldInformation ( split(/\n/, $Text) ) { |
7365 |
my ($FieldName, $FieldDescription, undef) = split(/\t/, $FieldInformation, 3); |
7366 |
$main::SearchFieldDescriptions{$FieldName} = $FieldDescription; |
7367 |
} |
7368 |
} |
7369 |
} |
7370 |
|
7371 |
#-------------------------------------------------------------------------- |
7372 |
# show list of all databases |
7373 |
# |
7374 |
# usage: ShowDatabaseCheckBoxes(@SelectedDatabases) |
7375 |
|
7376 |
sub ShowDatabaseCheckBoxes { |
7377 |
# Parse out the database names and put them into a |
7378 |
# hash table, they should be separated with a '\0' |
7379 |
my %Value; |
7380 |
|
7381 |
foreach my $ItemEntry ( @_ ) { |
7382 |
$Value{$ItemEntry} = $ItemEntry; |
7383 |
} |
7384 |
|
7385 |
print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>\n"); |
7386 |
print "<tr><td colspan=3 align=\"center\"> |
7387 |
<font size=-1>Oznaèi |
7388 |
<a href=\"javascript:SetChecked(1)\">sve</a>, |
7389 |
<a href=\"javascript:SetChecked(0)\">niti jednu</a>. |
7390 |
</font> |
7391 |
</td></tr>"; |
7392 |
|
7393 |
my @html_database; |
7394 |
|
7395 |
foreach my $key ( sort keys %main::DatabaseSort ) { |
7396 |
my $DatabaseName = $main::DatabaseSort{$key}; |
7397 |
my $Value = ((defined($Value{$DatabaseName})) || (scalar(keys(%main::DatabaseDescriptions)) == 1) || !defined($main::RemoteUser) ) ? "CHECKED" : ""; |
7398 |
my $ItemEntry = &lEncodeURLData($DatabaseName); |
7399 |
if ($main::DatabaseDescriptions{$DatabaseName}) { |
7400 |
push @html_database,"<TD ALIGN=LEFT VALIGN=TOP><INPUT TYPE=\"checkbox\" NAME=\"Database\" VALUE=\"$DatabaseName\" $Value> <A HREF=\"$ENV{'SCRIPT_NAME'}/GetDatabaseInfo?Database=$ItemEntry\" OnMouseOver=\"self.status='Informacije io bazi $main::DatabaseDescriptions{$DatabaseName} '; return true\"> $main::DatabaseDescriptions{$DatabaseName} </A> </TD>\n"; |
7401 |
} else { |
7402 |
push @html_database,"<td align=left valign=top>$main::DatabaseDescriptions{$DatabaseName}</td>\n"; |
7403 |
} |
7404 |
} |
7405 |
|
7406 |
|
7407 |
if ($main::ConfigurationData{'output-colums'}) { |
7408 |
# create database names in columns |
7409 |
|
7410 |
my $cols = $main::ConfigurationData{'show-nr-colums'}; |
7411 |
my $next = int($#html_database/$cols) ; |
7412 |
|
7413 |
for(my $i=0; $i <= $next ; $i++) { |
7414 |
print("<tr>"); |
7415 |
for(my $j=0; $j <= $cols; $j++) { |
7416 |
print($html_database[$i+$next*$j+$j] || ''); |
7417 |
} |
7418 |
print("</tr>"); |
7419 |
} |
7420 |
|
7421 |
} else { |
7422 |
for(my $i=0; $i <= $#html_database ; $i=$i+1) { |
7423 |
print("<tr>",$html_database[$i],"</tr>"); |
7424 |
} |
7425 |
} |
7426 |
|
7427 |
print("</TABLE>\n"); |
7428 |
} |