Changeset 1941 for trunk/gsdl/src/recpt/formattools.cpp
- Timestamp:
- 2001-02-09T15:41:33+13:00 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.