1 |
|
---|
2 | /**********************************************************************
|
---|
3 | *
|
---|
4 | * browsetools.cpp --
|
---|
5 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
6 | *
|
---|
7 | * A component of the Greenstone digital library software
|
---|
8 | * from the New Zealand Digital Library Project at the
|
---|
9 | * University of Waikato, New Zealand.
|
---|
10 | *
|
---|
11 | * This program is free software; you can redistribute it and/or modify
|
---|
12 | * it under the terms of the GNU General Public License as published by
|
---|
13 | * the Free Software Foundation; either version 2 of the License, or
|
---|
14 | * (at your option) any later version.
|
---|
15 | *
|
---|
16 | * This program is distributed in the hope that it will be useful,
|
---|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | * GNU General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with this program; if not, write to the Free Software
|
---|
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
24 | *
|
---|
25 | * $Id: browsetools.cpp 1860 2001-01-25 18:26:45Z cs025 $
|
---|
26 | *
|
---|
27 | *********************************************************************/
|
---|
28 |
|
---|
29 | #include "browsetools.h"
|
---|
30 | #include "OIDtools.h"
|
---|
31 |
|
---|
32 | // output_controls displays the detach, expand/contract contents,
|
---|
33 | // expand/contract text and highlighting/no highlighting buttons
|
---|
34 |
|
---|
35 | void output_controls (cgiargsclass &args, const text_tarray &ibuttons,
|
---|
36 | recptproto * /*collectproto*/, displayclass &disp,
|
---|
37 | outconvertclass &outconvert, ostream &textout,
|
---|
38 | ostream &/*logout*/) {
|
---|
39 |
|
---|
40 | if (args["u"] != "1") {
|
---|
41 |
|
---|
42 | FilterResponse_t response;
|
---|
43 | text_tarray metadata;
|
---|
44 | text_tarray buttons;
|
---|
45 |
|
---|
46 | text_tarray::const_iterator here = ibuttons.begin();
|
---|
47 | text_tarray::const_iterator end = ibuttons.end();
|
---|
48 |
|
---|
49 | while (here != end) {
|
---|
50 |
|
---|
51 | if (*here == "Detach")
|
---|
52 | buttons.push_back ("_document:imagedetach_");
|
---|
53 | else if (*here == "Highlight") {
|
---|
54 | if (args["hl"] == "1")
|
---|
55 | buttons.push_back ("_document:imagenohighlight_");
|
---|
56 | else
|
---|
57 | buttons.push_back ("_document:imagehighlight_");
|
---|
58 | } else if (*here == "Expand Contents") {
|
---|
59 | if (args["gc"] == "1")
|
---|
60 | buttons.push_back ("_document:imagecontracttoc_");
|
---|
61 | else
|
---|
62 | buttons.push_back ("_document:imageexpandtoc_");
|
---|
63 | } else if (*here == "Expand Text") {
|
---|
64 | if (args.getintarg("gt"))
|
---|
65 | buttons.push_back ("_document:imagecontracttext_");
|
---|
66 | else
|
---|
67 | buttons.push_back ("_document:imageexpandtext_");
|
---|
68 | }
|
---|
69 | here ++;
|
---|
70 | }
|
---|
71 |
|
---|
72 | here = buttons.begin();
|
---|
73 | end = buttons.end();
|
---|
74 | int count = 0;
|
---|
75 | while (here != end) {
|
---|
76 | if ((count != 0) && ((count % 2) == 0)) textout << "<br>\n";
|
---|
77 | textout << outconvert << disp << *here;
|
---|
78 | count ++;
|
---|
79 | here ++;
|
---|
80 | }
|
---|
81 | }
|
---|
82 | }
|
---|
83 |
|
---|
84 |
|
---|
85 | // at the moment this just writes out the html to display
|
---|
86 | // the cover image (assuming it's called cover.jpg)
|
---|
87 | // this whole thing should be done with a call to the collection
|
---|
88 | // server which would send a link to the cover image if there
|
---|
89 | // was one otherwise send title, author and stuff
|
---|
90 | void output_cover_image (cgiargsclass &args, recptproto * /*collectproto*/,
|
---|
91 | displayclass &disp, outconvertclass &outconvert,
|
---|
92 | ostream &textout, ostream &/*logout*/) {
|
---|
93 |
|
---|
94 | if (args["d"].empty()) return;
|
---|
95 |
|
---|
96 | textout << outconvert << disp <<
|
---|
97 | "<img src=\"_httpcollimg_/_thisOID_/cover.jpg\"><br>\n";
|
---|
98 | }
|
---|
99 |
|
---|
100 | void output_titles (cgiargsclass &args, recptproto *collectproto,
|
---|
101 | formatinfo_t &formatinfo, displayclass &disp,
|
---|
102 | outconvertclass &outconvert, ostream &textout,
|
---|
103 | ostream &logout) {
|
---|
104 |
|
---|
105 | if (args["d"].empty()) return;
|
---|
106 |
|
---|
107 | text_tset metadata;
|
---|
108 | bool getParents;
|
---|
109 | FilterResponse_t response;
|
---|
110 |
|
---|
111 | format_t *formatlistptr = new format_t();
|
---|
112 | parse_formatstring (formatinfo.DocumentHeading, formatlistptr, metadata, getParents);
|
---|
113 |
|
---|
114 | if (!get_info (args["d"], args["c"], metadata, getParents, collectproto, response, logout))
|
---|
115 | return;
|
---|
116 |
|
---|
117 | textout << outconvert << disp
|
---|
118 | << get_formatted_string (args["c"],collectproto,
|
---|
119 | response.docInfo[0], disp, formatlistptr,
|
---|
120 | logout);
|
---|
121 | }
|
---|
122 |
|
---|
123 |
|
---|
124 | static void recurse_contents (ResultDocInfo_t §ion, cgiargsclass &args, bool fulltoc,
|
---|
125 | browserclass *bptr, text_tset &metadata, bool &getParents,
|
---|
126 | format_t *formatlistptr, format_tmap &formatlistmap,
|
---|
127 | formatinfo_t &formatinfo, browsermapclass *browsermap,
|
---|
128 | int tabcount, recptproto *collectproto, displayclass &disp,
|
---|
129 | outconvertclass &outconvert, ostream &textout, ostream &logout) {
|
---|
130 | text_t formatstring;
|
---|
131 |
|
---|
132 | bool is_classify = false;
|
---|
133 | if (args["d"].empty() || fulltoc) is_classify = true;
|
---|
134 |
|
---|
135 | // output this section
|
---|
136 | bool use_table = is_table_content (formatlistptr);
|
---|
137 | tabcount += bptr->output_section_group (section, args, "", tabcount, formatlistptr, use_table,
|
---|
138 | metadata, getParents, collectproto, disp, outconvert,
|
---|
139 | textout, logout);
|
---|
140 |
|
---|
141 | text_t classification;
|
---|
142 | if (!is_classify) classification = "Document";
|
---|
143 | else get_top (args["cl"], classification);
|
---|
144 |
|
---|
145 | int haschildren = section.metadata["haschildren"].values[0].getint();
|
---|
146 | const text_t &doctype = section.metadata["doctype"].values[0];
|
---|
147 | text_t classifytype = section.metadata["childtype"].values[0];
|
---|
148 | // HLists and DateLists are displayed as VLists when contents
|
---|
149 | // are expanded, Paged documents are displayed as HLists
|
---|
150 | if (classifytype == "HList" || classifytype == "DateList") classifytype = "VList";
|
---|
151 | if (classifytype == "Paged") classifytype = "HList";
|
---|
152 |
|
---|
153 | // recurse through children
|
---|
154 | if ((haschildren == 1) && (!is_classify || fulltoc || doctype == "classify")) {
|
---|
155 |
|
---|
156 | // get browser for displaying children
|
---|
157 | bptr = browsermap->getbrowser (classifytype);
|
---|
158 | bptr->load_metadata_defaults (metadata);
|
---|
159 |
|
---|
160 | // get the formatstring if there is one
|
---|
161 | if (!get_formatstring (classification, classifytype,
|
---|
162 | formatinfo.formatstrings, formatstring))
|
---|
163 | formatstring = bptr->get_default_formatstring();
|
---|
164 |
|
---|
165 | format_tmap::const_iterator it = formatlistmap.find (formatstring);
|
---|
166 | // check if formatlistptr is cached
|
---|
167 | if (it != formatlistmap.end()) formatlistptr = (*it).second;
|
---|
168 | else {
|
---|
169 | formatlistptr = new format_t();
|
---|
170 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
171 | formatlistmap[formatstring] = formatlistptr;
|
---|
172 | }
|
---|
173 |
|
---|
174 | FilterResponse_t tmp;
|
---|
175 | get_children (section.OID, args["c"], metadata, getParents, collectproto, tmp, logout);
|
---|
176 | ResultDocInfo_tarray::iterator thisdoc = tmp.docInfo.begin();
|
---|
177 | ResultDocInfo_tarray::iterator lastdoc = tmp.docInfo.end();
|
---|
178 |
|
---|
179 | while (thisdoc != lastdoc) {
|
---|
180 | recurse_contents (*thisdoc, args, fulltoc, bptr, metadata, getParents,
|
---|
181 | formatlistptr, formatlistmap, formatinfo, browsermap,
|
---|
182 | tabcount, collectproto, disp, outconvert, textout, logout);
|
---|
183 | thisdoc ++;
|
---|
184 | }
|
---|
185 | }
|
---|
186 | }
|
---|
187 |
|
---|
188 |
|
---|
189 | // expanded_contents recurses through all contents. there's a special case
|
---|
190 | // for an HList when contents are expanded (i.e. it's displayed as a VList)
|
---|
191 | //
|
---|
192 | // if we're inside a document we expand all contents from the top,
|
---|
193 | // if we're at classification level we'll just expand out those contents below
|
---|
194 | // the current one
|
---|
195 |
|
---|
196 | void expanded_contents (cgiargsclass &args, int tabcount, bool fulltoc,
|
---|
197 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
198 | recptproto *collectproto, displayclass &disp,
|
---|
199 | outconvertclass &outconvert, ostream &textout,
|
---|
200 | ostream &logout) {
|
---|
201 |
|
---|
202 | if (args["d"].empty() && args["cl"].empty()) return;
|
---|
203 | text_t OID;
|
---|
204 |
|
---|
205 | FilterResponse_t response;
|
---|
206 | bool getParents = false;
|
---|
207 | text_tset metadata;
|
---|
208 | text_t classifytype, classification, formatstring;
|
---|
209 |
|
---|
210 | if (!args["d"].empty()) {
|
---|
211 | // document level
|
---|
212 | if (fulltoc) {
|
---|
213 | get_top (args["cl"], OID);
|
---|
214 | classification = OID;
|
---|
215 | }
|
---|
216 | else {
|
---|
217 | // always expand document level from top
|
---|
218 | get_top (args["d"], OID);
|
---|
219 | classification = "Document";
|
---|
220 | }
|
---|
221 | } else {
|
---|
222 | // classification level
|
---|
223 | OID = args["cl"];
|
---|
224 | get_top (args["cl"], classification);
|
---|
225 | }
|
---|
226 |
|
---|
227 | // get classifytype of this level
|
---|
228 | text_t tOID;
|
---|
229 | if (is_top(OID)) {
|
---|
230 | classifytype = "thistype";
|
---|
231 | tOID = OID;
|
---|
232 | } else {
|
---|
233 | classifytype = "childtype";
|
---|
234 | tOID = get_parent (OID);
|
---|
235 | }
|
---|
236 | metadata.insert (classifytype);
|
---|
237 |
|
---|
238 | if (!get_info (tOID, args["c"], metadata, getParents, collectproto, response, logout))
|
---|
239 | return;
|
---|
240 | classifytype = response.docInfo[0].metadata[classifytype].values[0];
|
---|
241 | // if we still don't have a classifytype we'll use the default
|
---|
242 | if (classifytype.empty()) {
|
---|
243 | browserclass *bptr = browsermap->get_default_browser ();
|
---|
244 | classifytype = bptr->get_browser_name ();
|
---|
245 | }
|
---|
246 |
|
---|
247 | // HLists are displayed as VLists when contents are expanded,
|
---|
248 | // Paged documents are displayed as HLists
|
---|
249 | if (classifytype == "HList") {
|
---|
250 | classifytype = "VList";
|
---|
251 | text_t pOID = get_parent (OID);
|
---|
252 | if (!pOID.empty()) {
|
---|
253 | OID = pOID;
|
---|
254 | // this is assuming that top levels are always 'Invisible' !!!
|
---|
255 | if (is_top (OID)) classifytype = "Invisible";
|
---|
256 | }
|
---|
257 | }
|
---|
258 | if (classifytype == "Paged") classifytype = "HList";
|
---|
259 |
|
---|
260 | metadata.erase (metadata.begin(), metadata.end());
|
---|
261 |
|
---|
262 | // metadata elements needed by recurse_contents
|
---|
263 | metadata.insert ("childtype");
|
---|
264 | metadata.insert ("doctype");
|
---|
265 | metadata.insert ("haschildren");
|
---|
266 |
|
---|
267 | // load up metadata array with browser defaults
|
---|
268 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
269 | bptr->load_metadata_defaults (metadata);
|
---|
270 |
|
---|
271 | // get the formatstring if there is one or use the browsers default
|
---|
272 | if (!get_formatstring (classification, classifytype,
|
---|
273 | formatinfo.formatstrings, formatstring))
|
---|
274 | formatstring = bptr->get_default_formatstring();
|
---|
275 |
|
---|
276 | format_t *formatlistptr = new format_t();
|
---|
277 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
278 |
|
---|
279 | // protocol call
|
---|
280 | if (!get_info (OID, args["c"], metadata, getParents, collectproto, response, logout))
|
---|
281 | return;
|
---|
282 |
|
---|
283 | format_tmap formatlistmap;
|
---|
284 | formatlistmap[formatstring] = formatlistptr;
|
---|
285 |
|
---|
286 | recurse_contents (response.docInfo[0], args, fulltoc, bptr, metadata,
|
---|
287 | getParents, formatlistptr, formatlistmap, formatinfo, browsermap,
|
---|
288 | tabcount, collectproto, disp, outconvert, textout, logout);
|
---|
289 |
|
---|
290 | // clean up format list pointers
|
---|
291 | format_tmap::const_iterator here = formatlistmap.begin();
|
---|
292 | format_tmap::const_iterator end = formatlistmap.end();
|
---|
293 | while (here != end) {
|
---|
294 | delete (*here).second;
|
---|
295 | here ++;
|
---|
296 | }
|
---|
297 | }
|
---|
298 |
|
---|
299 |
|
---|
300 | static void load_formatstring (const text_t &classifytype, text_tset &metadata,
|
---|
301 | bool &getParents, const text_t &classification,
|
---|
302 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
303 | format_tmap &formatlistmap) {
|
---|
304 | text_t formatstring;
|
---|
305 |
|
---|
306 | // load up metadata array with browser defaults
|
---|
307 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
308 | bptr->load_metadata_defaults (metadata);
|
---|
309 |
|
---|
310 | // get the formatstring if there is one or use the browsers default
|
---|
311 | if (!get_formatstring (classification, classifytype,
|
---|
312 | formatinfo.formatstrings, formatstring))
|
---|
313 | formatstring = bptr->get_default_formatstring();
|
---|
314 |
|
---|
315 | // see if it's cached
|
---|
316 | format_tmap::const_iterator it = formatlistmap.find (formatstring);
|
---|
317 | if (it == formatlistmap.end()) {
|
---|
318 | format_t *formatlistptr = new format_t();
|
---|
319 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
320 | formatlistmap[formatstring] = formatlistptr;
|
---|
321 | }
|
---|
322 | }
|
---|
323 |
|
---|
324 | static void load_formatstrings (FilterResponse_t &response, text_tset &metadata,
|
---|
325 | bool &getParents, const text_t &classification,
|
---|
326 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
327 | format_tmap &formatlistmap) {
|
---|
328 |
|
---|
329 | text_tset cache;
|
---|
330 |
|
---|
331 | ResultDocInfo_tarray::iterator thisdoc = response.docInfo.begin();
|
---|
332 | ResultDocInfo_tarray::iterator lastdoc = response.docInfo.end();
|
---|
333 |
|
---|
334 | while (thisdoc != lastdoc) {
|
---|
335 |
|
---|
336 | if (is_top ((*thisdoc).OID))
|
---|
337 | load_formatstring ((*thisdoc).metadata["thistype"].values[0], metadata,
|
---|
338 | getParents, classification, browsermap, formatinfo,
|
---|
339 | formatlistmap);
|
---|
340 |
|
---|
341 | text_t &childtype = (*thisdoc).metadata["childtype"].values[0];
|
---|
342 | text_tset::const_iterator it = cache.find (childtype);
|
---|
343 | if (it == cache.end()) {
|
---|
344 | load_formatstring (childtype, metadata, getParents, classification,
|
---|
345 | browsermap, formatinfo, formatlistmap);
|
---|
346 | cache.insert (childtype);
|
---|
347 | }
|
---|
348 | thisdoc ++;
|
---|
349 | }
|
---|
350 | }
|
---|
351 |
|
---|
352 | static void output_parents (FilterResponse_t &response, cgiargsclass &args,
|
---|
353 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
354 | format_tmap &formatlistmap, const text_t &classification,
|
---|
355 | int &tabcount, text_tset &metadata, bool &getParents,
|
---|
356 | recptproto *collectproto, displayclass &disp,
|
---|
357 | outconvertclass &outconvert, ostream &textout,
|
---|
358 | ostream &logout) {
|
---|
359 |
|
---|
360 | format_t *formatlistptr = NULL;
|
---|
361 | text_t classifytype, formatstring;
|
---|
362 | bool use_table, first = true;
|
---|
363 | ResultDocInfo_tarray::iterator thisparent = response.docInfo.begin();
|
---|
364 | ResultDocInfo_tarray::iterator lastparent = response.docInfo.end();
|
---|
365 | while (thisparent != lastparent) {
|
---|
366 |
|
---|
367 | // get classifytype of this level
|
---|
368 | if (is_top ((*thisparent).OID)) classifytype = (*thisparent).metadata["thistype"].values[0];
|
---|
369 | else if (!first) classifytype = (*(thisparent-1)).metadata["childtype"].values[0];
|
---|
370 |
|
---|
371 | // if we still don't have a classifytype we'll use the default
|
---|
372 | if (classifytype.empty()) {
|
---|
373 | browserclass *bptr = browsermap->get_default_browser ();
|
---|
374 | classifytype = bptr->get_browser_name ();
|
---|
375 | }
|
---|
376 |
|
---|
377 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
378 |
|
---|
379 | // get the formatstring if there is one or use the browsers default
|
---|
380 | if (!get_formatstring (classification, classifytype,
|
---|
381 | formatinfo.formatstrings, formatstring))
|
---|
382 | formatstring = bptr->get_default_formatstring();
|
---|
383 |
|
---|
384 | // see if it's cached
|
---|
385 | format_tmap::const_iterator it = formatlistmap.find (formatstring);
|
---|
386 | if (it != formatlistmap.end()) formatlistptr = (*it).second;
|
---|
387 | else {
|
---|
388 | logout << "browsetools error\n";
|
---|
389 | return;
|
---|
390 | }
|
---|
391 |
|
---|
392 | use_table = is_table_content (formatlistptr);
|
---|
393 | tabcount += bptr->output_section_group (*thisparent, args, "", tabcount, formatlistptr,
|
---|
394 | use_table, metadata, getParents, collectproto,
|
---|
395 | disp, outconvert, textout, logout);
|
---|
396 | first = false;
|
---|
397 | thisparent ++;
|
---|
398 | }
|
---|
399 | }
|
---|
400 |
|
---|
401 | void contracted_contents (cgiargsclass &args, int tabcount, bool fulltoc,
|
---|
402 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
403 | recptproto *collectproto, displayclass &disp,
|
---|
404 | outconvertclass &outconvert, ostream &textout,
|
---|
405 | ostream &logout) {
|
---|
406 |
|
---|
407 | FilterResponse_t response;
|
---|
408 | text_tset metadata;
|
---|
409 | bool getParents = false;
|
---|
410 | text_t formatstring;
|
---|
411 | text_tarray parents;
|
---|
412 | text_t OID = args["d"];
|
---|
413 | text_t classification = "Document";
|
---|
414 |
|
---|
415 | // if we're not outputting the TOC for a valid OID, then we should be giving
|
---|
416 | // the TOC of a classification
|
---|
417 | if (OID.empty()) {
|
---|
418 | OID = args["cl"];
|
---|
419 | get_top (OID, classification);
|
---|
420 | }
|
---|
421 | // if we're to give the full TOC of a document, get the parent for the whole
|
---|
422 | // document now
|
---|
423 | else if (fulltoc)
|
---|
424 | get_top (args["cl"], classification);
|
---|
425 |
|
---|
426 | bool haschildren = has_children (OID, args["c"], collectproto, logout);
|
---|
427 |
|
---|
428 | if ((!args["d"].empty()) && fulltoc)
|
---|
429 | get_parents_array (args["cl"] + ".fc", parents);
|
---|
430 | if (haschildren) get_parents_array (OID + ".fc", parents);
|
---|
431 | else get_parents_array (OID, parents);
|
---|
432 |
|
---|
433 | if (!parents.empty()) {
|
---|
434 | // get classifytypes of each parent
|
---|
435 | metadata.insert ("thistype");
|
---|
436 | metadata.insert ("childtype");
|
---|
437 |
|
---|
438 | if (!get_info (parents, args["c"], metadata, getParents, collectproto, response, logout))
|
---|
439 | return;
|
---|
440 |
|
---|
441 | // get formatstrings for all parents
|
---|
442 | format_tmap formatlistmap;
|
---|
443 | load_formatstrings (response, metadata, getParents, classification,
|
---|
444 | browsermap, formatinfo, formatlistmap);
|
---|
445 |
|
---|
446 | if (!get_info (parents, args["c"], metadata, getParents, collectproto, response, logout))
|
---|
447 | return;
|
---|
448 |
|
---|
449 | // display each parent
|
---|
450 | output_parents (response, args, browsermap, formatinfo, formatlistmap,
|
---|
451 | classification, tabcount, metadata, getParents,
|
---|
452 | collectproto, disp, outconvert, textout, logout);
|
---|
453 |
|
---|
454 | metadata.erase (metadata.begin(), metadata.end());
|
---|
455 |
|
---|
456 | // clean up cached format list pointers
|
---|
457 | format_tmap::const_iterator here = formatlistmap.begin();
|
---|
458 | format_tmap::const_iterator end = formatlistmap.end();
|
---|
459 | while (here != end) {
|
---|
460 | delete (*here).second;
|
---|
461 | here ++;
|
---|
462 | }
|
---|
463 | }
|
---|
464 |
|
---|
465 | // get childrens classifytype
|
---|
466 | text_t classifytype;
|
---|
467 | int numparents = response.docInfo.size();
|
---|
468 | if (!parents.empty())
|
---|
469 | classifytype = response.docInfo[numparents-1].metadata["childtype"].values[0];
|
---|
470 | else {
|
---|
471 | // use the default
|
---|
472 | browserclass *bptr = browsermap->get_default_browser ();
|
---|
473 | classifytype = bptr->get_browser_name ();
|
---|
474 | }
|
---|
475 |
|
---|
476 | // load up metadata array with browser defaults
|
---|
477 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
478 | bptr->load_metadata_defaults (metadata);
|
---|
479 |
|
---|
480 | // get the formatstring if there is one or use the browsers default
|
---|
481 | if (!get_formatstring (classification, classifytype,
|
---|
482 | formatinfo.formatstrings, formatstring))
|
---|
483 | formatstring = bptr->get_default_formatstring();
|
---|
484 |
|
---|
485 | format_t *formatlistptr = new format_t();
|
---|
486 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
487 |
|
---|
488 | if (haschildren)
|
---|
489 | get_children (OID, args["c"], metadata, getParents,
|
---|
490 | collectproto, response, logout);
|
---|
491 | else if (!is_top(OID)) {
|
---|
492 | get_children (OID + ".pr", args["c"], metadata, getParents,
|
---|
493 | collectproto, response, logout);
|
---|
494 | haschildren = true;
|
---|
495 | }
|
---|
496 |
|
---|
497 | // display children
|
---|
498 | if (haschildren) {
|
---|
499 | bool use_table = is_table_content (formatlistptr);
|
---|
500 | // collection used to be "" // **** // check with Stef!!!!
|
---|
501 | bptr->output_section_group (response, args, args["c"], tabcount, formatlistptr, use_table,
|
---|
502 | metadata, getParents, collectproto, disp, outconvert,
|
---|
503 | textout, logout);
|
---|
504 | }
|
---|
505 |
|
---|
506 | delete formatlistptr;
|
---|
507 | }
|
---|
508 |
|
---|
509 | /**
|
---|
510 | * This function outputs the contents of a classifier list to the reader -
|
---|
511 | * the document will in fact be empty, so this does the "real" output
|
---|
512 | */
|
---|
513 | void output_toc (cgiargsclass &args, browsermapclass *browsermap,
|
---|
514 | formatinfo_t &formatinfo, recptproto *collectproto,
|
---|
515 | displayclass &disp, outconvertclass &outconvert,
|
---|
516 | ostream &textout, ostream &logout) {
|
---|
517 |
|
---|
518 | int tabcount = 0;
|
---|
519 | bool havecontrols = false;
|
---|
520 | bool fulltoc = false;
|
---|
521 |
|
---|
522 | if (args["cl"] != "search") {
|
---|
523 | // see if there's a FullTOC string
|
---|
524 | text_t cl_top, full_toc;
|
---|
525 | get_top (args["cl"], cl_top);
|
---|
526 | if (get_formatstring (cl_top, "FullTOC", formatinfo.formatstrings, full_toc))
|
---|
527 | if (full_toc == "true") fulltoc = true;
|
---|
528 | }
|
---|
529 |
|
---|
530 | // get the cover image (if there is one) and the control buttons
|
---|
531 | // if we're inside a book
|
---|
532 | if ((!fulltoc) && (!args["d"].empty())) {
|
---|
533 | textout << "<center>\n";
|
---|
534 | textout << outconvert << disp << "<p><table width=_pagewidth_ cellpadding=0 cellspacing=0><tr>\n";
|
---|
535 | textout << "<td valign=top align=left";
|
---|
536 | if (formatinfo.DocumentContents) textout << " width=200>\n";
|
---|
537 | else textout << " width=100%>\n";
|
---|
538 | if (formatinfo.DocumentImages)
|
---|
539 | output_cover_image (args, collectproto, disp, outconvert, textout, logout);
|
---|
540 | else if (formatinfo.DocumentTitles)
|
---|
541 | output_titles (args, collectproto, formatinfo, disp, outconvert, textout, logout);
|
---|
542 | output_controls (args, formatinfo.DocumentButtons, collectproto, disp,
|
---|
543 | outconvert, textout, logout);
|
---|
544 | textout << "</td><td valign=top>\n";
|
---|
545 | havecontrols = true;
|
---|
546 | }
|
---|
547 |
|
---|
548 | if (formatinfo.DocumentContents || args["d"].empty()) {
|
---|
549 | if (args.getintarg("gc") == 1) {
|
---|
550 |
|
---|
551 | // expanded table of contents
|
---|
552 | expanded_contents (args, tabcount, fulltoc, browsermap, formatinfo,
|
---|
553 | collectproto, disp, outconvert, textout, logout);
|
---|
554 | } else {
|
---|
555 |
|
---|
556 | // contracted table of contents
|
---|
557 | contracted_contents (args, tabcount, fulltoc, browsermap, formatinfo,
|
---|
558 | collectproto, disp, outconvert, textout, logout);
|
---|
559 | }
|
---|
560 | }
|
---|
561 |
|
---|
562 | if (havecontrols) textout << "</td></tr></table></center>\n";
|
---|
563 | }
|
---|