Ignore:
Timestamp:
1999-08-11T10:38:09+12:00 (25 years ago)
Author:
sjboddie
Message:

added some more format options

File:
1 edited

Legend:

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

    r422 r442  
    1212/*
    1313   $Log$
     14   Revision 1.7  1999/08/10 22:38:08  sjboddie
     15   added some more format options
     16
    1417   Revision 1.6  1999/07/30 02:25:42  sjboddie
    1518   made format_date function global
     
    4245// a few function prototypes
    4346static text_t format_string (const ResultDocInfo_t &docinfo, format_t *formatlistptr,
    44                  const text_t &link, const text_t &icon);
     47                 const text_t &link, const text_t &icon, const text_t &text);
    4548
    4649static bool parse_action (text_t::const_iterator &here, const text_t::const_iterator &end,
     
    7174  orptr = NULL;
    7275};
     76
     77void formatinfo_t::clear() {
     78  DocumentImages = false;
     79  // note that DocumentTopPages is used in receptionist when translating
     80  // OIDs. changing the default here may require changing it there too.
     81  DocumentTopPages = true;
     82  DocumentHeading = "{Or}{[parent(Top):Title],[Title],untitled}";
     83  DocumentArrowsTop = true;
     84  DocumentArrowsBottom = true;
     85  DocumentGoTo = true;
     86  DocumentButtons.erase (DocumentButtons.begin(), DocumentButtons.end());
     87  DocumentButtons.push_back ("Detach");
     88  DocumentButtons.push_back ("Highlight");
     89  DocumentButtons.push_back ("Expand Text");
     90  DocumentButtons.push_back ("Expand Contents");
     91  DocumentText = "[Text]";
     92}
     93
    7394
    7495// returns a date of form _textmonthnn_ 31, 1999
     
    167188  else if (meta == "icon")
    168189    formatlistptr->command = comIcon;
     190
     191  else if (meta == "Text")
     192    formatlistptr->command = comDoc;
    169193
    170194  else {
     
    434458
    435459static text_t get_or (const ResultDocInfo_t &docinfo, format_t *orptr,
    436               const text_t &link, const text_t &icon) {
     460              const text_t &link, const text_t &icon, const text_t &text) {
    437461
    438462  text_t tmp;
    439463  while (orptr != NULL) {
    440464
    441     tmp = format_string (docinfo, orptr, link, icon);
     465    tmp = format_string (docinfo, orptr, link, icon, text);
    442466    if (!tmp.empty()) return tmp;
    443467
     
    449473static text_t get_if (const ResultDocInfo_t &docinfo, const decision_t &decision,
    450474              format_t *ifptr, format_t *elseptr, const text_t &link,
    451               const text_t &icon) {
     475              const text_t &icon, const text_t &text) {
    452476
    453477  // not much of a choice yet ...
     
    455479    if (get_meta (docinfo, decision.meta) != "") {
    456480      if (ifptr != NULL)
    457     return get_formatted_string (docinfo, ifptr, link, icon);
     481    return get_formatted_string (docinfo, ifptr, link, icon, text);
    458482    }
    459483    else {
    460484      if (elseptr != NULL)
    461     return get_formatted_string (docinfo, elseptr, link, icon);
     485    return get_formatted_string (docinfo, elseptr, link, icon, text);
    462486    }
    463487  }
     
    465489}
    466490
    467 static text_t format_string (const ResultDocInfo_t &docinfo, format_t *formatlistptr,
    468                  const text_t &link, const text_t &icon) {
     491text_t format_string (const ResultDocInfo_t &docinfo, format_t *formatlistptr,
     492              const text_t &link, const text_t &icon, const text_t &text) {
    469493
    470494  if (formatlistptr == NULL) return "";
     
    476500    return link;
    477501  case comEndLink:
    478     return "</a>";
     502    if (link.empty) return "";
     503    else return "</a>";
    479504  case comIcon:
    480505    return icon;
     
    483508  case comMeta:
    484509    return get_meta (docinfo, formatlistptr->meta);
     510  case comDoc:
     511    return text;
    485512  case comIf:
    486513    return get_if (docinfo, formatlistptr->decision, formatlistptr->ifptr,
    487            formatlistptr->elseptr, link, icon);
     514           formatlistptr->elseptr, link, icon, text);
    488515  case comOr:
    489     return get_or (docinfo, formatlistptr->orptr, link, icon);
     516    return get_or (docinfo, formatlistptr->orptr, link, icon, text);
    490517  }
    491518  return "";
    492519}
    493 
    494520
    495521
     
    497523                 const text_t &link, const text_t &icon) {
    498524
     525  text_t text;
     526
    499527  text_t ft;
    500528  while (formatlistptr != NULL) {
    501     ft += format_string (docinfo, formatlistptr, link, icon);
     529    ft += format_string (docinfo, formatlistptr, link, icon, text);
    502530    formatlistptr = formatlistptr->nextptr;
    503531  }
     
    510538  text_t link = "<a href=\"_httpdocument_&cl=search&d=" + docinfo.OID + "\">";
    511539  text_t icon = "_icontext_";
     540  text_t text;
    512541
    513542  text_t ft;
    514543  while (formatlistptr != NULL) {
    515     ft += format_string (docinfo, formatlistptr, link, icon);
     544    ft += format_string (docinfo, formatlistptr, link, icon, text);
    516545    formatlistptr = formatlistptr->nextptr;
    517546  }
     
    520549
    521550
    522 
    523 
     551text_t get_formatted_string (const ResultDocInfo_t &docinfo, format_t *formatlistptr,
     552                 const text_t &text) {
     553
     554  text_t link = "<a href=\"_httpdocument_&cl=search&d=" + docinfo.OID + "\">";
     555  text_t icon = "_icontext_";
     556
     557  text_t ft;
     558  while (formatlistptr != NULL) {
     559    ft += format_string (docinfo, formatlistptr, link, icon, text);
     560    formatlistptr = formatlistptr->nextptr;
     561  }
     562  return ft;
     563}
     564
     565
     566text_t get_formatted_string (const ResultDocInfo_t &docinfo, format_t *formatlistptr,
     567                 const text_t &link, const text_t &icon, const text_t &text) {
     568
     569  text_t ft;
     570  while (formatlistptr != NULL) {
     571    ft += format_string (docinfo, formatlistptr, link, icon, text);
     572    formatlistptr = formatlistptr->nextptr;
     573  }
     574  return ft;
     575}
     576
     577
     578
Note: See TracChangeset for help on using the changeset viewer.