364a8cdcd1451ec6db4018c534ce70a0cd94d94a
[egate.git] / www / mquery.egw
1 <html>
2 <head>
3 <title> WWW/Z39.50 Gateway Query Form</title>
4 </head>
5 <body>
6 {
7 # $Id: mquery.egw,v 1.15 1996/03/13 14:07:29 adam Exp $
8
9     if {[info commands saveState] == ""} {
10         source z39util.tcl
11     }
12
13     global setNo
14     global nextSetNo
15     global hist
16     global targets
17
18     if {[catch {set setNo $nextSetNo}]} {
19         set nextSetNo 1
20         set setNo 1
21     }
22
23     set useIcons 1
24     button-main
25     button-new-target
26
27     html {<form action="http:} $env(SCRIPT_NAME)
28     html / $sessionId {/msearch.egw/} $setNo {" method=get>} \n
29
30     set phost {}
31     set i 0
32     foreach t [lsort [egw_form target]] {
33         set host [lindex $t 0]
34         set base [lindex $t 1]
35         if {$host != $phost} {
36             set phost $host
37             incr i
38             set hist($setNo,$i,host) $host
39             set hist($setNo,$i,idAuthentication) [lindex $targets($host) 3]
40         }
41         lappend hist($setNo,$i,database) $base
42     }
43     set oSetNo [lindex $sessionParms 0]
44     if {$oSetNo < 0} {
45         set oSetNo 0
46     }
47     if {$i == 0 && $oSetNo && [info exists hist($oSetNo,0,host)]} {
48         for {set i 1} {$i <= $hist($oSetNo,0,host)} {incr i} {
49             set hist($setNo,$i,host) $hist($oSetNo,$i,host)
50             set hist($setNo,$i,idAuthentication) \
51                 $hist($oSetNo,$i,idAuthentication)
52             set hist($setNo,$i,database) $hist($oSetNo,$i,database)
53         }
54         incr i -1
55     }
56     if {$i == 0} {
57         html "<h2>No targets specified</h2></body></html>"
58         egw_abort 1
59     }
60
61     set curSort server
62     set curFormat brief    
63     if {$oSetNo} {
64         set curSort $hist($oSetNo,sort)
65         set curFormat $hist($oSetNo,format)
66     }
67
68     set hist($setNo,0,host) $i
69
70     html "<b>Fill-in this search form:</b><br>\n"
71     set fields [lindex $targets($host) 2]
72     for {set no 1} {$no < 4} {incr no} {
73
74         html {<select name="menu} $no {">} \n
75         set template {}
76         if {$oSetNo} {
77             set template [join $hist($oSetNo,form,menu$no)]
78         }
79         if {[string length $template] > 0} {
80             html {<option> } $template "\n"
81         }
82         foreach f $fields {
83             set name [lindex $f 0]
84             if {$template == $name} continue
85             html {<option> } $name \n
86         }
87         html "</select>\n"
88
89         html {<input type="text" name="entry} $no {" size=35 value="}
90
91         if {$oSetNo} {
92             if {[info exists hist($oSetNo,form,entry$no)]} {
93                 html [join $hist($oSetNo,form,entry$no) " "]
94             }
95         }
96         html {">} \n
97         if {$no < 3} {
98             html {<select name="logic} $no {">} \n
99             set template {}
100             if {$oSetNo} {
101                 set template [join $hist($oSetNo,form,logic$no) " "]
102             }
103             if {[string length $template] > 0} {
104                 html "<option> " $template \n
105             }
106             foreach op {And Or {And not}} {
107                 if {$template == $op} continue
108                 html "<option> " [join $op " "] \n
109             }
110             html "</select>\n"
111         }
112         html "<br>\n"
113     }
114
115     html {<input type=submit value="Search"><input type=reset value="Reset">}
116     html "<br>\n"
117
118     html {<b>Display each record in <select name="format">}
119     if {![string compare $curFormat brief]} {
120         html "<option>brief\n"
121         html "<option>medium\n"
122     } else {
123         html "<option>medium\n"
124         html "<option>brief\n"
125     }
126     html "</select> notation"
127     html { and sort by <select name="sort">}
128     if {![string compare $curSort score]} {
129         html "<option>score\n"
130         html "<option>server\n"
131     } else {
132         html "<option>server\n"
133         html "<option>score\n"
134     }
135     html "</select></b><br>\n"
136
137     set useIcons 0
138     button-main
139     button-new-target
140 }
141 {
142     catch maintenance
143     if {!$debug} return
144     html "<hr>\n"
145     html "<h3>Debug information</h3>\n"
146     html "sessionId: $sessionId <br>\n"
147     html "sessionParms: $sessionParms <br>\n"
148     foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
149         html $e {: } $env($e) {<br>} \n
150     }
151     set j $hist($setNo,0,host)
152     for {set i 1} {$i <= $j} {incr i} {
153         html "host=" $hist($setNo,$i,host) " " $hist($setNo,$i,database) 
154         html "<br>\n"
155     }
156     html "form: " [egw_form] " <br>\n"
157     html "target: " $host " <br>\n"
158     html "setNo: " $setNo " <br>\n"
159     html "nextSetNo: " $nextSetNo " <br>\n"
160 }
161 </body></html>