3 # $Id: search.egw,v 1.28 1996/01/12 13:08:30 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">}
76 if {$hist($setNo,$scanNo,scanTerm) == ""} {
83 } elseif {$dir == "f"} {
90 if {[z39scan $setNo $scanNo 0 $lines $pos $cache] != "1"} {
95 display-scan $setNo $scanNo 0
100 html {<a href="http:} $env(SCRIPT_NAME)
101 html / $sessionId {/search.egw/} $setNo + [expr $scanNo - 1] + b {">}
103 html {<img src="/egwgif/button-previous-terms.gif" }
104 html {alt="Next Terms" border=0></a>}
106 html {Previous Terms</a> | }
109 html {<a href="http:} $env(SCRIPT_NAME)
110 html / $sessionId {/search.egw/} $setNo + [expr $scanNo + 1] + f {">}
112 html {<img src="/egwgif/button-next-terms.gif" }
113 html {alt="Next Terms" border=0></a>}
115 html {Next Terms</a> | }
118 button-new-query 0 $setNo
122 html "<h3>Debug information</h3>\n"
123 html "sessionId: $sessionId <br>\n"
124 html "sessionParms: $sessionParms <br>\n"
125 foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
126 html $e {: } $env($e) {<br>} \n
128 html "form: " [wform] " <br>\n"
129 html "target: " $host " <br>\n"
130 html "databases: " $hist($setNo,database) " <br>\n"
131 html "selected: " [wform base] " <br>\n"
132 html "setNo: " $setNo " <br>\n"
133 html "nextSetNo: " $nextSetNo " <br>\n"
136 proc buttons {setNo setMax startPos after} {
144 if {$setMax < [z39.$setNo resultCount]} {
145 html {<a href="http:} $env(SCRIPT_NAME)
146 html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
147 html + [expr $setMax + $hist($setNo,maxPresent)]
149 html {"><img src="/egwgif/button-next-records.gif" alt="Next Records"}
150 html { border=0></a>}
152 html {">Next Records</a>} " | \n"
155 if {$startPos != "" && $startPos != "1"} {
156 html {<a href="http:} $env(SCRIPT_NAME)
157 html / $sessionId {/search.egw/} $setNo
158 html + [expr $startPos - $hist($setNo,maxPresent)]
159 html + [expr $startPos - 1]
161 html {"><img src="/egwgif/button-previous-records.gif" }
162 html {alt="Previous Records" border=0></a>}
164 html {">Previous Records</a>} " | \n"
167 button-new-query 1 $setNo
169 button-view-history 0
174 if {[info commands saveState] == ""} {
182 set setNo [lindex $sessionParms 0]
185 set hist($nextSetNo,idAuthentication) $hist($setNo,idAuthentication)
186 set hist($nextSetNo,host) $hist($setNo,host)
188 if {$nextSetNo == $setNo} {
192 catch {unset hist($setNo,hits)}
194 set hist($setNo,scan) 0
196 set hist($setNo,form,menu1) [wform menu1]
197 set hist($setNo,form,menu2) [wform menu2]
198 set hist($setNo,form,menu3) [wform menu3]
200 set hist($setNo,form,entry1) [wform entry1]
201 set hist($setNo,form,entry2) [wform entry2]
202 set hist($setNo,form,entry3) [wform entry3]
204 set hist($setNo,form,logic1) [wform logic1]
205 set hist($setNo,form,logic2) [wform logic2]
206 set hist($setNo,form,logic3) {}
208 set host $hist($setNo,host)
209 set databases [lindex $targets($host) 1]
212 if {[wform baseall] != ""} {
213 set hist($setNo,database) $databases
214 } elseif {$b == ""} {
215 set hist($setNo,database) $databases
217 set hist($setNo,database) $b
219 set hist($setNo,maxPresent) [wform hits]
220 if {$hist($setNo,maxPresent) == ""} {
221 set hist($setNo,maxPresent) 30
223 set i [lindex $sessionParms 1]
225 for {set j 1} {$j <= 3} {incr j} {
226 if {[wform scan$j] != ""} {
234 set hist($setNo,scan) $i
235 set termPlusAttr [build-scan $hist($setNo,host) $i]
236 set hist($setNo,$scanNo,scanTerm) [lindex $termPlusAttr 0]
237 set hist($setNo,scanAttr) [lindex $termPlusAttr 1]
238 start-scan $scanNo 0 {} {}
239 html "</body></html>\n"
243 set query [build-query $hist($setNo,host) 3]
244 if {"x$query" == "x"} {
245 html "<head><title> WWW/Z39.50 Gateway Search</title>\n<body>\n"
246 displayError "Empty query" \
247 "You must specify at least one search word"
248 html "</body></html>\n"
251 set hist($setNo,query) $query
253 if {[lindex $sessionParms 1] == "scan"} {
255 set hist($setNo,$scanNo,scanTerm) {}
256 start-scan $scanNo 0 {} {}
257 html "</body></html>\n"
260 if {![info exists hist($setNo,scan)]} return
261 if {$hist($setNo,scan) > 0} {
262 set scanNo [lindex $sessionParms 1]
263 set dir [lindex $sessionParms 2]
267 start-scan $scanNo 1 $dir $setNo
268 html "</body></html>\n"
272 set host $hist($setNo,host)
274 html "<head><title> WWW/Z39.50 Gateway Search " $host " </title>\n"
275 html "</head><body>\n"
277 set startPos [lindex $sessionParms 1]
278 set endPos [lindex $sessionParms 2]
281 if {$startPos == ""} {
282 if {[z39search $setNo 1 0 B] != "1"} {
285 set r [z39.$setNo resultCount]
286 set setOffset [z39.$setNo numberOfRecordsReturned]
287 if {$setOffset > 0} {
288 html {<h3> Records 1-} $setOffset " out of $r</h3>\n"
290 html "<h3> No hits</h3>\n"
294 display-rec 1 $setOffset display-brief 0
296 set setMax [z39.$setNo resultCount]
297 if {$setMax > $hist($setNo,maxPresent)} {
298 set setMax $hist($setNo,maxPresent)
301 if {[z39search $setNo 0 0 B] != "1"} {
304 set r [z39.$setNo resultCount]
305 set setOffset $startPos
306 set setMax [z39.$setNo resultCount]
307 if {$setMax > $endPos} {
311 buttons $setNo $setMax $startPos 0
314 html {<h3> Records } $startPos {-} $setMax " out of $r</h3>\n"
316 html "<h3> No hits</h3>\n"
322 z39present $setNo 0 $setOffset $setMax display-brief B
325 buttons $setNo $setMax $startPos 1
332 html "<h3>Debug information</h3>\n"
333 html "sessionId: $sessionId <br>\n"
334 html "sessionParms: $sessionParms <br>\n"
335 foreach n [array names env] {
336 html "env($n) = " $env($n) " <br>\n"
338 html "form: " [wform] " <br>\n"
339 html "target: " $host " <br>\n"
340 html "databases: " $hist($setNo,database) " <br>\n"
341 html "selected: " [wform base] " <br>\n"
342 html "query: --" $hist($setNo,query) "-- <br>"
343 html "setNo: " $setNo " <br>\n"
344 html "nextSetNo: " $nextSetNo " <br>\n"