In images Alt=... are defined.
[egate.git] / www / search.egw
1 <html>
2 {
3 # $Id: search.egw,v 1.21 1996/01/02 10:52:28 adam Exp $
4
5 proc perform-scan {} {
6     global sessionId
7     global sessionParms
8     global sessionWait
9     global setNo
10     global hist
11     global targets
12     global nextSetNo
13     global env
14
15     set scanNo 1000
16
17     set termPlusAttr [build-scan $hist($setNo,host) 3]
18
19     if {"$termPlusAttr" == ""} {
20         html "<head><title> WWW/Z39.50 Gateway Scan</title>\n<body>\n"
21         displayError "Empty query" \
22             "You must specify at least one search word"
23         html "</body></html>\n"
24         wabort
25     }
26     set hist($setNo,scanAttr) [lindex $termPlusAttr 1]
27     set hist($setNo,$scanNo,scanTerm) [lindex $termPlusAttr 0]
28     
29     set host $hist($setNo,host)
30
31     html "<head><title> WWW/Z39.50 Gateway Scan " $host " </title>\n"
32     html "</head><body>\n"
33
34     if {[z39scan $setNo $scanNo 0 20 10] != "1"} {
35         return
36     }
37     display-scan $setNo $scanNo 0
38
39     html "<hr>\n"
40     html "<h3>Debug information</h3>\n"
41     html "sessionId: $sessionId <br>\n"
42     html "sessionParms: $sessionParms <br>\n"
43     foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
44         html $e {: } $env($e) {<br>} \n
45     }
46     html "form: " [wform] " <br>\n"
47     html "target: " $host " <br>\n"
48     html "databases: " $hist($setNo,database) " <br>\n"
49     html "selected: " [wform base] " <br>\n"
50     html "setNo: " $setNo " <br>\n"
51     html "nextSetNo: " $nextSetNo " <br>\n"
52     
53     html "</body>\n"
54 }
55
56 proc buttons {setNo setMax startPos after} {
57     global sessionId
58     global useIcons
59     global env
60     global hist
61
62     if {!$useIcons && $after && $setMax < [z39.$setNo resultCount]} {
63         html "<p>\n"
64         html "<center>\n"
65         html {<a href="http:} $env(SCRIPT_NAME)
66         html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
67         html + [expr $setMax + $hist($setNo,maxPresent)]
68         html {"><img src="/gif/darrw.gif"></a>}
69         html "</center>\n"
70     }
71
72     html "<p>\n"
73     if {$useIcons} {
74         html {<img src="/gif/button-egw.gif" alt="Europagate" border=0>}
75     }
76     if {$setMax < [z39.$setNo resultCount]} {
77         html {<a href="http:} $env(SCRIPT_NAME)
78         html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
79         html + [expr $setMax + $hist($setNo,maxPresent)]
80         if {$useIcons} {
81             html {"><img src="/gif/button-next-records.gif" alt="Next Records"}
82             html { border=0></a>}
83         } else {
84             html {">Next Records</a>} " | \n"
85         }
86     }
87     if {$startPos != "" && $startPos != "1"} {
88         html {<a href="http:} $env(SCRIPT_NAME)
89         html / $sessionId {/search.egw/} $setNo 
90         html + [expr $startPos - $hist($setNo,maxPresent)]
91         html + [expr $startPos - 1]
92         if {$useIcons} {
93             html {"><img src="/gif/button-previous-records.gif" }
94             html {alt="Previous Records" border=0></a>}
95         } else {
96             html {">Previous Records</a>} " | \n"
97         }
98     }
99     html {<a href="http:} $env(SCRIPT_NAME)
100     html / $sessionId {/query.egw/} $hist($setNo,host) + $setNo 
101     if {$useIcons} {
102         html {"><img src="/gif/button-new-query.gif" }
103         html {alt="New Query" border=0></a>}
104     } else {
105         html {">New Query</a>} " | \n"
106     }
107
108     html {<a href="http:} $env(SCRIPT_NAME)
109     html / $sessionId {/targets.egw}
110     if {$useIcons} {
111         html {"><img src="/gif/button-new-target.gif" }
112         html {alt="New Target" border=0></a>}
113     } else {
114         html {">New Target</a>}
115     }
116     html "<p>\n"
117     if {!$useIcons && !$after && $startPos != "" && $startPos != "1"} {
118         html "<center>\n"
119         html {<a href="http:} $env(SCRIPT_NAME)
120         html / $sessionId {/search.egw/} $setNo 
121         html + [expr $startPos - $hist($setNo,maxPresent)]
122         html + [expr $startPos - 1]
123         html {"><img src="/gif/uarrw.gif"></a>}
124         html "</center><p>\n"
125     }
126
127 }
128
129     if {[info commands saveState] == ""} {
130         source z39util.tcl
131     }
132     global sessionWait
133     global nextSetNo
134     global setNo
135     global hist
136
137     set setNo [lindex $sessionParms 0]
138
139     if {[wform menu1] != ""} {
140         set hist($nextSetNo,idAuthentication) $hist($setNo,idAuthentication)
141         set hist($nextSetNo,host) $hist($setNo,host)
142
143         if {$nextSetNo == $setNo} {
144             set setNo $nextSetNo
145             incr nextSetNo
146         } else {
147             catch {unset hist($setNo,hits)}
148         }
149         set hist($setNo,form,menu1) [wform menu1]
150         set hist($setNo,form,menu2) [wform menu2]
151         set hist($setNo,form,menu3) [wform menu3]
152
153         set hist($setNo,form,entry1) [wform entry1]
154         set hist($setNo,form,entry2) [wform entry2]
155         set hist($setNo,form,entry3) [wform entry3]
156
157         set hist($setNo,form,logic1) [wform logic1]
158         set hist($setNo,form,logic2) [wform logic2]
159         
160         set host $hist($setNo,host)
161         set databases [lindex $targets($host) 1]
162
163         set b [wform base]
164         if {[wform baseall] != ""} {
165             set hist($setNo,database) $databases
166         } elseif {$b == ""} {
167             set hist($setNo,database) $databases
168         } else {
169             set hist($setNo,database) $b
170         }
171         set hist($setNo,maxPresent) [wform hits]
172         if {$hist($setNo,maxPresent) == ""} {
173             set hist($setNo,maxPresent) 30
174         }
175
176         if {[wform submit] == "Scan"} {
177             perform-scan
178             wabort
179         }
180         set query [build-query $hist($setNo,host) 3]
181         if {"x$query" == "x"} {
182             html "<head><title> WWW/Z39.50 Gateway Search</title>\n<body>\n"
183             displayError "Empty query" \
184                 "You must specify at least one search word"
185             html "</body></html>\n"
186             wabort
187         }
188         set hist($setNo,query) $query
189     }
190     set host $hist($setNo,host)
191
192     html "<head><title> WWW/Z39.50 Gateway Search " $host " </title>\n"
193     html "</head><body>\n"
194
195     set startPos [lindex $sessionParms 1]
196     set endPos [lindex $sessionParms 2]
197     set setMax 0
198     set setOffset 0
199     if {$startPos == ""} {
200         if {[z39search $setNo 1 0 B] != "1"} {
201             return
202         }
203         set r [z39.$setNo resultCount]
204         html "<h3> Search result $r hits</h3>\n"
205         wflush
206         set setOffset [z39.$setNo numberOfRecordsReturned]
207         display-rec 1 $setOffset display-brief 0
208         incr setOffset
209         set setMax [z39.$setNo resultCount]
210         if {$setMax > $hist($setNo,maxPresent)} {
211             set setMax $hist($setNo,maxPresent)
212         }
213     } else {
214         if {[z39search $setNo 0 0 B] != "1"} {
215             return 
216         }
217         set r [z39.$setNo resultCount]
218         set setOffset $startPos
219         set setMax [z39.$setNo resultCount]
220         if {$setMax > $endPos} {
221             set setMax $endPos
222         }
223         if {$setMax > 0} {
224             buttons $setNo $setMax $startPos 0
225         }
226         html "<h3> Search result $r hits</h3>\n"
227         wflush
228     }
229     if {$setMax > 0} {
230         z39present $setNo 0 $setOffset $setMax display-brief B
231     }
232
233     buttons $setNo $setMax $startPos 1
234 }
235
236 {
237     html "<hr>\n"
238     html "<h3>Debug information</h3>\n"
239     html "sessionId: $sessionId <br>\n"
240     html "sessionParms: $sessionParms <br>\n"
241     foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
242         html $e {: } $env($e) {<br>} \n
243     }
244     html "form: " [wform] " <br>\n"
245     html "target: " $host " <br>\n"
246     html "databases: " $hist($setNo,database) " <br>\n"
247     html "selected: " [wform base] " <br>\n"
248     html "query: --" $hist($setNo,query) "-- <br>"
249     html "setNo: " $setNo " <br>\n"
250     html "nextSetNo: " $nextSetNo " <br>\n"
251 }
252
253 </body>
254 </html>