Changeset 419 for trunk/gsdl/src
- Timestamp:
- 1999-07-30T14:16:10+12:00 (25 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/browsetools.cpp
r412 r419 12 12 /* 13 13 $Log$ 14 Revision 1.16 1999/07/30 02:16:10 sjboddie 15 -added ability to display nested classifications (expanded versions 16 of nested classifications has yet to be done). 17 -changed set_arrow_macros slightly to fit in with new showtoppage 18 format option 19 14 20 Revision 1.15 1999/07/21 05:01:56 sjboddie 15 21 wrote handler for DateList classification … … 79 85 #include "OIDtools.h" 80 86 #include "formattools.h" 81 82 83 // Note that at present the build software is capable (if you write a plugin to do84 // it) of generating classifications that contain other classifications of a85 // different type. This module can only handle one case of that however (i.e. an86 // AZList containing a Hierarchy classification as used by hdl's 'magazine'87 // section). It really needs redesigning to handle all cases.88 89 90 87 91 88 // simply checks to see if formatstring begins with a <td> tag … … 105 102 here ++; 106 103 } 104 return false; 105 } 106 107 static bool is_table_content (const format_t *formatlistptr) { 108 109 if (formatlistptr == NULL) return false; 110 111 if (formatlistptr->command == comText) 112 return is_table_content (formatlistptr->text); 113 107 114 return false; 108 115 } … … 164 171 165 172 173 // at the moment this just writes out the html to display 174 // the cover image (assuming it's called cover.jpg) 175 // this whole thing should be done with a call to the collection 176 // server which would send a link to the cover image if there 177 // was one otherwise send title, author and stuff 178 static void output_cover_image (cgiargsclass &args, recptproto */*collectproto*/, 179 displayclass &disp, outconvertclass &outconvert, 180 ostream &textout, ostream &/*logout*/) { 181 182 if (args["d"].empty()) return; 183 184 textout << outconvert << disp << 185 "<img src=\"_httpcollection_/archives/_thisOID_/cover.jpg\"><br>\n"; 186 } 187 188 166 189 167 190 /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- … … 177 200 ostream &textout, ostream &logout) { 178 201 179 if (args["d"].empty()) return; 202 text_t &arg_d = args["d"]; 203 if (arg_d.empty()) return; 180 204 181 205 text_tarray metadata; … … 183 207 ResultDocInfo_t docinfo; 184 208 text_t booktop, title, author; 209 text_t &collection = args["c"]; 185 210 186 211 metadata.push_back ("Title"); 187 212 metadata.push_back ("hastxt"); 188 if (get_info (args["d"], args["c"], metadata, false, collectproto, response, logout)) { 189 213 if (get_info (arg_d, collection, metadata, false, collectproto, response, logout)) { 214 215 metadata.erase (metadata.begin(), metadata.end()); 190 216 docinfo = response.docInfo[0]; 191 217 … … 193 219 << "\n<!-- Table of Contents produced by browsetools::output_book_toc -->\n\n"; 194 220 195 metadata.erase (metadata.begin()+1, metadata.end());196 metadata.push_back ("Creator");197 198 221 // get title and author of book 199 get_top (arg s["d"], booktop);222 get_top (arg_d, booktop); 200 223 metadata.push_back ("Title"); 201 224 metadata.push_back ("Creator"); 202 get_info (booktop, args["c"], metadata, false, collectproto, response, logout);225 get_info (booktop, collection, metadata, false, collectproto, response, logout); 203 226 title = response.docInfo[0].metadata[0].values[0]; 204 227 author = response.docInfo[0].metadata[1].values[0]; … … 214 237 215 238 // previous arrow 216 textout << "<table><tr valign=top>\n";217 textout << outconvert << disp<< "<td align=left>_document:prevarrow_</td>\n";239 textout << outconvert << disp << "<table><tr valign=top>\n" 240 << "<td align=left>_document:prevarrow_</td>\n"; 218 241 219 242 // page ? of ? text 220 textout << outconvert <<"<td align=center>\n";243 textout << "<td align=center>\n"; 221 244 222 245 if (is_number (docinfo.metadata[0].values[0])) { 223 246 text_t doctop; 224 247 metadata.push_back ("Title"); 225 get_top (arg s["d"], doctop);248 get_top (arg_d, doctop); 226 249 // get title of last sibling 227 if (get_info (doctop + ".lc", args["c"], metadata, false, collectproto, response, logout)) {250 if (get_info (doctop + ".lc", collection, metadata, false, collectproto, response, logout)) { 228 251 if (is_number (response.docInfo[0].metadata[0].values[0])) { 229 252 textout << outconvert << disp << "_document:page_" << docinfo.metadata[0].values[0] … … 271 294 // prototypes 272 295 273 static void output_hierarchy (const text_t &classifytype, cgiargsclass &args, 274 recptproto *collectproto, displayclass &disp, 275 outconvertclass &outconvert, ostream &textout, 276 ostream &logout); 277 static void output_contracted_hierarchy_toc (const text_t &classifytype, cgiargsclass &args, 278 recptproto *collectproto,displayclass &disp, 279 outconvertclass &outconvert, ostream &textout, 280 ostream &logout); 296 static void output_contracted_hierarchy_toc (const text_t &classifytype, text_t &formatstring, 297 cgiargsclass &args, recptproto *collectproto, 298 displayclass &disp, outconvertclass &outconvert, 299 ostream &textout, ostream &logout); 300 281 301 static void output_expanded_hierarchy_toc (cgiargsclass &args, recptproto *collectproto, 282 302 displayclass &disp, outconvertclass &outconvert, 283 303 ostream &textout, ostream &logout); 284 static void output_parents_toc (cgiargsclass &args, const text_tarray &parents, 285 int &tabcount, int &colnum, displayclass &disp, 286 recptproto *collectproto, outconvertclass &outconvert, 304 305 static void output_parents_toc (cgiargsclass &args, const FilterResponse_t &parents, 306 int &tabcount, displayclass &disp, 307 format_t *formatlistptr, outconvertclass &outconvert, 287 308 ostream &textout, ostream &logout); 288 static void output_siblings_toc (cgiargsclass &args, const FilterResponse_t &siblings, 289 int &tabcount, int &colnum, displayclass &disp, 290 outconvertclass &outconvert, ostream &textout, ostream &logout); 291 static void output_cover_image (cgiargsclass &args, recptproto *collectproto, 292 displayclass &disp, outconvertclass &outconvert, 293 ostream &textout, ostream &logout); 294 295 296 void hierarchy_toc (const text_t &classifytype, 297 cgiargsclass &args, recptproto *collectproto, 298 displayclass &disp, outconvertclass &outconvert, 299 ostream &textout, ostream &logout) { 300 301 textout << "\n<!-- Table of Contents produced by browsetools::hierarchy_toc -->\n\n"; 302 textout << "<p><table width=100% cellpadding=0 cellspacing=0 border=0><tr>\n"; 309 310 static void output_siblings_toc (const text_t &classifytype, cgiargsclass &args, 311 const FilterResponse_t &siblings, int &tabcount, 312 displayclass &disp, format_t *formatlistptr, 313 outconvertclass &outconvert, ostream &textout, 314 ostream &logout); 315 316 static void output_stdlist (cgiargsclass &args, ResultDocInfo_tarray::const_iterator &here, 317 ResultDocInfo_tarray::const_iterator &end, bool intable, 318 displayclass &disp, format_t *formatlistptr, 319 outconvertclass &outconvert, ostream &textout); 320 321 static void output_datelist (cgiargsclass &args, ResultDocInfo_tarray::const_iterator &here, 322 ResultDocInfo_tarray::const_iterator &end, bool intable, 323 displayclass &disp, format_t *formatlistptr, 324 outconvertclass &outconvert, ostream &textout); 325 326 327 328 329 void output_toc (const text_t &classifytype, text_t &formatstring, cgiargsclass &args, 330 bool cover, recptproto *collectproto, displayclass &disp, 331 outconvertclass &outconvert, ostream &textout, ostream &logout) { 332 333 bool havecontrols = false; 334 335 textout << "\n<!-- Table of Contents produced by browsetools::output_toc -->\n\n"; 303 336 304 337 // get the cover image (if there is one) and the control buttons 338 // if we're inside a book 305 339 if (!args["d"].empty()) { 340 textout << "<p><table cellpadding=0 cellspacing=0><tr>\n"; 306 341 textout << "<td valign=top width=200>\n"; 307 output_cover_image (args, collectproto, disp, outconvert, textout, logout);342 if (cover) output_cover_image (args, collectproto, disp, outconvert, textout, logout); 308 343 output_controls (args, collectproto, disp, outconvert, textout, logout); 309 textout << "</td>\n"; 344 textout << "</td><td valign=top>\n"; 345 havecontrols = true; 310 346 } 311 347 312 348 // get table of contents 313 textout << "<td valign=top>\n" 314 << "<table>\n"; 315 316 output_hierarchy (classifytype, args, collectproto, disp, outconvert, textout, logout); 317 318 textout << "</table>\n" 319 << "</td></tr></table>\n" 320 << "\n<!-- end of Table of Contents -->\n"; 321 } 322 323 void output_hierarchy (const text_t &classifytype, cgiargsclass &args, 324 recptproto *collectproto, displayclass &disp, 325 outconvertclass &outconvert, ostream &textout, 326 ostream &logout) { 349 textout << "<table>\n"; 327 350 328 351 if (args.getintarg("gc")) 329 352 output_expanded_hierarchy_toc(args, collectproto, disp, outconvert, textout, logout); 330 353 else 331 output_contracted_hierarchy_toc(classifytype, args, collectproto, disp, outconvert, textout, logout); 332 } 333 334 // at the moment this just writes out the html to display 335 // the cover image (assuming it's called cover.jpg) 336 // this whole thing should be done with a call to the collection 337 // server which would send a link to the cover image if there 338 // was one otherwise send title, author and stuff 339 void output_cover_image (cgiargsclass &args, recptproto */*collectproto*/, 340 displayclass &disp, outconvertclass &outconvert, 341 ostream &textout, ostream &/*logout*/) { 342 343 if (args["d"].empty()) return; 344 345 textout << outconvert << disp << 346 "<img src=\"_httpcollection_/archives/_thisOID_/cover.jpg\"><br>\n"; 347 } 348 349 350 void output_contracted_hierarchy_toc (const text_t &classifytype, cgiargsclass &args, 351 recptproto *collectproto,displayclass &disp, 352 outconvertclass &outconvert, ostream &textout, 353 ostream &logout) { 354 355 int colnum, tabcount = 0; 354 output_contracted_hierarchy_toc(classifytype, formatstring, args, collectproto, 355 disp, outconvert, textout, logout); 356 357 textout << "</table>\n"; 358 359 if (havecontrols) textout << "</td></tr></table>\n"; 360 361 textout << "\n<!-- end of Table of Contents -->\n"; 362 } 363 364 365 void output_contracted_hierarchy_toc (const text_t &classifytype, text_t &formatstring, 366 cgiargsclass &args, recptproto *collectproto, 367 displayclass &disp, outconvertclass &outconvert, 368 ostream &textout, ostream &logout) { 369 370 int tabcount = 0; 356 371 text_tarray parents, metadata; 357 FilterResponse_t siblings; 358 FilterResponse_t response; 372 FilterResponse_t fsiblings, fparents; 359 373 bool getParents = false; 360 374 361 375 text_t &arg_d = args["d"]; 362 text_t &arg_cl = args["cl"]; 363 364 metadata.push_back ("doctype"); 365 metadata.push_back ("Title"); 376 text_t OID = arg_d; 377 if (OID.empty()) OID = args["cl"]; 378 text_t &collection = args["c"]; 379 380 // if format string is empty use the default 381 if (formatstring.empty()) 382 formatstring = "<td valign=top nowrap>[link][icon][/link]</td><td>{Or}{[Title],Untitled}</td>"; 383 384 format_t *formatlistptr = new format_t(); 385 parse_formatstring (formatstring, formatlistptr, metadata, getParents); 386 387 metadata.push_back ("Date"); 366 388 metadata.push_back ("hastxt"); 367 389 metadata.push_back ("haschildren"); 368 369 // load up parent and sibling arrays370 if (arg_d.empty()) { 371 if (has_children (arg_cl, args["c"], collectproto, logout)) {372 get_parents_array ( arg_cl+ ".fc", parents);373 374 if (!get_children ( arg_cl, args["c"], metadata, getParents,375 collectproto, siblings, logout))390 metadata.push_back ("doctype"); 391 metadata.push_back ("classifytype"); 392 393 if (has_children (OID, collection, collectproto, logout)) { 394 get_parents_array (OID + ".fc", parents); 395 396 if (!get_children (OID, collection, metadata, getParents, 397 collectproto, fsiblings, logout)) 376 398 return; 377 378 get_parents_array (arg_cl, parents);379 if (!get_children (arg_cl + ".pr", args["c"], metadata,380 getParents, collectproto,siblings, logout))399 } else { 400 get_parents_array (OID, parents); 401 if (!get_children (OID + ".pr", collection, metadata, 402 getParents, collectproto, fsiblings, logout)) 381 403 return; 382 } 383 // don't want top parent of classification to be displayed 384 if (!parents.empty()) parents.erase (parents.begin()); 385 386 // this is a special case for an AZList containing a Hierarchy toc 387 if (classifytype == "AZList" && !parents.empty()) 388 parents.erase (parents.begin()); 389 390 } else { 391 if (has_children (arg_d, args["c"], collectproto, logout)) { 392 get_parents_array (arg_d + ".fc", parents); 393 if (!get_children (arg_d, args["c"], metadata, getParents, 394 collectproto, siblings, logout)) 395 return; 396 } else { 397 get_parents_array (arg_d, parents); 398 if (!get_children (arg_d + ".pr", args["c"], metadata, 399 getParents, collectproto, siblings, logout)) 400 return; 401 } 402 } 403 404 colnum = parents.size() + 1; 405 406 // sort out toc of sections parents 407 if (!parents.empty()) 408 output_parents_toc(args, parents, tabcount, colnum, disp, collectproto, 409 outconvert, textout, logout); 410 411 // sort out toc of sections siblings 412 if (!siblings.docInfo.empty()) 413 output_siblings_toc (args, siblings, tabcount, colnum, disp, 414 outconvert, textout, logout); 415 } 416 404 } 405 if (!get_info (parents, collection, metadata, false, collectproto, fparents, logout)) return; 406 407 if (!fparents.docInfo.empty()) 408 output_parents_toc(args, fparents, tabcount, disp, 409 formatlistptr, outconvert, textout, logout); 410 411 if (!fsiblings.docInfo.empty()) 412 output_siblings_toc (classifytype, args, fsiblings, tabcount, disp, 413 formatlistptr, outconvert, textout, logout); 414 } 415 416 void output_parents_toc (cgiargsclass &args, const FilterResponse_t &parents, 417 int &tabcount, displayclass &disp, 418 format_t *formatlistptr, outconvertclass &outconvert, 419 ostream &textout, ostream &/*logout*/) { 420 421 text_t tab, icon; 422 text_t &arg_cl = args["cl"]; 423 text_t &arg_d = args["d"]; 424 int numcols = parents.docInfo.size() + 1; 425 426 bool intable = is_table_content (formatlistptr); 427 428 ResultDocInfo_tarray::const_iterator thisparent = parents.docInfo.begin(); 429 ResultDocInfo_tarray::const_iterator end = parents.docInfo.end(); 430 431 int len = (*thisparent).metadata.size(); 432 const text_t &classifytype = (*thisparent).metadata[len-1].values[0]; 433 434 // don't want top level of any classifications to be displayed 435 if (arg_d.empty() && thisparent != end) {thisparent ++; numcols --;} 436 437 // don't want second level of classifications using classification links 438 if ((classifytype == "AZList" || classifytype == "DateList") && (thisparent != end)) 439 {thisparent ++; numcols --;} 440 441 // the tab line 442 if (thisparent != end) { 443 text_t coltabs; 444 for (int i = 0; i < numcols; i ++) coltabs += "_document:tab_"; 445 textout << outconvert << disp << "<tr>" << coltabs << "<td></td></tr>\n"; 446 } 447 448 while (thisparent != end) { 449 450 const text_t &doctype = (*thisparent).metadata[len-2].values.back(); 451 452 // set up icon and pointer 453 icon = "_document:icon"; 454 if ((doctype != "classify") && ((*thisparent).OID == arg_d)) 455 icon += "arrow"; 456 if (doctype == "classify") icon += "openbookshelf_"; 457 else if (is_top((*thisparent).OID)) icon += "openbook_"; 458 else icon += "openfolder_"; 459 460 if (tabcount == 1) textout << "<td></td>\n"; 461 else if (tabcount > 1) textout << "<td colspan=" << tabcount << "></td>"; 462 463 // set up the link 464 text_t link = "<a href=\"_httpdocument_"; 465 if (is_top((*thisparent).OID) && args.getintarg("x")) link = "<a name=top>"; 466 else 467 if (doctype == "classify") link += "&cl=" + (*thisparent).OID + ".pr\">"; 468 else 469 if (is_top ((*thisparent).OID)) 470 if (arg_cl.empty()) 471 link = "<a name=top>"; 472 else if (arg_cl == "search") 473 link = "<a href=\"_httpquery_\">"; 474 else 475 link += "&cl=" + arg_cl + "\">"; 476 else link += "&cl=" + arg_cl + "&d=" + (*thisparent).OID + ".pr\">"; 477 478 if ((numcols-tabcount) == 1) textout << "<td>"; 479 else if ((numcols-tabcount) > 1) textout << "<td colspan=" 480 << (numcols-tabcount) << ">"; 481 482 if (intable) textout << "<table><tr>"; 483 484 textout << outconvert << disp 485 << get_formatted_string (*thisparent, formatlistptr, link, icon); 486 487 if (intable) textout << "</tr></table>"; 488 textout << "</td></tr>\n"; 489 490 tabcount ++; 491 thisparent ++; 492 } 493 } 494 495 496 void output_siblings_toc (const text_t &classifytype, cgiargsclass &args, 497 const FilterResponse_t &siblings, int &tabcount, 498 displayclass &disp, format_t *formatlistptr, 499 outconvertclass &outconvert, ostream &textout, 500 ostream &/*logout*/) { 501 502 bool intable = is_table_content (formatlistptr); 503 504 ResultDocInfo_tarray::const_iterator thissibling = siblings.docInfo.begin(); 505 ResultDocInfo_tarray::const_iterator sibend = siblings.docInfo.end(); 506 507 if (thissibling == sibend) return; 508 509 // tabbing 510 if (tabcount) { 511 if (tabcount == 1) textout << "<tr><td></td>\n"; 512 else if (tabcount > 1) textout << "<tr><td colspan=" << tabcount << "></td>"; 513 textout << "<td><table>\n"; 514 } 515 516 if (!intable) textout << "<tr><td>\n"; 517 518 if (classifytype == "DateList") 519 output_datelist (args, thissibling, sibend, intable, disp, 520 formatlistptr, outconvert, textout); 521 else 522 output_stdlist (args, thissibling, sibend, intable, disp, 523 formatlistptr, outconvert, textout); 524 525 if (!intable) textout << "</td></tr></table>\n"; 526 if (tabcount) textout << "</table></td></tr>\n"; 527 } 528 529 void output_stdlist (cgiargsclass &args, ResultDocInfo_tarray::const_iterator &here, 530 ResultDocInfo_tarray::const_iterator &end, bool intable, 531 displayclass &disp, format_t *formatlistptr, 532 outconvertclass &outconvert, ostream &textout) { 533 534 text_t icon; 535 int count = 1; 536 int gt = args.getintarg("gt"); 537 text_t &arg_cl = args["cl"]; 538 text_t &arg_d = args["d"]; 539 540 while (here != end) { 541 542 int len = (*here).metadata.size(); 543 const text_t &doctype = (*here).metadata[len-2].values.back(); 544 const text_t &hastxt = (*here).metadata[len-4].values.back(); 545 const text_t &haschildren = (*here).metadata[len-3].values.back(); 546 547 // set up icon and pointer 548 icon = "_document:icon"; 549 if (doctype == "classify") { 550 if (((*here).OID == arg_cl) && (hastxt == "1")) 551 icon += "arrow"; 552 } else if ((*here).OID == arg_d) icon += "arrow"; 553 554 if (haschildren == "0") icon += "smalltext_"; 555 else if (doctype == "classify") icon += "closedbookshelf_"; 556 else if (is_top((*here).OID)) icon += "closedbook_"; 557 else icon += "closedfolder_"; 558 559 // set up link 560 text_t link = "<a href=\"_httpdocument_"; 561 if (doctype == "classify") link += "&cl=" + (*here).OID + "\">"; 562 else link += "&cl=" + arg_cl + "&d=" + (*here).OID + "\">"; 563 if (gt) { 564 link = "<a href=\"#" + text_t(count) + "\">"; 565 count ++; 566 } 567 568 if (intable) textout << "<tr>"; 569 570 textout << outconvert << disp 571 << get_formatted_string (*here, formatlistptr, link, icon) << "\n"; 572 573 if (intable) textout << "</tr>"; 574 575 here ++; 576 } 577 } 578 579 580 void output_datelist (cgiargsclass &args, ResultDocInfo_tarray::const_iterator &here, 581 ResultDocInfo_tarray::const_iterator &end, bool intable, 582 displayclass &disp, format_t *formatlistptr, 583 outconvertclass &outconvert, ostream &textout) { 584 585 text_t lastyear = "0000"; 586 text_t lastmonth = "00"; 587 588 while (here != end) { 589 590 int len = (*here).metadata.size(); 591 const text_t &doctype = (*here).metadata[len-2].values.back(); 592 const text_t &date = (*here).metadata[len-5].values.back(); 593 594 // bail on this document if it has no date 595 if (date.empty()) continue; 596 597 text_t::const_iterator datebegin = date.begin(); 598 599 text_t link = "<a href=\"_httpdocument_&cl="; 600 text_t icon = "_document:iconclosedbook_"; 601 602 if (doctype == "classify") { 603 icon = "_document:iconclosedbookshelf_"; 604 link += (*here).OID + "\">"; 605 } else link += args["cl"] + "&d=" + (*here).OID + "\">"; 606 607 text_t thisyear = substr (datebegin, datebegin+4); 608 text_t thismonth = substr (datebegin+4, datebegin+6); 609 610 textout << "<tr>\n"; 611 612 if (thisyear != lastyear) { 613 textout << outconvert << "<td><b>" << thisyear << "</b></td>"; 614 lastyear = thisyear; 615 } else 616 textout << "<td></td>"; 617 618 if (thismonth != lastmonth) { 619 textout << outconvert << disp << ("<td><b>_textmonth" + thismonth + "_</b></td>"); 620 lastmonth = thismonth; 621 } else 622 textout << "<td></td>"; 623 624 if (!intable) textout << "<td>\n"; 625 626 textout << outconvert << disp 627 << get_formatted_string (*here, formatlistptr, link, icon) << "\n"; 628 629 if (!intable) textout << "</td>"; 630 631 textout << "</tr>\n"; 632 633 here ++; 634 } 635 } 417 636 418 637 void output_expanded_hierarchy_toc (cgiargsclass &args, recptproto *collectproto, … … 547 766 } 548 767 549 550 void output_parents_toc (cgiargsclass &args, const text_tarray &parents,551 int &tabcount, int &colnum, displayclass &disp,552 recptproto *collectproto, outconvertclass &outconvert,553 ostream &textout, ostream &logout) {554 555 text_t tab, icon;556 text_tarray metadata;557 FilterResponse_t response;558 text_t doclink = "<a href=\"_httpdocument_";559 560 text_t &arg_cl = args["cl"];561 562 metadata.push_back ("doctype");563 metadata.push_back ("Title");564 565 text_tarray::const_iterator thisparent = parents.begin();566 text_tarray::const_iterator end = parents.end();567 568 while (thisparent != end) {569 if (get_info (*thisparent, args["c"], metadata, false, collectproto, response, logout)) {570 text_t &doctype = response.docInfo[0].metadata[0].values[0];571 text_t &title = response.docInfo[0].metadata[1].values[0];572 573 text_t icontabs, pointer;574 tab.clear();575 576 // set up icon for this parent577 icon = "_document:iconopenfolder_";578 if (doctype == "classify") icon = "_document:iconopenbookshelf_";579 else if (is_top(*thisparent)) icon = "_document:iconopenbook_";580 581 for (int j = 0; j < tabcount; j++)582 icontabs += "_document:icontab_";583 584 if (doctype != "classify") {585 if (*thisparent == args["d"]) {586 icontabs += "_document:iconpointer_";587 if (is_top (*thisparent))588 tabcount ++;589 else590 icontabs.erase (icontabs.begin(), icontabs.begin()+18);591 }592 }593 594 if (!icontabs.empty()) {595 tab = "<td valign=top";596 if (tabcount > 1) tab += " colspan=" + text_t(tabcount);597 tab += ">" + icontabs + "</td>";598 }599 tabcount ++;600 601 textout << outconvert << disp << "<tr>" << tab << "<td valign=top>";602 603 if (is_top(*thisparent) && args["x"] == "1") {604 textout << outconvert << disp << icon;605 } else {606 text_t link;607 if (doctype == "classify") link = doclink + "&cl=" + *thisparent + ".pr\">";608 else609 if (is_top (*thisparent))610 if (arg_cl.empty())611 link.clear();612 else if (arg_cl == "search")613 link = "<a href=\"_httpquery_\">";614 else615 link = doclink + "&cl=" + arg_cl + "\">";616 else link = doclink + "&cl=" + arg_cl + "&d=" + *thisparent + ".pr\">";617 618 textout << outconvert << disp << link << icon << "</a>";619 }620 textout << "</td><td";621 if (colnum > 1) textout << outconvert << " colspan=" << text_t(colnum);622 textout << outconvert << disp << ">" << title << "</td></tr>\n";623 colnum --;624 }625 thisparent ++;626 }627 }628 629 void output_siblings_toc (cgiargsclass &args, const FilterResponse_t &siblings,630 int &tabcount, int &colnum, displayclass &disp,631 outconvertclass &outconvert, ostream &textout,632 ostream &/*logout*/) {633 634 text_t tab, icon, pointer, child, doclink;635 int count = 1;636 637 doclink = "<a href=\"_httpdocument_";638 639 ResultDocInfo_tarray::const_iterator thissibling = siblings.docInfo.begin();640 ResultDocInfo_tarray::const_iterator sibend = siblings.docInfo.end();641 642 while (thissibling != sibend) {643 644 const text_t &doctype = (*thissibling).metadata[0].values[0];645 const text_t &title = (*thissibling).metadata[1].values[0];646 int hastxt = (*thissibling).metadata[2].values[0].getint();647 int haschildren = (*thissibling).metadata[3].values[0].getint();648 int gt = args.getintarg("gt");649 650 // set up icon for this sibling651 icon = "_document:iconclosedfolder_";652 if (doctype == "classify") icon = "_document:iconclosedbookshelf_";653 else if (is_top((*thissibling).OID)) icon = "_document:iconclosedbook_";654 655 // fit pointer into tabbing if current section656 // note that we don't want pointers at classification levels anymore657 // (unless the classification contains text)658 pointer = "_document:icontab_";659 if (doctype == "classify") {660 if ((*thissibling).OID == args["cl"] && hastxt)661 pointer = "_document:iconpointer_";662 } else if ((*thissibling).OID == args["d"]) pointer = "_document:iconpointer_";663 664 text_t thesetabs;665 for (int j = 0; j < (tabcount - 1); j++)666 thesetabs += "_document:icontab_";667 668 tab = "<td valign=top";669 if (tabcount > 1) tab += " colspan=" + text_t(tabcount);670 tab += ">" + thesetabs + pointer + "</td>";671 672 if (!haschildren) {673 // sibling is text document674 icon = "_document:iconsmalltext_";675 text_t link;676 if (doctype == "classify") link = "&cl=" + (*thissibling).OID;677 else link = "&cl=" + args["cl"] + "&d=" + (*thissibling).OID;678 679 textout << outconvert << disp << "<tr>" << tab << "<td valign=top>";680 if (!gt) {681 textout << outconvert << disp << doclink << link;682 } else {683 textout << "<a href=\"#" << count;684 count ++;685 }686 textout << outconvert << disp << "\">" << icon << "</a></td><td";687 if (colnum > 1) textout << " colspan=" << colnum;688 textout << outconvert << disp << ">" << title << "</td></tr>\n";689 690 } else {691 // sibling is closed book or folder692 text_t link;693 if (doctype == "classify") link = "&cl=" + (*thissibling).OID;694 else link = "&cl=" + args["cl"] + "&d=" + (*thissibling).OID;695 696 textout << outconvert << disp << "<tr>" << tab << "<td valign=top>"697 << doclink << link << "\">" << icon << "</a></td><td";698 if (colnum > 1) textout << " colspan=" << colnum;699 textout << outconvert << disp << ">" << title << "</td></tr>\n";700 }701 thissibling ++;702 }703 }704 705 706 /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-707 Functions for generating a "List" or "AZList type table of contents. These can be used only708 at classification level as it doesn't make sense to display document level stuff709 this way (I think!!)710 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/711 712 // prototypes713 714 static void output_list (text_t &formatstring, cgiargsclass &args,715 recptproto *collectproto, displayclass &disp,716 outconvertclass &outconvert, ostream &textout,717 ostream &logout);718 719 void list_toc (const text_t &classifytype, text_t &formatstring,720 cgiargsclass &args, recptproto *collectproto,721 displayclass &disp, outconvertclass &outconvert,722 ostream &textout, ostream &logout) {723 724 725 textout726 << "\n<!-- Table of Contents produced by browsetools::list_toc -->\n\n"727 << "<table cellpadding=0 cellspacing=2>\n";728 729 if (classifytype == "AZList" || classifytype == "List")730 output_list (formatstring, args, collectproto,731 disp, outconvert, textout, logout);732 733 else if (classifytype == "Hierarchy")734 output_hierarchy ("AZList", args, collectproto,735 disp, outconvert, textout, logout);736 737 textout << "</table>\n"738 << "<!-- end of Table of Contents -->\n";739 740 }741 742 void output_list (text_t &formatstring, cgiargsclass &args,743 recptproto *collectproto, displayclass &disp,744 outconvertclass &outconvert, ostream &textout,745 ostream &logout) {746 747 text_tarray metadata;748 bool getParents = false;749 FilterResponse_t response;750 751 text_t &arg_cl = args["cl"];752 753 // if format string is empty use the default754 if (formatstring.empty())755 formatstring = "<td valign=top nowrap>[link][icon][/link]</td><td>{Or}{[Title],Untitled}</td>";756 757 bool intable = is_table_content (formatstring);758 if (!intable) textout << "<tr><td>\n";759 760 format_t *formatlistptr = new format_t();761 parse_formatstring (formatstring, formatlistptr, metadata, getParents);762 metadata.push_back ("doctype"); // need this to decide which icon to use763 764 if (get_children (arg_cl, args["c"], metadata, getParents,765 collectproto, response, logout)) {766 767 ResultDocInfo_tarray::const_iterator sechere = response.docInfo.begin();768 ResultDocInfo_tarray::const_iterator secend = response.docInfo.end();769 770 while (sechere != secend) {771 const MetadataInfo_t &lastmeta = (*sechere).metadata.back();772 const text_t &doctype = lastmeta.values.back();773 774 text_t link = "<a href=\"_httpdocument_&cl=";775 text_t icon = "_document:iconclosedbook_";776 777 if (doctype == "classify") {778 icon = "_document:iconclosedbookshelf_";779 link += (*sechere).OID + "\">";780 } else link += arg_cl + "&d=" + (*sechere).OID + "\">";781 782 if (intable) textout << "<tr>\n";783 784 textout << outconvert << disp785 << get_formatted_string (*sechere, formatlistptr, link, icon) << "\n";786 787 if (intable) textout << "</tr>\n";788 789 sechere ++;790 }791 if (!intable) textout << "</td></tr>\n";792 }793 }794 795 796 /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-797 Functions for generating a "DateList" type table of contents. These can be used only798 at classification level as it doesn't make sense to display document level stuff799 this way (I think!!)800 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/801 802 // prototypes803 804 static void output_datelist (text_t &formatstring, cgiargsclass &args,805 recptproto *collectproto, displayclass &disp,806 outconvertclass &outconvert, ostream &textout,807 ostream &logout);808 809 810 811 void datelist_toc (const text_t &/*classifytype*/, text_t &formatstring,812 cgiargsclass &args, recptproto *collectproto,813 displayclass &disp, outconvertclass &outconvert,814 ostream &textout, ostream &logout) {815 816 textout817 << "\n<!-- Table of Contents produced by browsetools::datelist_toc -->\n\n"818 << "<table cellspacing=10>\n";819 820 output_datelist (formatstring, args, collectproto,821 disp, outconvert, textout, logout);822 823 textout << "</table>\n"824 << "<!-- end of Table of Contents -->\n";825 }826 827 void output_datelist (text_t &formatstring, cgiargsclass &args,828 recptproto *collectproto, displayclass &disp,829 outconvertclass &outconvert, ostream &textout,830 ostream &logout) {831 832 text_tarray metadata;833 bool getParents = false;834 FilterResponse_t response;835 836 text_t &arg_cl = args["cl"];837 838 // if format string is empty use the default839 if (formatstring.empty())840 formatstring = "<td valign=top nowrap>[link][icon][/link]</td><td>{Or}{[Title],Untitled}</td>";841 842 bool intable = is_table_content (formatstring);843 844 format_t *formatlistptr = new format_t();845 parse_formatstring (formatstring, formatlistptr, metadata, getParents);846 metadata.push_back ("doctype"); // need this to decide which icon to use847 metadata.push_back ("Date");848 849 if (get_children (arg_cl, args["c"], metadata, getParents,850 collectproto, response, logout)) {851 852 ResultDocInfo_tarray::const_iterator sechere = response.docInfo.begin();853 ResultDocInfo_tarray::const_iterator secend = response.docInfo.end();854 855 text_t lastyear = "0000";856 text_t lastmonth = "00";857 858 while (sechere != secend) {859 860 // grab date and doctype off end of metadata861 const MetadataInfo_t &metadate = *(sechere->metadata.end()-1);862 const text_t &date = metadate.values.back();863 const MetadataInfo_t &metadoctype = *(sechere->metadata.end()-2);864 const text_t &doctype = metadoctype.values.back();865 866 // bail on this document if it has no date867 if (date.empty()) continue;868 869 text_t::const_iterator datebegin = date.begin();870 871 text_t link = "<a href=\"_httpdocument_&cl=";872 text_t icon = "_document:iconclosedbook_";873 874 if (doctype == "classify") {875 icon = "_document:iconclosedbookshelf_";876 link += (*sechere).OID + "\">";877 } else link += arg_cl + "&d=" + (*sechere).OID + "\">";878 879 text_t thisyear = substr (datebegin, datebegin+4);880 text_t thismonth = substr (datebegin+4, datebegin+6);881 882 textout << "<tr>\n";883 884 if (thisyear != lastyear) {885 textout << outconvert << "<td><b>" << thisyear << "</b></td>";886 lastyear = thisyear;887 } else888 textout << "<td></td>";889 890 if (thismonth != lastmonth) {891 textout << outconvert << disp << ("<td><b>_textmonth" + thismonth + "_</b></td>");892 lastmonth = thismonth;893 } else894 textout << "<td></td>";895 896 if (!intable) textout << "<td>\n";897 898 textout << outconvert << disp899 << get_formatted_string (*sechere, formatlistptr, link, icon) << "\n";900 901 if (!intable) textout << "</td>";902 903 textout << "</tr>\n";904 905 sechere ++;906 }907 }908 }909 910 911 912 913 914 768 /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 915 769 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ … … 921 775 // fix this ;-) 922 776 void set_arrow_macros (const text_t &OID, const text_t &classifytype, 923 displayclass &disp, recptproto *collectproto, 924 const text_t &collection, ostream &logout) { 777 bool showtoppage, displayclass &disp, 778 recptproto *collectproto, const text_t &collection, 779 ostream &logout) { 925 780 926 781 if (OID.empty()) return; … … 959 814 // see if OIDs older sibling has children 960 815 if (get_info (OID + ".ps", collection, metadata, false, collectproto, response, logout)) { 961 if (!response.docInfo[0].metadata.empty() && 962 response.docInfo[0].metadata[0].values[0] == "1") 816 if (response.docInfo[0].metadata[0].values[0] == "1") 963 817 disp.setmacro ("httpprevarrow", "document", 964 818 "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.ps.lc,_httpdocument_&cl=_cgiargcl_.ps.lc)"); … … 967 821 "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.ps,_httpdocument_&cl=_cgiargcl_.ps)"); 968 822 } 969 } else if ( !is_top (OID))823 } else if (showtoppage && !is_top (OID)) 970 824 disp.setmacro ("httpprevarrow", "document", 971 825 "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.pr,_httpdocument_&cl=_cgiargcl_.pr)"); -
trunk/gsdl/src/recpt/browsetools.h
r412 r419 21 21 22 22 23 // Note that at present the build software is capable (if you write a plugin to do24 // it) of generating classifications that contain other classifications of a25 // different type. This module can only handle one case of that however (i.e. an26 // AZList containing a Hierarchy classification as used by hdl's 'magazine'27 // section). It really needs redesigning to handle all cases.28 29 30 23 void book_toc (cgiargsclass &args, recptproto *collectproto, 31 24 displayclass &disp, outconvertclass &outconvert, 32 25 ostream &textout, ostream &logout); 33 26 34 void hierarchy_toc (const text_t &classifytype, 35 cgiargsclass &args, recptproto *collectproto, 36 displayclass &disp, outconvertclass &outconvert, 37 ostream &textout, ostream &logout); 38 39 void list_toc (const text_t &classifytype, text_t &formatstring, 40 cgiargsclass &args, recptproto *collectproto, 41 displayclass &disp, outconvertclass &outconvert, 42 ostream &textout, ostream &logout); 43 44 void datelist_toc (const text_t &classifytype, text_t &formatstring, 45 cgiargsclass &args, recptproto *collectproto, 46 displayclass &disp, outconvertclass &outconvert, 47 ostream &textout, ostream &logout); 27 void output_toc (const text_t &classifytype, text_t &formatstring, cgiargsclass &args, 28 bool cover, recptproto *collectproto, displayclass &disp, 29 outconvertclass &outconvert, ostream &textout, ostream &logout); 48 30 49 31 void set_arrow_macros (const text_t &OID, const text_t &classifytype, 50 displayclass &disp, recptproto *collectproto,51 const text_t &collection, ostream &logout);52 32 bool showtoppage, displayclass &disp, 33 recptproto *collectproto, const text_t &collection, 34 ostream &logout); 53 35 54 36 #endif
Note:
See TracChangeset
for help on using the changeset viewer.