3 <title> WWW/Z39.50 Gateway Query Form</title>
7 # $Id: query.egw,v 1.31 1996/01/24 16:59:28 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><br>\n"
48 z39 callback ok-response
49 z39 failback fail-response
50 set thisHost [splitHostSpec $host]
51 if {$thisHost != $oldHost} {
52 catch {z39 disconnect}
55 if {[catch {z39 connect $thisHost}]} {
56 displayError "Cannot connect to target ${thisHost}" {}
57 html "</body></html>\n"
60 } elseif {$sessionWait == 0} {
61 if {[catch {egw_wait sessionWait 35}]} {
62 displayError "Cannot connect to target ${thisHost}" {}
63 html "</body></html>\n"
67 if {$sessionWait != 1} {
68 displayError "Cannot connect to target ${thisHost}" {}
69 html "</body></html>\n"
75 z39 idAuthentication $hist($setNo,idAuthentication)
76 if {[catch {z39 init}]} {
77 displayError "Cannot initialize target ${thisHost}" {}
78 html "</body></html>\n"
81 if {[catch {egw_wait sessionWait 60}]} {
82 displayError "Cannot initialize target ${thisHost}" {}
83 html "</body></html>\n"
86 if {$sessionWait != "1"} {
87 displayError "Cannot initialize target ${thisHost}" {}
88 html "</body></html>\n"
91 if {![z39 initResult]} {
92 displayError "Connection rejected by target ${thisHost}" \
93 [z39 userInformationField]
95 html "</body></html>\n"
99 set databases [lindex $targets($host) 1]
101 if {$initSet == ""} {
102 set databaseDefault [lindex $databases 0]
106 set databaseDefault $hist($oSetNo,database)
109 html {<form action="http:} $env(SCRIPT_NAME)
110 html / $sessionId {/search.egw/} $setNo {" method=get>} \n
111 set nodb [llength $databases]
114 html "The chosen target supports searching in "
115 html "several databases. <br>\n"
116 html "Choose the bases you want to search: <br>\n"
119 foreach d $databases {
120 html {<input type="checkbox" name="base" value="} $d
121 if {[lsearch $databaseDefault $d] == -1} {
124 html {" checked> } $d \n
129 html {<input type="checkbox" name="baseall" value="}
130 html [concat $databases] {"> All <br>} \n
133 html "Input your search criteria:<br>\n"
134 set fields [lindex $targets($host) 2]
135 for {set no 1} {$no < 4} {incr no} {
136 html {<select name="menu} $no {">} \n
139 set template [join $hist($oSetNo,form,menu$no)]
141 if {[string length $template] > 0} {
142 html {<option> } $template "\n"
145 set name [lindex $f 0]
146 if {$template == $name} continue
147 html {<option> } $name \n
150 html {<input type="text" name="entry} $no {"}
152 if {$scanLine == $no} {
153 set template [join $scanTerm " "]
154 } elseif {[info exists hist($oSetNo,form,entry$no)]} {
155 set template [join $hist($oSetNo,form,entry$no) " "]
157 if {[string length $template] > 0} {
158 html { value="} $template {"}
161 if {0 && [lsearch [z39 options] scan] >= 0} {
162 html {<input type="checkbox" name="scan} $no {" value="1" scan>}
165 html {<select name="logic} $no {">} \n
168 set template [join $hist($oSetNo,form,logic$no) " "]
170 if {[string length $template] > 0} {
171 html "<option> " $template \n
173 foreach op {And Or {And not}} {
174 if {$template == $op} continue
175 html "<option> " [join $op " "] \n
183 <input type=submit name=submit value="Search">
184 <input type=reset value="Reset">
187 html {Number of records to display in the result set list: }
188 html {<input type="text" name="hits" value="}
190 html $hist($oSetNo,maxPresent)
204 if {[lsearch [z39 options] scan] >= 0} {
205 button-scan-window 1 $setNo
207 button-view-history 0
215 html "<h3>Debug information</h3>\n"
216 html "sessionId: $sessionId <br>\n"
217 html "sessionParms: $sessionParms <br>\n"
218 foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
219 html $e {: } $env($e) {<br>} \n
221 html "form: " [egw_form] " <br>\n"
222 html "target: " $host " <br>\n"
223 html "databases: " $databases " <br>\n"
224 html "setNo: " $setNo " <br>\n"
225 html "nextSetNo: " $nextSetNo " <br>\n"
226 html "initSet: " $initSet " <br>\n"
227 html "scanLine: " $scanLine " <br>\n"
228 html "scanTerm: " $scanTerm " <br>\n"