Attempt to inform user if session has really terminated.
[egate.git] / www / mquery.egw
1 <html>
2 {
3 # $Id: mquery.egw,v 1.16 1996/03/14 11:50:45 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="http:} $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             set hist($setNo,$i,host) $host
41             set hist($setNo,$i,idAuthentication) [lindex $targets($host) 3]
42         }
43         lappend hist($setNo,$i,database) $base
44     }
45     set oSetNo [lindex $sessionParms 0]
46     if {$oSetNo < 0} {
47         set oSetNo 0
48     }
49     if {$i == 0 && $oSetNo && [info exists hist($oSetNo,0,host)]} {
50         for {set i 1} {$i <= $hist($oSetNo,0,host)} {incr i} {
51             set hist($setNo,$i,host) $hist($oSetNo,$i,host)
52             set hist($setNo,$i,idAuthentication) \
53                 $hist($oSetNo,$i,idAuthentication)
54             set hist($setNo,$i,database) $hist($oSetNo,$i,database)
55         }
56         incr i -1
57     }
58     if {$i == 0} {
59         html "<h2>No targets specified</h2></body></html>"
60         egw_abort 1
61     }
62
63     set curSort server
64     set curFormat brief    
65     if {$oSetNo} {
66         set curSort $hist($oSetNo,sort)
67         set curFormat $hist($oSetNo,format)
68     }
69
70     set hist($setNo,0,host) $i
71
72     html "<b>Fill-in this search form:</b><br>\n"
73     set fields [lindex $targets($host) 2]
74     for {set no 1} {$no < 4} {incr no} {
75
76         html {<select name="menu} $no {">} \n
77         set template {}
78         if {$oSetNo} {
79             set template [join $hist($oSetNo,form,menu$no)]
80         }
81         if {[string length $template] > 0} {
82             html {<option> } $template "\n"
83         }
84         foreach f $fields {
85             set name [lindex $f 0]
86             if {$template == $name} continue
87             html {<option> } $name \n
88         }
89         html "</select>\n"
90
91         html {<input type="text" name="entry} $no {" size=35 value="}
92
93         if {$oSetNo} {
94             if {[info exists hist($oSetNo,form,entry$no)]} {
95                 html [join $hist($oSetNo,form,entry$no) " "]
96             }
97         }
98         html {">} \n
99         if {$no < 3} {
100             html {<select name="logic} $no {">} \n
101             set template {}
102             if {$oSetNo} {
103                 set template [join $hist($oSetNo,form,logic$no) " "]
104             }
105             if {[string length $template] > 0} {
106                 html "<option> " $template \n
107             }
108             foreach op {And Or {And not}} {
109                 if {$template == $op} continue
110                 html "<option> " [join $op " "] \n
111             }
112             html "</select>\n"
113         }
114         html "<br>\n"
115     }
116
117     html {<input type=submit value="Search"><input type=reset value="Reset">}
118     html "<br>\n"
119
120     html {<b>Display each record in <select name="format">}
121     if {![string compare $curFormat brief]} {
122         html "<option>brief\n"
123         html "<option>medium\n"
124     } else {
125         html "<option>medium\n"
126         html "<option>brief\n"
127     }
128     html "</select> notation"
129     html { and sort by <select name="sort">}
130     if {![string compare $curSort score]} {
131         html "<option>score\n"
132         html "<option>server\n"
133     } else {
134         html "<option>server\n"
135         html "<option>score\n"
136     }
137     html "</select></b><br>\n"
138
139     set useIcons 0
140     button-main
141     button-new-target
142 }
143 {
144     catch maintenance
145     if {!$debug} return
146     html "<hr>\n"
147     html "<h3>Debug information</h3>\n"
148     html "sessionId: $sessionId <br>\n"
149     html "sessionParms: $sessionParms <br>\n"
150     foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
151         html $e {: } $env($e) {<br>} \n
152     }
153     set j $hist($setNo,0,host)
154     for {set i 1} {$i <= $j} {incr i} {
155         html "host=" $hist($setNo,$i,host) " " $hist($setNo,$i,database) 
156         html "<br>\n"
157     }
158     html "form: " [egw_form] " <br>\n"
159     html "target: " $host " <br>\n"
160     html "setNo: " $setNo " <br>\n"
161     html "nextSetNo: " $nextSetNo " <br>\n"
162 }
163 </body></html>