Changeset 1941 for trunk/gsdl
- Timestamp:
- 2001-02-09T15:41:33+13:00 (23 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/browsetools.cpp
r1860 r1941 121 121 } 122 122 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) { 130 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 123 154 124 155 static void recurse_contents (ResultDocInfo_t §ion, cgiargsclass &args, bool fulltoc, … … 542 573 output_controls (args, formatinfo.DocumentButtons, collectproto, disp, 543 574 outconvert, textout, logout); 544 textout << "</td><td valign=top>\n"; 575 textout << "</td><td valign=top>\n"; 545 576 havecontrols = true; 546 577 } … … 560 591 } 561 592 562 if (havecontrols) textout << "</td></tr></table></center>\n"; 563 } 593 if (havecontrols) textout << "</td></tr></table></center>\n"; 594 595 //if there is a format specified in the config file then 596 //try to display the related documents (may not be displayed 597 //if preference file does not indicate a wish to display 598 //related documents. 599 if (!formatinfo.RelatedDocuments.empty()) 600 output_related_docs(args, collectproto, formatinfo, disp, outconvert, textout, logout); 601 602 } 603 604 -
trunk/gsdl/src/recpt/documentaction.cpp
r1860 r1941 144 144 arg_ainfo.savedarginfo = cgiarginfo::must; 145 145 argsinfo.addarginfo (NULL, arg_ainfo); 146 147 //rd is whether a document will be displayed 148 //with a relevant document list 149 arg_ainfo.shortname = "rd"; 150 arg_ainfo.longname = "include relevant documents"; 151 arg_ainfo.multiplechar = false; 152 arg_ainfo.defaultstatus = cgiarginfo::weak; 153 arg_ainfo.argdefault = "0"; 154 arg_ainfo.savedarginfo = cgiarginfo::must; 155 argsinfo.addarginfo (NULL, arg_ainfo); 156 146 157 } 147 158 … … 183 194 if (xinfo != NULL) args["x"] = xinfo->argdefault; 184 195 } 196 197 //checks whether rd arg is valid 198 int arg_rd = args.getintarg("rd"); 199 if (arg_rd != 0 && arg_rd != 1) { 200 logout << "Warning: \"rd\" argument out of range (" << arg_rd << ")\n"; 201 cgiarginfo *rdinfo = argsinfo.getarginfo ("rd"); 202 if (rdinfo != NULL) args["rd"] = rdinfo->argdefault; 203 } 204 185 205 186 206 return true; … … 490 510 '|', formatinfo.DocumentButtons); 491 511 else if ((*format_here).first == "DocumentText") 492 formatinfo.DocumentText = (*format_here).second; 512 formatinfo.DocumentText = (*format_here).second; 513 else if ((*format_here).first == "RelatedDocuments") 514 formatinfo.RelatedDocuments = (*format_here).second; 493 515 else if (((*format_here).first == "DocumentUseHTML") && 494 516 ((*format_here).second == "true")) … … 565 587 options.push_back(opt); 566 588 } 567 589 590 //do not display relation metadata 591 disp.setmacro ("relateddoc", "document", ""); 592 593 //if preferences indicate relevant docs should be collected 594 //and there is no particular format specified then display 595 //this default format. 596 if(args["rd"] == "1" && formatinfo.RelatedDocuments.empty()){ 597 598 text_t relation = ""; //string for displaying relation metadata 599 600 //call function in formattools.cpp which will return the text of the 601 //related documents in a vertical list. This is the default format. 602 if (get_info (arg_d, collection, metadata, options, false, collectproto, response, logout)) 603 relation += get_related_docs(collection, collectproto, response.docInfo[0], logout); 604 605 //set macro to be the related document string 606 disp.setmacro ("relateddoc", "document", relation); 607 } 608 609 568 610 // get metadata for this document and it's parents 569 611 if (get_info (arg_d, collection, metadata, options, 570 612 true, collectproto, response, logout)) { 613 571 614 disp.setmacro ("header", "document", "_textheader_"); 572 615 573 616 text_tarray pagetitlearray; 574 617 if (!response.docInfo[0].metadata["Title"].values[0].empty()) 575 618 pagetitlearray.push_back (response.docInfo[0].metadata["Title"].values[0]); 619 576 620 if (args["gt"] != "1") { 577 621 MetadataInfo_t *parenttitle = response.docInfo[0].metadata["Title"].parent; … … 627 671 } 628 672 629 // Add a macro to display the phind classifier (if appropriate) 673 //if the document is not a document from a collection 674 //we must set the macro to be an empty string 675 disp.setmacro ("relateddoc", "document", ""); 676 677 // Add a macro to display the phind classifier (if appropriate) 630 678 text_t &childtype = response.docInfo[0].metadata["childtype"].values[0]; 631 679 if (childtype == "Phind") { … … 642 690 outconvertclass &outconvert, ostream &textout, 643 691 ostream &logout) { 644 645 692 646 693 // must have a valid collection server 647 694 recptproto *collectproto = protos->getrecptproto (args["c"], logout); … … 660 707 } 661 708 709 662 710 if (formatinfo.DocumentUseHTML) { 663 711 … … 682 730 } 683 731 732 684 733 textout << outconvert << disp << "_document:header_\n" 685 734 << "_document:content_\n"; 686 735 687 736 // output the table of contents 737 logout << "formatinfo.RelatedDocs: " << formatinfo.RelatedDocuments.getcstr() << endl; 688 738 output_toc (args, browsers, formatinfo, collectproto, 689 739 disp, outconvert, textout, logout); 690 740 741 //output the related documents (may be the empty string) 742 //will not output the docs if a format string is specified 743 textout << outconvert << disp << "_document:relateddoc_\n"; 744 691 745 // output the document text 692 746 textout << "<p>\n"; … … 774 828 } 775 829 830 776 831 format_t *formatlistptr = new format_t(); 777 832 parse_formatstring (formatinfo.DocumentText, formatlistptr, metadata, getParents); … … 779 834 metadata.insert ("hastxt"); 780 835 metadata.insert ("haschildren"); 781 836 782 837 if (formatinfo.DocumentText == "[Text]") 783 838 wanttext = 1; -
trunk/gsdl/src/recpt/formattools.cpp
r1610 r1941 69 69 DocumentHeading = "{Or}{[parent(Top):Title],[Title],untitled}<br>"; 70 70 DocumentContents = true; 71 DocumentArrowsBottom = true; 71 DocumentArrowsBottom = true; 72 72 DocumentButtons.erase (DocumentButtons.begin(), DocumentButtons.end()); 73 73 // DocumentButtons.push_back ("Expand Text"); … … 75 75 DocumentButtons.push_back ("Detach"); 76 76 DocumentButtons.push_back ("Highlight"); 77 RelatedDocuments = ""; 77 78 DocumentText = "<center><table width=_pagewidth_><tr><td>[Text]</td></tr></table></center>"; 78 79 formatstrings.erase (formatstrings.begin(), formatstrings.end()); … … 171 172 return day + " " + month + " " + year; 172 173 } 174 175 176 //this function gets the information associated with the relation 177 //metadata for the document associated with 'docinfo'. This relation 178 //metadata consists of a line of pairs containing 'collection, document OID' 179 //(this is the OID of the document related to the current document, and 180 //the collection the related document belongs to). For each of these pairs 181 //the title metadata is obtained and then an html link between the title 182 //of the related doc and the document's position (the document will be 183 //found in "<a href=\"_httpdocument_&c=collection&cl=search&d=OID"> 184 //(where collection is the related documents collection, and OID is the 185 //related documents OID). A list of these html links are made for as many 186 //related documents as there are. This list is then returned. If there are 187 //no related documents available for the current document then the string 188 //'.. no related documents .. ' is returned. 189 text_t get_related_docs(const text_t& collection, recptproto* collectproto, 190 ResultDocInfo_t &docinfo, ostream& logout){ 191 192 text_tset metadata; 193 194 //insert the metadata we wish to collect 195 metadata.insert("relation"); 196 metadata.insert("Title"); 197 metadata.insert("Subject"); //for emails, where title data doesn't apply 198 199 FilterResponse_t response; 200 text_t relation = ""; //string for displaying relation metadata 201 text_t relationTitle = ""; //the related documents Title (or subject) 202 text_t &relationOID = ""; //the related documents OID 203 204 //get the information associated with the metadata for current doc 205 if (get_info (docinfo.OID, collection, metadata, 206 false, collectproto, response, logout)) { 207 208 //if the relation metadata exists, store for displaying 209 if(!response.docInfo[0].metadata["relation"].values.empty()){ 210 relationOID += response.docInfo[0].metadata["relation"].values[0]; 211 212 //split relation data into pairs of collectionname,ID number 213 text_tarray relationpairs; 214 splitchar (relationOID.begin(), relationOID.end(), ' ', relationpairs); 215 216 text_tarray::const_iterator currDoc = relationpairs.begin(); 217 text_tarray::const_iterator lastDoc = relationpairs.end(); 218 219 //iterate through the pairs to split and display 220 while(currDoc != lastDoc){ 221 222 //split pairs into collectionname and ID 223 text_tarray relationdata; 224 splitchar ((*currDoc).begin(), (*currDoc).end(), ',', relationdata); 225 226 //get first element in the array (collection) 227 text_tarray::const_iterator doc_data = relationdata.begin(); 228 text_t document_collection = *doc_data; 229 doc_data++; //increment to get next item in array (oid) 230 text_t document_OID = *doc_data; 231 232 //create html link to related document 233 relation += "<a href=\"_httpdocument_&c=" + document_collection; 234 relation += "&cl=search&d=" + document_OID; 235 236 //get the information associated with the metadata for related doc 237 if (get_info (document_OID, document_collection, metadata, 238 false, collectproto, response, logout)) { 239 240 //if title metadata doesn't exist, collect subject metadata 241 //if that doesn't exist, just call it 'related document' 242 if (!response.docInfo[0].metadata["Title"].values[0].empty()) 243 relationTitle = response.docInfo[0].metadata["Title"].values[0]; 244 else if (!response.docInfo[0].metadata["Subject"].values.empty()) 245 relationTitle = response.docInfo[0].metadata["Subject"].values[0]; 246 else relationTitle = "RELATED DOCUMENT"; 247 248 } 249 250 //link the related document's title to its page 251 relation += "\">" + relationTitle + "</a>"; 252 relation += " (" + document_collection + ")<br>"; 253 254 currDoc++; 255 } 256 } 257 258 } 259 260 if(relation.empty()) //no relation data for documnet 261 relation = ".. no related documents .. "; 262 263 return relation; 264 } 265 266 173 267 174 268 static void get_parent_options (text_t &instring, metadata_t &metaoption) { … … 238 332 else if (meta == "Text") 239 333 formatlistptr->command = comDoc; 334 335 else if (meta == "RelatedDocuments") 336 formatlistptr->command = comRel; 240 337 241 338 else if (meta == "highlight") … … 645 742 } 646 743 744 745 647 746 text_t format_string (const text_t& collection, recptproto* collectproto, 648 747 ResultDocInfo_t &docinfo, displayclass &disp, … … 666 765 case comNum: 667 766 return docinfo.result_num; 767 case comRel: //if [RelatedDocuments] appears in format string, collect relation data 768 return get_related_docs(collection, collectproto, docinfo, logout); 668 769 case comMeta: 669 770 … … 692 793 = get_formatted_string(collection, collectproto, 693 794 response.docInfo[0], disp, expanded_formatlistptr, 694 link,icon,highlight, 695 logout); 795 link, icon, highlight, logout); 696 796 697 797 return expanded_metavalue; -
trunk/gsdl/src/recpt/formattools.h
r1610 r1941 34 34 35 35 enum command_t {comIf, comOr, comMeta, comText, comLink, comEndLink, comNum, comIcon, 36 comDoc, comHighlight, comEndHighlight };36 comDoc, comHighlight, comEndHighlight, comRel};//changed 37 37 enum pcommand_t {pNone, pImmediate, pTop, pAll}; 38 38 enum dcommand_t {dMeta, dText}; … … 88 88 text_tarray DocumentButtons; 89 89 text_t DocumentText; 90 //----------------- 91 text_t RelatedDocuments; 92 //---------------- 90 93 text_tmap formatstrings; 91 94 bool DocumentUseHTML; … … 102 105 103 106 text_t format_date (const text_t &date); 107 108 109 text_t get_related_docs(const text_t& collection, recptproto* collectproto, 110 ResultDocInfo_t &docinfo, ostream& logout); 111 104 112 105 113 bool parse_formatstring (const text_t &formatstring, format_t *formatlistptr, -
trunk/gsdl/src/recpt/zparse.tab.c
r1450 r1941 1 1 2 2 /* A Bison parser, made from zparse.y 3 by GNU Bison version 1.27 4 */ 3 by GNU Bison version 1.28 */ 5 4 6 5 #define YYBISON 1 /* Identify Bison output. */ … … 236 235 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ 237 236 #line 3 "/usr/share/bison.simple" 238 /* This file comes from bison-1.2 7. */237 /* This file comes from bison-1.28. */ 239 238 240 239 /* Skeleton output parser for bison, … … 451 450 452 451 453 #line 21 6"/usr/share/bison.simple"452 #line 217 "/usr/share/bison.simple" 454 453 455 454 /* The user can define YYPARSE_PARAM as the name of an argument to be passed … … 944 943 } 945 944 /* the action file gets copied in in place of this dollarsign */ 946 #line 54 2"/usr/share/bison.simple"945 #line 543 "/usr/share/bison.simple" 947 946 948 947
Note:
See TracChangeset
for help on using the changeset viewer.