1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * cstrbrowsetools.cpp --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * A component of the Greenstone digital library software
|
---|
7 | * from the New Zealand Digital Library Project at the
|
---|
8 | * University of Waikato, New Zealand.
|
---|
9 | *
|
---|
10 | * This program is free software; you can redistribute it and/or modify
|
---|
11 | * it under the terms of the GNU General Public License as published by
|
---|
12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
13 | * (at your option) any later version.
|
---|
14 | *
|
---|
15 | * This program is distributed in the hope that it will be useful,
|
---|
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | * GNU General Public License for more details.
|
---|
19 | *
|
---|
20 | * You should have received a copy of the GNU General Public License
|
---|
21 | * along with this program; if not, write to the Free Software
|
---|
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
23 | *
|
---|
24 | * $Id: cstrbrowsetools.cpp 911 2000-02-06 21:27:04Z sjboddie $
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 | #include "cstrbrowsetools.h"
|
---|
29 | #include "OIDtools.h"
|
---|
30 | #include "cgiutils.h"
|
---|
31 | #include "browsetools.h"
|
---|
32 |
|
---|
33 |
|
---|
34 |
|
---|
35 | // outputs the postscript, abstract, figures etc buttons
|
---|
36 | static void output_cstr_controls (cgiargsclass &args, const text_t &source,
|
---|
37 | const text_t &description, const text_t &figures,
|
---|
38 | displayclass &disp, outconvertclass &outconvert,
|
---|
39 | ostream &textout) {
|
---|
40 | text_tarray buttons;
|
---|
41 | text_t &arg_gg = args["gg"];
|
---|
42 |
|
---|
43 | if (!source.empty())
|
---|
44 | buttons.push_back ("_document:imagepostscript_(" + cgi_safe(source) + ")");
|
---|
45 |
|
---|
46 | if ((!description.empty()) && (arg_gg != "abstract"))
|
---|
47 | buttons.push_back ("_document:imageabstract_");
|
---|
48 |
|
---|
49 | if ((!figures.empty()) && (arg_gg != "figures"))
|
---|
50 | buttons.push_back ("_document:imagefigures_");
|
---|
51 |
|
---|
52 | if (arg_gg != "text")
|
---|
53 | buttons.push_back ("_document:imageviewtext_");
|
---|
54 |
|
---|
55 | textout << "<br>\n";
|
---|
56 |
|
---|
57 | text_tarray::const_iterator here = buttons.begin();
|
---|
58 | text_tarray::const_iterator end = buttons.end();
|
---|
59 | int count = 0;
|
---|
60 | while (here != end) {
|
---|
61 | if ((count != 0) && ((count % 3) == 0)) textout << "<br>\n";
|
---|
62 | textout << outconvert << disp << *here;
|
---|
63 | count ++;
|
---|
64 | here ++;
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 |
|
---|
69 |
|
---|
70 | void output_cstr_toc (cgiargsclass &args, browsermapclass *browsermap,
|
---|
71 | formatinfo_t &formatinfo, recptproto *collectproto,
|
---|
72 | displayclass &disp, outconvertclass &outconvert,
|
---|
73 | ostream &textout, ostream &logout) {
|
---|
74 |
|
---|
75 | int tabcount = 0;
|
---|
76 | bool havecontrols = false;
|
---|
77 | bool fulltoc = false;
|
---|
78 |
|
---|
79 |
|
---|
80 | if (args["cl"] != "search") {
|
---|
81 | // see if there's a FullTOC string
|
---|
82 | text_t cl_top, full_toc;
|
---|
83 | get_top (args["cl"], cl_top);
|
---|
84 | if (get_formatstring (cl_top, "FullTOC", formatinfo.formatstrings, full_toc))
|
---|
85 | if (full_toc == "true") fulltoc = true;
|
---|
86 | }
|
---|
87 | text_t &arg_d = args["d"];
|
---|
88 | // get the facsimile image (if there is one) and the control buttons
|
---|
89 | // if we're inside a book
|
---|
90 | if ((!fulltoc) && (!arg_d.empty())) {
|
---|
91 |
|
---|
92 | // this code from old cstr browsetools outputdocument_toc
|
---|
93 | text_tset metadata;
|
---|
94 | FilterResponse_t response;
|
---|
95 | ResultDocInfo_t docinfo;
|
---|
96 | text_t booktop, facsimiles, figures, description, source, summary;
|
---|
97 | text_t &collection = args["c"];
|
---|
98 |
|
---|
99 | metadata.insert ("Title");
|
---|
100 | if (get_info (arg_d, collection, metadata, false, collectproto, response, logout)) {
|
---|
101 |
|
---|
102 | metadata.erase (metadata.begin(), metadata.end());
|
---|
103 | docinfo = response.docInfo[0];
|
---|
104 |
|
---|
105 | textout
|
---|
106 | << "\n<!-- Table of Contents produced by cstrbrowsetools::output_document_toc -->\n\n";
|
---|
107 |
|
---|
108 | // get title and author of book
|
---|
109 | get_top (arg_d, booktop);
|
---|
110 | metadata.insert ("facsimiles");
|
---|
111 | metadata.insert ("figures");
|
---|
112 | metadata.insert ("Description");
|
---|
113 | metadata.insert ("Source");
|
---|
114 | metadata.insert ("Summary");
|
---|
115 | get_info (booktop, collection, metadata, false, collectproto, response, logout);
|
---|
116 | facsimiles = response.docInfo[0].metadata["facsimiles"].values[0];
|
---|
117 | figures = response.docInfo[0].metadata["figures"].values[0];
|
---|
118 | description = response.docInfo[0].metadata["Description"].values[0];
|
---|
119 | source = response.docInfo[0].metadata["Source"].values[0];
|
---|
120 | summary = response.docInfo[0].metadata["Summary"].values[0];
|
---|
121 |
|
---|
122 | metadata.erase (metadata.begin(), metadata.end());
|
---|
123 |
|
---|
124 | textout << outconvert << disp
|
---|
125 | << "<p><center>\n"
|
---|
126 | << "<table cellpadding=0 cellspacing=0 width=_pagewidth_>\n"
|
---|
127 | << "<tr valign=top><td>\n";
|
---|
128 |
|
---|
129 | /*
|
---|
130 | // don't want arrows and page number if text expanded
|
---|
131 | if (formatinfo.DocumentArrowsBottom && !args.getintarg ("gt")) {
|
---|
132 |
|
---|
133 | // previous arrow
|
---|
134 | textout << outconvert << disp << "<table><tr valign=top>\n"
|
---|
135 | << "<td align=left>_document:prevarrow_</td>\n";
|
---|
136 |
|
---|
137 | // page ? of ? text
|
---|
138 | textout << "<td align=center>\n";
|
---|
139 |
|
---|
140 | if (is_number (docinfo.metadata["Title"].values[0])) {
|
---|
141 | text_t doctop;
|
---|
142 | metadata.insert ("Title");
|
---|
143 | get_top (arg_d, doctop);
|
---|
144 | // get title of last sibling
|
---|
145 | if (get_info (doctop + ".lc", collection, metadata, false, collectproto, response, logout)) {
|
---|
146 | if (is_number (response.docInfo[0].metadata["Title"].values[0])) {
|
---|
147 | textout << outconvert << disp << "_document:page_" << docinfo.metadata["Title"].values[0]
|
---|
148 | << "_document:of_" << response.docInfo[0].metadata["Title"].values[0];
|
---|
149 | } else {
|
---|
150 | textout << outconvert << docinfo.metadata["Title"].values[0];
|
---|
151 | }
|
---|
152 | }
|
---|
153 | } else {
|
---|
154 | textout << outconvert << docinfo.metadata["Title"].values[0];
|
---|
155 | }
|
---|
156 |
|
---|
157 | // next arrow
|
---|
158 | textout << outconvert << disp << "</td>\n<td align=right>_document:nextarrow_</td>\n</table>\n";
|
---|
159 | }
|
---|
160 |
|
---|
161 | // goto line ****** ????????????
|
---|
162 | //if (formatinfo.DocumentGoTo)
|
---|
163 | textout << outconvert << disp << "_document:gotoform_";
|
---|
164 | */
|
---|
165 |
|
---|
166 | //if (formatinfo.DocumentArrowsBottom && !args.getintarg ("gt")) {
|
---|
167 | if (args.getintarg("gc") == 1) {
|
---|
168 |
|
---|
169 | // expanded table of contents
|
---|
170 | expanded_contents (args, tabcount, fulltoc, browsermap, formatinfo,
|
---|
171 | collectproto, disp, outconvert, textout, logout);
|
---|
172 | } else {
|
---|
173 |
|
---|
174 | // contracted table of contents
|
---|
175 | contracted_contents (args, tabcount, fulltoc, browsermap, formatinfo,
|
---|
176 | collectproto, disp, outconvert, textout, logout);
|
---|
177 | }
|
---|
178 | // }
|
---|
179 | // control buttons
|
---|
180 | output_controls (args, formatinfo.DocumentButtons, collectproto,
|
---|
181 | disp, outconvert, textout, logout);
|
---|
182 | textout << "</td><td valign=top>\n";
|
---|
183 |
|
---|
184 | if (!summary.empty())
|
---|
185 | textout << outconvert << summary << "\n";
|
---|
186 |
|
---|
187 | output_cstr_controls (args, source, description, figures,
|
---|
188 | disp, outconvert, textout);
|
---|
189 |
|
---|
190 | textout << "</td>\n";
|
---|
191 |
|
---|
192 | // facsimile image
|
---|
193 | // only want the first facsimile (some documents have two)
|
---|
194 | if (!facsimiles.empty()) {
|
---|
195 | text_t::const_iterator fbegin = facsimiles.begin();
|
---|
196 | facsimiles = substr (fbegin, findchar (fbegin, facsimiles.end(), ','));
|
---|
197 | textout << outconvert << disp << "<td valign=top><a href=\"_httpcurrentdocument_&gg=facsimiles\">"
|
---|
198 | << "<img src=\"_httpcollimg_/_thisOID_/"
|
---|
199 | << facsimiles << "\" width=150 height=250></a>" << "</td>\n";
|
---|
200 | }
|
---|
201 |
|
---|
202 |
|
---|
203 | textout << "</td></tr></table></center>\n";
|
---|
204 | textout << "\n<!-- end of Table of Contents -->\n";
|
---|
205 |
|
---|
206 | }
|
---|
207 |
|
---|
208 | /* textout << "<p><table cellpadding=0 cellspacing=0><tr>\n";
|
---|
209 | textout << "<td valign=top";
|
---|
210 | if (formatinfo.DocumentContents) textout << " width=200>\n";
|
---|
211 | else textout << " width=100%>\n";
|
---|
212 | if (formatinfo.DocumentImages)
|
---|
213 | output_cover_image (args, collectproto, disp, outconvert, textout, logout);
|
---|
214 | else if (formatinfo.DocumentTitles)
|
---|
215 | output_titles (args, collectproto, formatinfo, disp, outconvert, textout, logout);
|
---|
216 | output_controls (args, formatinfo.DocumentButtons, collectproto, disp,
|
---|
217 | outconvert, textout, logout);
|
---|
218 | textout << "</td><td valign=top>\n";
|
---|
219 | havecontrols = true; */
|
---|
220 | }
|
---|
221 | /*
|
---|
222 | if (formatinfo.DocumentContents || args["d"].empty()) {
|
---|
223 | if (args.getintarg("gc") == 1) {
|
---|
224 |
|
---|
225 | // expanded table of contents
|
---|
226 | expanded_contents (args, tabcount, fulltoc, browsermap, formatinfo,
|
---|
227 | collectproto, disp, outconvert, textout, logout);
|
---|
228 | } else {
|
---|
229 |
|
---|
230 | // contracted table of contents
|
---|
231 | contracted_contents (args, tabcount, fulltoc, browsermap, formatinfo,
|
---|
232 | collectproto, disp, outconvert, textout, logout);
|
---|
233 | }
|
---|
234 | }
|
---|
235 | */
|
---|
236 | if (havecontrols) textout << "</td></tr></table>\n";
|
---|
237 | }
|
---|
238 |
|
---|
239 |
|
---|
240 |
|
---|
241 |
|
---|
242 |
|
---|
243 |
|
---|
244 |
|
---|
245 |
|
---|
246 |
|
---|