Changeset 9948


Ignore:
Timestamp:
2005-05-25T13:51:57+12:00 (19 years ago)
Author:
kjdon
Message:

added [collection] and [collection:metaname] items to format statements. [collection] returns the coll name, and [collection:metaname] returns collection metadata, eg [collection:collectionname] or [colleciton:collectionextra]. this is really only useful for crosscollection searching, where you can't use the _collectionname_ etc macros.

Location:
trunk/gsdl/src/recpt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/formattools.cpp

    r9852 r9948  
    400400//'.. no related documents .. ' is returned.
    401401text_t get_related_docs(const text_t& collection, recptproto* collectproto,
    402                ResultDocInfo_t &docinfo, ostream& logout){
     402            ResultDocInfo_t &docinfo, ostream& logout){
    403403 
    404404  text_tset metadata;
     
    627627}
    628628
     629static 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
    629640static void parse_meta (text_t &meta, format_t *formatlistptr,
    630641            text_tset &metadata, bool &getParents) {
     
    681692  else if (meta == "DocRank")
    682693    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  }
    683698  else {
    684699    formatlistptr->command = comMeta;
     
    686701  }
    687702}
     703
    688704
    689705static bool parse_string (const text_t &formatstring, format_t *formatlistptr,
     
    10251041}
    10261042
    1027 static text_t get_child_meta (const text_t& collection, recptproto* collectproto,
     1043static text_t get_child_meta (const text_t& collection,
     1044                  recptproto* collectproto,
    10281045                  ResultDocInfo_t &docinfo, displayclass &disp,
    10291046                  const metadata_t &meta, text_tmap &options,
     
    11271144  while (orptr != NULL) {
    11281145
    1129     tmp = format_string (collection,collectproto, docinfo, disp, orptr,
     1146    tmp = format_string (collection,collectproto,docinfo, disp, orptr,
    11301147             options, logout);
    11311148    if (!tmp.empty()) return tmp;
     
    13681385          logout) != "") {
    13691386      if (ifptr != NULL)
    1370     return get_formatted_string (collection,collectproto, docinfo, disp, ifptr,
     1387    return get_formatted_string (collection,collectproto,docinfo, disp, ifptr,
    13711388                     options, logout);
    13721389    }
    13731390    else {
    13741391      if (elseptr != NULL)
    1375     return get_formatted_string (collection,collectproto, docinfo, disp, elseptr,
     1392    return get_formatted_string (collection,collectproto,docinfo, disp, elseptr,
    13761393                     options, logout);
    13771394    }
     
    14411458
    14421459static 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,
    14441462                  displayclass &disp, text_tmap &options,
    14451463                  ostream &logout) {
     
    14641482        {
    14651483           text_t expanded_metavalue
    1466           = get_formatted_string(collection, collectproto,
     1484         = get_formatted_string(collection, collectproto,
    14671485                     response.docInfo[0], disp, expanded_formatlistptr,
    14681486                     options, logout);
     
    14811499}
    14821500
     1501text_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}
    14831522text_t format_string (const text_t& collection, recptproto* collectproto,
    14841523              ResultDocInfo_t &docinfo, displayclass &disp,
     
    15121551     case comMeta:
    15131552    {
    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);
    15151554       return expand_metadata(metavalue, collection, collectproto, docinfo, disp, options, logout);
    15161555    }
     
    15431582    return get_or (collection,collectproto, docinfo, disp, formatlistptr->orptr,
    15441583               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   
    15451590  }
    15461591  return "";
     
    15661611// 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?
    15671612text_t format_text (const text_t& collection, recptproto* collectproto,
    1568                ResultDocInfo_t &docinfo, displayclass &disp,
    1569                text_tmap &options, ostream& logout) {
     1613            ResultDocInfo_t &docinfo, displayclass &disp,
     1614            text_tmap &options, ostream& logout) {
    15701615  if(!options["text"].empty()) {
    15711616    return options["text"];
  • trunk/gsdl/src/recpt/formattools.h

    r9401 r9948  
    3636        comDoc, comHighlight, comEndHighlight, comRel, comHref, comSummary,
    3737        comTOC, comImage, comDocumentButtonDetach, comDocumentButtonHighlight,
    38         comDocumentButtonExpandContents, comDocumentButtonExpandText, comOID, comRank};
     38        comDocumentButtonExpandContents, comDocumentButtonExpandText, comOID, comRank, comCollection};
    3939
    4040enum mcommand_t {mNone=0, mCgiSafe=1, mParent=2, mSibling=4, mChild=8};
Note: See TracChangeset for help on using the changeset viewer.