Ignore:
Timestamp:
1999-10-15T11:59:35+13:00 (25 years ago)
Author:
sjboddie
Message:

finished off browser classes

File:
1 edited

Legend:

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

    r649 r668  
    2828/*
    2929   $Log$
     30   Revision 1.2  1999/10/14 22:59:34  sjboddie
     31   finished off browser classes
     32
    3033   Revision 1.1  1999/10/10 08:14:11  sjboddie
    3134   - metadata now returns mp rather than array
     
    4649}
    4750
    48 
    49 
    50 // configure should be called once for each configuration line
    51 // the default version does nothing
    52 void vlistbrowserclass::configure (const text_t &/*key*/, const text_tarray &/*cfgline*/) {
    53 }
    54 
    55 // init should be called after all the configuration is done but
    56 // before any other methods are called
    57 bool vlistbrowserclass::init (ostream &/*logout*/) {
    58   return true;
    59 }
    60 
    6151// returns the name that specifies the browserclass type
    6252text_t vlistbrowserclass::get_browser_name () {
     
    6454}
    6555
    66 void vlistbrowserclass::processOID (cgiargsclass &/*args*/) {
    67 }
    68 
    6956void vlistbrowserclass::load_metadata_defaults (text_tset &metadata) {
    7057  metadata.insert ("haschildren");
    7158  metadata.insert ("doctype");
    72   metadata.insert ("classifytype");
     59}
     60
     61text_t vlistbrowserclass::get_default_formatstring () {
     62  return "<td>[link][icon][/link]</td><td>[highlight]{Or}{[Title],Untitled}[/highlight]</td>";
    7363}
    7464
    7565int vlistbrowserclass::output_section_group (ResultDocInfo_t &section, cgiargsclass &args,
    76                          const int &colnumber, format_t *formatlistptr,
    77                          const bool &use_table, displayclass &disp,
    78                          outconvertclass &outconvert, ostream &textout,
    79                          ostream &logout) {
     66                         int colnumber, format_t *formatlistptr,
     67                         bool use_table, text_tset &/*metadata*/, bool &/*getParents*/,
     68                         recptproto */*collectproto*/, displayclass &disp,
     69                         outconvertclass &outconvert, ostream &textout, ostream &/*logout*/) {
    8070
    8171  text_t link, icon;
    8272  get_link_icon (section, args, link, icon);
    83 
    84   output_section (section, colnumber, formatlistptr, use_table,
    85           link, icon, disp, outconvert, textout, logout);
    86  
    87   return 1;
    88 }
    89 
    90 void vlistbrowserclass::output_section (ResultDocInfo_t &section, const int &colnumber,
    91                     format_t *formatlistptr, const bool &use_table,
    92                     const text_t &link, const text_t &icon,
    93                     displayclass &disp, outconvertclass &outconvert,
    94                     ostream &textout, ostream &logout) {
    95                    
     73  bool highlight = false;
     74  if (!args["d"].empty()) {
     75    if (args["d"] == section.OID) highlight = true;
     76  } else
     77    if (args["cl"] == section.OID) highlight = true;
     78
     79
    9680  if (use_table || colnumber > 0) {
    97     textout << "<table><tr><td>";
     81    textout << "<table><tr>";
    9882    // get tab size
    9983    text_t tab; int itab;
     
    10185    itab = tab.getint();
    10286    if (colnumber > 0) textout << outconvert << disp
    103                    << "<img src=\"_httpimg_/space.gif\" width="
    104                    << (itab*colnumber) << ">";
    105     textout << "</td>";
    106   }
    107 
    108   textout << outconvert << disp << get_formatted_string (section, formatlistptr, link, icon);
    109 
     87                   << "<td><img src=\"_httpimg_/space.gif\" width="
     88                   << (itab*colnumber) << "></td>";
     89  }
     90
     91  textout << outconvert << disp << get_formatted_string (section, formatlistptr,
     92                             link, icon, highlight);
     93 
    11094  if (use_table  || colnumber > 0) textout << "</tr></table>\n";
     95
     96  return 1;
     97}
     98
     99int vlistbrowserclass::output_section_group (FilterResponse_t &sections, cgiargsclass &args,
     100                         int colnumber, format_t *formatlistptr,
     101                         bool use_table, text_tset &/*metadata*/, bool &/*getParents*/,
     102                         recptproto */*collectproto*/, displayclass &disp,
     103                         outconvertclass &outconvert, ostream &textout, ostream &/*logout*/) {
     104
     105  text_t link, icon;
     106  text_t &arg_d = args["d"];
     107  text_t &arg_cl = args["cl"];
     108
     109  if (colnumber > 0) {
     110    textout << "<table><tr>";
     111    // get tab size
     112    text_t tab; int itab;
     113    disp.expandstring ("Global", "_tabwidth_", tab);
     114    itab = tab.getint();
     115    if (colnumber > 0) textout << outconvert << disp
     116                   << "<td><img src=\"_httpimg_/space.gif\" width="
     117                   << (itab*colnumber) << "></td>";
     118    textout << "<td>";
     119  }
     120  if (use_table) textout << "<table>\n";
     121
     122  ResultDocInfo_tarray::iterator thissection = sections.docInfo.begin();
     123  ResultDocInfo_tarray::iterator endsection = sections.docInfo.end();
     124
     125  while (thissection != endsection) {
     126
     127    get_link_icon (*thissection, args, link, icon);
     128    bool highlight = false;
     129    if (!arg_d.empty()) {
     130      if (arg_d == (*thissection).OID) highlight = true;
     131    } else
     132      if (arg_cl == (*thissection).OID) highlight = true;
     133
     134    if (use_table || colnumber > 0) textout << "<tr>";
     135    textout << outconvert << disp << get_formatted_string (*thissection, formatlistptr,
     136                               link, icon, highlight);
     137    if (use_table || colnumber > 0) textout << "</tr>";
     138    textout << "\n";
     139    thissection ++;
     140  }
     141
     142  if (use_table) textout << "</table>\n";
     143  if (colnumber > 0) textout << "</table></td></tr></table>\n";
     144
     145  return 1;
    111146}
    112147
     
    119154  link = "<a href=\"_httpdocument_";
    120155  icon = "_document:icontext_";
    121   int haschildren = section.metadata["haschildren"].values.back().getint();
    122   const text_t doctype = section.metadata["doctype"].values.back();
     156  int haschildren = section.metadata["haschildren"].values[0].getint();
     157  const text_t doctype = section.metadata["doctype"].values[0];
     158
     159  text_t &arg_d = args["d"];
     160  text_t &arg_cl = args["cl"];
    123161
    124162  if (args["a"] == "q") {
     
    128166    link += "&cl=search&d=" + section.OID + "\">";
    129167
    130   } else if (!args["d"].empty()) {
     168  } else if (!arg_d.empty()) {
    131169    // document level
    132170    if (is_top(section.OID)) {
    133171      icon = "_document:iconopenbook_";
    134       if (args["cl"] == "search") link = "<a href=\"_httpquery_\">";
    135       else link += "&cl=" + args["cl"] + "&d=" + section.OID + ".pr\">";
     172      if (arg_cl == "search") link = "<a href=\"_httpquery_\">";
     173      else link += "&cl=" + arg_cl + "\">";
    136174   
    137175    } else if (haschildren == 1) {
    138       if ((args["gc"] == "1") || (is_child_of (section.OID, args["d"]))) {
     176      if ((args["gc"] == "1") ||
     177      (is_child_of (section.OID, arg_d)) ||
     178      (section.OID == arg_d)) {
    139179    icon = "_document:iconopenfolder_";
    140     link += "&cl=" + args["cl"] + "&d=" + section.OID + ".pr\">";
     180    link += "&cl=" + arg_cl + "&d=" + section.OID + ".pr\">";
    141181      } else {
    142182    icon = "_document:iconclosedfolder_";
    143     link += "&cl=" + args["cl"] + "&d=" + section.OID + "\">";
     183    link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
    144184      }
    145     } else link += "&cl=" + args["cl"] + "&d=" + section.OID + "\">";
     185    } else link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
    146186
    147187  } else {
     
    149189    if (haschildren == 1) {
    150190      if (doctype == "classify") {
    151     if ((args["gc"] == "1") || (is_child_of (section.OID, args["cl"]))) {
     191    if ((args["gc"] == "1") ||
     192        (is_child_of (section.OID, arg_cl)) ||
     193        (section.OID == arg_cl)) {
    152194      icon = "_document:iconopenbookshelf_";
    153195      link += "&cl=" + section.OID + ".pr\">";
     
    158200      } else {
    159201    icon = "_document:iconclosedbook_";
    160     link += "&cl=" + args["cl"] + "&d=" + section.OID + "\">";
     202    link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
    161203      }
    162204    } else {
    163205      if (doctype == "classify") link = "";
    164       else link += "&cl=" + args["cl"] + "&d=" + section.OID + "\">";
     206      else link += "&cl=" + arg_cl + "&d=" + section.OID + "\">";
    165207    }
    166208  }
Note: See TracChangeset for help on using the changeset viewer.