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