3 # $Id: search.egw,v 1.39 1996/03/14 11:50:48 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"
42 html {<a href="http:} $env(SCRIPT_NAME)
43 html / $sessionId {/search.egw/} $setNo + $targetNo +
44 html [expr $scanNo - 1] + b {">}
46 html {<img src="/egwgif/button-previous-terms.gif" }
47 html {alt="Next Terms" border=0></a>}
49 html {Previous Terms</a> | }
52 html {<a href="http:} $env(SCRIPT_NAME)
53 html / $sessionId {/search.egw/} $setNo + $targetNo +
54 html [expr $scanNo + 1] + f {">}
56 html {<img src="/egwgif/button-next-terms.gif" }
57 html {alt="Next Terms" border=0></a>}
59 html {Next Terms</a> | }
63 button-new-query $setNo
65 set databases [splitDatabaseSpec $host]
68 set databaseDefault [lindex $databases 0]
72 set databaseDefault $hist($oSetNo,$targetNo,database)
75 html {<form action="http:} $env(SCRIPT_NAME)
76 html / $sessionId {/search.egw/} $setNo + $targetNo {+1" method=get>} \n
77 set nodb [llength $databases]
80 html "Databases:<br>\n"
83 foreach d $databases {
84 html {<input type="checkbox" name="base" value="} $d
85 if {[lsearch $databaseDefault $d] == -1} {
88 html {" checked> } $d \n
93 html {<input type="checkbox" name="baseall" value="}
94 html [concat $databases] {"> All <br>} \n
97 html "Input your scan criteria:<br>\n"
98 set fields [lindex $targets($host) 2]
100 html {<select name="menu} $no {">} \n
103 set template [join $hist($oSetNo,form,menu$no)]
104 egw_log debug "template=$template"
106 if {[string length $template] > 0} {
107 html {<option> } $template \n
110 set name [lindex $f 0]
111 if {$template == $name} continue
112 html {<option> } $name \n
115 html {<input type="text" name="entry} $no {"}
117 html {<input type=submit name=submit value="Scan">}
122 if {$hist($setNo,$scanNo,scanTerm) == ""} {
124 button-new-query $setNo
129 display-scan $setNo $scanNo 0
134 html {<a href="http:} $env(SCRIPT_NAME)
135 html / $sessionId {/search.egw/} $setNo + $targetNo +
136 html [expr $scanNo - 1] + b {">}
138 html {<img src="/egwgif/button-previous-terms.gif" }
139 html {alt="Next Terms" border=0></a>}
141 html {Previous Terms</a> | }
144 html {<a href="http:} $env(SCRIPT_NAME)
145 html / $sessionId {/search.egw/} $setNo + $targetNo +
146 html [expr $scanNo + 1] + f {">}
148 html {<img src="/egwgif/button-next-terms.gif" }
149 html {alt="Next Terms" border=0></a>}
151 html {Next Terms</a> | }
154 button-new-query $setNo
158 html "<h3>Debug information</h3>\n"
159 html "sessionId: $sessionId <br>\n"
160 html "sessionParms: $sessionParms <br>\n"
161 foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
162 html $e {: } $env($e) {<br>} \n
164 html "form: " [egw_form] " <br>\n"
165 html "databases: " $hist($setNo,$targetNo,database) " <br>\n"
166 html "selected: " [egw_form base] " <br>\n"
167 html "setNo: " $setNo " <br>\n"
168 html "nextSetNo: " $nextSetNo " <br>\n"
171 if {[info commands saveState] == ""} {
173 if {![info exists debug]} {
183 set setNo [lindex $sessionParms 0]
184 set targetNo [lindex $sessionParms 1]
185 set startPos [lindex $sessionParms 2]
186 set endPos [lindex $sessionParms 3]
188 if {[egw_form] != ""} {
189 set hist($nextSetNo,$targetNo,idAuthentication) \
190 $hist($setNo,$targetNo,idAuthentication)
191 set hist($nextSetNo,$targetNo,host) \
192 $hist($setNo,$targetNo,host)
194 if {$nextSetNo == $setNo} {
198 catch {unset hist($setNo,$targetNo,hits)}
200 set hist($setNo,scan) 0
202 set hist($setNo,form,menu1) [egw_form menu1]
203 set hist($setNo,form,menu2) [egw_form menu2]
204 set hist($setNo,form,menu3) [egw_form menu3]
206 set hist($setNo,form,entry1) [egw_form entry1]
207 set hist($setNo,form,entry2) [egw_form entry2]
208 set hist($setNo,form,entry3) [egw_form entry3]
210 set hist($setNo,form,logic1) [egw_form logic1]
211 set hist($setNo,form,logic2) [egw_form logic2]
212 set hist($setNo,form,logic3) {}
214 set host $hist($setNo,0,host)
216 set databases [splitDatabaseSpec $host]
218 set b [egw_form base]
219 if {[egw_form baseall] != ""} {
220 set hist($setNo,$targetNo,database) $databases
221 } elseif {$b == ""} {
222 set hist($setNo,$targetNo,database) $databases
224 set hist($setNo,$targetNo,database) $b
226 set hist($setNo,maxPresent) [egw_form hits]
227 if {$hist($setNo,maxPresent) == ""} {
228 set hist($setNo,maxPresent) 30
230 set hist($setNo,format) brief
231 set hist($setNo,sort) server
233 set i [lindex $sessionParms 2]
234 if {[string length $i] == 0} {
235 for {set j 1} {$j <= 3} {incr j} {
236 if {[egw_form scan$j] != ""} {
242 if {[string length $i] != 0} {
244 set hist($setNo,scan) $i
245 set termPlusAttr [build-scan $hist($setNo,0,host) $i]
246 set hist($setNo,$scanNo,scanTerm) [lindex $termPlusAttr 0]
247 set hist($setNo,scanAttr) [lindex $termPlusAttr 1]
248 start-scan $scanNo $targetNo 0 {} $setNo
249 html "</body></html>\n"
253 set query [build-query $hist($setNo,0,host) 3]
254 if {[string length $query] == 0} {
255 html "<head><title> WWW/Z39.50 Gateway Search</title>\n<body>\n"
256 displayError "Empty query" \
257 "You must specify at least one search word"
258 html "</body></html>\n"
261 set hist($setNo,0,query) $query
262 } elseif {[lindex $sessionParms 2] == "hyper"} {
263 egw_log debug "hyper search"
264 set hist($nextSetNo,$targetNo,idAuthentication) \
265 $hist($setNo,$targetNo,idAuthentication)
266 set hist($nextSetNo,$targetNo,host) \
267 $hist($setNo,$targetNo,host)
268 set hist($nextSetNo,$targetNo,database) \
269 $hist($setNo,$targetNo,database)
271 if {$nextSetNo == $setNo} {
275 catch {unset hist($setNo,$targetNo,hits)}
277 set hist($setNo,scan) 0
278 set hist($setNo,$targetNo,query) \
279 "$hist($setNo,scanAttr) \"[lindex $sessionParms 3]\""
280 egw_log debug "hyper databases: $hist($setNo,$targetNo,database)"
281 set hist($setNo,form,entry1) [lindex $sessionParms 3]
283 } elseif {[lindex $sessionParms 2] == "scan"} {
284 egw_log debug "star scan"
286 set hist($setNo,$scanNo,scanTerm) {}
287 start-scan $scanNo $targetNo 0 {} {}
288 html "</body></html>\n"
291 if {![info exists hist($setNo,scan)]} return
292 if {$hist($setNo,scan) > 0} {
293 set scanNo [lindex $sessionParms 2]
294 set dir [lindex $sessionParms 3]
298 start-scan $scanNo $targetNo 1 $dir $setNo
299 html "</body></html>\n"
303 set host $hist($setNo,$targetNo,host)
305 html "<head><title> WWW/Z39.50 Gateway Search " [splitHostSpec $host]
307 html "</head><body>\n"
309 display-result-set-s $setNo $targetNo $startPos $endPos
315 html "<h3>Debug information</h3>\n"
316 html "sessionId: $sessionId <br>\n"
317 html "sessionParms: $sessionParms <br>\n"
318 foreach n [array names env] {
319 html "env($n) = " $env($n) " <br>\n"
321 html "form: " [egw_form] " <br>\n"
322 html "databases: " $hist($setNo,$targetNo,database) " <br>\n"
323 html "selected: " [egw_form base] " <br>\n"
324 html "query: --" $hist($setNo,$targetNo,query) "-- <br>"
325 html "setNo: " $setNo " <br>\n"
326 html "nextSetNo: " $nextSetNo " <br>\n"