Arrow gifs.
[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.15 1995/11/13 15:41:42 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
29     if {[info exists setNo]} {
30         set oldHost $hist($setNo,host)
31     } else {
32         set oldHost ""
33     }
34     if {[catch {set setNo $nextSetNo}]} {
35         set nextSetNo 1
36         set setNo 1
37     }
38     set hist($setNo,host) $host
39     set hist($setNo,idAuthentication) [lindex $targets($host) 3]
40
41     if {[catch {z39 failback fail-response}]} {
42         ir z39
43     }
44
45     html "<h2> Search in " [lindex $targets($host) 0] "</h2>\n"
46
47     z39 callback ok-response
48     z39 failback fail-response
49     if {$host != $oldHost} {
50         catch {z39 disconnect}
51
52         set sessionWait 0
53         if {[catch {z39 connect $host}]} {
54             html "Cannot connect to target ${host} <br>\n" 
55             html "</body></html>\n"
56             wabort
57         } elseif {$sessionWait == 0} {
58             if {[catch {zwait sessionWait 30}]} {
59                 html "Cannot connect to target ${host} <br>\n"
60                 html "</body></html>\n"
61                 z39 disconnect
62                 wabort
63             }
64             if {$sessionWait != 1} {
65                 html "Cannot connect to target ${host} <br>\n"
66                 html "</body></html>\n"
67                 z39 disconnect
68                 wabort
69             }
70         }
71         set sessionWait 0
72 #       z39 idAuthentication $hist($setNo,idAuthentication)
73         if {[catch {z39 init}]} {
74             htmlr "Cannot initialize with target ${host} <br>"
75             htmlr "</body></html>"
76             wabort
77         }
78         if {[catch {zwait sessionWait 60}]} {
79             htmlr "Cannot initialize with target ${host} <br>"
80             htmlr "</body></html>"
81             wabort
82         }       
83         if {$sessionWait != "1"} {
84             htmlr "Cannot initialize with target ${host} <br>"
85             htmlr "</body></html>"
86             wabort
87         }
88     }
89     set databases [lindex $targets($host) 1]
90
91     html {<form action="http:} $env(SCRIPT_NAME)
92     html / $sessionId {/search.egw/} $setNo {" method=post>} \n
93     set nodb [llength $databases]
94     if {$nodb > 1} {
95         if {$nodb > 2} {
96             html "The chosen target supports searching in "
97             html "several databases. <br>\n"
98             html "Choose the bases you want to search: <br>\n"
99         }
100         set i 0
101         foreach d $databases {
102             html {<input type="checkbox" name="base" value="} $d 
103             if {[incr i] > 1} {
104                 html {"> } $d \n
105             } else {
106                 html {" checked> } $d \n
107             }
108         }
109         html "<br>\n"
110         if {$nodb > 2} {
111             html {<input type="checkbox" name="base" value="} 
112             html [concat $databases] {"> All <br>} \n
113         }
114     }
115 }
116 <hr>
117 <h3>Input your search criteria: </h3> <br>
118 {
119     set fields [lindex $targets($host) 2]
120     for {set no 1} {$no < 4} {incr no} {
121         html {<select name="menu} $no {">} \n
122         foreach f $fields {
123             html {<option> } [lindex $f 0] \n
124         }
125         html "</select>\n"
126         html {<input type="text" name="entry} $no {" size=30>} \n
127         if {$no < 3} {
128             html {<select name="logic} $no {">} \n
129             html "<option> And\n"
130             html "<option> Or\n"
131             html "<option> And not\n"
132             html "</select>\n"
133         }
134         html "<br>\n"
135     }
136 }
137 <hr><p>
138 Alternatively you can enter your query in
139 <a href="http://www.dtv.dk/ccl.html"> CCL </a> here: <br>
140 <input type=text name="cclentry" size=52> <br>
141 <hr>
142 <input type=submit value="Search"><input type=reset value="Reset">
143 <h3> Various technical parameters: </h3> <br>
144 Max hits: <input type="text" name="hits" value="20" size=3>
145 Records are shown in:
146 <select name="format">
147 <option> Long format
148 <option> Medium format
149 <option> Short format
150 <option> Raw MARC
151 </select>
152 <br>
153 <p>
154 </form>
155 <hr>
156 This page is maintained by <a href="mailto:pwh@dtv.dk"> Peter Wad Hansen </a>.
157 Last modified 29. september 1995. <br>
158 <em> This and the following pages are under construction
159 and will continue to be so until the end of December 1995.</em>
160 <hr>
161
162 {
163     html {<a href="http:} $env(SCRIPT_NAME)
164     html / $sessionId {/targets.egw"> New target </a>}
165 }
166 {
167     html "<hr>\n"
168     html "<h3>Debug information</h3>\n"
169     html "sessionId: $sessionId <br>\n"
170     html "sessionParms: $sessionParms <br>\n"
171     foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
172         html $e {: } $env($e) {<br>} \n
173     }
174     html "form: " [wform] " <br>\n"
175     html "target: " $host " <br>\n"
176     html "databases: " $databases " <br>\n"
177     html "setNo: " $setNo " <br>\n"
178     html "nextSetNo: " $nextSetNo " <br>\n"
179 }
180 </body></html>
181
182