Changeset 649 for trunk/gsdl/src/recpt/documentaction.cpp
- Timestamp:
- 1999-10-10T21:14:12+13:00 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/documentaction.cpp
r604 r649 28 28 /* 29 29 $Log$ 30 Revision 1.26 1999/10/10 08:14:06 sjboddie 31 - metadata now returns mp rather than array 32 - redesigned browsing support (although it's not finished so 33 won't currently work ;-) 34 30 35 Revision 1.25 1999/09/17 04:46:05 sjboddie 31 36 fixed a couple of problems with 'unknown' classifier … … 225 230 } 226 231 227 bool documentaction::init (ostream &logout) {228 229 // classify_meta should contain names of all classifiers supported230 // by this receptionist. classifications using metadata names not231 // in this list will be displayed as "unknown"232 classify_meta.insert ("Title");233 classify_meta.insert ("List");234 classify_meta.insert ("Creator");235 classify_meta.insert ("Series");236 classify_meta.insert ("Date");237 classify_meta.insert ("Subject");238 classify_meta.insert ("Organization");239 classify_meta.insert ("Howto");240 classify_meta.insert ("Topic");241 classify_meta.insert ("Browse");242 classify_meta.insert ("People");243 244 return action::init (logout);245 }246 247 232 bool documentaction::check_cgiargs (cgiargsinfoclass &argsinfo, cgiargsclass &args, 248 233 ostream &logout) { … … 284 269 285 270 void documentaction::get_cgihead_info (cgiargsclass &/*args*/, response_t &response, 286 text_t &response_data, ostream &/*logout*/) {271 text_t &response_data, ostream &/*logout*/) { 287 272 response = content; 288 273 response_data = "text/html"; 289 274 } 290 275 291 292 276 // set_widthtspace calculates how wide the spaces in the nav bar should 293 277 // be and sets the appropriate macro 294 void documentaction::set_spacemacro (displayclass &disp, constFilterResponse_t &response) {278 void documentaction::set_spacemacro (displayclass &disp, FilterResponse_t &response) { 295 279 296 280 text_t width; … … 298 282 299 283 int numc = response.docInfo.size(); 300 ResultDocInfo_tarray:: const_iterator dochere = response.docInfo.begin();301 ResultDocInfo_tarray:: const_iterator docend = response.docInfo.end();284 ResultDocInfo_tarray::iterator dochere = response.docInfo.begin(); 285 ResultDocInfo_tarray::iterator docend = response.docInfo.end(); 302 286 303 287 disp.expandstring ("Global", "_pagewidth_", width); … … 308 292 309 293 while (dochere != docend) { 310 text_t title = (*dochere).metadata[0].values[0]; 311 text_tset::const_iterator it = classify_meta.find (title); 312 if (it == classify_meta.end()) title = "Unknown"; 294 const text_t &title = (*dochere).metadata["Title"].values[0]; 313 295 314 296 disp.expandstring ("document", "_" + title + "width_", width); 297 if (width == ("_" + title + "width_")) 298 disp.expandstring ("document", "_defaultwidth_", width); 315 299 iwidth += width.getint(); 316 300 dochere ++; … … 325 309 326 310 // set_navbarmacros sets _navigationbar_, _javaimagesnavbar_ and _httpbrowseXXX_ macros 327 void documentaction::set_navbarmacros (displayclass &disp, const FilterResponse_t &response, 311 // reponse contains 1 metadata field (Title) 312 void documentaction::set_navbarmacros (displayclass &disp, FilterResponse_t &response, 328 313 cgiargsclass &args) { 329 314 … … 334 319 get_top (args["cl"], topparent); 335 320 int numc = response.docInfo.size(); 336 ResultDocInfo_tarray:: const_iterator dochere = response.docInfo.begin();337 ResultDocInfo_tarray:: const_iterator docend = response.docInfo.end();321 ResultDocInfo_tarray::iterator dochere = response.docInfo.begin(); 322 ResultDocInfo_tarray::iterator docend = response.docInfo.end(); 338 323 339 324 navigationbar += "<nobr>\n"; … … 347 332 348 333 while (dochere != docend) { 349 text_t title = (*dochere).metadata[0].values[0]; 350 const text_t &classifytype = (*dochere).metadata[1].values[0]; 351 352 text_tset::const_iterator it = classify_meta.find (title); 353 if (it == classify_meta.end()) title = "Unknown"; 354 334 text_t title = (*dochere).metadata["Title"].values[0]; 335 336 bool unknown = false; 337 338 // test the _XXXwidth_ macro to see if image macros are 339 // defined for this type of classification - if not we'll 340 // just display the text 341 text_t tmpwidth; 342 disp.expandstring ("document", "_" + title + "width_", tmpwidth); 343 if (tmpwidth == ("_" + title + "width_")) unknown = true; 344 355 345 // if we're inside a document all the classification buttons should be enabled 356 if (arg_d.empty() && ((*dochere).OID == topparent)) 357 navigationbar += "_imagespacer__icontab" + title + "green_";358 else {359 navigationbar += "_imagespacer__image" + title + "_";360 346 if (arg_d.empty() && ((*dochere).OID == topparent)) { 347 if (unknown) navigationbar += "_imagespacer_ " + title + " "; 348 else navigationbar += "_imagespacer__icontab" + title + "green_"; 349 } else { 350 361 351 // set the _httpbrowseXXX_ macro for this classification 362 text_t link; 363 if (classifytype == "HTML") 364 link = "_httppagex_(html)&hp=" + (*dochere).OID + ".fc"; 365 else 366 link = "_httpdocument_&cl=" + (*dochere).OID; 367 368 if (classifytype == "AZList" || classifytype == "DateList") link += ".fc"; 369 disp.setmacro ("httpbrowse" + title, "Global", link); 370 371 } 372 javaimagesnavbar += "_java" + title + "_"; 352 if (unknown) navigationbar += "_imagespacer_ <a href=\"_httpdocument_&cl=" + 353 (*dochere).OID + "\">" + title + "</a> "; 354 else { 355 navigationbar += "_imagespacer__image" + title + "_"; 356 disp.setmacro ("httpbrowse" + title, "Global", "_httpdocument_&cl=" + (*dochere).OID); 357 } 358 } 359 if (!unknown) javaimagesnavbar += "_java" + title + "_"; 373 360 dochere ++; 374 361 } … … 376 363 navigationbar += "<!-- End of Navigation Bar -->\n"; 377 364 disp.setmacro ("navigationbar", "Global", navigationbar); 378 if (args.getintarg("v") == 0) 365 if (args.getintarg("v") == 0) 379 366 disp.setmacro ("javaimagesnavbar", "Global", javaimagesnavbar); 380 367 } 381 382 368 383 369 // define all the macros which might be used by other actions 384 370 // to produce pages. 385 void documentaction::define_external_macros (const ColInfoResponse_t &/*collectinfo*/, displayclass &disp,386 cgiargsclass &args, recptproto *collectproto,387 ostream &logout) {371 void documentaction::define_external_macros (const ColInfoResponse_t &/*collectinfo*/, 372 displayclass &disp, cgiargsclass &args, 373 recptproto *collectproto, ostream &logout) { 388 374 389 375 // define_external_macros sets the following macros: … … 413 399 InfoFiltersResponse_t filterinfo; 414 400 FilterResponse_t response; 415 text_t arraymetadata;401 text_tset metadata; 416 402 text_t &collection = args["c"]; 417 403 … … 424 410 if (filterinfo.filterNames.find ("BrowseFilter") != filterinfo.filterNames.end()) { 425 411 426 metadata.push_back ("Title"); 427 metadata.push_back ("classifytype"); 412 metadata.insert ("Title"); 428 413 bool getParents = false; 429 414 get_children ("", collection, metadata, getParents, collectproto, response, logout); … … 443 428 } 444 429 445 446 430 void documentaction::load_formatinfo (const text_tmap &colformat, int gt) { 447 431 … … 454 438 ((*format_here).second == "true")) 455 439 formatinfo.DocumentImages = true; 456 else if (((*format_here).first == "DocumentTopPages") &&457 ((*format_here).second == "false"))458 formatinfo.DocumentTopPages = false;459 440 else if ((*format_here).first == "DocumentHeading") 460 441 formatinfo.DocumentHeading = (*format_here).second; … … 473 454 else if ((*format_here).first == "DocumentText") 474 455 formatinfo.DocumentText = (*format_here).second; 456 else 457 formatinfo.formatstrings[(*format_here).first] = (*format_here).second; 475 458 476 459 format_here ++; … … 522 505 523 506 524 // sets the classificationlinks and navarrows macros525 void documentaction::get_classificationlinks (const text_t &arg_cl, const text_t &collection,526 recptproto *collectproto, displayclass &disp,527 ostream &logout) {528 529 FilterResponse_t response;530 text_t classificationlinks, navarrows, classtop;531 text_tarray metadata;532 533 metadata.push_back ("Title");534 metadata.push_back ("doctype");535 bool getParents = false;536 537 get_top (arg_cl, classtop);538 if (get_children (classtop, collection, metadata, getParents, collectproto, response, logout)) {539 540 // don't want links unless there are 2 or more sections541 if (response.docInfo.size() >= 2) {542 543 classificationlinks += "<!-- Classification Links -->\n";544 classificationlinks += "<table width=_pagewidth_ cellpadding=0 cellspacing=0 border=0>\n";545 classificationlinks += "<tr><td valign=top><center>\n";546 547 ResultDocInfo_tarray::const_iterator sechere = response.docInfo.begin();548 ResultDocInfo_tarray::const_iterator secend = response.docInfo.end();549 550 int lenlinks = 0;551 while (sechere != secend) {552 if ((*sechere).metadata[1].values[0] == "classify") {553 const text_t §ionheading = (*sechere).metadata[0].values[0];554 555 if (((*sechere).OID == arg_cl) || is_child_of((*sechere).OID, arg_cl)) {556 557 // set the _httpprevarrow_, _httpnextarrow_ macros while we're here558 if (formatinfo.DocumentArrowsBottom) {559 if (sechere != response.docInfo.begin())560 disp.setmacro ("httpprevarrow", "document", "_httpdocument_&cl=" + (*(sechere-1)).OID);561 if ((sechere + 1) != secend)562 disp.setmacro ("httpnextarrow", "document", "_httpdocument_&cl=" + (*(sechere+1)).OID);563 }564 565 lenlinks += sectionheading.size();566 classificationlinks += "<b>" + sectionheading + "</b>";567 if (lenlinks > 50) {568 classificationlinks += "<br>\n";569 lenlinks = 0;570 } else {571 if (sechere+1 != secend) classificationlinks += " \n";572 lenlinks += 3;573 }574 } else {575 lenlinks += sectionheading.size();576 classificationlinks += "<a href=\"_httpdocument_&cl=" + (*sechere).OID + "\">";577 classificationlinks += sectionheading + "</a>";578 if (lenlinks > 50) {579 classificationlinks += "<br>\n";580 lenlinks = 0;581 } else {582 if (sechere+1 != secend) classificationlinks += " \n";583 lenlinks += 3;584 }585 }586 }587 sechere ++;588 }589 590 classificationlinks += "\n</center></td></tr></table>\n";591 classificationlinks += "<!-- End of Classification Links -->\n";592 593 disp.setmacro ("classificationlinks", "document", classificationlinks);594 }595 }596 }597 598 599 507 // define all the macros which are related to pages generated 600 508 // by this action. we also load up the formatinfo structure 601 509 // here (it's used in do_action as well as here) 602 void documentaction::define_internal_macros (const ColInfoResponse_t &collectinfo, displayclass &disp,603 cgiargsclass &args, recptproto *collectproto,604 ostream &logout) {510 void documentaction::define_internal_macros (const ColInfoResponse_t &collectinfo, 511 displayclass &disp, cgiargsclass &args, 512 recptproto *collectproto, ostream &logout) { 605 513 606 514 // define_internal_macros sets the following macros: … … 609 517 610 518 // _imagethispage_ the title image to be displayed at top right of page 611 612 // _classificationlinks_ the links between classifications to be displayed613 // at top of list or datelist classifications614 615 // _httpprevarrow_ these are set if next or previous arrows616 // _httpnextarrow_ are to be used - (i.e. if it's an AZList or a DateList617 // classifytype at a top level or if it's a Book or a618 // Hierarchy classifytype at document level619 519 620 520 // _navarrows_ this may be overridden to "" when format option … … 633 533 if (collectproto == NULL) return; 634 534 635 text_t arraymetadata;535 text_tset metadata; 636 536 FilterResponse_t response; 637 537 text_t &arg_d = args["d"]; … … 644 544 disp.setmacro("navarrows", "document", ""); 645 545 646 metadata.push_back ("Title"); 647 metadata.push_back ("classifytype"); 648 metadata.push_back ("archivedir"); 546 metadata.insert ("Title"); 649 547 650 548 if (!arg_d.empty()) { 651 549 // we're at document level 550 551 metadata.insert ("archivedir"); 652 552 653 553 // get metadata for this document and it's parents … … 655 555 disp.setmacro ("header", "document", "_textheader_"); 656 556 657 text_t pagetitle; 658 if (gt) 659 pagetitle = *(response.docInfo[0].metadata[0].values.begin()); 660 else { 661 text_tarray::const_iterator this_title = response.docInfo[0].metadata[0].values.begin(); 662 text_tarray::const_iterator end_title = response.docInfo[0].metadata[0].values.end(); 663 while (this_title != end_title) { 664 if ((this_title + 1) == end_title) pagetitle += *this_title; 665 else pagetitle += *this_title + ": "; 666 this_title ++; 557 text_t pagetitle = response.docInfo[0].metadata["Title"].values[0]; 558 if (!gt) { 559 MetadataInfo_t *parent = response.docInfo[0].metadata["Title"].parent; 560 while (parent != NULL) { 561 pagetitle += ": " + parent->values[0]; 562 parent = parent->parent; 667 563 } 668 564 } 669 565 disp.setmacro ("pagetitle", "document", pagetitle); 670 disp.setmacro ("thisOID", "Global", response.docInfo[0].metadata[2].values[0]); 671 672 text_t &classifytype = response.docInfo[0].metadata[1].values[0]; 673 if (classifytype.empty()) classifytype = "Book"; // defaults to Book 674 675 // set arrow macros if required 676 if (((classifytype == "Book") && (formatinfo.DocumentArrowsTop || formatinfo.DocumentArrowsBottom)) || 677 ((classifytype == "Hierarchy") && formatinfo.DocumentArrowsBottom)) 678 set_arrow_macros (arg_d, classifytype, formatinfo.DocumentTopPages, 679 disp, collectproto, collection, logout); 566 disp.setmacro ("thisOID", "Global", response.docInfo[0].metadata["archivedir"].values[0]); 680 567 681 568 if (args["u"] != "1") … … 691 578 if (get_info (classtop, collection, metadata, false, collectproto, response, logout)) { 692 579 693 text_t title = response.docInfo[0].metadata[0].values[0]; 694 text_t &classifytype = response.docInfo[0].metadata[1].values[0]; 695 696 text_tset::const_iterator it = classify_meta.find (title); 697 if (it == classify_meta.end()) title = "Unknown"; 698 699 disp.setmacro ("pagetitle", "document", "_text" + title + "page_"); 700 disp.setmacro ("imagethispage", "document", "_icon" + title + "page_"); 701 702 // now get the metadata for each child of top level 703 // so we can generate the _classificationlinks_ and arrow macros 704 // (if they're required by the current classification type) 705 706 if ((classifytype == "AZList") || (classifytype == "DateList")) 707 get_classificationlinks (arg_cl, collection, collectproto, disp, logout); 708 580 text_t &title = response.docInfo[0].metadata["Title"].values[0]; 581 bool unknown = false; 582 583 // test the _XXXwidth_ macro to see if image macros are 584 // defined for this type of classification - if not we'll 585 // just display the text 586 text_t tmp; 587 disp.expandstring ("document", "_" + title + "width_", tmp); 588 if (tmp == ("_" + title + "width_")) unknown = true; 589 590 if (unknown) { 591 disp.setmacro ("pagetitle", "document", title); 592 disp.setmacro ("imagethispage", "document", "<h2>" + title + "</h2>"); 593 } else { 594 disp.setmacro ("pagetitle", "document", "_text" + title + "page_"); 595 disp.setmacro ("imagethispage", "document", "_icon" + title + "page_"); 596 } 709 597 } 710 598 } … … 713 601 714 602 715 bool documentaction::do_action (cgiargsclass &args, const ColInfoResponse_t & collectinfo,603 bool documentaction::do_action (cgiargsclass &args, const ColInfoResponse_t &/*collectinfo*/, 716 604 recptproto *collectproto, displayclass &disp, 717 605 outconvertclass &outconvert, ostream &textout, … … 725 613 } else { 726 614 727 text_tarray metadata; 728 FilterResponse_t response; 729 text_t toptitle, toptype, thistype, formatstring; 730 731 text_t &collection = args["c"]; 732 text_t &arg_d = args["d"]; 733 text_t &arg_cl = args["cl"]; 734 735 text_t OID = arg_d; 736 if (arg_d.empty()) OID = arg_cl; 737 615 text_t OID = args["d"]; 616 if (OID.empty()) OID = args["cl"]; 617 if (OID.empty()) { 618 textout << outconvert << disp << "Document contains no data_document:footer_\n"; 619 return true; 620 } 621 738 622 textout << outconvert << disp << "_document:header_\n" 739 623 << "_document:content_\n"; 740 624 741 if (arg_d.empty() && arg_cl.empty()) {742 textout << outconvert << disp << "Document contains no data_document:footer_\n";743 return true;744 }745 746 // get the classifytitle and classifytype for both the top level747 // and the current level (using getParent=true)748 metadata.push_back ("Title");749 metadata.push_back ("classifytype");750 if (get_info (OID, collection, metadata, true, collectproto, response, logout)) {751 toptitle = response.docInfo[0].metadata[0].values[0];752 toptype = response.docInfo[0].metadata[1].values[0];753 thistype = response.docInfo[0].metadata[1].values.back();754 }755 756 text_t formatkey = toptype + toptitle;757 if (!arg_d.empty()) formatkey = toptype + "Document";758 759 text_tmap::const_iterator it = collectinfo.format.find(formatkey);760 if (it != collectinfo.format.end()) formatstring = (*it).second;761 762 625 // output the table of contents 763 if (!arg_d.empty()) { 764 765 if (toptype == "Hierarchy") 766 output_standard_toc (thistype, formatinfo, formatstring, args, 767 collectproto, disp, outconvert, textout, logout); 768 769 else 770 output_document_toc (args, formatinfo, collectproto, disp, 771 outconvert, textout, logout); 772 773 } else { 774 output_standard_toc (thistype, formatinfo, formatstring, args, 775 collectproto, disp, outconvert, textout, logout); 776 } 626 output_toc (args, recpt->get_browsermap_ptr(), formatinfo, 627 collectproto, disp, outconvert, textout, logout); 777 628 778 629 // output the document text … … 785 636 } 786 637 787 void documentaction::output_text ( constResultDocInfo_t &docinfo, format_t *formatlistptr,638 void documentaction::output_text (ResultDocInfo_t &docinfo, format_t *formatlistptr, 788 639 const TermInfo_tarray &terminfo, const text_t &OID, 789 bool highlight, const text_t &hastxt, int wanttext,790 text_t &collection, recptproto *collectproto, displayclass &disp,791 outconvertclass &outconvert, ostream &textout,792 ostream & logout) {640 bool highlight, int hastxt, int wanttext, 641 text_t &collection, recptproto *collectproto, 642 displayclass &disp, outconvertclass &outconvert, 643 ostream &textout, ostream &logout) { 793 644 794 645 DocumentRequest_t docrequest; … … 796 647 comerror_t err; 797 648 798 if (hastxt == "1") {649 if (hastxt == 1) { 799 650 800 651 if (wanttext) { … … 830 681 FilterResponse_t inforesponse; 831 682 FilterResponse_t queryresponse; 832 text_t arraymetadata;683 text_tset metadata; 833 684 bool getParents = false; 834 685 bool highlight = false; … … 849 700 parse_formatstring (formatinfo.DocumentText, formatlistptr, metadata, getParents); 850 701 851 metadata. push_back("hastxt");852 metadata. push_back("haschildren");702 metadata.insert ("hastxt"); 703 metadata.insert ("haschildren"); 853 704 854 705 if (formatinfo.DocumentText == "[Text]") … … 864 715 865 716 if (get_info (OID, collection, metadata, getParents, collectproto, inforesponse, logout)) { 866 text_t hastxt = inforesponse.docInfo[0].metadata[metasize-2].values.back();867 text_t &haschildren = inforesponse.docInfo[0].metadata[metasize-1].values.back();717 int hastxt = inforesponse.docInfo[0].metadata["hastxt"].values[0].getint(); 718 int haschildren = inforesponse.docInfo[0].metadata["haschildren"].values[0].getint(); 868 719 869 720 if (arg_gt == 0) { … … 879 730 // text is to be expanded 880 731 text_t exOID = OID; 881 if (haschildren != "1") exOID = get_parent (OID);732 if (haschildren != 1) exOID = get_parent (OID); 882 733 if (exOID.empty()) exOID = OID; 883 734 884 735 // if we're not in a document (i.e. we're in a top level classification) 885 // we need to pass the "classify" stringto get_contents so that it736 // we need to pass "is_classify = true" to get_contents so that it 886 737 // doesn't recurse all the way through each document in the classification 887 text_t classifytype; 888 if (args["d"].empty()) classifytype = "classify"; 889 890 int i = 0; // not used 891 get_contents (exOID, classifytype, metadata, i, collection, 738 bool is_classify = false; 739 if (args["d"].empty()) is_classify = true; 740 741 get_contents (exOID, is_classify, metadata, collection, 892 742 collectproto, inforesponse, logout); 893 743 894 ResultDocInfo_tarray:: const_iterator sechere = inforesponse.docInfo.begin();895 ResultDocInfo_tarray:: const_iterator secend = inforesponse.docInfo.end();744 ResultDocInfo_tarray::iterator sechere = inforesponse.docInfo.begin(); 745 ResultDocInfo_tarray::iterator secend = inforesponse.docInfo.end(); 896 746 897 747 if (arg_gt == 1) { … … 902 752 int seccount = 0; 903 753 while (sechere != secend) { 904 const text_t &shastxt = (*sechere).metadata[metasize-2].values.back();905 if (shastxt == "1") seccount ++;754 int shastxt = (*sechere).metadata["hastxt"].values[0].getint(); 755 if (shastxt == 1) seccount ++; 906 756 if (seccount > 10) break; 907 757 sechere ++; … … 927 777 textout << outconvert << disp << "\n<p><a name=" << count << "></a>\n"; 928 778 929 const text_t &shastxt = (*sechere).metadata[metasize-2].values.back();779 int shastxt = (*sechere).metadata["hastxt"].values[0].getint(); 930 780 931 781 output_text (*sechere, formatlistptr, queryresponse.termInfo,
Note:
See TracChangeset
for help on using the changeset viewer.