Index: trunk/gsdl/src/recpt/documentaction.cpp
===================================================================
--- trunk/gsdl/src/recpt/documentaction.cpp	(revision 411)
+++ trunk/gsdl/src/recpt/documentaction.cpp	(revision 420)
@@ -12,4 +12,9 @@
 /*
    $Log$
+   Revision 1.15  1999/07/30 02:18:49  sjboddie
+   -added collectinfo argument to some functions
+   -caught up with changes to browsetools (allowing nested classifications)
+   -added showtoppage format option
+
    Revision 1.14  1999/07/21 05:01:09  sjboddie
    fixed up wrapping of classificationlinks
@@ -219,6 +224,7 @@
 // define all the macros which might be used by other actions
 // to produce pages. 
-void documentaction::define_external_macros (displayclass &disp, cgiargsclass &args, 
-					     recptproto *collectproto, ostream &logout) {
+void documentaction::define_external_macros (const ColInfoResponse_t &collectinfo, displayclass &disp, 
+					     cgiargsclass &args, recptproto *collectproto, 
+					     ostream &logout) {
   
   // define_external_macros sets the following macros:
@@ -278,12 +284,24 @@
   }
 
+  bool showtoppage = true;
+  text_tmap::const_iterator it = collectinfo.format.find("showtoppage");
+  if ((it != collectinfo.format.end()) && ((*it).second == "false")) showtoppage = false;
+
   // do a call to translate OIDs if required
   request.filterName = "NullFilter";
   request.filterResultOptions = FROID;
-  if (needs_translating (arg_d)) {
+  if ((!arg_d.empty()) && (needs_translating (arg_d) || !showtoppage)) {
     request.docSet.insert (arg_d);
+    request.fields.push_back ("classifytype");
+    request.filterResultOptions = FRmetadata;
+    request.getParents = true;
     collectproto->filter (collection, request, response, err, logout);
     arg_d = response.docInfo[0].OID;
-    request.docSet.erase (request.docSet.begin(), request.docSet.end());
+    
+    text_t &classifytype = response.docInfo[0].metadata[0].values[0];
+    if (classifytype.empty() || classifytype == "book")
+      if (!showtoppage && is_top (arg_d)) arg_d += ".fc";
+    
+    request.clear();
     disp.setmacro ("cgiargd", "Global", arg_d);
   }
@@ -391,6 +409,7 @@
 // define all the macros which are related to pages generated
 // by this action
-void documentaction::define_internal_macros (displayclass &disp, cgiargsclass &args, 
-					     recptproto *collectproto, ostream &logout) {
+void documentaction::define_internal_macros (const ColInfoResponse_t &collectinfo, displayclass &disp, 
+					     cgiargsclass &args, recptproto *collectproto, 
+					     ostream &logout) {
 
   // define_internal_macros sets the following macros:
@@ -420,9 +439,7 @@
   //                        to the archivedir metadata element
 
-
   // can't do anything if collectproto is null (i.e. no collection was specified)
   if (collectproto == NULL) return;
 
-  disp.setmacro("random", "document", rand());
   
   text_tarray metadata;
@@ -431,4 +448,6 @@
   text_t &arg_cl = args["cl"];
   text_t &collection = args["c"];
+
+  disp.setmacro("random", "document", rand());
 
   metadata.push_back ("Title");
@@ -461,6 +480,11 @@
       text_t &classifytype = response.docInfo[0].metadata[1].values[0];
       if (classifytype.empty()) classifytype = "Book"; // defaults to Book
-      if ((classifytype == "Book") || (classifytype == "Hierarchy"))
-	set_arrow_macros (arg_d, classifytype, disp, collectproto, collection, logout);
+      if ((classifytype == "Book") || (classifytype == "Hierarchy")) {
+	bool showtoppage = true;
+	text_tmap::const_iterator it = collectinfo.format.find("showtoppage");
+	if ((it != collectinfo.format.end()) && ((*it).second == "false")) showtoppage = false;
+	set_arrow_macros (arg_d, classifytype, showtoppage, disp, 
+			  collectproto, collection, logout);
+      }
 
       if (args["u"] != "1") {
@@ -572,7 +596,8 @@
 }
 
-bool documentaction::do_action (cgiargsclass &args, recptproto *collectproto,
-				displayclass &disp, outconvertclass &outconvert, 
-				ostream &textout, ostream &logout) {
+bool documentaction::do_action (cgiargsclass &args, const ColInfoResponse_t &collectinfo,
+				recptproto *collectproto, displayclass &disp, 
+				outconvertclass &outconvert, ostream &textout, 
+				ostream &logout) {
 
   if (collectproto == NULL) {
@@ -586,5 +611,6 @@
     FilterResponse_t response;
     text_t toptitle, toptype, thistype, formatstring;
-    
+    bool cover = false;
+
     text_t &collection = args["c"];
     text_t &arg_d = args["d"];
@@ -612,36 +638,23 @@
     }
 
+    text_tmap::const_iterator it = collectinfo.format.find(toptype + toptitle);
+    if (it != collectinfo.format.end()) formatstring = (*it).second;
+    it = collectinfo.format.find("cover");
+    if (it != collectinfo.format.end()) cover = true;
+
     // output the table of contents
     if (!arg_d.empty()) {
       
       if (toptype == "Hierarchy")
-	hierarchy_toc (thistype, args, collectproto, 
-		       disp, outconvert, textout, logout);
+	output_toc (thistype, formatstring, args, cover, collectproto, 
+		    disp, outconvert, textout, logout);
       else
-	// Book is the default for a document level toc - AZList, List and 
-	// DateList don't make sense for document level
+	// Book is the default for a document level toc
 	book_toc (args, collectproto, disp,
 		  outconvert, textout, logout);
+
     } else {
-
-      // see if we can find a formatstring for this type of toc
-      ColInfoResponse_t collectinfo;
-      comerror_t err;
-      collectproto->get_collectinfo (collection, collectinfo, err, logout);
-      if (err == noError) {
-	text_tmap::const_iterator it = collectinfo.format.find(toptype + toptitle);
-	if (it != collectinfo.format.end()) formatstring = (*it).second;
-      }
-      
-      if (toptype == "Hierarchy")
-	hierarchy_toc (thistype, args, collectproto, 
-		       disp, outconvert, textout, logout);
-      else if (toptype == "DateList")
-	datelist_toc (thistype, formatstring, args, collectproto, 
-		      disp, outconvert, textout, logout);
-      else 
-	// List is the default for a classification level toc - Book doesn't make 
-	// sense for classification level
-	list_toc (thistype, formatstring, args, collectproto, 
+      // Book should never used at classification level (I think;)
+      output_toc (thistype, formatstring, args, false, collectproto, 
 		  disp, outconvert, textout, logout);
     }
