Index: /trunk/gsdl/src/recpt/browsetools.cpp
===================================================================
--- /trunk/gsdl/src/recpt/browsetools.cpp	(revision 623)
+++ /trunk/gsdl/src/recpt/browsetools.cpp	(revision 624)
@@ -28,4 +28,8 @@
 /*
    $Log$
+   Revision 1.23  1999/09/23 10:09:17  sjboddie
+   made some changes so AZLists within other classifications are
+   handled properly
+
    Revision 1.22  1999/09/07 23:06:58  rjmcnab
    removed some compiler warnings.
@@ -331,5 +335,5 @@
 
 static void output_parents_toc (cgiargsclass &args, const FilterResponse_t &parents,
-				int &tabcount, displayclass &disp,
+				int &tabcount, displayclass &disp, recptproto *collectproto,
 				format_t *formatlistptr, outconvertclass &outconvert, 
 				ostream &textout, ostream &logout);
@@ -345,4 +349,9 @@
 			    displayclass &disp, format_t *formatlistptr, 
 			     outconvertclass &outconvert, ostream &textout);
+
+static void output_azlist (cgiargsclass &args, ResultDocInfo_tarray::const_iterator &here,
+			   ResultDocInfo_tarray::const_iterator &end, bool intable,
+			   displayclass &disp, format_t *formatlistptr, 
+			   outconvertclass &outconvert, ostream &textout);
 
 static void output_datelist (cgiargsclass &args, ResultDocInfo_tarray::const_iterator &here,
@@ -404,5 +413,11 @@
   text_t &arg_d = args["d"];
   text_t OID = arg_d;
-  if (OID.empty()) OID = args["cl"];
+  if (OID.empty()) {
+    // if classifytype is an AZList we need to jump to
+    // the first child
+    if (classifytype == "AZList") OID = args["cl"] + ".fc";
+    else OID = args["cl"];
+  }
+
   text_t &collection = args["c"];
 
@@ -430,10 +445,10 @@
     if (!get_children (OID + ".pr", collection, metadata, 
 		       getParents, collectproto, fsiblings, logout))
-	return;
+      return;
   }
   if (!get_info (parents, collection, metadata, false, collectproto, fparents, logout)) return;
   
   if (!fparents.docInfo.empty()) 
-    output_parents_toc(args, fparents, tabcount, disp, 
+    output_parents_toc(args, fparents, tabcount, disp, collectproto,
 		       formatlistptr, outconvert, textout, logout);
   
@@ -444,7 +459,7 @@
 
 void output_parents_toc (cgiargsclass &args, const FilterResponse_t &parents,
-			 int &tabcount, displayclass &disp, 
+			 int &tabcount, displayclass &disp, recptproto *collectproto,
 			 format_t *formatlistptr, outconvertclass &outconvert, 
-			 ostream &textout, ostream &/*logout*/) {  
+			 ostream &textout, ostream &logout) {  
 
   text_t tab, icon;
@@ -459,5 +474,5 @@
 
   int len = (*thisparent).metadata.size();
-  const text_t &classifytype = (*thisparent).metadata[len-1].values[0];
+  //  const text_t &classifytype = (*thisparent).metadata[len-1].values[0];
 
   // don't want top level of any classifications to be displayed
@@ -465,6 +480,6 @@
 
   // don't want second level of classifications using classification links
-  if ((classifytype == "AZList" || classifytype == "DateList") && (thisparent != end))
-    {thisparent ++; numcols --;}
+  //  if ((classifytype == "AZList" || classifytype == "DateList") && (thisparent != end))
+  //    {thisparent ++; numcols --;}
 
   // the tab line
@@ -475,34 +490,45 @@
   }
 
+  bool first = true;
   while (thisparent != end) {
 
+    text_t link;
+    bool azlist = false;
+    // set azlist if we're in an AZList section (i.e. immediate parent
+    // has classifytype of AZList
+    if (!first && (*(thisparent-1)).metadata[len-1].values[0] == "AZList")
+      azlist = true;
+  
     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_";
-    
+    bool thissection = false;
+
+    if (!azlist) {
+      // 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_";
+    
+      // set up the link
+      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 (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=" 
@@ -510,11 +536,36 @@
 
     if (intable) textout << "<table><tr>";
-    
-    textout << outconvert << disp 
-	    << get_formatted_string (*thisparent, formatlistptr, link, icon);
+
+    if (azlist) {
+      FilterResponse_t response;
+      // AZLists rely on Title metadata
+      text_tarray metadata;
+      metadata.push_back ("Title");
+
+      // need to get siblings of this classification
+      if (get_children ((*(thisparent-1)).OID, args["c"], metadata, false, 
+			collectproto, response, logout)) {
+
+	ResultDocInfo_tarray::const_iterator thissib = response.docInfo.begin();
+	ResultDocInfo_tarray::const_iterator endsib = response.docInfo.end();
+
+	while (thissib != endsib) {
+	  link = "<a href=\"_httpdocument_&cl=" + (*thissib).OID + "\">"; 
+	  const text_t &title = (*thissib).metadata[0].values.back(); 
+	  if ((*thissib).OID == (*thisparent).OID)
+	    textout << outconvert << disp << "<b>" << title << "</b>\n";
+	  else textout << outconvert << disp << link << title << "</a>\n";
+	  thissib ++;
+	}
+      }
+    } else {
+      textout << outconvert << disp 
+	      << get_formatted_string (*thisparent, formatlistptr, link, icon);
+    }
     
     if (intable) textout << "</tr></table>";
     textout << "</td></tr>\n";
 
+    first = false;
     tabcount ++;
     thisparent ++;
@@ -606,4 +657,55 @@
 }
 
+
+void output_azlist (cgiargsclass &args, ResultDocInfo_tarray::const_iterator &here,
+		    ResultDocInfo_tarray::const_iterator &end, bool intable,
+		    displayclass &disp, format_t *formatlistptr, 
+		    outconvertclass &outconvert, ostream &textout) {
+
+  int count = 1;
+  int gt = args.getintarg("gt");
+  text_t &arg_cl = args["cl"];
+  text_t &arg_d = args["d"];
+  text_t link;
+
+  if (intable) textout << "<tr><td>";
+
+  while (here != end) {
+
+    bool thissec = false;
+    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(); 
+    // AZLists are assumed to use Title metadata
+    const text_t &title = (*here).metadata[len-6].values.back(); 
+
+    // bail on this document if it has no title
+    if (title.empty()) continue;
+
+    if (doctype == "classify") {
+      if ((*here).OID == arg_cl) thissec = true;
+    } else if ((*here).OID == arg_d) thissec = true;
+    
+    // set up link
+    if (!thissec) {
+      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 (thissec)
+      textout << outconvert << disp << "<b>" << title << "</b>\n";
+    else
+      textout << outconvert << disp << link << title << "</a>\n";
+    
+    here ++;
+  }
+
+  if (intable) textout << "</td></tr>";
+}
 
 void output_datelist (cgiargsclass &args, ResultDocInfo_tarray::const_iterator &here,
