Index: trunk/cstr/src/recpt/cstrbrowsetools.cpp
===================================================================
--- trunk/cstr/src/recpt/cstrbrowsetools.cpp	(revision 891)
+++ trunk/cstr/src/recpt/cstrbrowsetools.cpp	(revision 911)
@@ -26,102 +26,12 @@
  *********************************************************************/
 
-/*
-   $Log$
-   Revision 1.1  2000/02/01 22:32:37  sjboddie
-   Initial revision
-
-   Revision 1.1  1999/09/07 21:49:41  sjboddie
-   new cstr receptionist
-
- */
-
-
 #include "cstrbrowsetools.h"
 #include "OIDtools.h"
 #include "cgiutils.h"
-
-// simply checks to see if formatstring begins with a <td> tag
-static bool is_table_content (const text_t &formatstring) {
-  text_t::const_iterator here = formatstring.begin();
-  text_t::const_iterator end = formatstring.end();
-  
-  while (here != end) {
-    if (*here != ' ') {
-      if (*here == '<') {
-	if ((*(here+1) == 't' || *(here+1) == 'T') &&
-	    (*(here+2) == 'd' || *(here+2) == 'D') &&
-	    (*(here+3) == '>' || *(here+3) == ' '))
-	  return true;
-      } else return false;
-    }
-    here ++;
-  }
-  return false;
-}
-
-static bool is_table_content (const format_t *formatlistptr) {
-
-  if (formatlistptr == NULL) return false;
-  
-  if (formatlistptr->command == comText)
-    return is_table_content (formatlistptr->text);
-    
-  return false;
-}
-
-
-// output_controls displays the detach, expand/contract contents,
-// expand/contract text and highlighting/no highlighting buttons
-static void output_controls (cgiargsclass &args, const text_tarray &ibuttons,
-			     recptproto */*collectproto*/, displayclass &disp, 
-			     outconvertclass &outconvert, ostream &textout, 
-			     ostream &/*logout*/) {
-
-  if (args["u"] != "1") {
-  
-    FilterResponse_t response;
-    text_tset metadata;
-    text_tarray buttons;
-
-    text_t &arg_gg = args["gg"];
-
-    text_tarray::const_iterator here = ibuttons.begin();
-    text_tarray::const_iterator end = ibuttons.end();
-
-    while (here != end) {
-    
-      if (*here == "Detach")
-	buttons.push_back ("_document:imagedetach_");
-      else if (*here == "Highlight" && arg_gg == "text") {
-	if (args["hl"] == "1") 
-	  buttons.push_back ("_document:imagenohighlight_");
-	else 
-	  buttons.push_back ("_document:imagehighlight_");
-	//      } else if (*here == "Expand Contents") {
-	//	if (args["gc"] == "1")
-	//	  buttons.push_back ("_document:imagecontracttoc_");
-	//	else 
-	//	  buttons.push_back ("_document:imageexpandtoc_");
-      } else if (*here == "Expand Text" && arg_gg == "text") {
-	if (args.getintarg("gt"))
-	  buttons.push_back ("_document:imagecontracttext_");
-	else 
-	  buttons.push_back ("_document:imageexpandtext_");
-      }
-      here ++;
-    }
-
-    here = buttons.begin();
-    end = buttons.end();
-    int count = 0;
-    while (here != end) {
-      if ((count != 0) && ((count % 3) == 0)) textout << "<br>\n";
-      textout << outconvert << disp << *here;
-      count ++;
-      here ++;
-    }
-  }
-}
-
+#include "browsetools.h"
+
+
+
+// outputs the postscript, abstract, figures etc buttons
 static void output_cstr_controls (cgiargsclass &args, const text_t &source, 
 				  const text_t &description, const text_t &figures, 
@@ -156,692 +66,181 @@
 }
 
-/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-Functions for generating a document type tables of contents. These aren't really tables of
-contents at all, just a title, some navigation buttons and arrows and maybe a page ? of ?
-type thing. These should only be called for document level tocs (i.e. when the "d" argument 
-is set) as I don't think it makes sense to display top level classifications in this way.
--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
-
-void output_document_toc (cgiargsclass &args, const formatinfo_t &formatinfo,
-			  recptproto *collectproto, displayclass &disp, 
-			  outconvertclass &outconvert, ostream &textout, 
-			  ostream &logout) {
-
+
+
+void output_cstr_toc (cgiargsclass &args, browsermapclass *browsermap,
+                 formatinfo_t &formatinfo, recptproto *collectproto,
+                 displayclass &disp, outconvertclass &outconvert,
+				ostream &textout, ostream &logout) {
+
+  int tabcount = 0;
+  bool havecontrols = false;
+  bool fulltoc = false;
+
+
+  if (args["cl"] != "search") {
+    // see if there's a FullTOC string
+    text_t cl_top, full_toc;
+    get_top (args["cl"], cl_top);
+    if (get_formatstring (cl_top, "FullTOC", formatinfo.formatstrings, full_toc))
+      if (full_toc == "true") fulltoc = true;
+  }
   text_t &arg_d = args["d"];
-  if (arg_d.empty()) return;
-
-  text_tset metadata;
-  FilterResponse_t response;
-  ResultDocInfo_t docinfo;
-  text_t booktop, facsimiles, figures, description, source, summary;
-  text_t &collection = args["c"];
-
-  metadata.insert ("Title");
-  if (get_info (arg_d, collection, metadata, false, collectproto, response, logout)) {
-
-    metadata.erase (metadata.begin(), metadata.end());
-    docinfo = response.docInfo[0];
-
-    textout 
-      << "\n<!-- Table of Contents produced by cstrbrowsetools::output_document_toc -->\n\n";
-
-    // get title and author of book
-    get_top (arg_d, booktop);
-    metadata.insert ("facsimiles");
-    metadata.insert ("figures");
-    metadata.insert ("Description");
-    metadata.insert ("Source");
-    metadata.insert ("Summary");
-    get_info (booktop, collection, metadata, false, collectproto, response, logout);
-    facsimiles = response.docInfo[0].metadata[0].values[0];
-    figures = response.docInfo[0].metadata[1].values[0];
-    description = response.docInfo[0].metadata[2].values[0];
-    source = response.docInfo[0].metadata[3].values[0];
-    summary = response.docInfo[0].metadata[4].values[0];
-
-    metadata.erase (metadata.begin(), metadata.end());
+  // get the facsimile image (if there is one) and the control buttons
+  // if we're inside a book
+  if ((!fulltoc) && (!arg_d.empty())) {
+
+    // this code from old cstr browsetools outputdocument_toc
+    text_tset metadata;
+    FilterResponse_t response;
+    ResultDocInfo_t docinfo;
+    text_t booktop, facsimiles, figures, description, source, summary;
+    text_t &collection = args["c"];
+
+    metadata.insert ("Title");
+    if (get_info (arg_d, collection, metadata, false, collectproto, response, logout)) {
+
+      metadata.erase (metadata.begin(), metadata.end());
+      docinfo = response.docInfo[0];
+      
+      textout 
+	<< "\n<!-- Table of Contents produced by cstrbrowsetools::output_document_toc -->\n\n";
+
+      // get title and author of book
+      get_top (arg_d, booktop);
+      metadata.insert ("facsimiles");
+      metadata.insert ("figures");
+      metadata.insert ("Description");
+      metadata.insert ("Source");
+      metadata.insert ("Summary");
+      get_info (booktop, collection, metadata, false, collectproto, response, logout);
+      facsimiles = response.docInfo[0].metadata["facsimiles"].values[0];
+      figures = response.docInfo[0].metadata["figures"].values[0];
+      description = response.docInfo[0].metadata["Description"].values[0];
+      source = response.docInfo[0].metadata["Source"].values[0];
+      summary = response.docInfo[0].metadata["Summary"].values[0];
+
+      metadata.erase (metadata.begin(), metadata.end());
   
-    textout << outconvert << disp 
-	    << "<p><center>\n"
-	    << "<table cellpadding=0 cellspacing=0 width=_pagewidth_>\n"
-	    << "<tr valign=top><td>\n";
-
-    // don't want arrows and page number if text expanded
-    if (formatinfo.DocumentArrowsBottom && !args.getintarg ("gt")) {
+      textout << outconvert << disp 
+	      << "<p><center>\n"
+	      << "<table cellpadding=0 cellspacing=0 width=_pagewidth_>\n"
+	      << "<tr valign=top><td>\n";
+
+      /*      
+      // don't want arrows and page number if text expanded
+      if (formatinfo.DocumentArrowsBottom && !args.getintarg ("gt")) {
     
-      // previous arrow
-      textout << outconvert << disp << "<table><tr valign=top>\n"
-	      << "<td align=left>_document:prevarrow_</td>\n";
+	// previous arrow
+	textout << outconvert << disp << "<table><tr valign=top>\n"
+		<< "<td align=left>_document:prevarrow_</td>\n";
     
-      // page ? of ? text
-      textout << "<td align=center>\n";
-      
-      if (is_number (docinfo.metadata[0].values[0])) {
-	text_t doctop;
-	metadata.insert ("Title");
-	get_top (arg_d, doctop);
-	// get title of last sibling
-	if (get_info (doctop + ".lc", collection, metadata, false, collectproto, response, logout)) {
-	  if (is_number (response.docInfo[0].metadata[0].values[0])) {
-	    textout << outconvert << disp << "_document:page_" << docinfo.metadata[0].values[0]
-		    << "_document:of_" << response.docInfo[0].metadata[0].values[0];
-	  } else {
-	    textout << outconvert << docinfo.metadata[0].values[0];
+	// page ? of ? text
+	textout << "<td align=center>\n";
+	
+	if (is_number (docinfo.metadata["Title"].values[0])) {
+	  text_t doctop;
+	  metadata.insert ("Title");
+	  get_top (arg_d, doctop);
+	  // get title of last sibling
+	  if (get_info (doctop + ".lc", collection, metadata, false, collectproto, response, logout)) {
+	    if (is_number (response.docInfo[0].metadata["Title"].values[0])) {
+	      textout << outconvert << disp << "_document:page_" << docinfo.metadata["Title"].values[0]
+		      << "_document:of_" << response.docInfo[0].metadata["Title"].values[0];
+	    } else {
+	      textout << outconvert << docinfo.metadata["Title"].values[0];
+	    }
 	  }
-	}
-      } else {
-	textout << outconvert << docinfo.metadata[0].values[0];
+	} else {
+	  textout << outconvert << docinfo.metadata["Title"].values[0];
       }
   
-      // next arrow
-      textout << outconvert << disp << "</td>\n<td align=right>_document:nextarrow_</td>\n</table>\n";
+	// next arrow
+	textout << outconvert << disp << "</td>\n<td align=right>_document:nextarrow_</td>\n</table>\n";
+      }
+      
+      // goto line ****** ????????????
+      //if (formatinfo.DocumentGoTo)
+      textout << outconvert << disp << "_document:gotoform_";
+      */
+
+      //if (formatinfo.DocumentArrowsBottom && !args.getintarg ("gt")) {
+	if (args.getintarg("gc") == 1) {
+	
+	  // expanded table of contents
+	  expanded_contents (args, tabcount, fulltoc, browsermap, formatinfo, 
+			     collectproto, disp, outconvert, textout, logout);
+	} else {
+	  
+	  // contracted table of contents
+	  contracted_contents (args, tabcount, fulltoc, browsermap, formatinfo, 
+			       collectproto, disp, outconvert, textout, logout);
+	}
+	// }
+      // control buttons
+      output_controls (args, formatinfo.DocumentButtons, collectproto, 
+		       disp, outconvert, textout, logout);
+      textout << "</td><td valign=top>\n";
+
+      if (!summary.empty())
+	textout << outconvert << summary << "\n";
+
+      output_cstr_controls (args, source, description, figures, 
+			    disp, outconvert, textout);
+
+      textout << "</td>\n";
+    
+      // facsimile image
+      // only want the first facsimile (some documents have two)
+      if (!facsimiles.empty()) {
+	text_t::const_iterator fbegin = facsimiles.begin();
+	facsimiles = substr (fbegin, findchar (fbegin, facsimiles.end(), ','));
+	textout << outconvert << disp << "<td valign=top><a href=\"_httpcurrentdocument_&gg=facsimiles\">"
+		<< "<img src=\"_httpcollimg_/_thisOID_/" 
+		<< facsimiles << "\" width=150 height=250></a>" << "</td>\n";
+      }
+      
+
+      textout << "</td></tr></table></center>\n";
+      textout << "\n<!-- end of Table of Contents -->\n";
+      
     }
 
-    // goto line ****** ????????????
-    //if (formatinfo.DocumentGoTo)
-    //  textout << outconvert << disp << "_document:gotoform_";
-
-    // control buttons
-    output_controls (args, formatinfo.DocumentButtons, collectproto, 
-		     disp, outconvert, textout, logout);
+    /*    textout << "<p><table cellpadding=0 cellspacing=0><tr>\n";
+    textout << "<td valign=top";
+    if (formatinfo.DocumentContents) textout << " width=200>\n";
+    else textout << " width=100%>\n";
+    if (formatinfo.DocumentImages) 
+      output_cover_image (args, collectproto, disp, outconvert, textout, logout);
+    else if (formatinfo.DocumentTitles)
+      output_titles (args, collectproto, formatinfo, disp, outconvert, textout, logout);
+    output_controls (args, formatinfo.DocumentButtons, collectproto, disp, 
+		     outconvert, textout, logout);
     textout << "</td><td valign=top>\n";
-
-    if (!summary.empty())
-      textout << outconvert << summary << "\n";
-
-    output_cstr_controls (args, source, description, figures, 
-			  disp, outconvert, textout);
-
-    textout << "</td>\n";
-    
-    // facsimile image
-    // only want the first facsimile (some documents have two)
-    if (!facsimiles.empty()) {
-      text_t::const_iterator fbegin = facsimiles.begin();
-      facsimiles = substr (fbegin, findchar (fbegin, facsimiles.end(), ','));
-      textout << outconvert << disp << "<td valign=top><a href=\"_httpcurrentdocument_&gg=facsimiles\">"
-	      << "<img src=\"_httpcollection_/archives/_thisOID_/" 
-	      << facsimiles << "\" width=150 height=250></a>" << "</td>\n";
+    havecontrols = true; */
+  }
+  /*
+  if (formatinfo.DocumentContents || args["d"].empty()) {
+    if (args.getintarg("gc") == 1) {
+      
+      // expanded table of contents
+      expanded_contents (args, tabcount, fulltoc, browsermap, formatinfo, 
+			 collectproto, disp, outconvert, textout, logout);
+    } else {
+      
+      // contracted table of contents
+      contracted_contents (args, tabcount, fulltoc, browsermap, formatinfo, 
+			   collectproto, disp, outconvert, textout, logout);
     }
-
-
-    textout << "</td></tr></table></center>\n";
-    textout << "\n<!-- end of Table of Contents -->\n";
-
-  }
+  }
+  */
+  if (havecontrols) textout << "</td></tr></table>\n";
 }
 
 
-/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-Functions for generating a "Hierarchy" type table of contents. These can be used either
-at top classification level or at document level (the difference being that a cover
-image and control buttons may be displayed at document level).
--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
-
-// prototypes
-
-static void output_contracted_hierarchy_toc (const text_t &classifytype, text_t &formatstring, 
-					     cgiargsclass &args, recptproto *collectproto, 
-					     displayclass &disp, outconvertclass &outconvert, 
-					     ostream &textout, ostream &logout);
-
-static void output_expanded_hierarchy_toc (cgiargsclass &args, recptproto *collectproto,
-					   displayclass &disp, outconvertclass &outconvert,
-					   ostream &textout, ostream &logout);
-
-static void output_parents_toc (cgiargsclass &args, const FilterResponse_t &parents,
-				int &tabcount, displayclass &disp,
-				format_t *formatlistptr, outconvertclass &outconvert, 
-				ostream &textout, ostream &logout);
-
-static void output_siblings_toc (const text_t &classifytype, cgiargsclass &args, 
-				 const FilterResponse_t &siblings, int &tabcount, 
-				 displayclass &disp, format_t *formatlistptr, 
-				 outconvertclass &outconvert, ostream &textout, 
-				 ostream &logout);
-
-static void output_stdlist (cgiargsclass &args, ResultDocInfo_tarray::iterator &here,
-			    ResultDocInfo_tarray::iterator &end, bool intable,
-			    displayclass &disp, format_t *formatlistptr, 
-			     outconvertclass &outconvert, ostream &textout);
-
-static void output_datelist (cgiargsclass &args, ResultDocInfo_tarray::iterator &here,
-			     ResultDocInfo_tarray::iterator &end, bool intable,
-			     displayclass &disp, format_t *formatlistptr, 
-			     outconvertclass &outconvert, ostream &textout);
-
-
-void output_standard_toc (const text_t &classifytype, const formatinfo_t &formatinfo,
-			  text_t &formatstring, cgiargsclass &args, 
-			  recptproto *collectproto, displayclass &disp, 
-			  outconvertclass &outconvert, ostream &textout, 
-			  ostream &logout) {
-
-  bool havecontrols = false;
-
-  textout << "\n<!-- Table of Contents produced by cstrbrowsetools::output_standard_toc -->\n\n";
-
-  // get the cover image (if there is one) and the control buttons
-  // if we're inside a book
-  if (!args["d"].empty()) {
-    textout << "<p><table cellpadding=0 cellspacing=0><tr>\n";
-    textout << "<td valign=top width=200>\n";
-    //    if (cover) output_cover_image (args, collectproto, disp, outconvert, textout, logout);
-    output_controls (args, formatinfo.DocumentButtons, collectproto, disp, outconvert, textout, logout);
-    textout << "</td><td valign=top>\n";
-    havecontrols = true;
-  }
-  
-  // get table of contents
-  textout << "<table>\n";
-
-  if (args.getintarg("gc"))
-    output_expanded_hierarchy_toc(args, collectproto, disp, outconvert, textout, logout);
-  else
-    output_contracted_hierarchy_toc(classifytype, formatstring, args, collectproto, 
-				    disp, outconvert, textout, logout);
-
-  textout << "</table>\n";
-
-  if (havecontrols) textout << "</td></tr></table>\n";
-
-  textout << "\n<!-- end of Table of Contents -->\n";
-}
-
-
-void output_contracted_hierarchy_toc (const text_t &classifytype, text_t &formatstring, 
-				      cgiargsclass &args, recptproto *collectproto, 
-				      displayclass &disp, outconvertclass &outconvert, 
-				      ostream &textout, ostream &logout) {
-
-  int tabcount = 0;
-  text_tarray parents;
-  text_tset metadata;
-  FilterResponse_t fsiblings, fparents;
-  bool getParents = false;
-
-  text_t &arg_d = args["d"];
-  text_t OID = arg_d;
-  if (OID.empty()) OID = args["cl"];
-  text_t &collection = args["c"];
-
-  // if format string is empty use the default
-  if (formatstring.empty()) 
-    formatstring = "<td valign=top nowrap>[link][icon][/link]</td><td>{Or}{[Title],Untitled}</td>";
-
-  format_t *formatlistptr = new format_t();
-  parse_formatstring (formatstring, formatlistptr, metadata, getParents);
-
-  metadata.insert ("Date");
-  metadata.insert ("hastxt");
-  metadata.insert ("haschildren");
-  metadata.insert ("doctype");
-  metadata.insert ("classifytype");
-
-  if (has_children (OID, collection, collectproto, logout)) {
-      get_parents_array (OID + ".fc", parents);
-
-      if (!get_children (OID, collection, metadata, getParents,
-			 collectproto, fsiblings, logout))
-	return;
-  } else {
-    get_parents_array (OID, parents);
-    if (!get_children (OID + ".pr", collection, metadata, 
-		       getParents, collectproto, fsiblings, logout))
-	return;
-  }
-  if (!get_info (parents, collection, metadata, false, collectproto, fparents, logout)) return;
-  
-  if (!fparents.docInfo.empty()) 
-    output_parents_toc(args, fparents, tabcount, disp, 
-		       formatlistptr, outconvert, textout, logout);
-  
-  if (!fsiblings.docInfo.empty()) 
-    output_siblings_toc (classifytype, args, fsiblings, tabcount, disp, 
-			 formatlistptr, outconvert, textout, logout);
-}
-void output_parents_toc (cgiargsclass &args, const FilterResponse_t &parents,
-			 int &tabcount, displayclass &disp,
-			 format_t *formatlistptr, outconvertclass &outconvert,
-			 ostream &textout, ostream &/*logout*/) {
-
-  text_t tab, icon;
-  text_t &arg_cl = args["cl"];
-  text_t &arg_d = args["d"];
-  int numcols = parents.docInfo.size() + 1;
-  
-  bool intable = is_table_content (formatlistptr);
-  
-  ResultDocInfo_tarray::iterator thisparent = parents.docInfo.begin();
-  ResultDocInfo_tarray::iterator end = parents.docInfo.end();
-
-  int len = (*thisparent).metadata.size();
-  const text_t &classifytype = (*thisparent).metadata[len-1].values[0];
-
-  // don't want top level of any classifications to be displayed
-  if (arg_d.empty() && thisparent != end) {thisparent ++; numcols --;}
-
-  // don't want second level of classifications using classification links
-  if ((classifytype == "AZList" || classifytype == "DateList") && (thisparent != end))
-    {thisparent ++; numcols --;}
-
-  // the tab line
-  if (thisparent != end) {
-    text_t coltabs;
-    for (int i = 0; i < numcols; i ++) coltabs += "_document:tab_";
-    textout << outconvert << disp << "<tr>" << coltabs << "<td></td></tr>\n";
-  }
-
-  while (thisparent != end) {
-
-    const text_t &doctype = (*thisparent).metadata[len-2].values.back();
-
-    // set up icon and pointer
-    icon = "_document:icon";
-    if ((doctype != "classify") && ((*thisparent).OID == arg_d))
-      icon += "arrow";
-    if (doctype == "classify") icon += "openbookshelf_";
-    else if (is_top((*thisparent).OID)) icon += "openbook_";
-    else icon += "openfolder_";
-    
-    if (tabcount == 1) textout << "<td></td>\n";
-    else if (tabcount > 1) textout << "<td colspan=" << tabcount << "></td>";
-    
-    // set up the link
-    text_t link = "<a href=\"_httpdocument_";
-    if (is_top((*thisparent).OID) && args.getintarg("x")) link = "<a name=top>";
-    else 
-      if (doctype == "classify") link += "&cl=" + (*thisparent).OID + ".pr\">";
-      else 
-	if (is_top ((*thisparent).OID)) 
-	  if (arg_cl.empty())
-	    link = "<a name=top>";
-	  else if (arg_cl == "search")
-	    link = "<a href=\"_httpquery_\">";
-	  else
-	    link += "&cl=" + arg_cl + "\">";
-	else link += "&cl=" + arg_cl + "&d=" + (*thisparent).OID + ".pr\">";
-    
-    if ((numcols-tabcount) == 1) textout << "<td>";
-    else if ((numcols-tabcount) > 1) textout << "<td colspan=" 
-					     << (numcols-tabcount) << ">";
-
-    if (intable) textout << "<table><tr>";
-    
-    textout << outconvert << disp 
-	    << get_formatted_string (*thisparent, formatlistptr, link, icon);
-    
-    if (intable) textout << "</tr></table>";
-    textout << "</td></tr>\n";
-
-    tabcount ++;
-    thisparent ++;
-  }
-}
-
-
-void output_siblings_toc (const text_t &classifytype, cgiargsclass &args, 
-			  const FilterResponse_t &siblings, int &tabcount, 
-			  displayclass &disp, format_t *formatlistptr, 
-			  outconvertclass &outconvert, ostream &textout, 
-			  ostream &/*logout*/) {
-
-  bool intable = is_table_content (formatlistptr); 
-
-  ResultDocInfo_tarray::const_iterator thissibling = siblings.docInfo.begin();
-  ResultDocInfo_tarray::const_iterator sibend = siblings.docInfo.end();
-
-  if (thissibling == sibend) return;
-
-  // tabbing
-  if (tabcount) {
-    if (tabcount == 1) textout << "<tr><td></td>\n";
-    else if (tabcount > 1) textout << "<tr><td colspan=" << tabcount << "></td>";
-    textout << "<td><table>\n";
-  }
-
-  if (!intable) textout << "<tr><td>\n";
-  
-  if (classifytype == "DateList")
-    output_datelist (args, thissibling, sibend, intable, disp, 
-		     formatlistptr, outconvert, textout);
-  else 
-    output_stdlist (args, thissibling, sibend, intable, disp, 
-		    formatlistptr, outconvert, textout);
-
-  if (!intable) textout << "</td></tr></table>\n";
-  if (tabcount) textout << "</table></td></tr>\n";
-}
-
-void output_stdlist (cgiargsclass &args, ResultDocInfo_tarray::iterator &here,
-		     ResultDocInfo_tarray::iterator &end, bool intable,
-		     displayclass &disp, format_t *formatlistptr, 
-		     outconvertclass &outconvert, ostream &textout) {
-
-  text_t icon;
-  int count = 1;
-  int gt = args.getintarg("gt");
-  text_t &arg_cl = args["cl"];
-  text_t &arg_d = args["d"];
-
-  while (here != end) {
-
-    int len = (*here).metadata.size();
-    const text_t &doctype = (*here).metadata[len-2].values.back();
-    const text_t &hastxt = (*here).metadata[len-4].values.back(); 
-    const text_t &haschildren = (*here).metadata[len-3].values.back();
-
-    // set up icon and pointer
-    icon = "_document:icon";
-    if (doctype == "classify") {
-      if (((*here).OID == arg_cl) && (hastxt == "1"))
-    	icon += "arrow";
-    } else if ((*here).OID == arg_d) icon += "arrow";
-
-    if (haschildren == "0") icon += "smalltext_";
-    else if (doctype == "classify") icon += "closedbookshelf_";
-    else if (is_top((*here).OID)) icon += "closedbook_";
-    else icon += "closedfolder_";
-    
-    // set up link
-    text_t link = "<a href=\"_httpdocument_";
-    if (doctype == "classify") link += "&cl=" + (*here).OID + "\">";
-    else link += "&cl=" + arg_cl + "&d=" + (*here).OID + "\">";
-    if (gt) {
-      link = "<a href=\"#" + text_t(count) + "\">";
-      count ++;
-    }
-
-    if (intable) textout << "<tr>";
-    
-    textout << outconvert << disp 
-	    << get_formatted_string (*here, formatlistptr, link, icon) << "\n";
-    
-    if (intable) textout << "</tr>";
-
-    here ++;
-  }
-}
-
-
-void output_datelist (cgiargsclass &args, ResultDocInfo_tarray::iterator &here,
-		      ResultDocInfo_tarray::iterator &end, bool intable,
-		      displayclass &disp, format_t *formatlistptr, 
-		      outconvertclass &outconvert, ostream &textout) {
-
-  text_t lastyear = "0000";
-  text_t lastmonth = "00";
-
-  while (here != end) {
-
-    int len = (*here).metadata.size();
-    const text_t &doctype = (*here).metadata[len-2].values.back();
-    const text_t &date = (*here).metadata[len-5].values.back(); 
-
-    // bail on this document if it has no date
-    if (date.empty()) continue;
-
-    text_t::const_iterator datebegin = date.begin();
-
-    text_t link = "<a href=\"_httpdocument_&cl=";
-    text_t icon = "_document:iconclosedbook_";
-      
-    if (doctype == "classify") {
-      icon = "_document:iconclosedbookshelf_";
-      link += (*here).OID + "\">";
-    } else link += args["cl"] + "&d=" + (*here).OID + "\">";
-
-    text_t thisyear = substr (datebegin, datebegin+4);
-    text_t thismonth = substr (datebegin+4, datebegin+6); 
-
-    textout << "<tr>\n";
-
-    if (thisyear != lastyear) {
-      textout << outconvert << "<td><b>" << thisyear << "</b></td>";
-      lastyear = thisyear;
-    } else
-      textout << "<td></td>";
-
-    if (thismonth != lastmonth) {
-      textout << outconvert << disp << ("<td><b>_textmonth" + thismonth + "_</b></td>");
-      lastmonth = thismonth;
-    } else
-      textout << "<td></td>";
-
-    if (!intable) textout << "<td>\n";
-    
-    textout << outconvert << disp 
-	      << get_formatted_string (*here, formatlistptr, link, icon) << "\n";
-
-    if (!intable) textout << "</td>";
-      
-    textout << "</tr>\n";
-
-    here ++;
-  }
-}
-
-void output_expanded_hierarchy_toc (cgiargsclass &args, recptproto *collectproto,
-				    displayclass &disp, outconvertclass &outconvert,
-				    ostream &textout, ostream &logout) {
-
-  text_t OID, topOID, icon;
-  bool is_classify;
-  FilterResponse_t response;
-  int tabcols=0, totalcols=0, lasttabcols=0;
-
-  int gt = args.getintarg("gt");
-  text_t doclink = "<a href=\"_httpdocument_&cl=";
-
-  text_t &arg_d = args["d"];
-  text_t &arg_cl = args["cl"];
-
-  if (arg_d.empty()) {
-    if (arg_cl.empty()) return;
-    OID = arg_cl;
-    topOID = OID; // don't always want to expand from top if expanding classifications
-    is_classify=true;
-  } else {
-    OID = arg_d;
-    get_top (arg_d, topOID);
-    is_classify=false;
-  }
-
-  // Get OIDs and metadata of all topOIDs contents (and topOID itself)
-  text_tset metadata;
-  metadata.insert ("Title");
-  metadata.insert ("haschildren");
-  metadata.insert ("doctype");
-  //  metadata.insert ("hastxt");
-
-  get_contents (topOID, is_classify, metadata, totalcols, 
-		args["c"], collectproto, response, logout);
-  int excess = countchar (topOID.begin(), topOID.end(), '.');
-  totalcols -= excess;
-
-  // allow for pointer
-  if (!is_classify && !gt) totalcols += 2;
-  else totalcols += 1;
-
-  ResultDocInfo_tarray::iterator thissection = response.docInfo.begin();
-  ResultDocInfo_tarray::iterator lastsection = response.docInfo.end();
-  
-  int count = 1;
-  while (thissection != lastsection) {
-    
-    const text_t &title = (*thissection).metadata[0].values[0];
-    const int haschildren = (*thissection).metadata[1].values[0].getint();
-    const text_t &doctype = (*thissection).metadata[2].values[0];
-
-    text_t icontabs, tab, pointer;
-
-    // set up icon
-    icon = "_document:iconsmalltext_";
-    if (is_top((*thissection).OID))
-      if (classifytype == "Document") icon = "_document:iconopenbook_";
-      else 
-	if (doctype == "classify") icon = "_document:iconopenbookshelf_";
-	else icon = "_document:iconclosedbook_";
-    else if (haschildren) 
-      if (classifytype == "Document") icon = "_document:iconopenfolder_";
-      else icon = "_document:iconopenbookshelf_";
-    
-    // set up tabbing
-    if ((classifytype == "classify") && (doctype != "classify"))
-      tabcols = lasttabcols + 1;
-    else {
-      tabcols = countchar ((*thissection).OID.begin(), (*thissection).OID.end(), '.');
-      lasttabcols = tabcols;
-    }
-    tabcols -= excess;
-
-    for (int i = 0; i < tabcols; i++) 
-      icontabs += "_document:icontab_";
-    
-    // set up pointer
-    if (classifytype == "Document" && !gt) {
-      if ((*thissection).OID == OID) pointer = "_document:iconpointer_";
-      else pointer = "_document:icontab_";
-      tabcols ++;
-    }
-    
-    int colsremaining = totalcols - tabcols;
-
-    if (tabcols > 0) {
-      tab = "<td";
-      if (tabcols > 1) tab += " colspan=" + text_t(tabcols);
-      tab += ">" + icontabs + pointer + "</td>";
-    }
-
-    textout << outconvert << disp << "<tr>" << tab << "<td>";
-    
-    if ((classifytype == "Document") && (is_top((*thissection).OID)) && 
-	(args.getintarg("x")))
-      textout << outconvert << disp << icon << "</td><td";
-
-    else {
-      if (!gt) {
-	const text_t &thisOID = (*thissection).OID;
-	text_t link;
-	if (is_top (thisOID))
-	  if (classifytype == "classify")
-	    link = doclink + arg_cl + "&d=" + thisOID + "\">";
-	  else
-	    if (arg_cl.empty())
-	      link.clear();
-	    else if (arg_cl == "search")
-	      link = "<a href=\"_httpquery_\">";
-	    else
-	      link = doclink + arg_cl + "\">";
-	else
-	  if (haschildren)
-	    if (classifytype == "classify")
-	      link = doclink + thisOID + ".pr\">";
-	    else
-	      link = doclink + arg_cl + "&d=" + thisOID + ".pr\">";
-	  else
-	    if (classifytype == "classify")
-	      link = doclink + thisOID + "\">";
-	    else
-	      link = doclink + arg_cl + "&d=" + thisOID + "\">";
-	
-	textout << outconvert << disp << link;
-      } else {
-	textout << "<a href=\"#" << count << "\">";
-	count ++;
-      }
-    
-      textout << outconvert << disp << icon << "</a></td><td";
-    }
-    if (colsremaining > 1) textout << " colspan=" << colsremaining;
-    textout << outconvert << disp << ">" << title << "</td></tr>\n";
-
-    thissection ++;
-  }
-}
-
-/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
-
-// set_arrow_macros sets the _httpprevarrow_ and _httpnextarrow_ macros
-// it shouldn't be called if OID is the top level of a book 
-// as the "hasprevious" and "hasnext" metadata won't be set
-// when the filter can't get OIDs parent info - one day I'll
-// fix this ;-)
-void set_arrow_macros (const text_t &OID, const text_t &classifytype,
-		       bool showtoppage, displayclass &disp, 
-		       recptproto *collectproto, const text_t &collection, 
-		       ostream &logout) {
-
-  if (OID.empty()) return;
-
-  text_tset metadata;
-  FilterResponse_t response;
-
-  metadata.insert ("haschildren");
-  metadata.insert ("hasnext");
-  metadata.insert ("hasprevious");
-  // get "haschildren", "hasnext" and "hasprevious" metadata for OID
-  if (get_info (OID, collection, metadata, false, collectproto, response, logout)) {
-
-    text_t haschildren = response.docInfo[0].metadata[0].values[0];
-    text_t hasnext = response.docInfo[0].metadata[1].values[0];
-    text_t hasprevious = response.docInfo[0].metadata[2].values[0];
-
-    if ((classifytype == "Hierarchy") || (classifytype == "Book")) {
-      if (haschildren == "1") 
-	disp.setmacro ("httpnextarrow", "document", 
-		       "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.fc,_httpdocument_&cl=_cgiargcl_.fc)");
-      else if (hasnext == "1")
-	disp.setmacro ("httpnextarrow", "document", 
-		       "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.ns,_httpdocument_&cl=_cgiargcl_.ns)");
-      else {
-	// see if parent has younger siblings
-	if (get_info (OID + ".pr", collection, metadata, false, collectproto, response, logout)) {
-	  if (!response.docInfo[0].metadata.empty() &&
-	      response.docInfo[0].metadata[1].values[0] == "1")
-	    disp.setmacro ("httpnextarrow", "document", 
-			   "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.pr.ns,_httpdocument_&cl=_cgiargcl_.pr.ns)");
-	}
-      }
-
-      if (hasprevious == "1") {
-	// see if OIDs older sibling has children
-	if (get_info (OID + ".ps", collection, metadata, false, collectproto, response, logout)) {
-	  if (response.docInfo[0].metadata[0].values[0] == "1")
-	    disp.setmacro ("httpprevarrow", "document", 
-			   "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.ps.lc,_httpdocument_&cl=_cgiargcl_.ps.lc)");
-	  else 
-	    disp.setmacro ("httpprevarrow", "document", 
-			   "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.ps,_httpdocument_&cl=_cgiargcl_.ps)");
-	} 
-      } else if (showtoppage && !is_top (OID))
-	disp.setmacro ("httpprevarrow", "document", 
-		       "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.pr,_httpdocument_&cl=_cgiargcl_.pr)");
-    }
-
-    else {
-      if (hasnext == "1")
-	disp.setmacro ("httpnextarrow", "document", 
-		       "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.ns,_httpdocument_&cl=_cgiargcl_.ns)");
-      if (hasprevious == "1")
-	disp.setmacro ("httpprevarrow", "document", 
-		       "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.ps,_httpdocument_&cl=_cgiargcl_.ps)");
-    }
-  }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
