3 # $Id: search.egw,v 1.29 1996/01/12 13:39:22 adam Exp $
5 proc start-scan {scanNo cache dir initSet} {
17 set host $hist($setNo,host)
19 html "<head><title> WWW/Z39.50 Gateway Scan " $host " </title>\n"
20 html "</head><body>\n"
22 set databases [lindex $targets($host) 1]
25 set databaseDefault [lindex $databases 0]
29 set databaseDefault $hist($oSetNo,database)
32 html {<form action="http:} $env(SCRIPT_NAME)
33 html / $sessionId {/search.egw/} $setNo {+1" method=get>} \n
34 set nodb [llength $databases]
37 html "Databases:<br>\n"
40 foreach d $databases {
41 html {<input type="checkbox" name="base" value="} $d
42 if {[lsearch $databaseDefault $d] == -1} {
45 html {" checked> } $d \n
50 html {<input type="checkbox" name="baseall" value="}
51 html [concat $databases] {"> All <br>} \n
53 html "Input your search criteria:<br>\n"
55 set fields [lindex $targets($host) 2]
57 html {<select name="menu} $no {">} \n
60 set template [join $hist($oSetNo,form,menu$no)]
62 if {[string length $template] > 0} {
63 html {<option> } $template \n
66 set name [lindex $f 0]
67 if {$template == $name} continue
68 html {<option> } $name \n
71 html {<input type="text" name="entry} $no {"}
73 html {<input type=submit name=submit value="Scan">}
79 if {$hist($setNo,$scanNo,scanTerm) == ""} {
80 button-new-query 0 $setNo
87 } elseif {$dir == "f"} {
94 if {[z39scan $setNo $scanNo 0 $lines $pos $cache] != "1"} {
98 html {<a href="http:} $env(SCRIPT_NAME)
99 html / $sessionId {/search.egw/} $setNo + [expr $scanNo - 1] + b {">}
101 html {<img src="/egwgif/button-previous-terms.gif" }
102 html {alt="Next Terms" border=0></a>}
104 html {Previous Terms</a> | }
107 html {<a href="http:} $env(SCRIPT_NAME)
108 html / $sessionId {/search.egw/} $setNo + [expr $scanNo + 1] + f {">}
110 html {<img src="/egwgif/button-next-terms.gif" }
111 html {alt="Next Terms" border=0></a>}
113 html {Next Terms</a> | }
116 button-new-query 0 $setNo
119 display-scan $setNo $scanNo 0
124 html {<a href="http:} $env(SCRIPT_NAME)
125 html / $sessionId {/search.egw/} $setNo + [expr $scanNo - 1] + b {">}
127 html {<img src="/egwgif/button-previous-terms.gif" }
128 html {alt="Next Terms" border=0></a>}
130 html {Previous Terms</a> | }
133 html {<a href="http:} $env(SCRIPT_NAME)
134 html / $sessionId {/search.egw/} $setNo + [expr $scanNo + 1] + f {">}
136 html {<img src="/egwgif/button-next-terms.gif" }
137 html {alt="Next Terms" border=0></a>}
139 html {Next Terms</a> | }
142 button-new-query 0 $setNo
146 html "<h3>Debug information</h3>\n"
147 html "sessionId: $sessionId <br>\n"
148 html "sessionParms: $sessionParms <br>\n"
149 foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
150 html $e {: } $env($e) {<br>} \n
152 html "form: " [wform] " <br>\n"
153 html "target: " $host " <br>\n"
154 html "databases: " $hist($setNo,database) " <br>\n"
155 html "selected: " [wform base] " <br>\n"
156 html "setNo: " $setNo " <br>\n"
157 html "nextSetNo: " $nextSetNo " <br>\n"
160 proc buttons {setNo setMax startPos after} {
168 if {$setMax < [z39.$setNo resultCount]} {
169 html {<a href="http:} $env(SCRIPT_NAME)
170 html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
171 html + [expr $setMax + $hist($setNo,maxPresent)]
173 html {"><img src="/egwgif/button-next-records.gif" alt="Next Records"}
174 html { border=0></a>}
176 html {">Next Records</a>} " | \n"
179 if {$startPos != "" && $startPos != "1"} {
180 html {<a href="http:} $env(SCRIPT_NAME)
181 html / $sessionId {/search.egw/} $setNo
182 html + [expr $startPos - $hist($setNo,maxPresent)]
183 html + [expr $startPos - 1]
185 html {"><img src="/egwgif/button-previous-records.gif" }
186 html {alt="Previous Records" border=0></a>}
188 html {">Previous Records</a>} " | \n"
191 button-new-query 1 $setNo
193 button-view-history 0
198 if {[info commands saveState] == ""} {
206 set setNo [lindex $sessionParms 0]
209 set hist($nextSetNo,idAuthentication) $hist($setNo,idAuthentication)
210 set hist($nextSetNo,host) $hist($setNo,host)
212 if {$nextSetNo == $setNo} {
216 catch {unset hist($setNo,hits)}
218 set hist($setNo,scan) 0
220 set hist($setNo,form,menu1) [wform menu1]
221 set hist($setNo,form,menu2) [wform menu2]
222 set hist($setNo,form,menu3) [wform menu3]
224 set hist($setNo,form,entry1) [wform entry1]
225 set hist($setNo,form,entry2) [wform entry2]
226 set hist($setNo,form,entry3) [wform entry3]
228 set hist($setNo,form,logic1) [wform logic1]
229 set hist($setNo,form,logic2) [wform logic2]
230 set hist($setNo,form,logic3) {}
232 set host $hist($setNo,host)
233 set databases [lindex $targets($host) 1]
236 if {[wform baseall] != ""} {
237 set hist($setNo,database) $databases
238 } elseif {$b == ""} {
239 set hist($setNo,database) $databases
241 set hist($setNo,database) $b
243 set hist($setNo,maxPresent) [wform hits]
244 if {$hist($setNo,maxPresent) == ""} {
245 set hist($setNo,maxPresent) 30
247 set i [lindex $sessionParms 1]
249 for {set j 1} {$j <= 3} {incr j} {
250 if {[wform scan$j] != ""} {
258 set hist($setNo,scan) $i
259 set termPlusAttr [build-scan $hist($setNo,host) $i]
260 set hist($setNo,$scanNo,scanTerm) [lindex $termPlusAttr 0]
261 set hist($setNo,scanAttr) [lindex $termPlusAttr 1]
262 start-scan $scanNo 0 {} {}
263 html "</body></html>\n"
267 set query [build-query $hist($setNo,host) 3]
268 if {"x$query" == "x"} {
269 html "<head><title> WWW/Z39.50 Gateway Search</title>\n<body>\n"
270 displayError "Empty query" \
271 "You must specify at least one search word"
272 html "</body></html>\n"
275 set hist($setNo,query) $query
277 if {[lindex $sessionParms 1] == "scan"} {
279 set hist($setNo,$scanNo,scanTerm) {}
280 start-scan $scanNo 0 {} {}
281 html "</body></html>\n"
284 if {![info exists hist($setNo,scan)]} return
285 if {$hist($setNo,scan) > 0} {
286 set scanNo [lindex $sessionParms 1]
287 set dir [lindex $sessionParms 2]
291 start-scan $scanNo 1 $dir $setNo
292 html "</body></html>\n"
296 set host $hist($setNo,host)
298 html "<head><title> WWW/Z39.50 Gateway Search " $host " </title>\n"
299 html "</head><body>\n"
301 set startPos [lindex $sessionParms 1]
302 set endPos [lindex $sessionParms 2]
305 if {$startPos == ""} {
306 if {[z39search $setNo 1 0 B] != "1"} {
309 set r [z39.$setNo resultCount]
310 set setOffset [z39.$setNo numberOfRecordsReturned]
311 if {$setOffset > 0} {
312 html {<h3> Records 1-} $setOffset " out of $r</h3>\n"
314 html "<h3> No hits</h3>\n"
318 display-rec 1 $setOffset display-brief 0
320 set setMax [z39.$setNo resultCount]
321 if {$setMax > $hist($setNo,maxPresent)} {
322 set setMax $hist($setNo,maxPresent)
325 if {[z39search $setNo 0 0 B] != "1"} {
328 set r [z39.$setNo resultCount]
329 set setOffset $startPos
330 set setMax [z39.$setNo resultCount]
331 if {$setMax > $endPos} {
335 buttons $setNo $setMax $startPos 0
338 html {<h3> Records } $startPos {-} $setMax " out of $r</h3>\n"
340 html "<h3> No hits</h3>\n"
346 z39present $setNo 0 $setOffset $setMax display-brief B
349 buttons $setNo $setMax $startPos 1
356 html "<h3>Debug information</h3>\n"
357 html "sessionId: $sessionId <br>\n"
358 html "sessionParms: $sessionParms <br>\n"
359 foreach n [array names env] {
360 html "env($n) = " $env($n) " <br>\n"
362 html "form: " [wform] " <br>\n"
363 html "target: " $host " <br>\n"
364 html "databases: " $hist($setNo,database) " <br>\n"
365 html "selected: " [wform base] " <br>\n"
366 html "query: --" $hist($setNo,query) "-- <br>"
367 html "setNo: " $setNo " <br>\n"
368 html "nextSetNo: " $nextSetNo " <br>\n"