[649] | 1 |
|
---|
[208] | 2 | /**********************************************************************
|
---|
| 3 | *
|
---|
| 4 | * browsetools.cpp --
|
---|
| 5 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
| 6 | *
|
---|
[533] | 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.
|
---|
[208] | 10 | *
|
---|
[533] | 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 | *
|
---|
[1860] | 25 | * $Id: browsetools.cpp 11131 2006-01-26 23:47:40Z jrm21 $
|
---|
| 26 | *
|
---|
[208] | 27 | *********************************************************************/
|
---|
| 28 |
|
---|
| 29 | #include "browsetools.h"
|
---|
[213] | 30 | #include "OIDtools.h"
|
---|
[4972] | 31 | #include "gsdlunicode.h"
|
---|
[208] | 32 |
|
---|
[7061] | 33 | #if defined(GSDL_USE_IOS_H)
|
---|
| 34 | # if defined(__WIN32__)
|
---|
| 35 | # include <strstrea.h> // vc4
|
---|
| 36 | # else
|
---|
| 37 | # include <strstream.h>
|
---|
| 38 | # endif
|
---|
| 39 | #else
|
---|
| 40 | # include <sstream>
|
---|
| 41 | #endif
|
---|
[4972] | 42 |
|
---|
| 43 |
|
---|
[1079] | 44 | // output_controls displays the detach, expand/contract contents,
|
---|
| 45 | // expand/contract text and highlighting/no highlighting buttons
|
---|
| 46 |
|
---|
| 47 | void output_controls (cgiargsclass &args, const text_tarray &ibuttons,
|
---|
| 48 | recptproto * /*collectproto*/, displayclass &disp,
|
---|
| 49 | outconvertclass &outconvert, ostream &textout,
|
---|
| 50 | ostream &/*logout*/) {
|
---|
| 51 |
|
---|
| 52 | if (args["u"] != "1") {
|
---|
| 53 |
|
---|
| 54 | FilterResponse_t response;
|
---|
| 55 | text_tarray metadata;
|
---|
| 56 | text_tarray buttons;
|
---|
| 57 |
|
---|
| 58 | text_tarray::const_iterator here = ibuttons.begin();
|
---|
| 59 | text_tarray::const_iterator end = ibuttons.end();
|
---|
| 60 |
|
---|
| 61 | while (here != end) {
|
---|
| 62 |
|
---|
| 63 | if (*here == "Detach")
|
---|
| 64 | buttons.push_back ("_document:imagedetach_");
|
---|
| 65 | else if (*here == "Highlight") {
|
---|
| 66 | if (args["hl"] == "1")
|
---|
| 67 | buttons.push_back ("_document:imagenohighlight_");
|
---|
| 68 | else
|
---|
| 69 | buttons.push_back ("_document:imagehighlight_");
|
---|
| 70 | } else if (*here == "Expand Contents") {
|
---|
| 71 | if (args["gc"] == "1")
|
---|
| 72 | buttons.push_back ("_document:imagecontracttoc_");
|
---|
| 73 | else
|
---|
| 74 | buttons.push_back ("_document:imageexpandtoc_");
|
---|
| 75 | } else if (*here == "Expand Text") {
|
---|
| 76 | if (args.getintarg("gt"))
|
---|
| 77 | buttons.push_back ("_document:imagecontracttext_");
|
---|
| 78 | else
|
---|
| 79 | buttons.push_back ("_document:imageexpandtext_");
|
---|
| 80 | }
|
---|
[9620] | 81 | ++here;
|
---|
[1079] | 82 | }
|
---|
| 83 |
|
---|
| 84 | here = buttons.begin();
|
---|
| 85 | end = buttons.end();
|
---|
| 86 | while (here != end) {
|
---|
| 87 | textout << outconvert << disp << *here;
|
---|
[9620] | 88 | ++here;
|
---|
[1079] | 89 | }
|
---|
| 90 | }
|
---|
| 91 | }
|
---|
| 92 |
|
---|
[4936] | 93 | text_t get_cover_image () {
|
---|
| 94 | return "_httpcollimg_/{Or}{[parent(Top):archivedir],[archivedir]}/cover.jpg";
|
---|
| 95 | }
|
---|
[1079] | 96 |
|
---|
| 97 | // at the moment this just writes out the html to display
|
---|
| 98 | // the cover image (assuming it's called cover.jpg)
|
---|
| 99 | // this whole thing should be done with a call to the collection
|
---|
| 100 | // server which would send a link to the cover image if there
|
---|
| 101 | // was one otherwise send title, author and stuff
|
---|
| 102 | void output_cover_image (cgiargsclass &args, recptproto * /*collectproto*/,
|
---|
| 103 | displayclass &disp, outconvertclass &outconvert,
|
---|
| 104 | ostream &textout, ostream &/*logout*/) {
|
---|
| 105 |
|
---|
| 106 | if (args["d"].empty()) return;
|
---|
| 107 |
|
---|
[11131] | 108 | textout << outconvert << disp << "<img alt=\"\" onError=\"src='_httpimg_/blank.gif'\" src=\"_httpcollimg_/_thisOID_/cover.jpg\">\n";
|
---|
[1079] | 109 | }
|
---|
| 110 |
|
---|
| 111 | void output_titles (cgiargsclass &args, recptproto *collectproto,
|
---|
[4972] | 112 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
| 113 | displayclass &disp, outconvertclass &outconvert,
|
---|
| 114 | ostream &textout, ostream &logout) {
|
---|
[1079] | 115 |
|
---|
| 116 | if (args["d"].empty()) return;
|
---|
| 117 |
|
---|
| 118 | text_tset metadata;
|
---|
| 119 | bool getParents;
|
---|
| 120 | FilterResponse_t response;
|
---|
| 121 |
|
---|
| 122 | format_t *formatlistptr = new format_t();
|
---|
| 123 | parse_formatstring (formatinfo.DocumentHeading, formatlistptr, metadata, getParents);
|
---|
| 124 |
|
---|
[7432] | 125 | if (!get_info (args["d"], args["c"], args["l"], metadata, getParents, collectproto, response, logout))
|
---|
[1079] | 126 | return;
|
---|
| 127 |
|
---|
[4972] | 128 | text_tmap options;
|
---|
| 129 | if (formatinfo.AllowExtendedOptions) {
|
---|
| 130 | load_extended_options(options, args, browsermap, formatinfo,
|
---|
| 131 | collectproto, disp, outconvert, logout);
|
---|
| 132 | }
|
---|
[1443] | 133 | textout << outconvert << disp
|
---|
[4906] | 134 | << get_formatted_string (args["c"],collectproto, response.docInfo[0], disp,
|
---|
| 135 | formatlistptr, options, logout);
|
---|
[1079] | 136 | }
|
---|
| 137 |
|
---|
[1941] | 138 | //this function outputs the related documents in the format specified
|
---|
| 139 | //in the collection configuration file if the collection preferences
|
---|
| 140 | //indicate they wish related documents to be displayed.
|
---|
| 141 | void output_related_docs (cgiargsclass &args, recptproto *collectproto,
|
---|
| 142 | formatinfo_t &formatinfo, displayclass &disp,
|
---|
| 143 | outconvertclass &outconvert, ostream &textout,
|
---|
| 144 | ostream &logout) {
|
---|
[1079] | 145 |
|
---|
[1941] | 146 | if (args["d"].empty()) return; //if no OID
|
---|
| 147 | if (args["rd"] != "1") return; //if preferences say no related documents
|
---|
| 148 |
|
---|
| 149 | text_tset metadata;
|
---|
| 150 | bool getParents;
|
---|
| 151 | FilterResponse_t response;
|
---|
| 152 |
|
---|
| 153 | //create new format pointer and parse the related doc format
|
---|
| 154 | //string specified in the collection config file
|
---|
| 155 | format_t *formatlistptr = new format_t();
|
---|
| 156 | parse_formatstring (formatinfo.RelatedDocuments, formatlistptr, metadata, getParents);
|
---|
| 157 |
|
---|
[7432] | 158 | if (!get_info (args["d"], args["c"], args["l"], metadata, getParents, collectproto, response, logout))
|
---|
[1941] | 159 | return;
|
---|
| 160 |
|
---|
| 161 | //get the format string from formattools.cpp
|
---|
[4906] | 162 | text_tmap options; // no options
|
---|
[1941] | 163 | text_t relateddocs = get_formatted_string (args["c"],collectproto, response.docInfo[0],
|
---|
[4906] | 164 | disp, formatlistptr, options, logout);
|
---|
[1941] | 165 | //output the related documents
|
---|
| 166 | textout << outconvert << disp << relateddocs;
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 |
|
---|
| 170 |
|
---|
[737] | 171 | static void recurse_contents (ResultDocInfo_t §ion, cgiargsclass &args, bool fulltoc,
|
---|
[649] | 172 | browserclass *bptr, text_tset &metadata, bool &getParents,
|
---|
| 173 | format_t *formatlistptr, format_tmap &formatlistmap,
|
---|
[1079] | 174 | formatinfo_t &formatinfo, browsermapclass *browsermap,
|
---|
[737] | 175 | int tabcount, recptproto *collectproto, displayclass &disp,
|
---|
[649] | 176 | outconvertclass &outconvert, ostream &textout, ostream &logout) {
|
---|
| 177 | text_t formatstring;
|
---|
[419] | 178 |
|
---|
[649] | 179 | bool is_classify = false;
|
---|
[737] | 180 | if (args["d"].empty() || fulltoc) is_classify = true;
|
---|
[404] | 181 |
|
---|
[649] | 182 | // output this section
|
---|
| 183 | bool use_table = is_table_content (formatlistptr);
|
---|
[4867] | 184 | tabcount += bptr->output_section_group (section, args, args["c"], tabcount, formatlistptr, use_table,
|
---|
[737] | 185 | metadata, getParents, collectproto, disp, outconvert,
|
---|
| 186 | textout, logout);
|
---|
[404] | 187 |
|
---|
[649] | 188 | text_t classification;
|
---|
| 189 | if (!is_classify) classification = "Document";
|
---|
[737] | 190 | else get_top (args["cl"], classification);
|
---|
[404] | 191 |
|
---|
[649] | 192 | int haschildren = section.metadata["haschildren"].values[0].getint();
|
---|
| 193 | const text_t &doctype = section.metadata["doctype"].values[0];
|
---|
[730] | 194 | text_t classifytype = section.metadata["childtype"].values[0];
|
---|
[737] | 195 | // HLists and DateLists are displayed as VLists when contents
|
---|
| 196 | // are expanded, Paged documents are displayed as HLists
|
---|
| 197 | if (classifytype == "HList" || classifytype == "DateList") classifytype = "VList";
|
---|
[667] | 198 | if (classifytype == "Paged") classifytype = "HList";
|
---|
[404] | 199 |
|
---|
[649] | 200 | // recurse through children
|
---|
[737] | 201 | if ((haschildren == 1) && (!is_classify || fulltoc || doctype == "classify")) {
|
---|
[404] | 202 |
|
---|
[649] | 203 | // get browser for displaying children
|
---|
| 204 | bptr = browsermap->getbrowser (classifytype);
|
---|
| 205 | bptr->load_metadata_defaults (metadata);
|
---|
[404] | 206 |
|
---|
[649] | 207 | // get the formatstring if there is one
|
---|
[1079] | 208 | if (!get_formatstring (classification, classifytype,
|
---|
| 209 | formatinfo.formatstrings, formatstring))
|
---|
[649] | 210 | formatstring = bptr->get_default_formatstring();
|
---|
[404] | 211 |
|
---|
[649] | 212 | format_tmap::const_iterator it = formatlistmap.find (formatstring);
|
---|
| 213 | // check if formatlistptr is cached
|
---|
| 214 | if (it != formatlistmap.end()) formatlistptr = (*it).second;
|
---|
| 215 | else {
|
---|
| 216 | formatlistptr = new format_t();
|
---|
| 217 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
| 218 | formatlistmap[formatstring] = formatlistptr;
|
---|
[469] | 219 | }
|
---|
[213] | 220 |
|
---|
[649] | 221 | FilterResponse_t tmp;
|
---|
[7432] | 222 | get_children (section.OID, args["c"], args["l"], metadata, getParents, collectproto, tmp, logout);
|
---|
[649] | 223 | ResultDocInfo_tarray::iterator thisdoc = tmp.docInfo.begin();
|
---|
| 224 | ResultDocInfo_tarray::iterator lastdoc = tmp.docInfo.end();
|
---|
[444] | 225 |
|
---|
[649] | 226 | while (thisdoc != lastdoc) {
|
---|
[737] | 227 | recurse_contents (*thisdoc, args, fulltoc, bptr, metadata, getParents,
|
---|
[1079] | 228 | formatlistptr, formatlistmap, formatinfo, browsermap,
|
---|
[737] | 229 | tabcount, collectproto, disp, outconvert, textout, logout);
|
---|
[9620] | 230 | ++thisdoc;
|
---|
[213] | 231 | }
|
---|
| 232 | }
|
---|
| 233 | }
|
---|
| 234 |
|
---|
[257] | 235 |
|
---|
[649] | 236 | // expanded_contents recurses through all contents. there's a special case
|
---|
| 237 | // for an HList when contents are expanded (i.e. it's displayed as a VList)
|
---|
| 238 | //
|
---|
| 239 | // if we're inside a document we expand all contents from the top,
|
---|
| 240 | // if we're at classification level we'll just expand out those contents below
|
---|
| 241 | // the current one
|
---|
[344] | 242 |
|
---|
[1079] | 243 | void expanded_contents (cgiargsclass &args, int tabcount, bool fulltoc,
|
---|
| 244 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
| 245 | recptproto *collectproto, displayclass &disp,
|
---|
| 246 | outconvertclass &outconvert, ostream &textout,
|
---|
| 247 | ostream &logout) {
|
---|
[248] | 248 |
|
---|
[649] | 249 | if (args["d"].empty() && args["cl"].empty()) return;
|
---|
| 250 | text_t OID;
|
---|
| 251 |
|
---|
| 252 | FilterResponse_t response;
|
---|
[404] | 253 | bool getParents = false;
|
---|
[649] | 254 | text_tset metadata;
|
---|
| 255 | text_t classifytype, classification, formatstring;
|
---|
[213] | 256 |
|
---|
[649] | 257 | if (!args["d"].empty()) {
|
---|
[737] | 258 | // document level
|
---|
| 259 | if (fulltoc) {
|
---|
| 260 | get_top (args["cl"], OID);
|
---|
| 261 | classification = OID;
|
---|
| 262 | }
|
---|
| 263 | else {
|
---|
| 264 | // always expand document level from top
|
---|
| 265 | get_top (args["d"], OID);
|
---|
| 266 | classification = "Document";
|
---|
| 267 | }
|
---|
[649] | 268 | } else {
|
---|
| 269 | // classification level
|
---|
| 270 | OID = args["cl"];
|
---|
| 271 | get_top (args["cl"], classification);
|
---|
[624] | 272 | }
|
---|
| 273 |
|
---|
[649] | 274 | // get classifytype of this level
|
---|
| 275 | text_t tOID;
|
---|
| 276 | if (is_top(OID)) {
|
---|
| 277 | classifytype = "thistype";
|
---|
| 278 | tOID = OID;
|
---|
[419] | 279 | } else {
|
---|
[649] | 280 | classifytype = "childtype";
|
---|
| 281 | tOID = get_parent (OID);
|
---|
[419] | 282 | }
|
---|
[649] | 283 | metadata.insert (classifytype);
|
---|
[344] | 284 |
|
---|
[7432] | 285 | if (!get_info (tOID, args["c"], args["l"], metadata, getParents, collectproto, response, logout))
|
---|
[649] | 286 | return;
|
---|
| 287 | classifytype = response.docInfo[0].metadata[classifytype].values[0];
|
---|
| 288 | // if we still don't have a classifytype we'll use the default
|
---|
| 289 | if (classifytype.empty()) {
|
---|
| 290 | browserclass *bptr = browsermap->get_default_browser ();
|
---|
| 291 | classifytype = bptr->get_browser_name ();
|
---|
[257] | 292 | }
|
---|
| 293 |
|
---|
[649] | 294 | // HLists are displayed as VLists when contents are expanded,
|
---|
[730] | 295 | // Paged documents are displayed as HLists
|
---|
[778] | 296 | if (classifytype == "HList") {
|
---|
| 297 | classifytype = "VList";
|
---|
| 298 | text_t pOID = get_parent (OID);
|
---|
| 299 | if (!pOID.empty()) {
|
---|
| 300 | OID = pOID;
|
---|
| 301 | // this is assuming that top levels are always 'Invisible' !!!
|
---|
| 302 | if (is_top (OID)) classifytype = "Invisible";
|
---|
| 303 | }
|
---|
| 304 | }
|
---|
[730] | 305 | if (classifytype == "Paged") classifytype = "HList";
|
---|
[213] | 306 |
|
---|
[649] | 307 | metadata.erase (metadata.begin(), metadata.end());
|
---|
| 308 |
|
---|
| 309 | // metadata elements needed by recurse_contents
|
---|
[730] | 310 | metadata.insert ("childtype");
|
---|
[649] | 311 | metadata.insert ("doctype");
|
---|
| 312 | metadata.insert ("haschildren");
|
---|
[419] | 313 |
|
---|
[649] | 314 | // load up metadata array with browser defaults
|
---|
| 315 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
| 316 | bptr->load_metadata_defaults (metadata);
|
---|
[624] | 317 |
|
---|
[649] | 318 | // get the formatstring if there is one or use the browsers default
|
---|
[1079] | 319 | if (!get_formatstring (classification, classifytype,
|
---|
| 320 | formatinfo.formatstrings, formatstring))
|
---|
[649] | 321 | formatstring = bptr->get_default_formatstring();
|
---|
[419] | 322 |
|
---|
[649] | 323 | format_t *formatlistptr = new format_t();
|
---|
| 324 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
[624] | 325 |
|
---|
[649] | 326 | // protocol call
|
---|
[7432] | 327 | if (!get_info (OID, args["c"], args["l"], metadata, getParents, collectproto, response, logout))
|
---|
[649] | 328 | return;
|
---|
[624] | 329 |
|
---|
[649] | 330 | format_tmap formatlistmap;
|
---|
| 331 | formatlistmap[formatstring] = formatlistptr;
|
---|
[624] | 332 |
|
---|
[737] | 333 | recurse_contents (response.docInfo[0], args, fulltoc, bptr, metadata,
|
---|
[1079] | 334 | getParents, formatlistptr, formatlistmap, formatinfo, browsermap,
|
---|
[737] | 335 | tabcount, collectproto, disp, outconvert, textout, logout);
|
---|
[624] | 336 |
|
---|
[649] | 337 | // clean up format list pointers
|
---|
| 338 | format_tmap::const_iterator here = formatlistmap.begin();
|
---|
| 339 | format_tmap::const_iterator end = formatlistmap.end();
|
---|
| 340 | while (here != end) {
|
---|
| 341 | delete (*here).second;
|
---|
[9620] | 342 | ++here;
|
---|
[419] | 343 | }
|
---|
| 344 | }
|
---|
| 345 |
|
---|
[667] | 346 |
|
---|
[649] | 347 | static void load_formatstring (const text_t &classifytype, text_tset &metadata,
|
---|
| 348 | bool &getParents, const text_t &classification,
|
---|
[1079] | 349 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
[649] | 350 | format_tmap &formatlistmap) {
|
---|
| 351 | text_t formatstring;
|
---|
[419] | 352 |
|
---|
[649] | 353 | // load up metadata array with browser defaults
|
---|
| 354 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
| 355 | bptr->load_metadata_defaults (metadata);
|
---|
[419] | 356 |
|
---|
[649] | 357 | // get the formatstring if there is one or use the browsers default
|
---|
[1079] | 358 | if (!get_formatstring (classification, classifytype,
|
---|
| 359 | formatinfo.formatstrings, formatstring))
|
---|
[649] | 360 | formatstring = bptr->get_default_formatstring();
|
---|
[419] | 361 |
|
---|
[649] | 362 | // see if it's cached
|
---|
| 363 | format_tmap::const_iterator it = formatlistmap.find (formatstring);
|
---|
| 364 | if (it == formatlistmap.end()) {
|
---|
| 365 | format_t *formatlistptr = new format_t();
|
---|
| 366 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
| 367 | formatlistmap[formatstring] = formatlistptr;
|
---|
[419] | 368 | }
|
---|
[208] | 369 | }
|
---|
[213] | 370 |
|
---|
[649] | 371 | static void load_formatstrings (FilterResponse_t &response, text_tset &metadata,
|
---|
| 372 | bool &getParents, const text_t &classification,
|
---|
[1079] | 373 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
[649] | 374 | format_tmap &formatlistmap) {
|
---|
[213] | 375 |
|
---|
[649] | 376 | text_tset cache;
|
---|
[419] | 377 |
|
---|
[649] | 378 | ResultDocInfo_tarray::iterator thisdoc = response.docInfo.begin();
|
---|
| 379 | ResultDocInfo_tarray::iterator lastdoc = response.docInfo.end();
|
---|
[419] | 380 |
|
---|
[649] | 381 | while (thisdoc != lastdoc) {
|
---|
[667] | 382 |
|
---|
[10567] | 383 | if (is_top ((*thisdoc).OID)) {
|
---|
[667] | 384 | load_formatstring ((*thisdoc).metadata["thistype"].values[0], metadata,
|
---|
[1079] | 385 | getParents, classification, browsermap, formatinfo,
|
---|
[667] | 386 | formatlistmap);
|
---|
[10567] | 387 | }
|
---|
| 388 |
|
---|
| 389 | // sometimes childtype is not set - why??
|
---|
| 390 | if ((*thisdoc).metadata.find("childtype") != (*thisdoc).metadata.end()) {
|
---|
| 391 | text_t &childtype = (*thisdoc).metadata["childtype"].values[0];
|
---|
[667] | 392 |
|
---|
[10567] | 393 | text_tset::const_iterator it = cache.find (childtype);
|
---|
| 394 | if (it == cache.end()) {
|
---|
| 395 | load_formatstring (childtype, metadata, getParents, classification,
|
---|
| 396 | browsermap, formatinfo, formatlistmap);
|
---|
| 397 | cache.insert (childtype);
|
---|
| 398 | }
|
---|
[649] | 399 | }
|
---|
[9620] | 400 | ++thisdoc;
|
---|
[419] | 401 | }
|
---|
| 402 | }
|
---|
| 403 |
|
---|
[667] | 404 | static void output_parents (FilterResponse_t &response, cgiargsclass &args,
|
---|
[1079] | 405 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
[667] | 406 | format_tmap &formatlistmap, const text_t &classification,
|
---|
[737] | 407 | int &tabcount, text_tset &metadata, bool &getParents,
|
---|
[667] | 408 | recptproto *collectproto, displayclass &disp,
|
---|
[688] | 409 | outconvertclass &outconvert, ostream &textout,
|
---|
[667] | 410 | ostream &logout) {
|
---|
[419] | 411 |
|
---|
[667] | 412 | format_t *formatlistptr = NULL;
|
---|
| 413 | text_t classifytype, formatstring;
|
---|
| 414 | bool use_table, first = true;
|
---|
| 415 | ResultDocInfo_tarray::iterator thisparent = response.docInfo.begin();
|
---|
| 416 | ResultDocInfo_tarray::iterator lastparent = response.docInfo.end();
|
---|
| 417 | while (thisparent != lastparent) {
|
---|
| 418 |
|
---|
| 419 | // get classifytype of this level
|
---|
| 420 | if (is_top ((*thisparent).OID)) classifytype = (*thisparent).metadata["thistype"].values[0];
|
---|
[10567] | 421 | else if (!first && (*(thisparent-1)).metadata.find("childtype") != (*(thisparent-1)).metadata.end()) classifytype = (*(thisparent-1)).metadata["childtype"].values[0];
|
---|
[667] | 422 |
|
---|
| 423 | // if we still don't have a classifytype we'll use the default
|
---|
| 424 | if (classifytype.empty()) {
|
---|
| 425 | browserclass *bptr = browsermap->get_default_browser ();
|
---|
| 426 | classifytype = bptr->get_browser_name ();
|
---|
| 427 | }
|
---|
| 428 |
|
---|
| 429 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
| 430 |
|
---|
| 431 | // get the formatstring if there is one or use the browsers default
|
---|
[1079] | 432 | if (!get_formatstring (classification, classifytype,
|
---|
| 433 | formatinfo.formatstrings, formatstring))
|
---|
[667] | 434 | formatstring = bptr->get_default_formatstring();
|
---|
| 435 |
|
---|
| 436 | // see if it's cached
|
---|
| 437 | format_tmap::const_iterator it = formatlistmap.find (formatstring);
|
---|
| 438 | if (it != formatlistmap.end()) formatlistptr = (*it).second;
|
---|
| 439 | else {
|
---|
| 440 | logout << "browsetools error\n";
|
---|
| 441 | return;
|
---|
| 442 | }
|
---|
| 443 |
|
---|
| 444 | use_table = is_table_content (formatlistptr);
|
---|
[748] | 445 | tabcount += bptr->output_section_group (*thisparent, args, "", tabcount, formatlistptr,
|
---|
[737] | 446 | use_table, metadata, getParents, collectproto,
|
---|
| 447 | disp, outconvert, textout, logout);
|
---|
[667] | 448 | first = false;
|
---|
[9620] | 449 | ++thisparent;
|
---|
[667] | 450 | }
|
---|
| 451 | }
|
---|
| 452 |
|
---|
[1079] | 453 | void contracted_contents (cgiargsclass &args, int tabcount, bool fulltoc,
|
---|
| 454 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
| 455 | recptproto *collectproto, displayclass &disp,
|
---|
| 456 | outconvertclass &outconvert, ostream &textout,
|
---|
| 457 | ostream &logout) {
|
---|
[914] | 458 |
|
---|
[257] | 459 | FilterResponse_t response;
|
---|
[649] | 460 | text_tset metadata;
|
---|
| 461 | bool getParents = false;
|
---|
[667] | 462 | text_t formatstring;
|
---|
[649] | 463 | text_tarray parents;
|
---|
| 464 | text_t OID = args["d"];
|
---|
| 465 | text_t classification = "Document";
|
---|
[1860] | 466 |
|
---|
| 467 | // if we're not outputting the TOC for a valid OID, then we should be giving
|
---|
| 468 | // the TOC of a classification
|
---|
[667] | 469 | if (OID.empty()) {
|
---|
| 470 | OID = args["cl"];
|
---|
| 471 | get_top (OID, classification);
|
---|
[1860] | 472 | }
|
---|
| 473 | // if we're to give the full TOC of a document, get the parent for the whole
|
---|
| 474 | // document now
|
---|
| 475 | else if (fulltoc)
|
---|
[737] | 476 | get_top (args["cl"], classification);
|
---|
[257] | 477 |
|
---|
[7432] | 478 | bool haschildren = has_children (OID, args["c"], args["l"], collectproto, logout);
|
---|
[257] | 479 |
|
---|
[737] | 480 | if ((!args["d"].empty()) && fulltoc)
|
---|
| 481 | get_parents_array (args["cl"] + ".fc", parents);
|
---|
[649] | 482 | if (haschildren) get_parents_array (OID + ".fc", parents);
|
---|
| 483 | else get_parents_array (OID, parents);
|
---|
[279] | 484 |
|
---|
[667] | 485 | if (!parents.empty()) {
|
---|
| 486 | // get classifytypes of each parent
|
---|
| 487 | metadata.insert ("thistype");
|
---|
| 488 | metadata.insert ("childtype");
|
---|
| 489 |
|
---|
[7432] | 490 | if (!get_info (parents, args["c"], args["l"], metadata, getParents, collectproto, response, logout))
|
---|
[667] | 491 | return;
|
---|
| 492 |
|
---|
| 493 | // get formatstrings for all parents
|
---|
| 494 | format_tmap formatlistmap;
|
---|
| 495 | load_formatstrings (response, metadata, getParents, classification,
|
---|
[1079] | 496 | browsermap, formatinfo, formatlistmap);
|
---|
[213] | 497 |
|
---|
[7432] | 498 | if (!get_info (parents, args["c"], args["l"], metadata, getParents, collectproto, response, logout))
|
---|
[667] | 499 | return;
|
---|
| 500 |
|
---|
| 501 | // display each parent
|
---|
[1079] | 502 | output_parents (response, args, browsermap, formatinfo, formatlistmap,
|
---|
[737] | 503 | classification, tabcount, metadata, getParents,
|
---|
[667] | 504 | collectproto, disp, outconvert, textout, logout);
|
---|
| 505 |
|
---|
| 506 | metadata.erase (metadata.begin(), metadata.end());
|
---|
| 507 |
|
---|
| 508 | // clean up cached format list pointers
|
---|
| 509 | format_tmap::const_iterator here = formatlistmap.begin();
|
---|
| 510 | format_tmap::const_iterator end = formatlistmap.end();
|
---|
| 511 | while (here != end) {
|
---|
| 512 | delete (*here).second;
|
---|
[9620] | 513 | ++here;
|
---|
[667] | 514 | }
|
---|
| 515 | }
|
---|
[257] | 516 |
|
---|
[667] | 517 | // get childrens classifytype
|
---|
| 518 | text_t classifytype;
|
---|
| 519 | int numparents = response.docInfo.size();
|
---|
[10567] | 520 | if (!parents.empty() && (response.docInfo[numparents-1].metadata.find("childtype") != response.docInfo[numparents-1].metadata.end()))
|
---|
[667] | 521 | classifytype = response.docInfo[numparents-1].metadata["childtype"].values[0];
|
---|
| 522 | else {
|
---|
| 523 | // use the default
|
---|
| 524 | browserclass *bptr = browsermap->get_default_browser ();
|
---|
| 525 | classifytype = bptr->get_browser_name ();
|
---|
| 526 | }
|
---|
| 527 |
|
---|
| 528 | // load up metadata array with browser defaults
|
---|
| 529 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
| 530 | bptr->load_metadata_defaults (metadata);
|
---|
[213] | 531 |
|
---|
[7193] | 532 | if (classifytype == "DateList") {
|
---|
[10981] | 533 | text_t datelist = args["dm"];
|
---|
| 534 | text_tarray dates;
|
---|
| 535 | splitchar(datelist.begin(), datelist.end(), ',', dates);
|
---|
| 536 | text_tarray::iterator begin = dates.begin();
|
---|
| 537 | text_tarray::iterator end = dates.end();
|
---|
| 538 | while (begin!= end) {
|
---|
| 539 | metadata.insert(*begin);
|
---|
| 540 | begin++;
|
---|
| 541 | }
|
---|
| 542 | //metadata.insert(args["dm"]);
|
---|
[7193] | 543 | }
|
---|
| 544 |
|
---|
[667] | 545 | // get the formatstring if there is one or use the browsers default
|
---|
[1079] | 546 | if (!get_formatstring (classification, classifytype,
|
---|
| 547 | formatinfo.formatstrings, formatstring))
|
---|
[667] | 548 | formatstring = bptr->get_default_formatstring();
|
---|
| 549 |
|
---|
| 550 | format_t *formatlistptr = new format_t();
|
---|
| 551 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
| 552 |
|
---|
| 553 | if (haschildren)
|
---|
[7432] | 554 | get_children (OID, args["c"], args["l"], metadata, getParents,
|
---|
[667] | 555 | collectproto, response, logout);
|
---|
[941] | 556 | else if (!is_top(OID)) {
|
---|
[7432] | 557 | get_children (OID + ".pr", args["c"], args["l"], metadata, getParents,
|
---|
[667] | 558 | collectproto, response, logout);
|
---|
[941] | 559 | haschildren = true;
|
---|
| 560 | }
|
---|
[667] | 561 |
|
---|
| 562 | // display children
|
---|
[941] | 563 | if (haschildren) {
|
---|
| 564 | bool use_table = is_table_content (formatlistptr);
|
---|
[1443] | 565 | bptr->output_section_group (response, args, args["c"], tabcount, formatlistptr, use_table,
|
---|
[941] | 566 | metadata, getParents, collectproto, disp, outconvert,
|
---|
| 567 | textout, logout);
|
---|
| 568 | }
|
---|
[667] | 569 | delete formatlistptr;
|
---|
[213] | 570 | }
|
---|
| 571 |
|
---|
[1860] | 572 | /**
|
---|
[2805] | 573 | * This function outputs contents of a classifier to the reader
|
---|
| 574 | * including parent levels
|
---|
| 575 | */
|
---|
| 576 | void expand_show_contents (cgiargsclass &args, int tabcount, bool fulltoc,
|
---|
| 577 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
| 578 | recptproto *collectproto, displayclass &disp,
|
---|
| 579 | outconvertclass &outconvert, ostream &textout,
|
---|
| 580 | ostream &logout)
|
---|
| 581 | {
|
---|
| 582 |
|
---|
| 583 | int coloffset = 0;
|
---|
| 584 | text_tarray parents;
|
---|
| 585 | FilterResponse_t response;
|
---|
| 586 | text_t OID = args["d"];
|
---|
| 587 | if (OID.empty()) OID = args["cl"];
|
---|
| 588 |
|
---|
[7432] | 589 | bool haschildren = has_children (OID, args["c"], args["l"], collectproto, logout);
|
---|
[2805] | 590 |
|
---|
| 591 | // get parents list
|
---|
| 592 | if (!is_top(OID)) get_parents_array (OID, parents);
|
---|
| 593 | if (args["d"].empty() || haschildren || parents.empty())
|
---|
| 594 | parents.push_back(OID);
|
---|
| 595 |
|
---|
| 596 | // if inside a book top title is needed
|
---|
| 597 | if (!args["d"].empty()) {
|
---|
| 598 |
|
---|
| 599 | coloffset = 1;
|
---|
| 600 | text_t classification, classifytype, formatstring, topOID = parents[0];
|
---|
| 601 | text_tset metadata;
|
---|
| 602 | format_t *formatlistptr = new format_t();
|
---|
| 603 | bool use_table, getParents = false;
|
---|
| 604 |
|
---|
| 605 | get_top (args["cl"], classification);
|
---|
| 606 |
|
---|
| 607 | // getting information about top OID
|
---|
| 608 | metadata.insert ("thistype");
|
---|
| 609 |
|
---|
[7432] | 610 | get_info ( topOID, args["c"], args["l"], metadata, getParents, collectproto, response, logout);
|
---|
[2805] | 611 | if (!response.docInfo[0].metadata["thistype"].values.empty())
|
---|
| 612 | classifytype = response.docInfo[0].metadata["thistype"].values[0];
|
---|
| 613 |
|
---|
| 614 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
| 615 |
|
---|
| 616 | if (classifytype.empty()) {
|
---|
| 617 | bptr = browsermap->get_default_browser();
|
---|
| 618 | }
|
---|
| 619 |
|
---|
| 620 | // get the formatstring if there is one or use the browsers default
|
---|
| 621 | if (!get_formatstring (classification, classifytype,
|
---|
| 622 | formatinfo.formatstrings, formatstring))
|
---|
| 623 | formatstring = bptr->get_default_formatstring();
|
---|
| 624 |
|
---|
| 625 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
| 626 |
|
---|
| 627 | metadata.insert ("doctype");
|
---|
| 628 | metadata.insert ("haschildren");
|
---|
| 629 |
|
---|
[7432] | 630 | get_info (topOID, args["c"], args["l"], metadata, getParents, collectproto, response, logout);
|
---|
[2805] | 631 |
|
---|
| 632 | // ouput top OID section
|
---|
| 633 | use_table = is_table_content (formatlistptr);
|
---|
| 634 | bptr->output_section_group (response.docInfo[0], args, "", tabcount, formatlistptr, use_table,
|
---|
| 635 | metadata, getParents, collectproto, disp, outconvert, textout, logout);
|
---|
| 636 |
|
---|
| 637 | }
|
---|
| 638 |
|
---|
| 639 | recurse_contents_levels (parents, args, coloffset, tabcount, fulltoc, browsermap,
|
---|
| 640 | formatinfo, collectproto, disp, outconvert, textout, logout);
|
---|
| 641 |
|
---|
[10553] | 642 | // This messes things up when gc = 2 and doesn't seem to matter otherwise. By Richard Managh
|
---|
| 643 | // textout << outconvert << "</table></td></tr></table>\n";
|
---|
[2805] | 644 | }
|
---|
| 645 |
|
---|
| 646 | void recurse_contents_levels (text_tarray &parents,
|
---|
| 647 | cgiargsclass &args, int coloffset, int tabcount, bool fulltoc,
|
---|
| 648 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
| 649 | recptproto *collectproto, displayclass &disp,
|
---|
| 650 | outconvertclass &outconvert, ostream &textout,
|
---|
| 651 | ostream &logout)
|
---|
| 652 | {
|
---|
| 653 | FilterResponse_t response;
|
---|
| 654 | text_tset metadata;
|
---|
| 655 | text_t OID, formatstring, classification, classifytype;;
|
---|
| 656 | bool use_table, getParents = false;
|
---|
| 657 | int haschildren = 0;
|
---|
| 658 | format_t *formatlistptr = new format_t();
|
---|
| 659 |
|
---|
| 660 | // display children for last level
|
---|
| 661 | if (tabcount == (parents.size() - 1)) {
|
---|
| 662 |
|
---|
| 663 | logout << "@@@lastlevel@@@\n";
|
---|
| 664 | // setting metadata fields
|
---|
| 665 | metadata.insert ("thistype");
|
---|
| 666 | metadata.insert ("childtype");
|
---|
| 667 | metadata.insert ("haschildren");
|
---|
| 668 |
|
---|
| 669 | OID = parents[tabcount];
|
---|
[7432] | 670 | get_info (OID, args["c"], args["l"], metadata, getParents, collectproto, response, logout);
|
---|
[2805] | 671 | get_top (OID, classification);
|
---|
| 672 |
|
---|
| 673 | if (!response.docInfo.empty())
|
---|
| 674 | haschildren = response.docInfo[0].metadata["haschildren"].values[0].getint();
|
---|
| 675 |
|
---|
| 676 | // get childrens classifytype
|
---|
| 677 | if (!response.docInfo.empty())
|
---|
| 678 | classifytype = response.docInfo[0].metadata["childtype"].values[0];
|
---|
| 679 | else {
|
---|
| 680 | // use the default
|
---|
| 681 | browserclass *bptr = browsermap->get_default_browser ();
|
---|
| 682 | classifytype = bptr->get_browser_name ();
|
---|
| 683 | }
|
---|
| 684 |
|
---|
| 685 | // load up metadata array with browser defaults
|
---|
| 686 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
| 687 | bptr->load_metadata_defaults (metadata);
|
---|
| 688 |
|
---|
| 689 | // get the formatstring if there is one or use the browsers default
|
---|
| 690 | if (!get_formatstring (classification, classifytype,
|
---|
| 691 | formatinfo.formatstrings, formatstring))
|
---|
| 692 | formatstring = bptr->get_default_formatstring();
|
---|
| 693 |
|
---|
| 694 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
| 695 |
|
---|
| 696 | if (haschildren)
|
---|
[7432] | 697 | get_children (OID, args["c"], args["l"], metadata, getParents,
|
---|
[2805] | 698 | collectproto, response, logout);
|
---|
| 699 | else if (!is_top(OID)) {
|
---|
[7432] | 700 | get_children (OID + ".pr", args["c"], args["l"], metadata, getParents,
|
---|
[2805] | 701 | collectproto, response, logout);
|
---|
| 702 | haschildren = true;
|
---|
| 703 | }
|
---|
| 704 |
|
---|
| 705 | // display children
|
---|
| 706 | if (haschildren) {
|
---|
| 707 | use_table = is_table_content (formatlistptr);
|
---|
| 708 | bptr->output_section_group (response, args, args["c"], coloffset + tabcount, formatlistptr, use_table,
|
---|
| 709 | metadata, getParents, collectproto, disp, outconvert,
|
---|
| 710 | textout, logout);
|
---|
| 711 | }
|
---|
| 712 |
|
---|
| 713 | } else {
|
---|
| 714 |
|
---|
| 715 | text_t pOID;
|
---|
| 716 | OID = parents[tabcount];
|
---|
| 717 | get_top (OID, classification);
|
---|
| 718 |
|
---|
| 719 | // load metadata fields
|
---|
| 720 | metadata.insert ("thistype");
|
---|
| 721 | metadata.insert ("childtype");
|
---|
| 722 | metadata.insert ("haschildren");
|
---|
| 723 | metadata.insert ("doctype");
|
---|
| 724 |
|
---|
| 725 | if (tabcount) pOID = parents[tabcount-1];
|
---|
| 726 | else pOID = OID;
|
---|
[7432] | 727 | get_info (pOID, args["c"], args["l"], metadata, getParents, collectproto, response, logout);
|
---|
[2805] | 728 |
|
---|
| 729 | // get classifytype of this level
|
---|
| 730 | if (is_top (pOID)) classifytype = response.docInfo[0].metadata["childtype"].values[0];
|
---|
| 731 | else classifytype = response.docInfo[0].metadata["thistype"].values[0];
|
---|
| 732 |
|
---|
| 733 | // if we still don't have a classifytype we'll use the default
|
---|
| 734 | if (classifytype.empty()) {
|
---|
| 735 | browserclass *bptr = browsermap->get_default_browser ();
|
---|
| 736 | classifytype = bptr->get_browser_name ();
|
---|
| 737 | }
|
---|
| 738 |
|
---|
| 739 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
| 740 |
|
---|
| 741 | // get the formatstring if there is one or use the browsers default
|
---|
| 742 | if (!get_formatstring (classification, classifytype,
|
---|
| 743 | formatinfo.formatstrings, formatstring))
|
---|
| 744 | formatstring = bptr->get_default_formatstring();
|
---|
| 745 |
|
---|
| 746 |
|
---|
| 747 | // parse format string
|
---|
| 748 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
| 749 |
|
---|
| 750 | use_table = is_table_content (formatlistptr);
|
---|
| 751 |
|
---|
[7432] | 752 | get_children (OID, args["c"], args["l"], metadata, getParents, collectproto, response, logout);
|
---|
[2805] | 753 |
|
---|
| 754 | ResultDocInfo_tarray::iterator thissibling = response.docInfo.begin();
|
---|
| 755 | ResultDocInfo_tarray::iterator lastsibling = response.docInfo.end();
|
---|
| 756 |
|
---|
| 757 | while (thissibling != lastsibling) {
|
---|
| 758 |
|
---|
| 759 | logout << "@@@level:@@@" << tabcount << "\n";
|
---|
| 760 |
|
---|
| 761 | bptr->output_section_group (*thissibling, args, args["c"], coloffset + tabcount, formatlistptr,
|
---|
| 762 | use_table, metadata, getParents, collectproto,
|
---|
| 763 | disp, outconvert, textout, logout);
|
---|
| 764 |
|
---|
| 765 | if ((*thissibling).OID == parents[tabcount+1]) {
|
---|
| 766 | recurse_contents_levels (parents, args, coloffset, tabcount+1, fulltoc, browsermap,
|
---|
| 767 | formatinfo, collectproto, disp, outconvert,textout, logout);
|
---|
| 768 | }
|
---|
| 769 |
|
---|
[9620] | 770 | ++thissibling;
|
---|
[2805] | 771 | }
|
---|
| 772 | }
|
---|
| 773 | delete formatlistptr;
|
---|
| 774 | }
|
---|
| 775 |
|
---|
| 776 | /**
|
---|
[1860] | 777 | * This function outputs the contents of a classifier list to the reader -
|
---|
| 778 | * the document will in fact be empty, so this does the "real" output
|
---|
| 779 | */
|
---|
[649] | 780 | void output_toc (cgiargsclass &args, browsermapclass *browsermap,
|
---|
[1079] | 781 | formatinfo_t &formatinfo, recptproto *collectproto,
|
---|
[649] | 782 | displayclass &disp, outconvertclass &outconvert,
|
---|
| 783 | ostream &textout, ostream &logout) {
|
---|
[344] | 784 |
|
---|
[4983] | 785 | if (!args["d"].empty() && formatinfo.AllowExtendedOptions) {
|
---|
| 786 | // If AllowExtendedOptions is set and we're viewing a document,
|
---|
| 787 | // DocumentButtons, DocumentContent, and DocumentImages are effectively
|
---|
| 788 | // disabled. We just output the DocumentHeading format string and
|
---|
| 789 | // return
|
---|
[4972] | 790 | output_titles (args, collectproto, browsermap, formatinfo, disp, outconvert, textout, logout);
|
---|
| 791 | return;
|
---|
| 792 | }
|
---|
| 793 |
|
---|
[737] | 794 | int tabcount = 0;
|
---|
| 795 | bool fulltoc = false;
|
---|
| 796 |
|
---|
| 797 | if (args["cl"] != "search") {
|
---|
| 798 | // see if there's a FullTOC string
|
---|
| 799 | text_t cl_top, full_toc;
|
---|
| 800 | get_top (args["cl"], cl_top);
|
---|
[1079] | 801 | if (get_formatstring (cl_top, "FullTOC", formatinfo.formatstrings, full_toc))
|
---|
[737] | 802 | if (full_toc == "true") fulltoc = true;
|
---|
| 803 | }
|
---|
[1079] | 804 |
|
---|
| 805 | // get the cover image (if there is one) and the control buttons
|
---|
| 806 | // if we're inside a book
|
---|
| 807 | if ((!fulltoc) && (!args["d"].empty())) {
|
---|
[11131] | 808 | textout << outconvert << "<div class=\"heading\">\n";
|
---|
[1079] | 809 | if (formatinfo.DocumentImages)
|
---|
| 810 | output_cover_image (args, collectproto, disp, outconvert, textout, logout);
|
---|
| 811 | else if (formatinfo.DocumentTitles)
|
---|
[4972] | 812 | output_titles (args, collectproto, browsermap, formatinfo, disp, outconvert, textout, logout);
|
---|
[11131] | 813 | textout << outconvert << "\n</div>\n\n<div class=\"buttons\" id=\"toc_buttons\">\n";
|
---|
[2664] | 814 | if (args["u"] != "1") {
|
---|
| 815 | output_controls (args, formatinfo.DocumentButtons, collectproto, disp,
|
---|
| 816 | outconvert, textout, logout);
|
---|
| 817 | }
|
---|
[11131] | 818 | textout << outconvert << "</div>\n\n";
|
---|
[1079] | 819 | }
|
---|
[248] | 820 |
|
---|
[1079] | 821 | if (formatinfo.DocumentContents || args["d"].empty()) {
|
---|
[11131] | 822 | textout << outconvert << "<div class=\"toc\">\n";
|
---|
[1079] | 823 | if (args.getintarg("gc") == 1) {
|
---|
[667] | 824 |
|
---|
[1079] | 825 | // expanded table of contents
|
---|
| 826 | expanded_contents (args, tabcount, fulltoc, browsermap, formatinfo,
|
---|
| 827 | collectproto, disp, outconvert, textout, logout);
|
---|
[2805] | 828 | } else if (args.getintarg("gc") == 2) {
|
---|
| 829 |
|
---|
| 830 | // expand visible levels of table of contents
|
---|
| 831 | expand_show_contents(args, tabcount, fulltoc, browsermap, formatinfo,
|
---|
| 832 | collectproto, disp, outconvert, textout, logout);
|
---|
[11131] | 833 | } else {
|
---|
[1059] | 834 |
|
---|
[1079] | 835 | // contracted table of contents
|
---|
| 836 | contracted_contents (args, tabcount, fulltoc, browsermap, formatinfo,
|
---|
| 837 | collectproto, disp, outconvert, textout, logout);
|
---|
| 838 | }
|
---|
[11131] | 839 | textout << outconvert << "</div>\n";
|
---|
[667] | 840 | }
|
---|
[1079] | 841 |
|
---|
[1941] | 842 | //if there is a format specified in the config file then
|
---|
| 843 | //try to display the related documents (may not be displayed
|
---|
| 844 | //if preference file does not indicate a wish to display
|
---|
| 845 | //related documents.
|
---|
| 846 | if (!formatinfo.RelatedDocuments.empty())
|
---|
| 847 | output_related_docs(args, collectproto, formatinfo, disp, outconvert, textout, logout);
|
---|
| 848 |
|
---|
[248] | 849 | }
|
---|
[1941] | 850 |
|
---|
[4972] | 851 | void load_extended_options(text_tmap &options, cgiargsclass &args, browsermapclass *browsers,
|
---|
| 852 | formatinfo_t &formatinfo, recptproto *collectproto,
|
---|
| 853 | displayclass &disp, outconvertclass &outconvert, ostream &logout) {
|
---|
| 854 |
|
---|
| 855 | options["DocImage"] = get_cover_image();
|
---|
| 856 |
|
---|
[7061] | 857 | #if defined(GSDL_USE_IOS_H)
|
---|
| 858 | ostrstream *tmpstr = new ostrstream();
|
---|
| 859 | #else
|
---|
| 860 | ostringstream *tmpstr = new ostringstream(ostringstream::binary);
|
---|
| 861 | #endif
|
---|
| 862 |
|
---|
[4972] | 863 | if (args["gc"] == "1") {
|
---|
| 864 | expanded_contents (args, 0, false, browsers, formatinfo,
|
---|
[7061] | 865 | collectproto, disp, outconvert, *tmpstr,
|
---|
[4972] | 866 | logout);
|
---|
| 867 | } else {
|
---|
| 868 | contracted_contents (args, 0, false, browsers, formatinfo,
|
---|
[7061] | 869 | collectproto, disp, outconvert, *tmpstr, logout);
|
---|
[4972] | 870 | }
|
---|
[7061] | 871 | #if defined(GSDL_USE_IOS_H)
|
---|
| 872 | char *t = tmpstr->str();
|
---|
| 873 | text_t tmp;
|
---|
| 874 | tmp.setcarr(t, tmpstr->pcount());
|
---|
| 875 | delete [] t;
|
---|
| 876 | #else
|
---|
| 877 | text_t tmp = (char *)(tmpstr->str().c_str());
|
---|
| 878 | #endif
|
---|
[4972] | 879 | int len = tmp.size();
|
---|
| 880 | char *ctmp = tmp.getcstr();
|
---|
| 881 | utf8inconvertclass utf82text_t;
|
---|
| 882 | utf82text_t.setinput(ctmp, len);
|
---|
| 883 | convertclass::status_t status;
|
---|
| 884 | utf82text_t.convert(tmp, status);
|
---|
| 885 | options["DocTOC"] = tmp;
|
---|
[9633] | 886 | delete []ctmp;
|
---|
[7061] | 887 | delete tmpstr;
|
---|
[4972] | 888 |
|
---|
| 889 | options["DocumentButtonDetach"] = "_document:imagedetach_";
|
---|
| 890 | if (args["hl"] == "1") {
|
---|
| 891 | options["DocumentButtonHighlight"] = "_document:imagenohighlight_";
|
---|
| 892 | } else {
|
---|
| 893 | options["DocumentButtonHighlight"] = "_document:imagehighlight_";
|
---|
| 894 | }
|
---|
| 895 | if (args["gc"] == "1") {
|
---|
| 896 | options["DocumentButtonExpandContents"] = "_document:imagecontracttoc_";
|
---|
| 897 | } else {
|
---|
| 898 | options["DocumentButtonExpandContents"] = "_document:imageexpandtoc_";
|
---|
| 899 | }
|
---|
| 900 | if (args["gt"] == "1") {
|
---|
| 901 | options["DocumentButtonExpandText"] = "_document:imagecontracttext_";
|
---|
| 902 | } else {
|
---|
| 903 | options["DocumentButtonExpandText"] = "_document:imageexpandtext_";
|
---|
| 904 | }
|
---|
| 905 | }
|
---|