Changeset 213


Ignore:
Timestamp:
1999-03-29T14:14:31+12:00 (25 years ago)
Author:
sjboddie
Message:

More changes to browseaction

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

Legend:

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

    r211 r213  
    1212/*
    1313   $Log$
     14   Revision 1.4  1999/03/29 02:14:25  sjboddie
     15
     16   More changes to browseaction
     17
    1418   Revision 1.3  1999/03/25 03:13:42  sjboddie
    1519
     
    7983
    8084// don't know how to do this yet either ...
    81 bool contains_text (const text_t &OID) {
     85bool contains_text (const text_t &/*OID*/) {
    8286  return true;
    8387}
  • trunk/gsdl/src/recpt/browseaction.cpp

    r207 r213  
    1212/*
    1313   $Log$
     14   Revision 1.2  1999/03/29 02:14:27  sjboddie
     15
     16   More changes to browseaction
     17
    1418   Revision 1.1  1999/03/25 03:09:40  sjboddie
    1519
     
    2125
    2226#include "browseaction.h"
    23 #include "OIDtools.h"
    2427#include "browsetools.h"
    2528
    2629browseaction::browseaction () {
    2730  // this action uses cgi variables "a", "d", "cl",
    28   // "x", and "g"
     31  // "x", "gc", and "gt"
    2932  cgiarginfo arg_ainfo;
    3033  arg_ainfo.shortname = "a";
     
    5255  argsinfo.addarginfo (NULL, arg_ainfo);
    5356
    54   // in this action "g" controls the expand/contract
    55   // text and expand/contract contents functions
    56   // i.e 00 is both contracted 01 is contents contracted,
    57   // text expanded etc.
    58   arg_ainfo.shortname = "g";
    59   arg_ainfo.longname = "browse type";
    60   arg_ainfo.multiplechar = true;
     57  // in this action "gc" controls the expand/contract
     58  // contents function
     59  arg_ainfo.shortname = "gc";
     60  arg_ainfo.longname = "expand contents";
     61  arg_ainfo.multiplechar = false;
    6162  arg_ainfo.defaultstatus = cgiarginfo::weak;
    62   arg_ainfo.argdefault = "00";
     63  arg_ainfo.argdefault = "0";
     64  arg_ainfo.savedarginfo = cgiarginfo::can;
     65  argsinfo.addarginfo (NULL, arg_ainfo);
     66
     67  // in this action "gt" controls the expand/contract
     68  // text function
     69  arg_ainfo.shortname = "gt";
     70  arg_ainfo.longname = "expand text";
     71  arg_ainfo.multiplechar = false;
     72  arg_ainfo.defaultstatus = cgiarginfo::weak;
     73  arg_ainfo.argdefault = "0";
    6374  arg_ainfo.savedarginfo = cgiarginfo::can;
    6475  argsinfo.addarginfo (NULL, arg_ainfo);
     
    95106                       recptproto *collectproto, ostream &logout) {
    96107
    97   text_t ctype, cname, toc;
    98   collectproto->get_classification_type (args["cl"], ctype, cname);
     108  text_t ctype, cname, toc, navbar;
     109
     110  collectproto->get_classification_info (args["cl"], ctype, cname);
    99111
    100112  // set the _toc_ macro
    101113  if (ctype == "hierarchy") get_hierarchy_toc (args, collectproto, toc, logout);
    102114  else if (ctype == "book") get_book_toc (args, collectproto, toc, logout);
    103   else if (ctype == "datelist") get_datelist_toc (args, collectproto, toc, logout);
    104   else get_list_toc (args, collectproto, toc, logout); // list is the default
     115  else if (ctype == "datelist") {
     116    get_datelist_toc (args, collectproto, toc, logout);
     117    set_arrow_links (disp, args, collectproto, cname, logout);
     118    set_classification_links (disp, args, collectproto, cname, logout);
     119  } else {
     120    get_list_toc (args, collectproto, toc, logout); // list is the default
     121    set_arrow_links (disp, args, collectproto, cname, logout);
     122    set_classification_links (disp, args, collectproto, cname, logout);
     123  }
    105124  disp.setmacro ("toc", cname, toc);
     125
     126  // set the _navigationbar_ macro
     127  set_navigation_bar (disp, args, collectproto, cname, logout);
    106128}
    107129
     
    109131bool browseaction::do_action (cgiargsclass &args, recptproto *collectproto,
    110132                  displayclass &disp, outconvertclass &outconvert,
    111                   ostream &textout, ostream &logout) {
     133                  ostream &textout, ostream &/*logout*/) {
    112134
    113135  if (collectproto == NULL) return false;
    114136
    115137  text_t ctype, cname;
    116   collectproto->get_classification_type (args["cl"], ctype, cname);
     138  collectproto->get_classification_info (args["cl"], ctype, cname);
    117139
    118140  textout << outconvert << disp << ("_" + cname + ":header_\n")
    119       << ("_" + cname + ":imagestandardbar_\n") << ("_" + cname + ":content_\n")
    120       << ("_" + cname + ":footer_\n");
     141      << ("_" + cname + ":content_\n") << ("_" + cname + ":footer_\n");
    121142
    122143  return true;
    123144}
    124145
    125 
    126 
    127 
    128 //////////////////////////////////////////////////////////////////////////////////////////////
    129 // get_top_locator returns (in return_text) the html for the top browsing section
    130 
    131 void browseaction::get_top_locator(cgiargsclass &args, recptproto *collectproto,
    132                       bool oversize, text_t &return_text, ostream &logout) {
    133  
    134   return_text = "\n<!-- top locator produced by browseaction::get_top_locator -->\n\n";
    135 
    136   comerror_t err;
    137   MetadataResponse_t resp;
    138   MetadataRequest_t req;
    139   text_t doclink;
    140   text_t &arg_d = args["d"];
    141 
    142   return_text += "<p><table width=\"100%\" cellpadding=0 cellspacing=0 border=0><tr>\n";
    143  
    144   if (args["x"] == "1") doclink = "<a href=\"_gwcgi_?e=_compressedoptions_&q=_urlsafequerystring_&x=1";
    145   else doclink = "<a href=\"_gwcgi_?e=_compressedoptions_&q=_urlsafequerystring_";
    146 
    147   // get book cover jpeg and detach/expand/collapse buttons
    148   if (!arg_d.empty() && !is_top (arg_d)) {
    149     text_t top, jpeg_file;
    150     get_top(arg_d, top);
    151 
    152     req.OIDs.push_back (top);
    153     req.fields.push_back ("Title");
    154     req.languages.push_back ("en");
    155 
    156     collectproto->get_metadata (args["c"], req, resp, err, logout);
    157     if (err == noError) {
    158       text_t jobnum;
    159       jobnum = resp.metadata[0];
    160       jpeg_file = "_httpcollection_/archives/" + jobnum + "/" + jpeg_file + ".jpg";
    161       return_text += "<td valign=top width=200><img src=\"" + jpeg_file + "\"><br>\n";
    162     } else {
    163       return_text += "Error (" + get_comerror_string (err)
    164           + ") while getting metadata\n";
    165     }
    166 
    167     if (args["u"] != 1) {
    168       // detach button
    169       return_text += doclink + "&x=1\" target=\"_pagedest_\" ";
    170       return_text += "_imagedetach_";
    171       // expand/collapse contents button
    172       if (args["g"][0] == '1') {
    173     return_text += doclink + "&g=0";
    174     return_text.push_back(args["g"][1]);
    175     return_text += "_imagecontracttoc_";
    176       } else {
    177       return_text += doclink + "&g=1";
    178       return_text.push_back(args["g"][1]);
    179       return_text += "_imageexpandtoc_";
    180       }
    181       // expand/collapse text buttons
    182       if (args["g"][1] == '1') {
    183     return_text += doclink + "&g=";
    184     return_text.push_back(args["g"][0]);
    185     return_text += "_imagecontracttext_";
    186       } else {
    187     return_text += doclink + "&g=";
    188     return_text.push_back(args["g"][0]);
    189     return_text += "_imageexpandtext_";
    190       }
    191     }
    192    
    193     if (oversize) {
    194       return_text += "<font color=#FF0000><br>_iconwarning_ this will generate a <br>large amount of\n";
    195       return_text += "data <br>\n";
    196       return_text += doclink + "&n=1&g=";
    197       return_text.push_back(args["g"][0]);
    198       return_text += "1\" _imagecont_</font>\n";
    199     }
    200 
    201     return_text += "</td>\n";
    202    
    203   } else {
    204     // don't want expanded contents at top levels
    205     if (args["g"][0] == '1') {
    206       text_t t;
    207       t.push_back('0');
    208       t.push_back(args["g"][1]);
    209       args.setarg("g", t);
    210     }
    211   }
    212   return_text += "<td valign=top>\n";
    213  
    214   // get table of contents
    215   if (args["g"][0] == '1') {
    216     get_expanded_toc(args, collectproto, return_text, logout);
    217   } else {
    218     get_contracted_toc(args, collectproto, return_text, logout);
    219   }
    220 
    221   return_text += "</td></tr></table>\n";
    222   return_text += "\n<!-- end of top locator -->\n";
    223 }
    224 
    225 
    226 void browseaction::get_contracted_toc (cgiargsclass &args, recptproto *collectproto,
    227                           text_t &return_text, ostream &logout) {
    228  
    229   return_text += "\n<!-- contracted toc produced by browseaction::get_contracted_toc -->\n";
    230 
    231   int colnum, tabcount = 0;
    232   text_tarray parents, siblings;
    233  
    234   // load up the parents array
    235 
    236   // don't want classifications unless at top level contents
    237   if (!(args["cl"]).empty() && is_top(args["d"]))
    238     get_parents_array (args["cl"] + ".", parents);
    239   get_parents_array (args["d"], parents);
    240 
    241   // load up siblings array
    242   if ((args["d"]).empty()) get_children_array (get_parent(args["cl"]), siblings);
    243   else if (is_top (args["d"])) get_children_array (args["cl"], siblings);
    244   else get_children_array (get_parent(args["d"]), siblings);
    245 
    246   return_text += "<table>\n";
    247   colnum = parents.size() + 1;
    248 
    249   // sort out toc of sections parents
    250   if (parents.size() > 0)
    251     get_parents_toc(args, parents, tabcount, colnum, return_text);
    252  
    253   // sort out toc of sections siblings
    254   if (siblings.size() > 0)
    255     get_siblings_toc (args, siblings, tabcount, colnum, return_text);
    256              
    257   return_text += "</table>\n";
    258   return_text += "\n<!-- end of contracted toc -->\n";
    259 }
    260 
    261 
    262 void browseaction::get_expanded_toc (cgiargsclass &args, recptproto *collectproto,
    263                         text_t &return_text, ostream &logout) {
    264 
    265   return_text += "\n<!-- expanded toc produced by browseaction::get_expanded_toc -->\n";
    266   /*
    267   text_t doclink, icon, pointer, tab, pagetype;
    268   int totalcols, tabcols, tabsleft;
    269   text_tarray contents;
    270  
    271   // get array of all contents to be included (all contents of entire book)
    272   text_t book_top;
    273   get_book_top (booksection, book_top);
    274   get_contents (book_top, gdbm, contents, totalcols);
    275  
    276   vector<text_t>::const_iterator section = contents.begin();
    277   vector<text_t>::const_iterator end = contents.end();
    278  
    279   int count = 1;
    280   while (section != end) {
    281     tab.clear();
    282     gdbm.getinfo(*section, info);
    283     text_t icontabs;
    284 
    285     // set up icon
    286     icon = "_iconsmalltext_";
    287     if (is_top_level(*section)) icon = "_iconopenbook_";
    288     else if (!info.contents.empty()) icon = "_iconopenfolder_";
    289 
    290     // set up pointer
    291     if (*section == booksection) pointer = "_iconpointer_";
    292     else pointer = "_icontab_";
    293 
    294     // set up tabbing
    295     tabcols = count_dots(*section);
    296     for (int i = 0; i < (tabcols - 1); i++) {
    297       icontabs += "_icontab_";
    298     }
    299     //char *tabcolsstr;
    300     //itoa(tabcols, tabcolsstr, 10);
    301     tab = "<td valign=top colspan=" + text_t(tabcols);
    302     tab += ">" + icontabs + pointer + "</td>";
    303     tabsleft = totalcols - tabcols;
    304    
    305     // set up url
    306     if (is_book(*section) && !is_top_level(*section))   
    307       doclink = "<a href=\"_httptext_";
    308     else doclink = "<a href=\"_httpbrowse_";
    309     if (args["x"] == "1") doclink += "&x=1";
    310    
    311     return_text += "<tr>" + tab + "<td valign=top>";
    312     if (is_top_level(*section) && args["x"] == "1") {
    313       return_text += "<a href=\"\" onClick = \"close_detach()";
    314     } else {
    315       if (args["g"][1] == '0' || is_top_level(*section) ||
    316       !are_same_chapter(booksection, *section) ||
    317       !info.contents.empty()) {
    318     return_text += doclink + "d=" + classification;
    319     return_text += "." + *section + "&a=" + pagetype;
    320       } else {
    321     return_text += "<a href=\"#";
    322     return_text += count;
    323     count ++;
    324       }
    325     }
    326     return_text += "\">" + icon + "</a></td>";
    327     return_text += "<td colspan=" + text_t(tabsleft);
    328     return_text += ">" + info.title;
    329     return_text += "</td></tr>\n";
    330    
    331     section ++;
    332   }
    333   return_text += "</table>\n";
    334   return_text += "</td></tr></table>\n";
    335   */
    336   return_text += "\n<!-- end of expanded toc -->\n";
    337 }
    338 
    339 
    340 void browseaction::get_parents_toc (cgiargsclass &args, const text_tarray &parents,
    341                        int &tabcount, int &colnum, text_t &return_text) { 
    342 
    343   return_text += "\n<!-- parents toc produced by browseaction::get_parents_toc -->\n";
    344 
    345   text_t section, tab, icon, doclink;
    346 
    347   doclink = "<a href=\"_httpbrowse_";
    348   if (args["x"] == "1") doclink += "&x=1";
    349 
    350   text_tarray::const_iterator thisparent = parents.begin();
    351   text_tarray::const_iterator end = parents.end();
    352 
    353   while (thisparent != end) {
    354     text_t icontabs;
    355     section.clear();
    356     tab.clear();
    357    
    358     // set up icon for this parent
    359     icon = "_iconopenfolder_";
    360     if (is_classification(*thisparent)) icon = "_iconopenbookshelf_";
    361     else if (is_top(*thisparent)) icon = "_iconopenbook_";
    362    
    363     for (int j = 0; j < tabcount; j++)
    364       icontabs += "_icontab_";
    365      
    366     if (!icontabs.empty()) {
    367       tab = "<td valign=top";
    368       if (tabcount > 1) tab += " colspan=" + text_t(tabcount);
    369       tab += ">" + icontabs + "</td>";
    370     }
    371     tabcount ++;
    372    
    373     if (is_top(*thisparent) && args["x"] == "1") {
    374       return_text += "<tr>" + tab + "<td valign=top><a href=\"\" ";
    375       return_text += "onClick = \"close_detach()\">" + icon + "</a></td>";
    376     } else {
    377       if (is_classification (*thisparent))
    378     return_text += "<tr>" + tab + "<td valign=top>" + doclink + "&cl=" + *thisparent;
    379       else
    380     // this may not need cl= bit once compressed args is done
    381     return_text += "<tr>" + tab + "<td valign=top>" + doclink + "&cl=" + args["cl"] + "&d=" + *thisparent;
    382       return_text += "\">" + icon + "</a></td>";
    383     }
    384     return_text += "<td";
    385     if (colnum > 1) return_text += " colspan=" + text_t(colnum);
    386     return_text += ">" + *thisparent + " title ";
    387     return_text += " by " + *thisparent + " author ";
    388     return_text += "</td></tr>\n";
    389     colnum --;
    390     thisparent ++;
    391   }
    392 
    393   return_text += "\n<!-- end of parents toc -->\n";
    394 }
    395 
    396 
    397 void browseaction::get_siblings_toc (cgiargsclass &args, const text_tarray &siblings,
    398                         int &tabcount, int &colnum, text_t &return_text) {
    399  
    400   return_text += "\n<!-- siblings toc produced by browseaction::get_siblings_toc -->\n";
    401 
    402   text_t tab, icon, pointer, child, doclink;
    403   int count = 1;
    404 
    405   doclink = "<a href=\"_httpbrowse_";
    406   if (args["x"] == "1") doclink += "&x=1";
    407  
    408   text_tarray::const_iterator thissibling = siblings.begin();
    409   text_tarray::const_iterator sibend = siblings.end();
    410  
    411   while (thissibling != sibend) {
    412 
    413     // set up icon for this sibling
    414     icon = "_iconclosedfolder_";
    415     if (is_classification(*thissibling)) icon = "_iconclosedbookshelf_";
    416     else if (is_top(*thissibling)) icon = "_iconclosedbook_";
    417    
    418     // fit pointer into tabbing if current section
    419     pointer = "_icontab_";
    420     if (is_classification(*thissibling)) {
    421       if (*thissibling == args["cl"])
    422     pointer = "_iconpointer_";
    423     } else if (*thissibling == args["d"]) pointer = "_iconpointer_";
    424    
    425     text_t thesetabs;
    426     for (int j = 0; j < (tabcount - 1); j++)
    427       thesetabs += "_icontab_";
    428    
    429     tab = "<td valign=top";
    430     if (tabcount > 1) tab += " colspan=" + text_t(tabcount);
    431     tab += ">" + thesetabs + pointer + "</td>";
    432    
    433     if (contains_text(*thissibling)) {
    434       // sibling is text document
    435       icon = "_iconsmalltext_";
    436      
    437       return_text += "<tr>" + tab + "<td valign=top>";
    438       if (args["g"][1] == '0') {
    439     return_text += doclink + "&d=" + *thissibling;
    440       } else {
    441     return_text += "<a href=\"#";
    442     return_text += count;
    443     count ++;
    444       }
    445       return_text += "\">" + icon + "</a></td><td";
    446       if (colnum > 1) return_text += " colspan=" + text_t(colnum);
    447       return_text += ">" + *thissibling + " title";
    448       return_text += " by " + *thissibling + " author";
    449       return_text += "</td></tr>\n";
    450     } else {
    451       // sibling is closed book or folder so clicking
    452       // it should open contents
    453       get_first_child(*thissibling, child);
    454      
    455       return_text += "<tr>" + tab + "<td valign=top>" + doclink + "&d=" + child;
    456       return_text += "\">" + icon + "</a></td><td";
    457       if (colnum > 1) return_text += " colspan=" + text_t(colnum);
    458       return_text += ">" + *thissibling + " title";
    459       return_text += " by " + *thissibling + " author";
    460       return_text += "</td></tr>\n";
    461     }
    462     thissibling ++;
    463   } 
    464   return_text += "\n<!-- end of siblings toc -->\n";
    465 }
  • trunk/gsdl/src/recpt/browseaction.h

    r207 r213  
    1919class browseaction : public action {
    2020
    21 
    22 protected:
    23   void get_browse_bar(const text_t &classification, text_t &return_text);
    24   void get_top_locator(cgiargsclass &args, recptproto *collectproto,
    25                bool oversize, text_t &return_text, ostream &logout);
    26   void get_contracted_toc (cgiargsclass &args, recptproto *collectproto,
    27                text_t &return_text, ostream &logout);
    28   void get_expanded_toc (cgiargsclass &args, recptproto *collectproto,
    29              text_t &return_text, ostream &logout);
    30   void get_parents_toc (cgiargsclass &args, const text_tarray &parents,
    31             int &tabcount, int &colnum, text_t &return_text); 
    32   void get_siblings_toc (cgiargsclass &args, const text_tarray &siblings,
    33              int &tabcount, int &colnum, text_t &return_text);
    3421
    3522public:
  • trunk/gsdl/src/recpt/browsetools.cpp

    r208 r213  
    1212/*
    1313   $Log$
     14   Revision 1.2  1999/03/29 02:14:29  sjboddie
     15
     16   More changes to browseaction
     17
    1418   Revision 1.1  1999/03/25 03:10:15  sjboddie
    1519
     
    2024
    2125#include "browsetools.h"
     26#include "OIDtools.h"
     27
     28// sets all the required macros for displaying the navigation bar
     29void set_navigation_bar (displayclass &disp, cgiargsclass &args,
     30             recptproto *collectproto, const text_t &cname,
     31             ostream &/*logout*/) {
     32
     33  text_tarray classifications;
     34  text_t width, navigationbar, javaimagesnavbar;
     35  int twidth, swidth, iwidth = 0;
     36
     37  collectproto->get_all_classifications (classifications);
     38  text_tarray::const_iterator here = classifications.begin();
     39  text_tarray::const_iterator end = classifications.end();
     40
     41  navigationbar = "<!-- Navigation Bar -->\n";
     42
     43  // calculate width of spacers and set macro
     44  if (args.getintarg("v") == 0) {
     45    disp.expandstring ("Global", "_pagewidth_", width);
     46    twidth = width.getint();
     47
     48    disp.expandstring ("query", "_searchwidth_", width);
     49    iwidth += width.getint();
     50
     51    while (here != end) {
     52      disp.expandstring (*here, "_" + *here + "width_", width);
     53      iwidth += width.getint();
     54      here ++;
     55    }
     56
     57    if (classifications.size() == 0) swidth = twidth - iwidth;
     58    else if ((twidth - iwidth) < int(classifications.size())) swidth = 2;
     59    else swidth = (twidth - iwidth) / classifications.size();
     60    disp.setmacro ("widthtspace", "Global", swidth);
     61  }
     62
     63  navigationbar += "<nobr>\n_imagesearch_";
     64  javaimagesnavbar = "_javasearch_";
     65  here = classifications.begin();
     66  while (here != end) {
     67    if (*here == cname)
     68      navigationbar += "_imagespacer__icontab" + *here + "green_";
     69    else
     70      navigationbar += "_imagespacer__image" + *here + "_";
     71    javaimagesnavbar += "_java" + *here + "_";
     72    here ++;
     73  }
     74  navigationbar += "\n</nobr>\n";
     75  navigationbar += "<!-- End of Navigation Bar -->\n";
     76  disp.setmacro ("navigationbar", cname, navigationbar);
     77  if (args.getintarg("v") == 0)
     78    disp.setmacro ("javaimagesnavbar", cname, javaimagesnavbar);
     79}
     80
     81
     82// sets the _httparrowprevious_ and _httparrownext_ macros
     83// used by the forward and reverse navigation arrows
     84void set_arrow_links (displayclass &disp, cgiargsclass &args,
     85              recptproto */*collectproto*/, const text_t &cname,
     86              ostream &/*logout*/) {
     87
     88  disp.setmacro ("httparrowprevious", cname, args["d"] + ".prevpage");
     89  disp.setmacro ("httparrownext", cname, args["d"] + ".nextpage");
     90
     91}
     92
     93
     94// sets the _classificationlinks_ macro
     95void set_classification_links (displayclass &disp, cgiargsclass &args,
     96                   recptproto */*collectproto*/, const text_t &cname,
     97                   ostream &/*logout*/) {
     98
     99  if ((args["cl"]).empty()) return;
     100
     101  text_t link = "<a\nhref=\"_httpbrowse_&d=";
     102  text_tarray siblings;
     103  text_t child, classificationlinks;
     104
     105  get_children_array (get_parent(args["cl"]), siblings);
     106   
     107  classificationlinks += "<!-- Classification Links -->\n";
     108  classificationlinks += "<table width=_pagewidth_ cellpadding=0 cellspacing=0 border=0>\n";
     109  classificationlinks += "<tr><td valign=top><center>\n";
     110 
     111  text_tarray::const_iterator here = siblings.begin();
     112  text_tarray::const_iterator end = siblings.end();
     113
     114  while (here != end) {
     115    if (*here == args["cl"]) {
     116      classificationlinks += "\n<b>" + *here + "</b>&nbsp;&nbsp;&nbsp;";
     117    } else {
     118      get_first_child (*here, child);
     119      classificationlinks += link + *here + "." + child + "\">";
     120      classificationlinks += *here + "</a>";
     121      if ((here + 1) != end) classificationlinks += "&nbsp;&nbsp;&nbsp;";
     122    }
     123    here ++;
     124  }
     125 
     126  classificationlinks += "\n</center></td></tr></table>\n";
     127  classificationlinks += "<!-- End of Classification Links -->\n";
     128 
     129  disp.setmacro ("classificationlinks", cname, classificationlinks);
     130}
    22131
    23132
     
    25134            text_t &toc, ostream &logout) {
    26135
    27 
    28 
    29 }
    30 
    31 void get_book_toc (cgiargsclass &args, recptproto *collectproto,
    32            text_t &toc, ostream &logout) {
    33 
    34 }
    35 
    36 void get_datelist_toc (cgiargsclass &args, recptproto *collectproto,
    37                text_t &toc, ostream &logout) {
    38 
    39 }
    40 
    41 void get_list_toc (cgiargsclass &args, recptproto *collectproto,
    42            text_t &toc, ostream &logout) {
    43 
    44 }
     136  toc.clear();
     137  toc += "\n<!-- Table of Contents produced by browsetools::get_hierarchy_toc -->\n\n";
     138
     139  toc += "<p><table width=100% cellpadding=0 cellspacing=0 border=0><tr>\n";
     140  toc += "<td valign=top>\n";
     141 
     142  // get table of contents
     143  if (args.getintarg("gc"))
     144    get_expanded_toc(args, collectproto, toc, logout);
     145  else
     146    get_contracted_toc(args, collectproto, toc, logout);
     147 
     148  toc += "</td></tr></table>\n";
     149  toc += "\n<!-- end of Table of Contents -->\n";
     150}
     151
     152
     153void get_book_toc (cgiargsclass &/*args*/, recptproto */*collectproto*/,
     154           text_t &/*toc*/, ostream &/*logout*/) {
     155
     156}
     157
     158
     159void get_datelist_toc (cgiargsclass &/*args*/, recptproto */*collectproto*/,
     160               text_t &/*toc*/, ostream &/*logout*/) {
     161
     162}
     163
     164
     165void get_list_toc (cgiargsclass &args, recptproto */*collectproto*/,
     166           text_t &toc, ostream &/*logout*/) {
     167
     168  text_tarray siblings;
     169  toc += "\n<!-- Table of Contents produced by browsetools::get_list_toc -->\n\n";
     170
     171  // load up siblings array
     172  if ((args["d"]).empty()) get_children_array (get_parent(args["cl"]), siblings);
     173  else if (is_top (args["d"])) get_children_array (args["cl"], siblings);
     174  else get_children_array (get_parent(args["d"]), siblings);
     175
     176  text_t section, child;
     177  text_t doclink = "<a href=\"_httptext_&d=";
     178  toc += "<p>\n";
     179 
     180  text_tarray::const_iterator thissection = siblings.begin();
     181  text_tarray::const_iterator end = siblings.end();
     182 
     183  while (thissection != end) {
     184   
     185    section.clear();
     186    child.clear();
     187
     188    get_first_child(*thissection, child);
     189
     190    toc += "<br>" + doclink + *thissection + "." + child +
     191      ".1\">" + *thissection + " title</a>\n";
     192    thissection ++;
     193  }
     194  toc += "\n<!-- end of Table of Contents -->\n";
     195}
     196
     197
     198void get_contracted_toc (cgiargsclass &args, recptproto */*collectproto*/,
     199             text_t &return_text, ostream &/*logout*/) {
     200 
     201  int colnum, tabcount = 0;
     202  text_tarray parents, siblings;
     203 
     204  // load up the parents array
     205  // don't want classifications unless at top level contents
     206  if (!(args["cl"]).empty() && is_top(args["d"]))
     207    get_parents_array (args["cl"] + ".", parents);
     208  get_parents_array (args["d"], parents);
     209
     210  // load up siblings array
     211  if ((args["d"]).empty()) get_children_array (get_parent(args["cl"]), siblings);
     212  else if (is_top (args["d"])) get_children_array (args["cl"], siblings);
     213  else get_children_array (get_parent(args["d"]), siblings);
     214
     215  return_text += "<table>\n";
     216  colnum = parents.size() + 1;
     217
     218  // sort out toc of sections parents
     219  if (parents.size() > 0)
     220    get_parents_toc(args, parents, tabcount, colnum, return_text);
     221 
     222  // sort out toc of sections siblings
     223  if (siblings.size() > 0)
     224    get_siblings_toc (args, siblings, tabcount, colnum, return_text);
     225             
     226  return_text += "</table>\n";
     227}
     228
     229
     230void get_expanded_toc (cgiargsclass &/*args*/, recptproto */*collectproto*/,
     231               text_t &/*return_text*/, ostream &/*logout*/) {
     232
     233  /*
     234  text_t doclink, icon, pointer, tab, pagetype;
     235  int totalcols, tabcols, tabsleft;
     236  text_tarray contents;
     237 
     238  // get array of all contents to be included (all contents of entire book)
     239  text_t book_top;
     240  get_book_top (booksection, book_top);
     241  get_contents (book_top, gdbm, contents, totalcols);
     242 
     243  vector<text_t>::const_iterator section = contents.begin();
     244  vector<text_t>::const_iterator end = contents.end();
     245 
     246  int count = 1;
     247  while (section != end) {
     248    tab.clear();
     249    gdbm.getinfo(*section, info);
     250    text_t icontabs;
     251
     252    // set up icon
     253    icon = "_iconsmalltext_";
     254    if (is_top_level(*section)) icon = "_iconopenbook_";
     255    else if (!info.contents.empty()) icon = "_iconopenfolder_";
     256
     257    // set up pointer
     258    if (*section == booksection) pointer = "_iconpointer_";
     259    else pointer = "_icontab_";
     260
     261    // set up tabbing
     262    tabcols = count_dots(*section);
     263    for (int i = 0; i < (tabcols - 1); i++) {
     264      icontabs += "_icontab_";
     265    }
     266    //char *tabcolsstr;
     267    //itoa(tabcols, tabcolsstr, 10);
     268    tab = "<td valign=top colspan=" + text_t(tabcols);
     269    tab += ">" + icontabs + pointer + "</td>";
     270    tabsleft = totalcols - tabcols;
     271   
     272    // set up url
     273    if (is_book(*section) && !is_top_level(*section))   
     274      doclink = "<a href=\"_httptext_";
     275    else doclink = "<a href=\"_httpbrowse_";
     276    if (args["x"] == "1") doclink += "&x=1";
     277   
     278    return_text += "<tr>" + tab + "<td valign=top>";
     279    if (is_top_level(*section) && args["x"] == "1") {
     280      return_text += "<a href=\"\" onClick = \"close_detach()";
     281    } else {
     282      if (args["g"][1] == '0' || is_top_level(*section) ||
     283      !are_same_chapter(booksection, *section) ||
     284      !info.contents.empty()) {
     285    return_text += doclink + "d=" + classification;
     286    return_text += "." + *section + "&a=" + pagetype;
     287      } else {
     288    return_text += "<a href=\"#";
     289    return_text += count;
     290    count ++;
     291      }
     292    }
     293    return_text += "\">" + icon + "</a></td>";
     294    return_text += "<td colspan=" + text_t(tabsleft);
     295    return_text += ">" + info.title;
     296    return_text += "</td></tr>\n";
     297   
     298    section ++;
     299  }
     300  return_text += "</table>\n";
     301  return_text += "</td></tr></table>\n";
     302  */
     303}
     304
     305
     306void get_parents_toc (cgiargsclass &args, const text_tarray &parents,
     307              int &tabcount, int &colnum, text_t &return_text) { 
     308
     309  text_t section, tab, icon, doclink;
     310
     311  doclink = "<a href=\"_httpbrowse_";
     312  if (args["x"] == "1") doclink += "&x=1";
     313
     314  text_tarray::const_iterator thisparent = parents.begin();
     315  text_tarray::const_iterator end = parents.end();
     316
     317  while (thisparent != end) {
     318    text_t icontabs;
     319    section.clear();
     320    tab.clear();
     321   
     322    // set up icon for this parent
     323    icon = "_iconopenfolder_";
     324    if (is_classification(*thisparent)) icon = "_iconopenbookshelf_";
     325    else if (is_top(*thisparent)) icon = "_iconopenbook_";
     326   
     327    for (int j = 0; j < tabcount; j++)
     328      icontabs += "_icontab_";
     329     
     330    if (!icontabs.empty()) {
     331      tab = "<td valign=top";
     332      if (tabcount > 1) tab += " colspan=" + text_t(tabcount);
     333      tab += ">" + icontabs + "</td>";
     334    }
     335    tabcount ++;
     336   
     337    if (is_top(*thisparent) && args["x"] == "1") {
     338      return_text += "<tr>" + tab + "<td valign=top><a href=\"\" ";
     339      return_text += "onClick = \"close_detach()\">" + icon + "</a></td>";
     340    } else {
     341      if (is_classification (*thisparent))
     342    return_text += "<tr>" + tab + "<td valign=top>" + doclink + "&cl=" + *thisparent;
     343      else
     344    // this may not need cl= bit once compressed args is done
     345    return_text += "<tr>" + tab + "<td valign=top>" + doclink + "&cl=" + args["cl"] + "&d=" + *thisparent;
     346      return_text += "\">" + icon + "</a></td>";
     347    }
     348    return_text += "<td";
     349    if (colnum > 1) return_text += " colspan=" + text_t(colnum);
     350    return_text += ">" + *thisparent + " title ";
     351    return_text += " by " + *thisparent + " author ";
     352    return_text += "</td></tr>\n";
     353    colnum --;
     354    thisparent ++;
     355  }
     356}
     357
     358
     359void get_siblings_toc (cgiargsclass &args, const text_tarray &siblings,
     360               int &tabcount, int &colnum, text_t &return_text) {
     361 
     362  text_t tab, icon, pointer, child, doclink;
     363  int count = 1;
     364
     365  doclink = "<a href=\"_httpbrowse_";
     366  if (args["x"] == "1") doclink += "&x=1";
     367 
     368  text_tarray::const_iterator thissibling = siblings.begin();
     369  text_tarray::const_iterator sibend = siblings.end();
     370 
     371  while (thissibling != sibend) {
     372
     373    // set up icon for this sibling
     374    icon = "_iconclosedfolder_";
     375    if (is_classification(*thissibling)) icon = "_iconclosedbookshelf_";
     376    else if (is_top(*thissibling)) icon = "_iconclosedbook_";
     377   
     378    // fit pointer into tabbing if current section
     379    pointer = "_icontab_";
     380    if (is_classification(*thissibling)) {
     381      if (*thissibling == args["cl"])
     382    pointer = "_iconpointer_";
     383    } else if (*thissibling == args["d"]) pointer = "_iconpointer_";
     384   
     385    text_t thesetabs;
     386    for (int j = 0; j < (tabcount - 1); j++)
     387      thesetabs += "_icontab_";
     388   
     389    tab = "<td valign=top";
     390    if (tabcount > 1) tab += " colspan=" + text_t(tabcount);
     391    tab += ">" + thesetabs + pointer + "</td>";
     392   
     393    if (contains_text(*thissibling)) {
     394      // sibling is text document
     395      icon = "_iconsmalltext_";
     396     
     397      return_text += "<tr>" + tab + "<td valign=top>";
     398      if (args["g"][1] == '0') {
     399    return_text += doclink + "&d=" + *thissibling;
     400      } else {
     401    return_text += "<a href=\"#";
     402    return_text += count;
     403    count ++;
     404      }
     405      return_text += "\">" + icon + "</a></td><td";
     406      if (colnum > 1) return_text += " colspan=" + text_t(colnum);
     407      return_text += ">" + *thissibling + " title";
     408      return_text += " by " + *thissibling + " author";
     409      return_text += "</td></tr>\n";
     410    } else {
     411      // sibling is closed book or folder so clicking
     412      // it should open contents
     413      get_first_child(*thissibling, child);
     414     
     415      return_text += "<tr>" + tab + "<td valign=top>" + doclink + "&d=" + child;
     416      return_text += "\">" + icon + "</a></td><td";
     417      if (colnum > 1) return_text += " colspan=" + text_t(colnum);
     418      return_text += ">" + *thissibling + " title";
     419      return_text += " by " + *thissibling + " author";
     420      return_text += "</td></tr>\n";
     421    }
     422    thissibling ++;
     423  } 
     424}
  • trunk/gsdl/src/recpt/browsetools.h

    r208 r213  
    2020#include "recptproto.h"
    2121
     22void set_navigation_bar (displayclass &disp, cgiargsclass &args,
     23             recptproto *collectproto, const text_t &cname,
     24             ostream &logout);
     25void set_arrow_links (displayclass &disp, cgiargsclass &args,
     26              recptproto *collectproto, const text_t &cname,
     27              ostream &logout);
     28void set_classification_links (displayclass &disp, cgiargsclass &args,
     29                   recptproto *collectproto, const text_t &cname,
     30                   ostream &logout);
     31
    2232void get_hierarchy_toc (cgiargsclass &args, recptproto *collectproto,
    2333            text_t &toc, ostream &logout);
     
    2939           text_t &toc, ostream &logout);
    3040
     41void get_contracted_toc (cgiargsclass &args, recptproto *collectproto,
     42             text_t &return_text, ostream &logout);
     43void get_expanded_toc (cgiargsclass &args, recptproto *collectproto,
     44               text_t &return_text, ostream &logout);
     45void get_parents_toc (cgiargsclass &args, const text_tarray &parents,
     46              int &tabcount, int &colnum, text_t &return_text);
     47void get_siblings_toc (cgiargsclass &args, const text_tarray &siblings,
     48               int &tabcount, int &colnum, text_t &return_text);
     49
    3150
    3251#endif
  • trunk/gsdl/src/recpt/recptproto.h

    r209 r213  
    100100  // should be done - type should be one of hierarchy, book,
    101101  // list, datelist or none. name should be one of subject,
    102   // date, title, author
    103   virtual void get_classification_type (const text_t &OID, text_t &ctype, text_t &cname) {
    104     cname = "subject";
    105     ctype = "hierarchy";
     102  // date, title, author, series, howto, or organization
     103  virtual void get_classification_info (const text_t &/*OID*/, text_t &ctype, text_t &cname) {
     104    cname = "title";
     105    ctype = "list";
     106  }
     107
     108  // return list of all classifications supported by this collection
     109  // e.g. "title", "subject" and "date". Should be tested somewhere I guess
     110  // to make sure all classifications are supported by this receptionist
     111  virtual void get_all_classifications (text_tarray &classifications) {
     112    classifications.push_back ("subject");
     113    classifications.push_back ("title");
     114    classifications.push_back ("series");
    106115  }
    107116};
Note: See TracChangeset for help on using the changeset viewer.