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