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