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