3 # $Id: query.egw,v 1.39 1996/03/14 11:50:47 adam Exp $
5 if {[info commands saveState] == ""} {
7 if {![info exists debug]} {
13 proc fail-response {} {
27 html {<head><title> WWW/Z39.50 Gateway Query Form</title></head><body>}
29 set initSet [lindex $sessionParms 0]
30 set host [lindex $sessionParms 1]
31 set scanLine [lindex $sessionParms 2]
32 set scanTerm [lrange $sessionParms 3 end]
34 if {[catch {set setNo $nextSetNo}]} {
38 if {[catch {set oldHost [z390 connect]}]} {
42 set hist($setNo,0,host) $host
43 set hist($setNo,0,idAuthentication) [lindex $targets($host) 3]
47 z390 callback ok-response
48 z390 failback fail-response
49 set thisHost [splitHostSpec $host]
50 if {[string compare $thisHost $oldHost]} {
51 catch {z390 disconnect}
54 if {[catch {z390 connect $thisHost}]} {
55 displayError "Cannot connect to target ${thisHost}" {}
56 html "</body></html>\n"
59 } elseif {$sessionWait == 0} {
60 if {[catch {egw_wait sessionWait 35}]} {
61 displayError "Cannot connect to target ${thisHost}" {}
62 html "</body></html>\n"
66 if {$sessionWait != 1} {
67 displayError "Cannot connect to target ${thisHost}" {}
68 html "</body></html>\n"
74 z390 idAuthentication $hist($setNo,0,idAuthentication)
75 if {[catch {z390 init}]} {
76 displayError "Cannot initialize target ${thisHost}" {}
77 html "</body></html>\n"
80 if {$sessionWait == 0 && [catch {egw_wait sessionWait 60}]} {
81 displayError "Cannot initialize target ${thisHost}" {}
82 html "</body></html>\n"
85 if {$sessionWait != "1"} {
86 displayError "Cannot initialize target ${thisHost}" {}
87 html "</body></html>\n"
90 if {![z390 initResult]} {
91 displayError "Connection rejected by target ${thisHost}" \
92 [z390 userInformationField]
94 html "</body></html>\n"
102 if {[lsearch [z390 options] scan] >= 0} {
103 button-scan-window $setNo
107 html "<h2>" [lindex $targets($host) 0] "</h2><br>\n"
109 html [lindex $targets($host) 4] "<br>\n"
111 set databases [splitDatabaseSpec $host]
112 if {$initSet == -1} {
113 set databaseDefault [lindex $databases 0]
117 set databaseDefault $hist($oSetNo,0,database)
120 html {<form action="http:} $env(SCRIPT_NAME)
121 html / $sessionId {/search.egw/} $setNo + 0 {" method=get>} \n
122 set nodb [llength $databases]
125 html "The chosen target supports searching in "
126 html "several databases. <br>\n"
127 html "Choose the bases you want to search: <br>\n"
130 foreach d $databases {
131 html {<input type="checkbox" name="base" value="} $d
132 if {[lsearch $databaseDefault $d] == -1} {
135 html {" checked> } $d \n
140 html {<input type="checkbox" name="baseall" value="}
141 html [concat $databases] {"> All <br>} \n
144 html "<b>Fill-in this search form:</b><br>\n"
145 set fields [lindex $targets($host) 2]
146 for {set no 1} {$no < 4} {incr no} {
147 html {<select name="menu} $no {">} \n
150 set template [join $hist($oSetNo,form,menu$no)]
152 if {[string length $template] > 0} {
153 html {<option> } $template "\n"
156 set name [lindex $f 0]
157 if {$template == $name} continue
158 html {<option> } $name \n
161 html {<input type="text" name="entry} $no {"}
163 if {$scanLine == $no} {
164 set template [join $scanTerm " "]
165 } elseif {[info exists hist($oSetNo,form,entry$no)]} {
166 set template [join $hist($oSetNo,form,entry$no) " "]
168 if {[string length $template] > 0} {
169 html { value="} $template {"}
172 if {0 && [lsearch [z390 options] scan] >= 0} {
173 html {<input type="checkbox" name="scan} $no {" value="1" scan>}
176 html {<select name="logic} $no {">} \n
179 set template [join $hist($oSetNo,form,logic$no) " "]
181 if {[string length $template] > 0} {
182 html "<option> " $template \n
184 foreach op {And Or {And not}} {
185 if {$template == $op} continue
186 html "<option> " [join $op " "] \n
194 <input type=submit name=submit value="Search">
195 <input type=reset value="Reset">
198 html {Number of records to display in the result set list: }
199 html {<input type="text" name="hits" value="}
201 html $hist($oSetNo,maxPresent)
212 if {[lsearch [z390 options] scan] >= 0} {
213 button-scan-window $setNo
223 html "<h3>Debug information</h3>\n"
224 html "sessionId: $sessionId <br>\n"
225 html "sessionParms: $sessionParms <br>\n"
226 foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
227 html $e {: } $env($e) {<br>} \n
229 html "form: " [egw_form] " <br>\n"
230 html "target: " $host " <br>\n"
231 html "databases: " $databases " <br>\n"
232 html "setNo: " $setNo " <br>\n"
233 html "nextSetNo: " $nextSetNo " <br>\n"
234 html "initSet: " $initSet " <br>\n"
235 html "scanLine: " $scanLine " <br>\n"
236 html "scanTerm: " $scanTerm " <br>\n"