source: trunk/protemix/src/recpt/browsetools.cpp@ 3207

Last change on this file since 3207 was 3207, checked in by sjboddie, 20 years ago

* empty log message *

  • Property svn:keywords set to Author Date Id Revision
File size: 26.8 KB
Line 
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 *
26 *********************************************************************/
27
28#include "browsetools.h"
29#include "OIDtools.h"
30
31// output_controls displays the detach, expand/contract contents,
32// expand/contract text and highlighting/no highlighting buttons
33
34void output_controls (cgiargsclass &args, const text_tarray &ibuttons,
35 recptproto *collectproto, displayclass &disp,
36 outconvertclass &outconvert, ostream &textout,
37 ostream &logout) {
38
39 FilterResponse_t response;
40 text_tset metadata;
41 metadata.insert("pdf");
42
43 if (!get_info (args["d"], args["c"], metadata, false, collectproto, response, logout)) return;
44
45 if (!response.docInfo[0].metadata["pdf"].values[0].empty()) {
46 textout << outconvert << disp << "_document:imagepagepdf_";
47 }
48
49 text_t top;
50 get_top (args["d"], top);
51 if (!get_info (top, args["c"], metadata, false, collectproto, response, logout)) return;
52 if (!response.docInfo[0].metadata["pdf"].values[0].empty()) {
53 textout << outconvert << disp << "_document:imagearticlepdf_";
54 }
55
56 textout << outconvert << disp
57 << "_document:imagedetach_";
58 if (args["hl"] == "1") {
59 textout << outconvert << disp << "_document:imagenohighlight_";
60 } else {
61 textout << outconvert << disp << "_document:imagehighlight_";
62 }
63}
64
65// at the moment this just writes out the html to display
66// the cover image (assuming it's called cover.jpg)
67// this whole thing should be done with a call to the collection
68// server which would send a link to the cover image if there
69// was one otherwise send title, author and stuff
70void output_cover_image (cgiargsclass &args, recptproto * /*collectproto*/,
71 displayclass &disp, outconvertclass &outconvert,
72 ostream &textout, ostream &/*logout*/) {
73
74 if (args["d"].empty()) return;
75
76 textout << outconvert << disp <<
77 "<img src=\"_httpcollimg_/_thisOID_/cover.jpg\"><br>\n";
78}
79
80void output_titles (cgiargsclass &args, recptproto *collectproto,
81 formatinfo_t &formatinfo, displayclass &disp,
82 outconvertclass &outconvert, ostream &textout,
83 ostream &logout) {
84
85 if (args["d"].empty()) return;
86
87 text_tset metadata;
88 bool getParents;
89 FilterResponse_t response;
90
91 format_t *formatlistptr = new format_t();
92 parse_formatstring (formatinfo.DocumentHeading, formatlistptr, metadata, getParents);
93
94 if (!get_info (args["d"], args["c"], metadata, getParents, collectproto, response, logout))
95 return;
96
97 textout << outconvert << disp
98 << get_formatted_string (args["c"],collectproto,
99 response.docInfo[0], disp, formatlistptr,
100 logout);
101}
102
103//this function outputs the related documents in the format specified
104//in the collection configuration file if the collection preferences
105//indicate they wish related documents to be displayed.
106void output_related_docs (cgiargsclass &args, recptproto *collectproto,
107 formatinfo_t &formatinfo, displayclass &disp,
108 outconvertclass &outconvert, ostream &textout,
109 ostream &logout) {
110
111 if (args["d"].empty()) return; //if no OID
112 if (args["rd"] != "1") return; //if preferences say no related documents
113
114 text_tset metadata;
115 bool getParents;
116 FilterResponse_t response;
117
118 //create new format pointer and parse the related doc format
119 //string specified in the collection config file
120 format_t *formatlistptr = new format_t();
121 parse_formatstring (formatinfo.RelatedDocuments, formatlistptr, metadata, getParents);
122
123 if (!get_info (args["d"], args["c"], metadata, getParents, collectproto, response, logout))
124 return;
125
126 //get the format string from formattools.cpp
127 text_t relateddocs = get_formatted_string (args["c"],collectproto, response.docInfo[0],
128 disp, formatlistptr, logout);
129 //output the related documents
130 textout << outconvert << disp << relateddocs;
131}
132
133
134
135static void recurse_contents (ResultDocInfo_t &section, cgiargsclass &args, bool fulltoc,
136 browserclass *bptr, text_tset &metadata, bool &getParents,
137 format_t *formatlistptr, format_tmap &formatlistmap,
138 formatinfo_t &formatinfo, browsermapclass *browsermap,
139 int tabcount, recptproto *collectproto, displayclass &disp,
140 outconvertclass &outconvert, ostream &textout, ostream &logout) {
141 text_t formatstring;
142
143 bool is_classify = false;
144 if (args["d"].empty() || fulltoc) is_classify = true;
145
146 // output this section
147 bool use_table = is_table_content (formatlistptr);
148 tabcount += bptr->output_section_group (section, args, "", tabcount, formatlistptr, use_table,
149 metadata, getParents, collectproto, disp, outconvert,
150 textout, logout);
151
152 text_t classification;
153 if (!is_classify) classification = "Document";
154 else get_top (args["cl"], classification);
155
156 int haschildren = section.metadata["haschildren"].values[0].getint();
157 const text_t &doctype = section.metadata["doctype"].values[0];
158 text_t classifytype = section.metadata["childtype"].values[0];
159 // HLists and DateLists are displayed as VLists when contents
160 // are expanded, Paged documents are displayed as HLists
161 if (classifytype == "HList" || classifytype == "DateList") classifytype = "VList";
162 if (classifytype == "Paged") classifytype = "HList";
163
164 // recurse through children
165 if ((haschildren == 1) && (!is_classify || fulltoc || doctype == "classify")) {
166
167 // get browser for displaying children
168 bptr = browsermap->getbrowser (classifytype);
169 bptr->load_metadata_defaults (metadata);
170
171 // get the formatstring if there is one
172 if (!get_formatstring (classification, classifytype,
173 formatinfo.formatstrings, formatstring))
174 formatstring = bptr->get_default_formatstring();
175
176 format_tmap::const_iterator it = formatlistmap.find (formatstring);
177 // check if formatlistptr is cached
178 if (it != formatlistmap.end()) formatlistptr = (*it).second;
179 else {
180 formatlistptr = new format_t();
181 parse_formatstring (formatstring, formatlistptr, metadata, getParents);
182 formatlistmap[formatstring] = formatlistptr;
183 }
184
185 FilterResponse_t tmp;
186 get_children (section.OID, args["c"], metadata, getParents, collectproto, tmp, logout);
187 ResultDocInfo_tarray::iterator thisdoc = tmp.docInfo.begin();
188 ResultDocInfo_tarray::iterator lastdoc = tmp.docInfo.end();
189
190 while (thisdoc != lastdoc) {
191 recurse_contents (*thisdoc, args, fulltoc, bptr, metadata, getParents,
192 formatlistptr, formatlistmap, formatinfo, browsermap,
193 tabcount, collectproto, disp, outconvert, textout, logout);
194 thisdoc ++;
195 }
196 }
197}
198
199
200// expanded_contents recurses through all contents. there's a special case
201// for an HList when contents are expanded (i.e. it's displayed as a VList)
202//
203// if we're inside a document we expand all contents from the top,
204// if we're at classification level we'll just expand out those contents below
205// the current one
206
207void expanded_contents (cgiargsclass &args, int tabcount, bool fulltoc,
208 browsermapclass *browsermap, formatinfo_t &formatinfo,
209 recptproto *collectproto, displayclass &disp,
210 outconvertclass &outconvert, ostream &textout,
211 ostream &logout) {
212
213 if (args["d"].empty() && args["cl"].empty()) return;
214 text_t OID;
215
216 FilterResponse_t response;
217 bool getParents = false;
218 text_tset metadata;
219 text_t classifytype, classification, formatstring;
220
221 if (!args["d"].empty()) {
222 // document level
223 if (fulltoc) {
224 get_top (args["cl"], OID);
225 classification = OID;
226 }
227 else {
228 // always expand document level from top
229 get_top (args["d"], OID);
230 classification = "Document";
231 }
232 } else {
233 // classification level
234 OID = args["cl"];
235 get_top (args["cl"], classification);
236 }
237
238 // get classifytype of this level
239 text_t tOID;
240 if (is_top(OID)) {
241 classifytype = "thistype";
242 tOID = OID;
243 } else {
244 classifytype = "childtype";
245 tOID = get_parent (OID);
246 }
247 metadata.insert (classifytype);
248
249 if (!get_info (tOID, args["c"], metadata, getParents, collectproto, response, logout))
250 return;
251 classifytype = response.docInfo[0].metadata[classifytype].values[0];
252 // if we still don't have a classifytype we'll use the default
253 if (classifytype.empty()) {
254 browserclass *bptr = browsermap->get_default_browser ();
255 classifytype = bptr->get_browser_name ();
256 }
257
258 // HLists are displayed as VLists when contents are expanded,
259 // Paged documents are displayed as HLists
260 if (classifytype == "HList") {
261 classifytype = "VList";
262 text_t pOID = get_parent (OID);
263 if (!pOID.empty()) {
264 OID = pOID;
265 // this is assuming that top levels are always 'Invisible' !!!
266 if (is_top (OID)) classifytype = "Invisible";
267 }
268 }
269 if (classifytype == "Paged") classifytype = "HList";
270
271 metadata.erase (metadata.begin(), metadata.end());
272
273 // metadata elements needed by recurse_contents
274 metadata.insert ("childtype");
275 metadata.insert ("doctype");
276 metadata.insert ("haschildren");
277
278 // load up metadata array with browser defaults
279 browserclass *bptr = browsermap->getbrowser (classifytype);
280 bptr->load_metadata_defaults (metadata);
281
282 // get the formatstring if there is one or use the browsers default
283 if (!get_formatstring (classification, classifytype,
284 formatinfo.formatstrings, formatstring))
285 formatstring = bptr->get_default_formatstring();
286
287 format_t *formatlistptr = new format_t();
288 parse_formatstring (formatstring, formatlistptr, metadata, getParents);
289
290 // protocol call
291 if (!get_info (OID, args["c"], metadata, getParents, collectproto, response, logout))
292 return;
293
294 format_tmap formatlistmap;
295 formatlistmap[formatstring] = formatlistptr;
296
297 recurse_contents (response.docInfo[0], args, fulltoc, bptr, metadata,
298 getParents, formatlistptr, formatlistmap, formatinfo, browsermap,
299 tabcount, collectproto, disp, outconvert, textout, logout);
300
301 // clean up format list pointers
302 format_tmap::const_iterator here = formatlistmap.begin();
303 format_tmap::const_iterator end = formatlistmap.end();
304 while (here != end) {
305 delete (*here).second;
306 here ++;
307 }
308}
309
310
311static void load_formatstring (const text_t &classifytype, text_tset &metadata,
312 bool &getParents, const text_t &classification,
313 browsermapclass *browsermap, formatinfo_t &formatinfo,
314 format_tmap &formatlistmap) {
315 text_t formatstring;
316
317 // load up metadata array with browser defaults
318 browserclass *bptr = browsermap->getbrowser (classifytype);
319 bptr->load_metadata_defaults (metadata);
320
321 // get the formatstring if there is one or use the browsers default
322 if (!get_formatstring (classification, classifytype,
323 formatinfo.formatstrings, formatstring))
324 formatstring = bptr->get_default_formatstring();
325
326 // see if it's cached
327 format_tmap::const_iterator it = formatlistmap.find (formatstring);
328 if (it == formatlistmap.end()) {
329 format_t *formatlistptr = new format_t();
330 parse_formatstring (formatstring, formatlistptr, metadata, getParents);
331 formatlistmap[formatstring] = formatlistptr;
332 }
333}
334
335static void load_formatstrings (FilterResponse_t &response, text_tset &metadata,
336 bool &getParents, const text_t &classification,
337 browsermapclass *browsermap, formatinfo_t &formatinfo,
338 format_tmap &formatlistmap) {
339
340 text_tset cache;
341
342 ResultDocInfo_tarray::iterator thisdoc = response.docInfo.begin();
343 ResultDocInfo_tarray::iterator lastdoc = response.docInfo.end();
344
345 while (thisdoc != lastdoc) {
346
347 if (is_top ((*thisdoc).OID))
348 load_formatstring ((*thisdoc).metadata["thistype"].values[0], metadata,
349 getParents, classification, browsermap, formatinfo,
350 formatlistmap);
351
352 text_t &childtype = (*thisdoc).metadata["childtype"].values[0];
353 text_tset::const_iterator it = cache.find (childtype);
354 if (it == cache.end()) {
355 load_formatstring (childtype, metadata, getParents, classification,
356 browsermap, formatinfo, formatlistmap);
357 cache.insert (childtype);
358 }
359 thisdoc ++;
360 }
361}
362
363static void output_parents (FilterResponse_t &response, cgiargsclass &args,
364 browsermapclass *browsermap, formatinfo_t &formatinfo,
365 format_tmap &formatlistmap, const text_t &classification,
366 int &tabcount, text_tset &metadata, bool &getParents,
367 recptproto *collectproto, displayclass &disp,
368 outconvertclass &outconvert, ostream &textout,
369 ostream &logout) {
370
371 format_t *formatlistptr = NULL;
372 text_t classifytype, formatstring;
373 bool use_table, first = true;
374 ResultDocInfo_tarray::iterator thisparent = response.docInfo.begin();
375 ResultDocInfo_tarray::iterator lastparent = response.docInfo.end();
376 while (thisparent != lastparent) {
377
378 // get classifytype of this level
379 if (is_top ((*thisparent).OID)) classifytype = (*thisparent).metadata["thistype"].values[0];
380 else if (!first) classifytype = (*(thisparent-1)).metadata["childtype"].values[0];
381
382 // if we still don't have a classifytype we'll use the default
383 if (classifytype.empty()) {
384 browserclass *bptr = browsermap->get_default_browser ();
385 classifytype = bptr->get_browser_name ();
386 }
387
388 browserclass *bptr = browsermap->getbrowser (classifytype);
389
390 // get the formatstring if there is one or use the browsers default
391 if (!get_formatstring (classification, classifytype,
392 formatinfo.formatstrings, formatstring))
393 formatstring = bptr->get_default_formatstring();
394
395 // see if it's cached
396 format_tmap::const_iterator it = formatlistmap.find (formatstring);
397 if (it != formatlistmap.end()) formatlistptr = (*it).second;
398 else {
399 logout << "browsetools error\n";
400 return;
401 }
402
403 use_table = is_table_content (formatlistptr);
404 tabcount += bptr->output_section_group (*thisparent, args, "", tabcount, formatlistptr,
405 use_table, metadata, getParents, collectproto,
406 disp, outconvert, textout, logout);
407 first = false;
408 thisparent ++;
409 }
410}
411
412void contracted_contents (cgiargsclass &args, int tabcount, bool fulltoc,
413 browsermapclass *browsermap, formatinfo_t &formatinfo,
414 recptproto *collectproto, displayclass &disp,
415 outconvertclass &outconvert, ostream &textout,
416 ostream &logout) {
417
418 FilterResponse_t response;
419 text_tset metadata;
420 bool getParents = false;
421 text_t formatstring;
422 text_tarray parents;
423 text_t OID = args["d"];
424 text_t classification = "Document";
425
426 // if we're not outputting the TOC for a valid OID, then we should be giving
427 // the TOC of a classification
428 if (OID.empty()) {
429 OID = args["cl"];
430 get_top (OID, classification);
431 }
432 // if we're to give the full TOC of a document, get the parent for the whole
433 // document now
434 else if (fulltoc)
435 get_top (args["cl"], classification);
436
437 bool haschildren = has_children (OID, args["c"], collectproto, logout);
438
439 if ((!args["d"].empty()) && fulltoc)
440 get_parents_array (args["cl"] + ".fc", parents);
441 if (haschildren) get_parents_array (OID + ".fc", parents);
442 else get_parents_array (OID, parents);
443
444 if (!parents.empty()) {
445 // get classifytypes of each parent
446 metadata.insert ("thistype");
447 metadata.insert ("childtype");
448
449 if (!get_info (parents, args["c"], metadata, getParents, collectproto, response, logout))
450 return;
451
452 // get formatstrings for all parents
453 format_tmap formatlistmap;
454 load_formatstrings (response, metadata, getParents, classification,
455 browsermap, formatinfo, formatlistmap);
456
457 if (!get_info (parents, args["c"], metadata, getParents, collectproto, response, logout))
458 return;
459
460 // display each parent
461 output_parents (response, args, browsermap, formatinfo, formatlistmap,
462 classification, tabcount, metadata, getParents,
463 collectproto, disp, outconvert, textout, logout);
464
465 metadata.erase (metadata.begin(), metadata.end());
466
467 // clean up cached format list pointers
468 format_tmap::const_iterator here = formatlistmap.begin();
469 format_tmap::const_iterator end = formatlistmap.end();
470 while (here != end) {
471 delete (*here).second;
472 here ++;
473 }
474 }
475
476 // get childrens classifytype
477 text_t classifytype;
478 int numparents = response.docInfo.size();
479 if (!parents.empty())
480 classifytype = response.docInfo[numparents-1].metadata["childtype"].values[0];
481 else {
482 // use the default
483 browserclass *bptr = browsermap->get_default_browser ();
484 classifytype = bptr->get_browser_name ();
485 }
486
487 // load up metadata array with browser defaults
488 browserclass *bptr = browsermap->getbrowser (classifytype);
489 bptr->load_metadata_defaults (metadata);
490
491 // get the formatstring if there is one or use the browsers default
492 if (!get_formatstring (classification, classifytype,
493 formatinfo.formatstrings, formatstring))
494 formatstring = bptr->get_default_formatstring();
495
496 format_t *formatlistptr = new format_t();
497 parse_formatstring (formatstring, formatlistptr, metadata, getParents);
498
499 if (haschildren)
500 get_children (OID, args["c"], metadata, getParents,
501 collectproto, response, logout);
502 else if (!is_top(OID)) {
503 get_children (OID + ".pr", args["c"], metadata, getParents,
504 collectproto, response, logout);
505 haschildren = true;
506 }
507
508 // display children
509 if (haschildren) {
510 bool use_table = is_table_content (formatlistptr);
511 // collection used to be "" // **** // check with Stef!!!!
512 bptr->output_section_group (response, args, args["c"], tabcount, formatlistptr, use_table,
513 metadata, getParents, collectproto, disp, outconvert,
514 textout, logout);
515 }
516 delete formatlistptr;
517}
518
519/**
520 * This function outputs contents of a classifier to the reader
521 * including parent levels
522 */
523void expand_show_contents (cgiargsclass &args, int tabcount, bool fulltoc,
524 browsermapclass *browsermap, formatinfo_t &formatinfo,
525 recptproto *collectproto, displayclass &disp,
526 outconvertclass &outconvert, ostream &textout,
527 ostream &logout)
528{
529
530 int coloffset = 0;
531 text_tarray parents;
532 FilterResponse_t response;
533 text_t OID = args["d"];
534 if (OID.empty()) OID = args["cl"];
535
536 bool haschildren = has_children (OID, args["c"], collectproto, logout);
537
538 // get parents list
539 if (!is_top(OID)) get_parents_array (OID, parents);
540 if (args["d"].empty() || haschildren || parents.empty())
541 parents.push_back(OID);
542
543 // if inside a book top title is needed
544 if (!args["d"].empty()) {
545
546 coloffset = 1;
547 text_t classification, classifytype, formatstring, topOID = parents[0];
548 text_tset metadata;
549 format_t *formatlistptr = new format_t();
550 bool use_table, getParents = false;
551
552 get_top (args["cl"], classification);
553
554 // getting information about top OID
555 metadata.insert ("thistype");
556
557 get_info ( topOID, args["c"], metadata, getParents, collectproto, response, logout);
558 if (!response.docInfo[0].metadata["thistype"].values.empty())
559 classifytype = response.docInfo[0].metadata["thistype"].values[0];
560
561 browserclass *bptr = browsermap->getbrowser (classifytype);
562
563 if (classifytype.empty()) {
564 bptr = browsermap->get_default_browser();
565 }
566
567 // get the formatstring if there is one or use the browsers default
568 if (!get_formatstring (classification, classifytype,
569 formatinfo.formatstrings, formatstring))
570 formatstring = bptr->get_default_formatstring();
571
572 parse_formatstring (formatstring, formatlistptr, metadata, getParents);
573
574 metadata.insert ("doctype");
575 metadata.insert ("haschildren");
576
577 get_info (topOID, args["c"], metadata, getParents, collectproto, response, logout);
578
579 // ouput top OID section
580 use_table = is_table_content (formatlistptr);
581 bptr->output_section_group (response.docInfo[0], args, "", tabcount, formatlistptr, use_table,
582 metadata, getParents, collectproto, disp, outconvert, textout, logout);
583
584 }
585
586 recurse_contents_levels (parents, args, coloffset, tabcount, fulltoc, browsermap,
587 formatinfo, collectproto, disp, outconvert, textout, logout);
588
589 textout << "</table></td></tr></table>\n";
590}
591
592void recurse_contents_levels (text_tarray &parents,
593 cgiargsclass &args, int coloffset, int tabcount, bool fulltoc,
594 browsermapclass *browsermap, formatinfo_t &formatinfo,
595 recptproto *collectproto, displayclass &disp,
596 outconvertclass &outconvert, ostream &textout,
597 ostream &logout)
598{
599 FilterResponse_t response;
600 text_tset metadata;
601 text_t OID, formatstring, classification, classifytype;;
602 bool use_table, getParents = false;
603 int haschildren = 0;
604 format_t *formatlistptr = new format_t();
605
606 // display children for last level
607 if (tabcount == (parents.size() - 1)) {
608
609 logout << "@@@lastlevel@@@\n";
610 // setting metadata fields
611 metadata.insert ("thistype");
612 metadata.insert ("childtype");
613 metadata.insert ("haschildren");
614
615 OID = parents[tabcount];
616 get_info (OID, args["c"], metadata, getParents, collectproto, response, logout);
617 get_top (OID, classification);
618
619 if (!response.docInfo.empty())
620 haschildren = response.docInfo[0].metadata["haschildren"].values[0].getint();
621
622 // get childrens classifytype
623 if (!response.docInfo.empty())
624 classifytype = response.docInfo[0].metadata["childtype"].values[0];
625 else {
626 // use the default
627 browserclass *bptr = browsermap->get_default_browser ();
628 classifytype = bptr->get_browser_name ();
629 }
630
631 // load up metadata array with browser defaults
632 browserclass *bptr = browsermap->getbrowser (classifytype);
633 bptr->load_metadata_defaults (metadata);
634
635 // get the formatstring if there is one or use the browsers default
636 if (!get_formatstring (classification, classifytype,
637 formatinfo.formatstrings, formatstring))
638 formatstring = bptr->get_default_formatstring();
639
640 parse_formatstring (formatstring, formatlistptr, metadata, getParents);
641
642 if (haschildren)
643 get_children (OID, args["c"], metadata, getParents,
644 collectproto, response, logout);
645 else if (!is_top(OID)) {
646 get_children (OID + ".pr", args["c"], metadata, getParents,
647 collectproto, response, logout);
648 haschildren = true;
649 }
650
651 // display children
652 if (haschildren) {
653 use_table = is_table_content (formatlistptr);
654 bptr->output_section_group (response, args, args["c"], coloffset + tabcount, formatlistptr, use_table,
655 metadata, getParents, collectproto, disp, outconvert,
656 textout, logout);
657 }
658
659 } else {
660
661 text_t pOID;
662 OID = parents[tabcount];
663 get_top (OID, classification);
664
665 // load metadata fields
666 metadata.insert ("thistype");
667 metadata.insert ("childtype");
668 metadata.insert ("haschildren");
669 metadata.insert ("doctype");
670
671 if (tabcount) pOID = parents[tabcount-1];
672 else pOID = OID;
673 get_info (pOID, args["c"], metadata, getParents, collectproto, response, logout);
674
675 // get classifytype of this level
676 if (is_top (pOID)) classifytype = response.docInfo[0].metadata["childtype"].values[0];
677 else classifytype = response.docInfo[0].metadata["thistype"].values[0];
678
679 // if we still don't have a classifytype we'll use the default
680 if (classifytype.empty()) {
681 browserclass *bptr = browsermap->get_default_browser ();
682 classifytype = bptr->get_browser_name ();
683 }
684
685 browserclass *bptr = browsermap->getbrowser (classifytype);
686
687 // get the formatstring if there is one or use the browsers default
688 if (!get_formatstring (classification, classifytype,
689 formatinfo.formatstrings, formatstring))
690 formatstring = bptr->get_default_formatstring();
691
692
693 // parse format string
694 parse_formatstring (formatstring, formatlistptr, metadata, getParents);
695
696 use_table = is_table_content (formatlistptr);
697
698 get_children (OID, args["c"], metadata, getParents, collectproto, response, logout);
699
700 ResultDocInfo_tarray::iterator thissibling = response.docInfo.begin();
701 ResultDocInfo_tarray::iterator lastsibling = response.docInfo.end();
702
703 while (thissibling != lastsibling) {
704
705 logout << "@@@level:@@@" << tabcount << "\n";
706
707 bptr->output_section_group (*thissibling, args, args["c"], coloffset + tabcount, formatlistptr,
708 use_table, metadata, getParents, collectproto,
709 disp, outconvert, textout, logout);
710
711 if ((*thissibling).OID == parents[tabcount+1]) {
712 recurse_contents_levels (parents, args, coloffset, tabcount+1, fulltoc, browsermap,
713 formatinfo, collectproto, disp, outconvert,textout, logout);
714 }
715
716 thissibling ++;
717 }
718 }
719 delete formatlistptr;
720}
721
722/**
723 * This function outputs the contents of a classifier list to the reader -
724 * the document will in fact be empty, so this does the "real" output
725 */
726void output_toc (cgiargsclass &args, browsermapclass *browsermap,
727 formatinfo_t &formatinfo, recptproto *collectproto,
728 displayclass &disp, outconvertclass &outconvert,
729 ostream &textout, ostream &logout) {
730
731 int tabcount = 0;
732 bool havecontrols = false;
733 bool fulltoc = false;
734
735 if (args["cl"] != "search") {
736 // see if there's a FullTOC string
737 text_t cl_top, full_toc;
738 get_top (args["cl"], cl_top);
739 if (get_formatstring (cl_top, "FullTOC", formatinfo.formatstrings, full_toc))
740 if (full_toc == "true") fulltoc = true;
741 }
742
743 // get the cover image (if there is one) and the control buttons
744 // if we're inside a book
745 if ((!fulltoc) && (!args["d"].empty())) {
746 textout << "<center>\n";
747 textout << outconvert << disp
748 << "<p><table width=\"638\" cellpadding=\"0\" cellspacing=\"0\">\n"
749 << "<tr valign=\"top\">\n"
750 << "<td>\n";
751 output_titles (args, collectproto, formatinfo, disp, outconvert, textout, logout);
752 textout << "</td></tr>\n"
753 << "<tr><td>\n";
754 havecontrols = true;
755 }
756
757 if (formatinfo.DocumentContents || args["d"].empty()) {
758 if (args.getintarg("gc") == 1) {
759
760 // expanded table of contents
761 expanded_contents (args, tabcount, fulltoc, browsermap, formatinfo,
762 collectproto, disp, outconvert, textout, logout);
763 } else if (args.getintarg("gc") == 2) {
764
765 // expand visible levels of table of contents
766 expand_show_contents(args, tabcount, fulltoc, browsermap, formatinfo,
767 collectproto, disp, outconvert, textout, logout);
768 } else {
769
770 // contracted table of contents
771 contracted_contents (args, tabcount, fulltoc, browsermap, formatinfo,
772 collectproto, disp, outconvert, textout, logout);
773 }
774 }
775
776 if (havecontrols) {
777 textout << "</td></tr>\n"
778 << "<tr><td>\n";
779 output_controls (args, formatinfo.DocumentButtons, collectproto, disp,
780 outconvert, textout, logout);
781 textout << "</td></tr></table></center>\n";
782 }
783}
784
Note: See TracBrowser for help on using the repository browser.