Changeset 284 for trunk/gsdl/src/recpt/documentaction.cpp
- Timestamp:
- 1999-06-24T17:12:25+12:00 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/documentaction.cpp
r282 r284 12 12 /* 13 13 $Log$ 14 Revision 1.8 1999/06/24 05:12:20 sjboddie 15 lots of small changes 16 14 17 Revision 1.7 1999/06/17 03:06:58 sjboddie 15 18 got detach button working properly - the close book icon is now disabled … … 148 151 } 149 152 150 bool documentaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &/*args*/, 151 ostream &/*logout*/) { 152 // don't want to check anything yet. 153 bool documentaction::check_cgiargs (cgiargsinfoclass &argsinfo, cgiargsclass &args, 154 ostream &logout) { 155 156 // note that "gp" argument gets checked in define_external_macros() 157 158 // check gc argument 159 int arg_gc = args.getintarg("gc"); 160 if (arg_gc != 0 && arg_gc != 1) { 161 logout << "Warning: \"gc\" argument out of range (" << arg_gc << ")\n"; 162 cgiarginfo *gcinfo = argsinfo.getarginfo ("gc"); 163 if (gcinfo != NULL) args["gc"] = gcinfo->argdefault; 164 } 165 166 // check gt argument (may be either 0, 1 or 2) 167 int arg_gt = args.getintarg("gt"); 168 if (arg_gt != 0 && arg_gt != 1 && arg_gt != 2) { 169 logout << "Warning: \"gt\" argument out of range (" << arg_gt << ")\n"; 170 cgiarginfo *gtinfo = argsinfo.getarginfo ("gt"); 171 if (gtinfo != NULL) args["gt"] = gtinfo->argdefault; 172 } 173 174 // check hl argument 175 int arg_hl = args.getintarg("hl"); 176 if (arg_hl != 0 && arg_hl != 1) { 177 logout << "Warning: \"hl\" argument out of range (" << arg_hl << ")\n"; 178 cgiarginfo *hlinfo = argsinfo.getarginfo ("hl"); 179 if (hlinfo != NULL) args["hl"] = hlinfo->argdefault; 180 } 181 182 // check x argument 183 int arg_x = args.getintarg("x"); 184 if (arg_x != 0 && arg_x != 1) { 185 logout << "Warning: \"x\" argument out of range (" << arg_x << ")\n"; 186 cgiarginfo *xinfo = argsinfo.getarginfo ("x"); 187 if (xinfo != NULL) args["x"] = xinfo->argdefault; 188 } 189 153 190 return true; 154 191 } … … 380 417 381 418 text_t pagetitle; 382 text_tarray::const_iterator this_title = response.docInfo[0].metadata[0].values.begin(); 383 text_tarray::const_iterator end_title = response.docInfo[0].metadata[0].values.end(); 384 while (this_title != end_title) { 385 if ((this_title + 1) == end_title) pagetitle += *this_title; 386 else pagetitle += *this_title + ": "; 387 this_title ++; 419 if (args.getintarg("gt") == 2) 420 pagetitle = *(response.docInfo[0].metadata[0].values.begin()); 421 else { 422 text_tarray::const_iterator this_title = response.docInfo[0].metadata[0].values.begin(); 423 text_tarray::const_iterator end_title = response.docInfo[0].metadata[0].values.end(); 424 while (this_title != end_title) { 425 if ((this_title + 1) == end_title) pagetitle += *this_title; 426 else pagetitle += *this_title + ": "; 427 this_title ++; 428 } 388 429 } 389 430 disp.setmacro ("pagetitle", "document", pagetitle); … … 423 464 text_t &classifytype = response.docInfo[0].metadata[1].values[0]; 424 465 425 disp.setmacro ("imagethispage", "document", 426 "_icon" + title + "page_"); 466 disp.setmacro ("pagetitle", "document", "_text" + title + "page_"); 467 468 disp.setmacro ("imagethispage", "document", "_icon" + title + "page_"); 427 469 428 470 // now get the metadata for each child of top level … … 495 537 text_tarray metadata; 496 538 FilterResponse_t response; 497 FilterResponse_t queryresponse;498 DocumentRequest_t docrequest;499 DocumentResponse_t docresponse;500 539 text_t topparent, classifytype, classifytitle; 501 comerror_t err;502 bool highlight = false;503 540 504 541 text_t &arg_d = args["d"]; 505 542 text_t &arg_cl = args["cl"]; 506 text_t &collection = args["c"];507 543 508 544 text_t OID = arg_d; … … 515 551 textout << outconvert << disp << "Document contains no data_document:footer_\n"; 516 552 return true; 517 }518 519 // if we have a query string and highlighting is turned on we need520 // to redo the query to get the terms for highlighting521 if (!args["q"].empty() && args.getintarg("hl")) {522 FilterRequest_t request;523 text_t quotedstring; // don't use this here524 request.filterResultOptions = FRmatchTerms;525 if (do_query (request, args, collectproto, quotedstring, queryresponse, logout))526 highlight = true;527 553 } 528 554 … … 531 557 metadata.push_back ("Title"); 532 558 metadata.push_back ("classifytype"); 533 if (get_info (topparent, collection, metadata, false, collectproto, response, logout)) {559 if (get_info (topparent, args["c"], metadata, false, collectproto, response, logout)) { 534 560 classifytitle = response.docInfo[0].metadata[0].values[0]; 535 561 classifytype = response.docInfo[0].metadata[1].values[0]; 536 562 } 537 563 564 // output the table of contents 538 565 if (!arg_d.empty()) { 539 566 … … 542 569 outconvert, textout, logout); 543 570 else 544 // Book is the default for a document level toc - AZList and Datelist don't545 // make sense for document level571 // Book is the default for a document level toc - AZList, List and 572 // Datelist don't make sense for document level 546 573 output_book_toc (classifytitle, args, collectproto, disp, 547 574 outconvert, textout, logout); … … 554 581 output_datelist_toc (classifytitle, args, collectproto, disp, 555 582 outconvert, textout, logout); 583 else if (classifytype == "List") 584 output_list_toc (classifytitle, args, collectproto, disp, 585 outconvert, textout, logout); 556 586 else 557 587 // AZList is the default for a classification level toc - Book doesn't make … … 560 590 outconvert, textout, logout); 561 591 } 562 563 // get info on this document 564 metadata.erase (metadata.begin(), metadata.end()); 565 metadata.push_back("Title"); 566 metadata.push_back("hastxt"); 567 metadata.push_back("haschildren"); 568 569 if (get_info (OID, collection, metadata, false, collectproto, response, logout)) { 570 text_t &title = response.docInfo[0].metadata[0].values[0]; 571 int hastxt = response.docInfo[0].metadata[1].values[0].getint(); 572 int haschildren = response.docInfo[0].metadata[2].values[0].getint(); 592 593 // output the document text 594 output_document (OID, args, collectproto, disp, outconvert, textout, logout); 595 596 textout << outconvert << disp << "_document:footer_\n"; 597 } 598 return true; 599 } 600 601 602 void documentaction::output_document (const text_t &OID, cgiargsclass &args, 603 recptproto *collectproto, displayclass &disp, 604 outconvertclass &outconvert, ostream &textout, 605 ostream &logout) { 606 FilterResponse_t inforesponse; 607 DocumentRequest_t docrequest; 608 DocumentResponse_t docresponse; 609 FilterResponse_t queryresponse; 610 comerror_t err; 611 text_tarray metadata; 612 bool highlight = false; 613 int arg_gt = args.getintarg("gt"); 614 text_t &collection = args["c"]; 615 616 // if we have a query string and highlighting is turned on we need 617 // to redo the query to get the terms for highlighting 618 if (!args["q"].empty() && args.getintarg("hl")) { 619 FilterRequest_t request; 620 request.filterResultOptions = FRmatchTerms; 621 text_t quotedquery; // not used 622 if (do_query (request, args, collectproto, quotedquery, queryresponse, logout)) 623 highlight = true; 624 } 625 626 // get info on this document 627 metadata.push_back("Title"); 628 metadata.push_back("hastxt"); 629 metadata.push_back("haschildren"); 630 631 if (get_info (OID, collection, metadata, false, collectproto, inforesponse, logout)) { 632 text_t title = inforesponse.docInfo[0].metadata[0].values[0]; 633 int hastxt = inforesponse.docInfo[0].metadata[1].values[0].getint(); 634 int haschildren = inforesponse.docInfo[0].metadata[2].values[0].getint(); 573 635 574 int gt = args.getintarg("gt"); 575 if (gt == 0) { 576 if (hastxt == 1) { 577 // get the text 636 if (arg_gt == 0) { 637 if (hastxt == 1) { 638 // get the text 639 docrequest.OID = OID; 640 collectproto->get_document (collection, docrequest, docresponse, err, logout); 641 642 textout << outconvert << disp << "<p>\n<h3>" << title << "</h3>"; 643 if (highlight) 644 highlighttext(docresponse.doc, queryresponse.termInfo, disp, 645 outconvert, textout, logout); 646 else 647 textout << outconvert << disp << docresponse.doc; 648 } 649 } else { 650 651 // text is to be expanded 652 text_t exOID = OID; 653 if (!haschildren) exOID = get_parent (OID); 654 655 // if we're not in a document (i.e. we're in a top level classification) 656 // we need to pass the "classify" string to get_contents so that it 657 // doesn't recurse all the way through each document in the classification 658 text_t classifytype; 659 if (args["d"].empty()) classifytype = "classify"; 660 661 int i; // not used 662 get_contents (exOID, classifytype, i, collection, collectproto, inforesponse, logout); 663 664 ResultDocInfo_tarray::const_iterator sechere = inforesponse.docInfo.begin(); 665 ResultDocInfo_tarray::const_iterator secend = inforesponse.docInfo.end(); 666 667 if (arg_gt == 1) { 668 // check if there are more than 10 sections containing text to be expanded - 669 // if there are output warning message - this isn't a great way to do this 670 // since the sections may be very large or very small - one day I'll fix it 671 // -- Stefan. 672 int seccount = 0; 673 while (sechere != secend) { 674 if ((*sechere).metadata[3].values[0] == "1") seccount ++; 675 if (seccount > 10) break; 676 sechere ++; 677 } 678 if (seccount > 10) { 679 // more than 10 sections so output warning message and text 680 // for current section only 681 textout << outconvert << disp << "_document:textltwarning_"; 578 682 docrequest.OID = OID; 579 683 collectproto->get_document (collection, docrequest, docresponse, err, logout); … … 586 690 textout << outconvert << disp << docresponse.doc; 587 691 } 588 } else { 589 590 // text is to be expanded 591 int tmp; // this doesn't get used here 592 if (!haschildren) 593 OID = get_parent (OID); 594 595 get_contents (OID, classifytype, tmp, collection, collectproto, response, logout); 596 597 ResultDocInfo_tarray::const_iterator sechere = response.docInfo.begin(); 598 ResultDocInfo_tarray::const_iterator secend = response.docInfo.end(); 599 600 if (gt == 1) { 601 // check if there are more than 10 sections containing text to be expanded - 602 // if there are output warning message - this isn't a great way to do this 603 // since the sections may be very large or very small - one day I'll fix it 604 // -- Stefan. 605 int seccount = 0; 606 while (sechere != secend) { 607 if ((*sechere).metadata[3].values[0] == "1") seccount ++; 608 if (seccount > 10) break; 609 sechere ++; 692 else arg_gt = 2; 693 } 694 695 if (arg_gt == 2) { 696 // get the text for each section 697 sechere = inforesponse.docInfo.begin(); 698 int count = 0; 699 while (sechere != secend) { 700 textout << outconvert << disp << "\n<p><a name=" << count << "><h3>" 701 << (*sechere).metadata[0].values[0] << "</h3></a>\n"; 702 if ((*sechere).metadata[3].values[0] == "1") { 703 docrequest.OID = (*sechere).OID; 704 collectproto->get_document (collection, docrequest, docresponse, err, logout); 705 if (highlight) 706 highlighttext(docresponse.doc, queryresponse.termInfo, disp, 707 outconvert, textout, logout); 708 else 709 textout << outconvert << disp << docresponse.doc; 610 710 } 611 if (seccount > 10) textout << outconvert << disp << "_document:textltwarning_";612 else gt = 2;711 count ++; 712 sechere ++; 613 713 } 614 615 if (gt == 2) { 616 // get the text for each section 617 sechere = response.docInfo.begin(); 618 int count = 0; 619 while (sechere != secend) { 620 textout << outconvert << disp << "\n<p><a name=" << count << "><h3>" 621 << (*sechere).metadata[0].values[0] << "</h3></a>\n"; 622 if ((*sechere).metadata[3].values[0] == "1") { 623 docrequest.OID = (*sechere).OID; 624 collectproto->get_document (collection, docrequest, docresponse, err, logout); 625 if (highlight) 626 highlighttext(docresponse.doc, queryresponse.termInfo, disp, 627 outconvert, textout, logout); 628 else 629 textout << outconvert << disp << docresponse.doc; 630 } 631 count ++; 632 sechere ++; 633 } 634 } 635 } 636 } 637 textout << outconvert << disp << "_document:footer_\n"; 638 } 639 return true; 640 } 641 714 } 715 } 716 } 717 } 642 718 643 719 // highlighttext highlights query terms in text string and outputs the resulting text string
Note:
See TracChangeset
for help on using the changeset viewer.