3 # $Id: search.egw,v 1.33 1996/02/29 15:41:39 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 " [splitHostSpec $host]
21 html "</head><body>\n"
29 } elseif {$dir == "f"} {
36 if {$hist($setNo,$scanNo,scanTerm) != ""} {
37 if {[z39scan $setNo $scanNo 0 $lines $pos $cache] != "1"} {
38 button-new-query 0 $setNo
39 egw_log debug "z39_scan failed"
42 html {<a href="http:} $env(SCRIPT_NAME)
43 html / $sessionId {/search.egw/} $setNo + [expr $scanNo - 1] + b {">}
45 html {<img src="/egwgif/button-previous-terms.gif" }
46 html {alt="Next Terms" border=0></a>}
48 html {Previous Terms</a> | }
51 html {<a href="http:} $env(SCRIPT_NAME)
52 html / $sessionId {/search.egw/} $setNo + [expr $scanNo + 1] + f {">}
54 html {<img src="/egwgif/button-next-terms.gif" }
55 html {alt="Next Terms" border=0></a>}
57 html {Next Terms</a> | }
61 button-new-query 0 $setNo
63 set databases [lindex $targets($host) 1]
66 set databaseDefault [lindex $databases 0]
70 set databaseDefault $hist($oSetNo,database)
73 html {<form action="http:} $env(SCRIPT_NAME)
74 html / $sessionId {/search.egw/} $setNo {+1" method=get>} \n
75 set nodb [llength $databases]
78 html "Databases:<br>\n"
81 foreach d $databases {
82 html {<input type="checkbox" name="base" value="} $d
83 if {[lsearch $databaseDefault $d] == -1} {
86 html {" checked> } $d \n
91 html {<input type="checkbox" name="baseall" value="}
92 html [concat $databases] {"> All <br>} \n
95 html "Input your scan criteria:<br>\n"
96 set fields [lindex $targets($host) 2]
98 html {<select name="menu} $no {">} \n
101 set template [join $hist($oSetNo,form,menu$no)]
102 egw_log debug "template=$template"
104 if {[string length $template] > 0} {
105 html {<option> } $template \n
108 set name [lindex $f 0]
109 if {$template == $name} continue
110 html {<option> } $name \n
113 html {<input type="text" name="entry} $no {"}
115 html {<input type=submit name=submit value="Scan">}
120 if {$hist($setNo,$scanNo,scanTerm) == ""} {
122 button-new-query 0 $setNo
127 display-scan $setNo $scanNo 0
132 html {<a href="http:} $env(SCRIPT_NAME)
133 html / $sessionId {/search.egw/} $setNo + [expr $scanNo - 1] + b {">}
135 html {<img src="/egwgif/button-previous-terms.gif" }
136 html {alt="Next Terms" border=0></a>}
138 html {Previous Terms</a> | }
141 html {<a href="http:} $env(SCRIPT_NAME)
142 html / $sessionId {/search.egw/} $setNo + [expr $scanNo + 1] + f {">}
144 html {<img src="/egwgif/button-next-terms.gif" }
145 html {alt="Next Terms" border=0></a>}
147 html {Next Terms</a> | }
150 button-new-query 0 $setNo
154 html "<h3>Debug information</h3>\n"
155 html "sessionId: $sessionId <br>\n"
156 html "sessionParms: $sessionParms <br>\n"
157 foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
158 html $e {: } $env($e) {<br>} \n
160 html "form: " [egw_form] " <br>\n"
161 html "target: " $host " <br>\n"
162 html "databases: " $hist($setNo,database) " <br>\n"
163 html "selected: " [egw_form base] " <br>\n"
164 html "setNo: " $setNo " <br>\n"
165 html "nextSetNo: " $nextSetNo " <br>\n"
168 proc buttons {setNo setMax startPos after} {
176 if {$setMax > 0 && $setMax < [z39.$setNo resultCount]} {
177 html {<a href="http:} $env(SCRIPT_NAME)
178 html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
179 html + [expr $setMax + $hist($setNo,maxPresent)]
181 html {"><img src="/egwgif/button-next-records.gif" alt="Next Records"}
182 html { border=0></a>}
184 html {">Next Records</a>} " | \n"
187 if {$setMax > 0 && $startPos != "" && $startPos != "1"} {
188 html {<a href="http:} $env(SCRIPT_NAME)
189 html / $sessionId {/search.egw/} $setNo
190 html + [expr $startPos - $hist($setNo,maxPresent)]
191 html + [expr $startPos - 1]
193 html {"><img src="/egwgif/button-previous-records.gif" }
194 html {alt="Previous Records" border=0></a>}
196 html {">Previous Records</a>} " | \n"
199 button-new-query 1 $setNo
201 button-view-history 0
206 if {[info commands saveState] == ""} {
214 set setNo [lindex $sessionParms 0]
215 set startPos [lindex $sessionParms 1]
216 set endPos [lindex $sessionParms 2]
218 if {[egw_form] != ""} {
219 set hist($nextSetNo,idAuthentication) $hist($setNo,idAuthentication)
220 set hist($nextSetNo,host) $hist($setNo,host)
222 if {$nextSetNo == $setNo} {
226 catch {unset hist($setNo,hits)}
228 set hist($setNo,scan) 0
230 set hist($setNo,form,menu1) [egw_form menu1]
231 set hist($setNo,form,menu2) [egw_form menu2]
232 set hist($setNo,form,menu3) [egw_form menu3]
234 set hist($setNo,form,entry1) [egw_form entry1]
235 set hist($setNo,form,entry2) [egw_form entry2]
236 set hist($setNo,form,entry3) [egw_form entry3]
238 set hist($setNo,form,logic1) [egw_form logic1]
239 set hist($setNo,form,logic2) [egw_form logic2]
240 set hist($setNo,form,logic3) {}
242 set host $hist($setNo,host)
243 set databases [lindex $targets($host) 1]
245 set b [egw_form base]
246 if {[egw_form baseall] != ""} {
247 set hist($setNo,database) $databases
248 } elseif {$b == ""} {
249 set hist($setNo,database) $databases
251 set hist($setNo,database) $b
253 set hist($setNo,maxPresent) [egw_form hits]
254 if {$hist($setNo,maxPresent) == ""} {
255 set hist($setNo,maxPresent) 30
257 set i [lindex $sessionParms 1]
259 for {set j 1} {$j <= 3} {incr j} {
260 if {[egw_form scan$j] != ""} {
268 set hist($setNo,scan) $i
269 set termPlusAttr [build-scan $hist($setNo,host) $i]
270 set hist($setNo,$scanNo,scanTerm) [lindex $termPlusAttr 0]
271 set hist($setNo,scanAttr) [lindex $termPlusAttr 1]
272 start-scan $scanNo 0 {} $setNo
273 html "</body></html>\n"
277 set query [build-query $hist($setNo,host) 3]
278 if {"x$query" == "x"} {
279 html "<head><title> WWW/Z39.50 Gateway Search</title>\n<body>\n"
280 displayError "Empty query" \
281 "You must specify at least one search word"
282 html "</body></html>\n"
285 set hist($setNo,query) $query
286 } elseif {[lindex $sessionParms 1] == "hyper"} {
287 egw_log debug "hyper search"
288 set hist($nextSetNo,idAuthentication) $hist($setNo,idAuthentication)
289 set hist($nextSetNo,host) $hist($setNo,host)
290 set hist($nextSetNo,database) $hist($setNo,database)
292 if {$nextSetNo == $setNo} {
296 catch {unset hist($setNo,hits)}
298 set hist($setNo,scan) 0
299 set hist($setNo,query) \
300 "$hist($setNo,scanAttr) \"[lindex $sessionParms 2]\""
301 egw_log debug "hyper databases: $hist($setNo,database)"
302 set hist($setNo,form,entry1) [lindex $sessionParms 2]
304 } elseif {[lindex $sessionParms 1] == "scan"} {
305 egw_log debug "star scan"
307 set hist($setNo,$scanNo,scanTerm) {}
308 start-scan $scanNo 0 {} {}
309 html "</body></html>\n"
312 if {![info exists hist($setNo,scan)]} return
313 if {$hist($setNo,scan) > 0} {
314 set scanNo [lindex $sessionParms 1]
315 set dir [lindex $sessionParms 2]
319 start-scan $scanNo 1 $dir $setNo
320 html "</body></html>\n"
324 set host $hist($setNo,host)
326 html "<head><title> WWW/Z39.50 Gateway Search " [splitHostSpec $host]
328 html "</head><body>\n"
333 if {$startPos == ""} {
334 if {[z39search $setNo 1 0 B] != "1"} {
337 set r [z39.$setNo resultCount]
339 set setMax [z39.$setNo resultCount]
340 if {$setMax > $hist($setNo,maxPresent)} {
341 set setMax $hist($setNo,maxPresent)
343 buttons $setNo $setMax $startPos 0
345 set setOffset [z39.$setNo numberOfRecordsReturned]
347 html {<h3> Records 1-} $setMax " out of $r</h3>\n"
349 html "<h3> No hits</h3>\n"
353 display-rec 1 $setMax display-brief 0
357 if {[z39search $setNo 0 0 B] != "1"} {
360 set r [z39.$setNo resultCount]
361 set setOffset $startPos
362 set setMax [z39.$setNo resultCount]
363 if {$setMax > $endPos} {
366 buttons $setNo $setMax $startPos 0
368 html {<h3> Records } $startPos {-} $setMax " out of $r</h3>\n"
370 html "<h3> No hits</h3>\n"
376 z39present $setNo 0 $setOffset $setMax display-brief B
380 buttons $setNo $setMax $startPos 1
387 html "<h3>Debug information</h3>\n"
388 html "sessionId: $sessionId <br>\n"
389 html "sessionParms: $sessionParms <br>\n"
390 foreach n [array names env] {
391 html "env($n) = " $env($n) " <br>\n"
393 html "form: " [egw_form] " <br>\n"
394 html "target: " $host " <br>\n"
395 html "databases: " $hist($setNo,database) " <br>\n"
396 html "selected: " [egw_form base] " <br>\n"
397 html "query: --" $hist($setNo,query) "-- <br>"
398 html "setNo: " $setNo " <br>\n"
399 html "nextSetNo: " $nextSetNo " <br>\n"