Arrow gifs.
[egate.git] / www / search.egw
1 <html>
2 {
3 # $Id: search.egw,v 1.15 1995/11/13 15:41:44 adam Exp $
4
5 proc buttons {setNo setMax startPos after} {
6     global sessionId
7     global env
8     global hist
9
10     if {$after && $setMax < [z39.$setNo resultCount]} {
11         html "<p>\n"
12         html "<center>\n"
13         html {<a href="http:} $env(SCRIPT_NAME)
14         html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
15         html + [expr $setMax + $hist($setNo,maxPresent)]
16         html {"><img src="/gif/darrw.gif"></a>}
17         html "</center>\n"
18     }
19
20     html "<p>\n"
21     if {$setMax < [z39.$setNo resultCount]} {
22         html {<a href="http:} $env(SCRIPT_NAME)
23         html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
24         html + [expr $setMax + $hist($setNo,maxPresent)]
25         html {">Next records</a>} " | \n"
26     }
27     if {$startPos != "" && $startPos != "1"} {
28         html {<a href="http:} $env(SCRIPT_NAME)
29         html / $sessionId {/search.egw/} $setNo 
30         html + [expr $startPos - $hist($setNo,maxPresent)]
31         html + [expr $startPos - 1]
32         html {">Previous records</a>} " | \n"
33     }
34     html {<a href="http:} $env(SCRIPT_NAME)
35     html / $sessionId {/query.egw/} $hist($setNo,host) + $setNo 
36     html {">New query</a>} " | \n"
37
38     html {<a href="http:} $env(SCRIPT_NAME)
39     html / $sessionId {/targets.egw">New target</a>} "<p>\n"
40
41     if {!$after && $startPos != "" && $startPos != "1"} {
42         html "<center>\n"
43         html {<a href="http:} $env(SCRIPT_NAME)
44         html / $sessionId {/search.egw/} $setNo 
45         html + [expr $startPos - $hist($setNo,maxPresent)]
46         html + [expr $startPos - 1]
47         html {"><img src="/gif/uarrw.gif"></a>}
48         html "</center><p>\n"
49     }
50
51 }
52
53     if {[info commands saveState] == ""} {
54         source z39util.tcl
55     }
56     global sessionWait
57     global nextSetNo
58     global setNo
59     global hist
60
61     set setNo [lindex $sessionParms 0]
62     if {[wform menu1] != ""} {
63         set hist($nextSetNo,idAuthentication) $hist($setNo,idAuthentication)
64         set hist($nextSetNo,host) $hist($setNo,host)
65         set setNo $nextSetNo
66         html "using host " $hist($setNo,host) " <br\n"
67         incr nextSetNo
68
69         set hist($setNo,query) [build-query $hist($setNo,host)]
70         set b [wform base]
71         if {$b == ""} {
72             set hist($setNo,database) $databases
73         } else {
74             set hist($setNo,database) $b
75         }
76         set hist($setNo,maxPresent) [wform hits]
77         if {$hist($setNo,maxPresent) == ""} {
78             set hist($setNo,maxPresent) 30
79         }
80     }
81     set host $hist($setNo,host)
82     set databases [lindex $targets($host) 1]
83
84     html "<head><title> WWW/Z39.50 Gateway Search " $host " </title>\n"
85     html "</head><body>\n"
86
87     set startPos [lindex $sessionParms 1]
88     set endPos [lindex $sessionParms 2]
89     set setMax 0
90     set setOffset 0
91     if {$startPos == ""} {
92         if {[z39search $setNo 1 0 B] != "1"} {
93             return
94         }
95         set r [z39.$setNo resultCount]
96         html "<h2> Search result $r hits</h2>\n"
97         wflush
98         set setOffset [z39.$setNo numberOfRecordsReturned]
99         display-rec 1 $setOffset display-brief 0
100         incr setOffset
101         set setMax [z39.$setNo resultCount]
102         if {$setMax > $hist($setNo,maxPresent)} {
103             set setMax $hist($setNo,maxPresent)
104         }
105     } else {
106         if {[z39search $setNo 0 0 B] != "1"} {
107             return 
108         }
109         set r [z39.$setNo resultCount]
110         html "<h2> Search result $r hits</h2>\n"
111         wflush
112         set setOffset $startPos
113         set setMax [z39.$setNo resultCount]
114         if {$setMax > $endPos} {
115             set setMax $endPos
116         }
117         if {$setMax > 0} {
118             buttons $setNo $setMax $startPos 0
119         }
120     }
121     if {$setMax > 0} {
122         z39present $setNo 0 $setOffset $setMax display-brief B
123     }
124
125     buttons $setNo $setMax $startPos 1
126 }
127
128 {
129     html "<hr>\n"
130     html "<h3>Debug information</h3>\n"
131     html "sessionId: $sessionId <br>\n"
132     html "sessionParms: $sessionParms <br>\n"
133     foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
134         html $e {: } $env($e) {<br>} \n
135     }
136     html "form: " [wform] " <br>\n"
137     html "target: " $host " <br>\n"
138     html "databases: " $hist($setNo,database) " <br>\n"
139     html "selected: " [wform base] " <br>\n"
140     html "query: --" $hist($setNo,query) "-- <br>"
141     html "setNo: " $setNo " <br>\n"
142     html "nextSetNo: " $nextSetNo " <br>\n"
143 }
144
145 </body>
146 </html>