Previus/next scan buttons in scan.
[egate.git] / www / query.egw
1 <html>
2 <head>
3 <title> WWW/Z39.50 Gateway Query Form</title>
4 </head>
5 <body>
6 {
7 # $Id: query.egw,v 1.23 1996/01/03 08:59:41 adam Exp $
8
9     if {[info commands saveState] == ""} {
10         source z39util.tcl
11     }
12
13 proc fail-response {} {
14     global sessionWait
15     set sessionWait -1
16 }
17
18 proc ok-response {} {
19     global sessionWait
20     set sessionWait 1
21 }
22
23     global setNo
24     global nextSetNo
25     global hist
26
27     set host [lindex $sessionParms 0]
28     set initSet [lindex $sessionParms 1]
29     set scanLine [lindex $sessionParms 2]
30     set scanTerm [lindex $sessionParms 3]
31
32     if {[catch {set setNo $nextSetNo}]} {
33         set nextSetNo 1
34         set setNo 1
35     }
36     if {[catch {set oldHost [z39 connect]}]} {
37         set oldHost ""
38     }
39
40     set hist($setNo,host) $host
41     set hist($setNo,idAuthentication) [lindex $targets($host) 3]
42
43     if {[catch {z39 failback fail-response}]} {
44         ir z39
45     }
46
47     html "<h2>Search in " [lindex $targets($host) 0] "</h2>\n"
48
49     z39 callback ok-response
50     z39 failback fail-response
51     if {$host != $oldHost} {
52         catch {z39 disconnect}
53
54         set sessionWait 0
55         if {[catch {z39 connect $host}]} {
56             displayError "Cannot connect to target ${host}" {}
57             html "</body></html>\n"
58             z39 disconnect
59             wabort
60         } elseif {$sessionWait == 0} {
61             if {[catch {zwait sessionWait 35}]} {
62                 displayError "Cannot connect to target ${host}" {}
63                 html "</body></html>\n"
64                 z39 disconnect
65                 wabort
66             }
67             if {$sessionWait != 1} {
68                 displayError "Cannot connect to target ${host}" {}
69                 html "</body></html>\n"
70                 z39 disconnect
71                 wabort
72             }
73         }
74         set sessionWait 0
75         z39 idAuthentication $hist($setNo,idAuthentication)
76         if {[catch {z39 init}]} {
77             displayError "Cannot initialize target ${host}" {}
78             html "</body></html>\n"
79             wabort
80         }
81         if {[catch {zwait sessionWait 60}]} {
82             displayError "Cannot initialize target ${host}" {}
83             html "</body></html>\n"
84             wabort
85         }       
86         if {$sessionWait != "1"} {
87             displayError "Cannot initialize target ${host}" {}
88             htmlr "</body></html>\n"
89             wabort
90         }
91         if {![z39 initResult]} {
92             displayError "Connection rejected by target ${host}" \
93                  [z39 userInformationField]
94             z39 disconnect
95             htmlr "</body></html>"
96             wabort
97         }
98     }
99     set databases [lindex $targets($host) 1]
100
101 #    if {[catch {set prevHost $hist([expr $setNo - 1],host)}]} {
102 #        set databaseDefault [lindex $databases 0]
103 #        set oSetNo 0
104 #    } else {
105 #        set oSetNo [expr $setNo - 1]
106 #        set databaseDefault $hist($oSetNo,database)
107 #    }
108     if {$initSet == ""} {
109         set databaseDefault [lindex $databases 0]
110         set oSetNo 0
111     } else {
112         set oSetNo $initSet
113         set databaseDefault $hist($oSetNo,database)
114     }
115     
116     html {<form action="http:} $env(SCRIPT_NAME)
117     html / $sessionId {/search.egw/} $setNo {" method=post>} \n
118     set nodb [llength $databases]
119     if {$nodb > 1} {
120         if {$nodb > 2} {
121             html "The chosen target supports searching in "
122             html "several databases. <br>\n"
123             html "Choose the bases you want to search: <br>\n"
124         }
125         set i 0
126         foreach d $databases {
127             html {<input type="checkbox" name="base" value="} $d 
128             if {[lsearch $databaseDefault $d] == -1} {
129                 html {"> } $d \n
130             } else {
131                 html {" checked> } $d \n
132             }
133         }
134         html "<br>\n"
135         if {$nodb > 2} {
136             html {<input type="checkbox" name="baseall" value="} 
137             html [concat $databases] {"> All <br>} \n
138         }
139         html "Input your search criteria:<br>\n"
140     }
141     set fields [lindex $targets($host) 2]
142     for {set no 1} {$no < 4} {incr no} {
143         html {<select name="menu} $no {">} \n
144         if {$oSetNo > 0} {
145             html {<option> } $hist($oSetNo,form,menu$no) \n
146         }
147         foreach f $fields {
148             set name [lindex $f 0]
149             if {$oSetNo > 0} {
150                 if {$hist($oSetNo,form,menu$no) == $name} continue
151             }
152             html {<option> } $name \n
153         }
154         html "</select>\n"
155         html {<input type="text" name="entry} $no {"}
156         if {$scanLine == $no} {
157             html { value="} $scanTerm {" }
158         }
159         html { size=35>} \n
160         html {<input type="checkbox" name="scan} $no {" value="1" scan>}
161         if {$no < 3} {
162             html {<select name="logic} $no {">} \n
163             if {$oSetNo > 0} {
164                 html "<option> " $hist($oSetNo,form,logic$no) \n
165             }
166             foreach op {And Or {And not}} {
167                 if {$oSetNo > 0} {
168                     if {$hist($oSetNo,form,logic$no) == $op} continue
169                 }
170                 html "<option> " $op \n
171             }
172             html "</select>\n"
173         }
174         html "<br>\n"
175     }
176 }
177
178 <input type=submit name=submit value="Search">
179 <input type=reset value="Reset">
180 <br>
181 {
182     html {Number of records to display in the result set list: }
183     html {<input type="text" name="hits" value="}
184     if {$oSetNo > 0} {
185         html $hist($oSetNo,maxPresent)
186     } else {
187         html 20
188     }
189     html {" size=3>}
190 }
191 </form>
192 <p>
193
194 {
195     html {<img src="/gif/button-egw.gif" alt="Europagate" border=0></a>}
196     html {<a href="http:} $env(SCRIPT_NAME)
197     html / $sessionId {/targets.egw}
198     html {"><img src="/gif/button-new-target.gif" alt="New Target" }
199     html {border=0 alt="New Target"></a>}
200 }
201
202 <hr>
203 This page is maintained by <a href="mailto:pwh@dtv.dk"> Peter Wad Hansen </a>.
204 Last modified 29. september 1995. <br>
205 <em> This and the following pages are under construction
206 and will continue to be so until the end of December 1995.</em>
207
208 {
209     html "<hr>\n"
210     html "<h3>Debug information</h3>\n"
211     html "sessionId: $sessionId <br>\n"
212     html "sessionParms: $sessionParms <br>\n"
213     foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
214         html $e {: } $env($e) {<br>} \n
215     }
216     html "form: " [wform] " <br>\n"
217     html "target: " $host " <br>\n"
218     html "databases: " $databases " <br>\n"
219     html "setNo: " $setNo " <br>\n"
220     html "nextSetNo: " $nextSetNo " <br>\n"
221     html "initSet: " $initSet " <br>\n"
222     html "scanLine: " $scanLine " <br>\n"
223     html "scanTerm: " $scanTerm " <br>\n"
224 }
225 </body></html>
226
227