3 # $Id: search.egw,v 1.41 2001/02/26 14:32:36 adam Exp $
5 proc start-scan {scanNo targetNo cache dir initSet} {
17 set host $hist($setNo,$targetNo,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 $setNo
39 egw_log debug "z39_scan failed"
45 html {<a href="} $env(SCRIPT_NAME)
46 html / $sessionId {/search.egw/} $setNo + $targetNo +
47 html [expr $scanNo - 1] + b {">}
49 html {<img src="/egwgif/button-previous-terms.gif" }
50 html {alt="Next Terms" border=0></a>}
52 html {Previous Terms</a>}
58 html {<a href="} $env(SCRIPT_NAME)
59 html / $sessionId {/search.egw/} $setNo + $targetNo +
60 html [expr $scanNo + 1] + f {">}
62 html {<img src="/egwgif/button-next-terms.gif" }
63 html {alt="Next Terms" border=0></a>}
69 button-new-query $setNo
71 set databases [splitDatabaseSpec $host]
74 set databaseDefault [lindex $databases 0]
78 set databaseDefault $hist($oSetNo,$targetNo,database)
81 html {<form action="} $env(SCRIPT_NAME)
82 html / $sessionId {/search.egw/} $setNo + $targetNo {+1" method=get>} \n
83 set nodb [llength $databases]
86 html "Databases:<br>\n"
89 foreach d $databases {
90 html {<input type="checkbox" name="base" value="} $d
91 if {[lsearch $databaseDefault $d] == -1} {
94 html {" checked> } $d \n
99 html {<input type="checkbox" name="baseall" value="}
100 html [concat $databases] {"> All <br>} \n
103 html "Input your scan criteria:<br>\n"
104 set fields [lindex $targets($host) 2]
106 html {<select name="menu} $no {">} \n
109 set template [join $hist($oSetNo,form,menu$no)]
110 egw_log debug "template=$template"
112 if {[string length $template] > 0} {
113 html {<option> } $template \n
116 set name [lindex $f 0]
117 if {$template == $name} continue
118 html {<option> } $name \n
121 html {<input type="text" name="entry} $no {"}
123 html {<input type=submit name=submit value="Scan">}
128 if {$hist($setNo,$scanNo,scanTerm) == ""} {
130 button-new-query $setNo
135 display-scan $setNo $scanNo 0
143 html {<a href="} $env(SCRIPT_NAME)
144 html / $sessionId {/search.egw/} $setNo + $targetNo +
145 html [expr $scanNo - 1] + b {">}
147 html {<img src="/egwgif/button-previous-terms.gif" }
148 html {alt="Next Terms" border=0></a>}
150 html {Previous Terms</a>}
156 html {<a href="} $env(SCRIPT_NAME)
157 html / $sessionId {/search.egw/} $setNo + $targetNo +
158 html [expr $scanNo + 1] + f {">}
160 html {<img src="/egwgif/button-next-terms.gif" }
161 html {alt="Next Terms" border=0></a>}
163 html {Next Terms</a>}
166 button-new-query $setNo
170 html "<h3>Debug information</h3>\n"
171 html "sessionId: $sessionId <br>\n"
172 html "sessionParms: $sessionParms <br>\n"
173 foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
174 html $e {: } $env($e) {<br>} \n
176 html "form: " [egw_form] " <br>\n"
177 html "databases: " $hist($setNo,$targetNo,database) " <br>\n"
178 html "selected: " [egw_form base] " <br>\n"
179 html "setNo: " $setNo " <br>\n"
180 html "nextSetNo: " $nextSetNo " <br>\n"
183 if {[info commands saveState] == ""} {
185 if {![info exists debug]} {
195 set setNo [lindex $sessionParms 0]
196 set targetNo [lindex $sessionParms 1]
197 set startPos [lindex $sessionParms 2]
198 set endPos [lindex $sessionParms 3]
200 if {[egw_form] != ""} {
201 set hist($nextSetNo,$targetNo,idAuthentication) \
202 $hist($setNo,$targetNo,idAuthentication)
203 set hist($nextSetNo,$targetNo,host) \
204 $hist($setNo,$targetNo,host)
206 if {$nextSetNo == $setNo} {
210 catch {unset hist($setNo,$targetNo,hits)}
212 set hist($setNo,scan) 0
214 set hist($setNo,form,menu1) [egw_form menu1]
215 set hist($setNo,form,menu2) [egw_form menu2]
216 set hist($setNo,form,menu3) [egw_form menu3]
218 set hist($setNo,form,entry1) [egw_form entry1]
219 set hist($setNo,form,entry2) [egw_form entry2]
220 set hist($setNo,form,entry3) [egw_form entry3]
222 set hist($setNo,form,logic1) [egw_form logic1]
223 set hist($setNo,form,logic2) [egw_form logic2]
224 set hist($setNo,form,logic3) {}
226 set host $hist($setNo,0,host)
228 set databases [splitDatabaseSpec $host]
230 set b [egw_form base]
231 if {[egw_form baseall] != ""} {
232 set hist($setNo,$targetNo,database) $databases
233 } elseif {$b == ""} {
234 set hist($setNo,$targetNo,database) $databases
236 set hist($setNo,$targetNo,database) $b
238 set hist($setNo,maxPresent) [egw_form hits]
239 if {$hist($setNo,maxPresent) == ""} {
240 set hist($setNo,maxPresent) 30
242 set hist($setNo,format) brief
243 set hist($setNo,sort) server
245 set i [lindex $sessionParms 2]
246 if {[string length $i] == 0} {
247 for {set j 1} {$j <= 3} {incr j} {
248 if {[egw_form scan$j] != ""} {
254 if {[string length $i] != 0} {
256 set hist($setNo,scan) $i
257 set termPlusAttr [build-scan $hist($setNo,0,host) $i]
258 set hist($setNo,$scanNo,scanTerm) [lindex $termPlusAttr 0]
259 set hist($setNo,scanAttr) [lindex $termPlusAttr 1]
260 start-scan $scanNo $targetNo 0 {} $setNo
261 html "</body></html>\n"
265 set query [build-query $hist($setNo,0,host) 3]
266 if {[string length $query] == 0} {
267 html "<head><title> WWW/Z39.50 Gateway Search</title>\n<body>\n"
268 displayError "Empty query" \
269 "You must specify at least one search word"
270 html "</body></html>\n"
273 set hist($setNo,0,query) $query
274 } elseif {[lindex $sessionParms 2] == "hyper"} {
275 egw_log debug "hyper search"
276 set hist($nextSetNo,$targetNo,idAuthentication) \
277 $hist($setNo,$targetNo,idAuthentication)
278 set hist($nextSetNo,$targetNo,host) \
279 $hist($setNo,$targetNo,host)
280 set hist($nextSetNo,$targetNo,database) \
281 $hist($setNo,$targetNo,database)
283 if {$nextSetNo == $setNo} {
287 catch {unset hist($setNo,$targetNo,hits)}
289 set hist($setNo,scan) 0
290 set hist($setNo,$targetNo,query) \
291 "$hist($setNo,scanAttr) \"[lindex $sessionParms 3]\""
292 egw_log debug "hyper databases: $hist($setNo,$targetNo,database)"
293 set hist($setNo,form,entry1) [lindex $sessionParms 3]
295 } elseif {[lindex $sessionParms 2] == "scan"} {
296 egw_log debug "star scan"
298 set hist($setNo,$scanNo,scanTerm) {}
299 start-scan $scanNo $targetNo 0 {} {}
300 html "</body></html>\n"
303 if {![info exists hist($setNo,scan)]} return
304 if {$hist($setNo,scan) > 0} {
305 set scanNo [lindex $sessionParms 2]
306 set dir [lindex $sessionParms 3]
310 start-scan $scanNo $targetNo 1 $dir $setNo
311 html "</body></html>\n"
315 set host $hist($setNo,$targetNo,host)
317 html "<head><title> WWW/Z39.50 Gateway Search " [splitHostSpec $host]
319 html "</head><body>\n"
321 display-result-set-s $setNo $targetNo $startPos $endPos
327 html "<h3>Debug information</h3>\n"
328 html "sessionId: $sessionId <br>\n"
329 html "sessionParms: $sessionParms <br>\n"
330 foreach n [array names env] {
331 html "env($n) = " $env($n) " <br>\n"
333 html "form: " [egw_form] " <br>\n"
334 html "databases: " $hist($setNo,$targetNo,database) " <br>\n"
335 html "selected: " [egw_form base] " <br>\n"
336 html "query: --" $hist($setNo,$targetNo,query) "-- <br>"
337 html "setNo: " $setNo " <br>\n"
338 html "nextSetNo: " $nextSetNo " <br>\n"