3 <title> WWW/Z39.50 Gateway Query Form</title>
7 # $Id: query.egw,v 1.26 1996/01/08 08:42:15 adam Exp $
9 if {[info commands saveState] == ""} {
13 proc fail-response {} {
27 set host [lindex $sessionParms 0]
28 set initSet [lindex $sessionParms 1]
29 set scanLine [lindex $sessionParms 2]
30 set scanTerm [lrange $sessionParms 3 end]
32 if {[catch {set setNo $nextSetNo}]} {
36 if {[catch {set oldHost [z39 connect]}]} {
40 set hist($setNo,host) $host
41 set hist($setNo,idAuthentication) [lindex $targets($host) 3]
43 if {[catch {z39 failback fail-response}]} {
47 html "<h2>Search in " [lindex $targets($host) 0] "</h2>\n"
48 z39 callback ok-response
49 z39 failback fail-response
50 if {$host != $oldHost} {
51 catch {z39 disconnect}
54 if {[catch {z39 connect $host}]} {
55 displayError "Cannot connect to target ${host}" {}
56 html "</body></html>\n"
59 } elseif {$sessionWait == 0} {
60 if {[catch {zwait sessionWait 35}]} {
61 displayError "Cannot connect to target ${host}" {}
62 html "</body></html>\n"
66 if {$sessionWait != 1} {
67 displayError "Cannot connect to target ${host}" {}
68 html "</body></html>\n"
74 z39 idAuthentication $hist($setNo,idAuthentication)
75 if {[catch {z39 init}]} {
76 displayError "Cannot initialize target ${host}" {}
77 html "</body></html>\n"
80 if {[catch {zwait sessionWait 60}]} {
81 displayError "Cannot initialize target ${host}" {}
82 html "</body></html>\n"
85 if {$sessionWait != "1"} {
86 displayError "Cannot initialize target ${host}" {}
87 htmlr "</body></html>\n"
90 if {![z39 initResult]} {
91 displayError "Connection rejected by target ${host}" \
92 [z39 userInformationField]
94 htmlr "</body></html>"
98 set databases [lindex $targets($host) 1]
100 # if {[catch {set prevHost $hist([expr $setNo - 1],host)}]} {
101 # set databaseDefault [lindex $databases 0]
104 # set oSetNo [expr $setNo - 1]
105 # set databaseDefault $hist($oSetNo,database)
107 if {$initSet == ""} {
108 set databaseDefault [lindex $databases 0]
112 set databaseDefault $hist($oSetNo,database)
115 html {<form action="http:} $env(SCRIPT_NAME)
116 html / $sessionId {/search.egw/} $setNo {" method=get>} \n
117 set nodb [llength $databases]
120 html "The chosen target supports searching in "
121 html "several databases. <br>\n"
122 html "Choose the bases you want to search: <br>\n"
125 foreach d $databases {
126 html {<input type="checkbox" name="base" value="} $d
127 if {[lsearch $databaseDefault $d] == -1} {
130 html {" checked> } $d \n
135 html {<input type="checkbox" name="baseall" value="}
136 html [concat $databases] {"> All <br>} \n
138 html "Input your search criteria:<br>\n"
140 set fields [lindex $targets($host) 2]
141 for {set no 1} {$no < 4} {incr no} {
142 html {<select name="menu} $no {">} \n
144 html {<option> } $hist($oSetNo,form,menu$no) \n
147 set name [lindex $f 0]
149 if {$hist($oSetNo,form,menu$no) == $name} continue
151 html {<option> } $name \n
154 html {<input type="text" name="entry} $no {"}
155 if {$scanLine == $no} {
156 html { value="} [join $scanTerm " "] {"}
157 } elseif {[info exists hist($oSetNo,form,entry$no)]} {
158 html { value="} [join $hist($oSetNo,form,entry$no) " "] {"}
161 if {[lsearch [z39 options] scan] >= 0} {
162 html {<input type="checkbox" name="scan} $no {" value="1" scan>}
165 html {<select name="logic} $no {">} \n
167 html "<option> " [join $hist($oSetNo,form,logic$no) " "] \n
169 foreach op {And Or {And not}} {
171 if {$hist($oSetNo,form,logic$no) == $op} continue
173 html "<option> " [join $op " "] \n
181 <input type=submit name=submit value="Search">
182 <input type=reset value="Reset">
185 html {Number of records to display in the result set list: }
186 html {<input type="text" name="hits" value="}
188 html $hist($oSetNo,maxPresent)
201 button-view-history 0
209 html "<h3>Debug information</h3>\n"
210 html "sessionId: $sessionId <br>\n"
211 html "sessionParms: $sessionParms <br>\n"
212 foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
213 html $e {: } $env($e) {<br>} \n
215 html "form: " [wform] " <br>\n"
216 html "target: " $host " <br>\n"
217 html "databases: " $databases " <br>\n"
218 html "setNo: " $setNo " <br>\n"
219 html "nextSetNo: " $nextSetNo " <br>\n"
220 html "initSet: " $initSet " <br>\n"
221 html "scanLine: " $scanLine " <br>\n"
222 html "scanTerm: " $scanTerm " <br>\n"