Added descriptive text field in target info.
[egate.git] / www / search.egw
1 <html>
2 {
3 # $Id: search.egw,v 1.10 1995/11/08 12:42:17 adam Exp $
4
5 proc buttons {setNo setMax startPos} {
6     global sessionId
7     global env
8     global hist
9
10     html "<p>\n"
11     if {$setMax < [z39.$setNo resultCount]} {
12         html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
13         html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
14         html + [expr $setMax + $hist($setNo,maxPresent)] {"> Next </a>} "| \n"
15     }
16     if {$startPos != "" && $startPos != "1"} {
17         html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
18         html / $sessionId {/search.egw/} $setNo 
19         if {[expr $startPos - $hist($setNo,maxPresent)] > 1} {
20             html + [expr $startPos - $hist($setNo,maxPresent)]
21             html + [expr $startPos - 1]
22         }
23         html {"> Prev </a>} "| \n"
24     }
25     html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
26     html / $sessionId {/targets.egw"> New target </a>} " | \n"
27     html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
28     html / $sessionId {/query.egw/} $hist($setNo,host) + $setNo 
29     html {"> New query </a>} "<p>\n"
30 }
31
32     if {[info commands saveState] == ""} {
33         source z39util.tcl
34     }
35     global sessionWait
36     global nextSetNo
37     global setNo
38     global hist
39
40     set oldHost $hist($setNo,host)
41
42     if {[wform menu1] == ""} {
43         set setNo [lindex $sessionParms 0]
44     } else {
45         if {![info exists hist($nextSetNo,host)]} {
46            set hist($nextSetNo,host) $oldHost
47         }
48         set setNo $nextSetNo
49         html "using host " $hist($setNo,host) " <br\n"
50         incr nextSetNo
51
52         set hist($setNo,query) [build-query $hist($setNo,host)]
53         set b [wform base]
54         if {$b == ""} {
55             set hist($setNo,database) $databases
56         } else {
57             set hist($setNo,database) $b
58         }
59         set hist($setNo,maxPresent) [wform hits]
60         if {$hist($setNo,maxPresent) == ""} {
61             set hist($setNo,maxPresent) 30
62         }
63     }
64     set host $hist($setNo,host)
65     set databases [lindex $targets($host) 1]
66
67     html "<head><title> WWW/Z39.50 Gateway Search " $host " </title>\n"
68     html "</head><body>\n"
69
70     set startPos [lindex $sessionParms 1]
71     set endPos [lindex $sessionParms 2]
72     set setMax 0
73     set setOffset 0
74     if {$startPos == ""} {
75         if {[z39search $setNo 1] != "1"} {
76             return
77         }
78         set r [z39.$setNo resultCount]
79         html "<h2> Search result $r hits</h2>\n"
80         wflush
81         set setOffset [z39.$setNo numberOfRecordsReturned]
82         display-rec 1 $setOffset display-brief z39
83         incr setOffset
84         set setMax [z39.$setNo resultCount]
85         if {$setMax > $hist($setNo,maxPresent)} {
86             set setMax $hist($setNo,maxPresent)
87         }
88     } else {
89         if {[z39search $setNo 0] != "1"} {
90             return 
91         }
92         set r [z39.$setNo resultCount]
93         html "<h2> Search result $r hits</h2>\n"
94         wflush
95         set setOffset $startPos
96         set setMax [z39.$setNo resultCount]
97         if {$setMax > $endPos} {
98             set setMax $endPos
99         }
100         if {$setMax > 0} {
101             buttons $setNo $setMax $startPos
102         }
103     }
104     if {$setMax > 0} {
105         z39present $setNo $setOffset $setMax display-brief
106     }
107
108     buttons $setNo $setMax $startPos
109 }
110
111 {
112     html "<hr>\n"
113     html "<h3>Debug information</h3>\n"
114     html "sessionId: $sessionId <br>\n"
115     html "sessionParms: $sessionParms <br>\n"
116     foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
117         html $e {: } $env($e) {<br>} \n
118     }
119     html "form: " [wform] " <br>\n"
120     html "target: " $host " <br>\n"
121     html "databases: " $hist($setNo,database) " <br>\n"
122     html "selected: " [wform base] " <br>\n"
123     html "query: --" $hist($setNo,query) "-- <br>"
124     html "setNo: " $setNo " <br>\n"
125     html "nextSetNo: " $nextSetNo " <br>\n"
126 }
127
128 </body>
129 </html>