3 # $Id: search.egw,v 1.22 1996/01/03 08:59:43 adam Exp $
5 proc start-scan {scanNo cache dir} {
15 set host $hist($setNo,host)
17 html "<head><title> WWW/Z39.50 Gateway Scan " $host " </title>\n"
18 html "</head><body>\n"
20 if {$hist($setNo,$scanNo,scanTerm) == ""} {
21 displayError "Empty query" \
22 "You must specify at least one search word"
23 html "</body></html>\n"
30 } elseif {$dir == "f"} {
37 if {[z39scan $setNo $scanNo 0 $lines $pos $cache] != "1"} {
40 html {<a href="http:} $env(SCRIPT_NAME)
41 html / $sessionId {/search.egw/} $setNo + [expr $scanNo - 1] + b
42 html {">Backward</a>} "\n"
44 html {<a href="http:} $env(SCRIPT_NAME)
45 html / $sessionId {/search.egw/} $setNo + [expr $scanNo + 1] + f
46 html {">Forward</a><br>}
48 display-scan $setNo $scanNo 0
50 html {<a href="http:} $env(SCRIPT_NAME)
51 html / $sessionId {/search.egw/} $setNo + [expr $scanNo - 1] + b
52 html {">Backward</a>} "\n"
54 html {<a href="http:} $env(SCRIPT_NAME)
55 html / $sessionId {/search.egw/} $setNo + [expr $scanNo + 1] + f
56 html {">Forward</a><br>}
59 html "<h3>Debug information</h3>\n"
60 html "sessionId: $sessionId <br>\n"
61 html "sessionParms: $sessionParms <br>\n"
62 foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
63 html $e {: } $env($e) {<br>} \n
65 html "form: " [wform] " <br>\n"
66 html "target: " $host " <br>\n"
67 html "databases: " $hist($setNo,database) " <br>\n"
68 html "selected: " [wform base] " <br>\n"
69 html "setNo: " $setNo " <br>\n"
70 html "nextSetNo: " $nextSetNo " <br>\n"
75 proc buttons {setNo setMax startPos after} {
81 if {!$useIcons && $after && $setMax < [z39.$setNo resultCount]} {
84 html {<a href="http:} $env(SCRIPT_NAME)
85 html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
86 html + [expr $setMax + $hist($setNo,maxPresent)]
87 html {"><img src="/gif/darrw.gif"></a>}
93 html {<img src="/gif/button-egw.gif" alt="Europagate" border=0>}
95 if {$setMax < [z39.$setNo resultCount]} {
96 html {<a href="http:} $env(SCRIPT_NAME)
97 html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
98 html + [expr $setMax + $hist($setNo,maxPresent)]
100 html {"><img src="/gif/button-next-records.gif" alt="Next Records"}
101 html { border=0></a>}
103 html {">Next Records</a>} " | \n"
106 if {$startPos != "" && $startPos != "1"} {
107 html {<a href="http:} $env(SCRIPT_NAME)
108 html / $sessionId {/search.egw/} $setNo
109 html + [expr $startPos - $hist($setNo,maxPresent)]
110 html + [expr $startPos - 1]
112 html {"><img src="/gif/button-previous-records.gif" }
113 html {alt="Previous Records" border=0></a>}
115 html {">Previous Records</a>} " | \n"
118 html {<a href="http:} $env(SCRIPT_NAME)
119 html / $sessionId {/query.egw/} $hist($setNo,host) + $setNo
121 html {"><img src="/gif/button-new-query.gif" }
122 html {alt="New Query" border=0></a>}
124 html {">New Query</a>} " | \n"
127 html {<a href="http:} $env(SCRIPT_NAME)
128 html / $sessionId {/targets.egw}
130 html {"><img src="/gif/button-new-target.gif" }
131 html {alt="New Target" border=0></a>}
133 html {">New Target</a>}
136 if {!$useIcons && !$after && $startPos != "" && $startPos != "1"} {
138 html {<a href="http:} $env(SCRIPT_NAME)
139 html / $sessionId {/search.egw/} $setNo
140 html + [expr $startPos - $hist($setNo,maxPresent)]
141 html + [expr $startPos - 1]
142 html {"><img src="/gif/uarrw.gif"></a>}
143 html "</center><p>\n"
148 if {[info commands saveState] == ""} {
156 set setNo [lindex $sessionParms 0]
159 set hist($nextSetNo,idAuthentication) $hist($setNo,idAuthentication)
160 set hist($nextSetNo,host) $hist($setNo,host)
162 if {$nextSetNo == $setNo} {
166 catch {unset hist($setNo,hits)}
168 set hist($setNo,form,menu1) [wform menu1]
169 set hist($setNo,form,menu2) [wform menu2]
170 set hist($setNo,form,menu3) [wform menu3]
172 set hist($setNo,form,entry1) [wform entry1]
173 set hist($setNo,form,entry2) [wform entry2]
174 set hist($setNo,form,entry3) [wform entry3]
176 set hist($setNo,form,logic1) [wform logic1]
177 set hist($setNo,form,logic2) [wform logic2]
179 set host $hist($setNo,host)
180 set databases [lindex $targets($host) 1]
183 if {[wform baseall] != ""} {
184 set hist($setNo,database) $databases
185 } elseif {$b == ""} {
186 set hist($setNo,database) $databases
188 set hist($setNo,database) $b
190 set hist($setNo,maxPresent) [wform hits]
191 if {$hist($setNo,maxPresent) == ""} {
192 set hist($setNo,maxPresent) 30
194 for {set i 1} {$i <= 3} {incr i} {
195 if {[wform scan$i] != ""} {
197 set hist($setNo,scan) $i
198 set termPlusAttr [build-scan $hist($setNo,host) $i]
199 set hist($setNo,$scanNo,scanTerm) [lindex $termPlusAttr 0]
200 set hist($setNo,scanAttr) [lindex $termPlusAttr 1]
201 start-scan $scanNo 0 {}
206 set hist($setNo,scan) 0
207 set query [build-query $hist($setNo,host) 3]
208 if {"x$query" == "x"} {
209 html "<head><title> WWW/Z39.50 Gateway Search</title>\n<body>\n"
210 displayError "Empty query" \
211 "You must specify at least one search word"
212 html "</body></html>\n"
215 set hist($setNo,query) $query
217 if {$hist($setNo,scan) > 0} {
218 set scanNo [lindex $sessionParms 1]
219 set dir [lindex $sessionParms 2]
223 start-scan $scanNo 1 $dir
227 set host $hist($setNo,host)
229 html "<head><title> WWW/Z39.50 Gateway Search " $host " </title>\n"
230 html "</head><body>\n"
232 set startPos [lindex $sessionParms 1]
233 set endPos [lindex $sessionParms 2]
236 if {$startPos == ""} {
237 if {[z39search $setNo 1 0 B] != "1"} {
240 set r [z39.$setNo resultCount]
241 html "<h3> Search result $r hits</h3>\n"
243 set setOffset [z39.$setNo numberOfRecordsReturned]
244 display-rec 1 $setOffset display-brief 0
246 set setMax [z39.$setNo resultCount]
247 if {$setMax > $hist($setNo,maxPresent)} {
248 set setMax $hist($setNo,maxPresent)
251 if {[z39search $setNo 0 0 B] != "1"} {
254 set r [z39.$setNo resultCount]
255 set setOffset $startPos
256 set setMax [z39.$setNo resultCount]
257 if {$setMax > $endPos} {
261 buttons $setNo $setMax $startPos 0
263 html "<h3> Search result $r hits</h3>\n"
267 z39present $setNo 0 $setOffset $setMax display-brief B
270 buttons $setNo $setMax $startPos 1
275 html "<h3>Debug information</h3>\n"
276 html "sessionId: $sessionId <br>\n"
277 html "sessionParms: $sessionParms <br>\n"
278 foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
279 html $e {: } $env($e) {<br>} \n
281 html "form: " [wform] " <br>\n"
282 html "target: " $host " <br>\n"
283 html "databases: " $hist($setNo,database) " <br>\n"
284 html "selected: " [wform base] " <br>\n"
285 html "query: --" $hist($setNo,query) "-- <br>"
286 html "setNo: " $setNo " <br>\n"
287 html "nextSetNo: " $nextSetNo " <br>\n"