Changeset 9948
- Timestamp:
- 2005-05-25T13:51:57+12:00 (19 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/formattools.cpp
r9852 r9948 400 400 //'.. no related documents .. ' is returned. 401 401 text_t get_related_docs(const text_t& collection, recptproto* collectproto, 402 402 ResultDocInfo_t &docinfo, ostream& logout){ 403 403 404 404 text_tset metadata; … … 627 627 } 628 628 629 static void parse_coll_meta(text_t &meta, metadata_t &metaoption) { 630 if (meta == "collection") { 631 // no qualifiers 632 metaoption.metaname = g_EmptyText; 633 return; 634 } 635 meta = substr (meta.begin()+11, meta.end()); 636 metaoption.metaname = meta; 637 638 } 639 629 640 static void parse_meta (text_t &meta, format_t *formatlistptr, 630 641 text_tset &metadata, bool &getParents) { … … 681 692 else if (meta == "DocRank") 682 693 formatlistptr->command = comRank; 694 else if (meta.size() >= 10 && (substr(meta.begin(), meta.begin()+10) == "collection")) { 695 formatlistptr->command = comCollection; 696 parse_coll_meta(meta, formatlistptr->meta); 697 } 683 698 else { 684 699 formatlistptr->command = comMeta; … … 686 701 } 687 702 } 703 688 704 689 705 static bool parse_string (const text_t &formatstring, format_t *formatlistptr, … … 1025 1041 } 1026 1042 1027 static text_t get_child_meta (const text_t& collection, recptproto* collectproto, 1043 static text_t get_child_meta (const text_t& collection, 1044 recptproto* collectproto, 1028 1045 ResultDocInfo_t &docinfo, displayclass &disp, 1029 1046 const metadata_t &meta, text_tmap &options, … … 1127 1144 while (orptr != NULL) { 1128 1145 1129 tmp = format_string (collection,collectproto, 1146 tmp = format_string (collection,collectproto,docinfo, disp, orptr, 1130 1147 options, logout); 1131 1148 if (!tmp.empty()) return tmp; … … 1368 1385 logout) != "") { 1369 1386 if (ifptr != NULL) 1370 return get_formatted_string (collection,collectproto, 1387 return get_formatted_string (collection,collectproto,docinfo, disp, ifptr, 1371 1388 options, logout); 1372 1389 } 1373 1390 else { 1374 1391 if (elseptr != NULL) 1375 return get_formatted_string (collection,collectproto, 1392 return get_formatted_string (collection,collectproto,docinfo, disp, elseptr, 1376 1393 options, logout); 1377 1394 } … … 1441 1458 1442 1459 static text_t expand_metadata(const text_t &metavalue, const text_t& collection, 1443 recptproto* collectproto, ResultDocInfo_t &docinfo, 1460 recptproto* collectproto, 1461 ResultDocInfo_t &docinfo, 1444 1462 displayclass &disp, text_tmap &options, 1445 1463 ostream &logout) { … … 1464 1482 { 1465 1483 text_t expanded_metavalue 1466 = get_formatted_string(collection, collectproto,1484 = get_formatted_string(collection, collectproto, 1467 1485 response.docInfo[0], disp, expanded_formatlistptr, 1468 1486 options, logout); … … 1481 1499 } 1482 1500 1501 text_t get_collection_meta(const text_t& collection, recptproto* collectproto, 1502 displayclass &disp, 1503 text_t meta_name, ostream& logout) { 1504 1505 ColInfoResponse_t collectinfo; 1506 comerror_t err; 1507 collectproto->get_collectinfo (collection, collectinfo,err,logout); 1508 text_t meta_value = ""; 1509 text_t lang; 1510 disp.expandstring("_cgiargl_",lang); 1511 if (lang.empty()) { 1512 lang = "en"; 1513 } 1514 1515 if (err == noError) { 1516 meta_value = collectinfo.get_collectionmeta(meta_name, lang); 1517 } 1518 return meta_value; 1519 1520 1521 } 1483 1522 text_t format_string (const text_t& collection, recptproto* collectproto, 1484 1523 ResultDocInfo_t &docinfo, displayclass &disp, … … 1512 1551 case comMeta: 1513 1552 { 1514 const text_t& metavalue = get_meta (collection,collectproto, docinfo, disp,formatlistptr->meta,options,logout);1553 const text_t& metavalue = get_meta (collection,collectproto, docinfo, disp,formatlistptr->meta,options,logout); 1515 1554 return expand_metadata(metavalue, collection, collectproto, docinfo, disp, options, logout); 1516 1555 } … … 1543 1582 return get_or (collection,collectproto, docinfo, disp, formatlistptr->orptr, 1544 1583 options, logout); 1584 case comCollection: 1585 if (formatlistptr->meta.metaname == g_EmptyText) { 1586 return collection; 1587 } 1588 return get_collection_meta(collection, collectproto, disp, formatlistptr->meta.metaname, logout); 1589 1545 1590 } 1546 1591 return ""; … … 1566 1611 // we have only preloaded the text in DocumentAction. But you may want to get the text in query. so copy what we have done with format_summary and get the text here. probably is quite expensive? 1567 1612 text_t format_text (const text_t& collection, recptproto* collectproto, 1568 1569 1613 ResultDocInfo_t &docinfo, displayclass &disp, 1614 text_tmap &options, ostream& logout) { 1570 1615 if(!options["text"].empty()) { 1571 1616 return options["text"]; -
trunk/gsdl/src/recpt/formattools.h
r9401 r9948 36 36 comDoc, comHighlight, comEndHighlight, comRel, comHref, comSummary, 37 37 comTOC, comImage, comDocumentButtonDetach, comDocumentButtonHighlight, 38 comDocumentButtonExpandContents, comDocumentButtonExpandText, comOID, comRank };38 comDocumentButtonExpandContents, comDocumentButtonExpandText, comOID, comRank, comCollection}; 39 39 40 40 enum mcommand_t {mNone=0, mCgiSafe=1, mParent=2, mSibling=4, mChild=8};
Note:
See TracChangeset
for help on using the changeset viewer.