3 # $Id: search.egw,v 1.26 1996/01/09 16:16:48 adam Exp $
5 proc start-scan {scanNo cache dir} {
17 set host $hist($setNo,host)
19 html "<head><title> WWW/Z39.50 Gateway Scan " $host " </title>\n"
20 html "</head><body>\n"
22 if {$hist($setNo,$scanNo,scanTerm) == ""} {
23 displayError "Empty query" \
24 "You must specify at least one search word"
31 } elseif {$dir == "f"} {
38 if {[z39scan $setNo $scanNo 0 $lines $pos $cache] != "1"} {
43 html {<a href="http:} $env(SCRIPT_NAME)
44 html / $sessionId {/search.egw/} $setNo + [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 + [expr $scanNo + 1] + f {">}
55 html {<img src="/egwgif/button-next-terms.gif" }
56 html {alt="Next Terms" border=0></a>}
58 html {Next Terms</a> | }
61 button-new-query 0 $setNo
64 display-scan $setNo $scanNo 0
69 html {<a href="http:} $env(SCRIPT_NAME)
70 html / $sessionId {/search.egw/} $setNo + [expr $scanNo - 1] + b {">}
72 html {<img src="/egwgif/button-previous-terms.gif" }
73 html {alt="Next Terms" border=0></a>}
75 html {Previous Terms</a> | }
78 html {<a href="http:} $env(SCRIPT_NAME)
79 html / $sessionId {/search.egw/} $setNo + [expr $scanNo + 1] + f {">}
81 html {<img src="/egwgif/button-next-terms.gif" }
82 html {alt="Next Terms" border=0></a>}
84 html {Next Terms</a> | }
87 button-new-query 0 $setNo
91 html "<h3>Debug information</h3>\n"
92 html "sessionId: $sessionId <br>\n"
93 html "sessionParms: $sessionParms <br>\n"
94 foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
95 html $e {: } $env($e) {<br>} \n
97 html "form: " [wform] " <br>\n"
98 html "target: " $host " <br>\n"
99 html "databases: " $hist($setNo,database) " <br>\n"
100 html "selected: " [wform base] " <br>\n"
101 html "setNo: " $setNo " <br>\n"
102 html "nextSetNo: " $nextSetNo " <br>\n"
105 proc buttons {setNo setMax startPos after} {
113 if {$setMax < [z39.$setNo resultCount]} {
114 html {<a href="http:} $env(SCRIPT_NAME)
115 html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
116 html + [expr $setMax + $hist($setNo,maxPresent)]
118 html {"><img src="/egwgif/button-next-records.gif" alt="Next Records"}
119 html { border=0></a>}
121 html {">Next Records</a>} " | \n"
124 if {$startPos != "" && $startPos != "1"} {
125 html {<a href="http:} $env(SCRIPT_NAME)
126 html / $sessionId {/search.egw/} $setNo
127 html + [expr $startPos - $hist($setNo,maxPresent)]
128 html + [expr $startPos - 1]
130 html {"><img src="/egwgif/button-previous-records.gif" }
131 html {alt="Previous Records" border=0></a>}
133 html {">Previous Records</a>} " | \n"
136 button-new-query 1 $setNo
138 button-view-history 0
143 if {[info commands saveState] == ""} {
151 set setNo [lindex $sessionParms 0]
154 set hist($nextSetNo,idAuthentication) $hist($setNo,idAuthentication)
155 set hist($nextSetNo,host) $hist($setNo,host)
157 if {$nextSetNo == $setNo} {
161 catch {unset hist($setNo,hits)}
163 set hist($setNo,scan) 0
165 set hist($setNo,form,menu1) [wform menu1]
166 set hist($setNo,form,menu2) [wform menu2]
167 set hist($setNo,form,menu3) [wform menu3]
169 set hist($setNo,form,entry1) [wform entry1]
170 set hist($setNo,form,entry2) [wform entry2]
171 set hist($setNo,form,entry3) [wform entry3]
173 set hist($setNo,form,logic1) [wform logic1]
174 set hist($setNo,form,logic2) [wform logic2]
175 set hist($setNo,form,logic3) {}
177 set host $hist($setNo,host)
178 set databases [lindex $targets($host) 1]
181 if {[wform baseall] != ""} {
182 set hist($setNo,database) $databases
183 } elseif {$b == ""} {
184 set hist($setNo,database) $databases
186 set hist($setNo,database) $b
188 set hist($setNo,maxPresent) [wform hits]
189 if {$hist($setNo,maxPresent) == ""} {
190 set hist($setNo,maxPresent) 30
192 for {set i 1} {$i <= 3} {incr i} {
193 if {[wform scan$i] != ""} {
195 set hist($setNo,scan) $i
196 set termPlusAttr [build-scan $hist($setNo,host) $i]
197 set hist($setNo,$scanNo,scanTerm) [lindex $termPlusAttr 0]
198 set hist($setNo,scanAttr) [lindex $termPlusAttr 1]
199 start-scan $scanNo 0 {}
200 html "</body></html>\n"
205 set query [build-query $hist($setNo,host) 3]
206 if {"x$query" == "x"} {
207 html "<head><title> WWW/Z39.50 Gateway Search</title>\n<body>\n"
208 displayError "Empty query" \
209 "You must specify at least one search word"
210 html "</body></html>\n"
213 set hist($setNo,query) $query
215 if {![info exists hist($setNo,scan)]} return
216 if {$hist($setNo,scan) > 0} {
217 set scanNo [lindex $sessionParms 1]
218 set dir [lindex $sessionParms 2]
222 start-scan $scanNo 1 $dir
223 html "</body></html>\n"
227 set host $hist($setNo,host)
229 html "<head><title> WWW/Z39.50 Gateway Search " $host " </title>\n"
230 html "</head><body>\n"
232 set startPos [lindex $sessionParms 1]
233 set endPos [lindex $sessionParms 2]
236 if {$startPos == ""} {
237 if {[z39search $setNo 1 0 B] != "1"} {
240 set r [z39.$setNo resultCount]
241 set setOffset [z39.$setNo numberOfRecordsReturned]
242 if {$setOffset > 0} {
243 html {<h3> Records 1-} $setOffset " out of $r</h3>\n"
245 html "<h3> No hits</h3>\n"
249 display-rec 1 $setOffset display-brief 0
251 set setMax [z39.$setNo resultCount]
252 if {$setMax > $hist($setNo,maxPresent)} {
253 set setMax $hist($setNo,maxPresent)
256 if {[z39search $setNo 0 0 B] != "1"} {
259 set r [z39.$setNo resultCount]
260 set setOffset $startPos
261 set setMax [z39.$setNo resultCount]
262 if {$setMax > $endPos} {
266 buttons $setNo $setMax $startPos 0
269 html {<h3> Records } $startPos {-} $setMax " out of $r</h3>\n"
271 html "<h3> No hits</h3>\n"
277 z39present $setNo 0 $setOffset $setMax display-brief B
280 buttons $setNo $setMax $startPos 1
287 html "<h3>Debug information</h3>\n"
288 html "sessionId: $sessionId <br>\n"
289 html "sessionParms: $sessionParms <br>\n"
290 foreach n [array names env] {
291 html "env($n) = " $env($n) " <br>\n"
293 html "form: " [wform] " <br>\n"
294 html "target: " $host " <br>\n"
295 html "databases: " $hist($setNo,database) " <br>\n"
296 html "selected: " [wform base] " <br>\n"
297 html "query: --" $hist($setNo,query) "-- <br>"
298 html "setNo: " $setNo " <br>\n"
299 html "nextSetNo: " $nextSetNo " <br>\n"