Index: /trunk/cstr/src/recpt/cstrbrowsetools.cpp
===================================================================
--- /trunk/cstr/src/recpt/cstrbrowsetools.cpp	(revision 2486)
+++ /trunk/cstr/src/recpt/cstrbrowsetools.cpp	(revision 2486)
@@ -0,0 +1,246 @@
+/**********************************************************************
+ *
+ * cstrbrowsetools.cpp -- 
+ * Copyright (C) 1999  The New Zealand Digital Library Project
+ *
+ * A component of the Greenstone digital library software
+ * from the New Zealand Digital Library Project at the
+ * University of Waikato, New Zealand.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id$
+ *
+ *********************************************************************/
+
+#include "cstrbrowsetools.h"
+#include "OIDtools.h"
+#include "cgiutils.h"
+#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, 
+				  displayclass &disp, outconvertclass &outconvert, 
+				  ostream &textout) {
+  text_tarray buttons;
+  text_t &arg_gg = args["gg"];
+  
+  if (!source.empty())
+    buttons.push_back ("_document:imagepostscript_(" + cgi_safe(source) + ")");
+
+  if ((!description.empty()) && (arg_gg != "abstract"))
+    buttons.push_back ("_document:imageabstract_");
+
+  if ((!figures.empty()) && (arg_gg != "figures"))
+    buttons.push_back ("_document:imagefigures_");
+
+  if (arg_gg != "text")
+    buttons.push_back ("_document:imageviewtext_");
+
+  textout << "<br>\n";
+
+  text_tarray::const_iterator here = buttons.begin();
+  text_tarray::const_iterator end = buttons.end();
+  int count = 0;
+  while (here != end) {
+    if ((count != 0) && ((count % 3) == 0)) textout << "<br>\n";
+    textout << outconvert << disp << *here;
+    count ++;
+    here ++;
+  }
+}
+
+
+
+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"];
+  // 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")) {
+    
+	// 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["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["Title"].values[0];
+      }
+  
+	// 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=\"_httpprefix_/collect/cstr/index/assoc/_thisOID_/" 
+		<< facsimiles << "\" width=150 height=250></a>" << "</td>\n";
+      }
+      
+
+      textout << "</td></tr></table></center>\n";
+      textout << "\n<!-- end of Table of Contents -->\n";
+      
+    }
+
+    /*    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";
+    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);
+    }
+  }
+  */
+  if (havecontrols) textout << "</td></tr></table>\n";
+}
+
+
+
+
+
+
+
+
+
Index: /trunk/cstr/src/recpt/cstrbrowsetools.h
===================================================================
--- /trunk/cstr/src/recpt/cstrbrowsetools.h	(revision 2486)
+++ /trunk/cstr/src/recpt/cstrbrowsetools.h	(revision 2486)
@@ -0,0 +1,47 @@
+/**********************************************************************
+ *
+ * cstrbrowsetools.h -- 
+ * Copyright (C) 1999  The New Zealand Digital Library Project
+ *
+ * A component of the Greenstone digital library software
+ * from the New Zealand Digital Library Project at the
+ * University of Waikato, New Zealand.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id$
+ *
+ *********************************************************************/
+
+
+#ifndef CSTRBROWSETOOLS_H
+#define CSTRBROWSETOOLS_H
+
+#include "gsdlconf.h"
+#include "text_t.h"
+#include "cgiargs.h"
+#include "display.h"
+#include "recptproto.h"
+#include "formattools.h"
+#include "browsetools.h"
+
+void output_cstr_toc (cgiargsclass &args, browsermapclass *browsermap,
+                 formatinfo_t &formatinfo, recptproto *collectproto,
+                 displayclass &disp, outconvertclass &outconvert,
+                 ostream &textout, ostream &logout);
+
+
+#endif
+
Index: /trunk/cstr/src/recpt/cstrpagedbrowserclass.cpp
===================================================================
--- /trunk/cstr/src/recpt/cstrpagedbrowserclass.cpp	(revision 2486)
+++ /trunk/cstr/src/recpt/cstrpagedbrowserclass.cpp	(revision 2486)
@@ -0,0 +1,115 @@
+/**********************************************************************
+ *
+ * pagedbrowserclass.cpp -- 
+ * Copyright (C) 1999  The New Zealand Digital Library Project
+ *
+ * A component of the Greenstone digital library software
+ * from the New Zealand Digital Library Project at the
+ * University of Waikato, New Zealand.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * 
+ *
+ *********************************************************************/
+
+
+#include "cstrpagedbrowserclass.h"
+#include <assert.h>
+#include "OIDtools.h"
+
+cstrpagedbrowserclass::cstrpagedbrowserclass () {
+}
+
+cstrpagedbrowserclass::~cstrpagedbrowserclass () {
+}
+
+
+int cstrpagedbrowserclass::output_section_group (FilterResponse_t &sections, cgiargsclass &args,
+					     const text_t &/*collection*/, int /*colnumber*/, 
+					     format_t * /*formatlistptr*/, bool /*use_table*/, 
+					     text_tset &/*metadata*/, bool &/*getParents*/,
+					     recptproto * /*collectproto*/, displayclass &disp, 
+					     outconvertclass &outconvert, ostream &textout, 
+					     ostream &/*logout*/) {
+
+  text_t &arg_d = args["d"];
+
+  // this browser class only handles document levels
+  if (arg_d.empty()) return 0;
+
+  // dont want page nums and arrows if text is expanded
+  if (!args.getintarg("gt")) {
+    text_t previousOID, previoustitle, nextOID, nexttitle;
+    text_t previousarrow, nextarrow;
+    bool found = false;
+    
+    text_t pagenum;
+    // this should be our list of pages
+    
+    ResultDocInfo_tarray::iterator thissection = sections.docInfo.begin();
+    ResultDocInfo_tarray::iterator endsection = sections.docInfo.end();
+    
+    while (thissection != endsection) {
+      if (arg_d == (*thissection).OID) {
+	found = true;
+	pagenum= "<td><center><b>_document:page_" +
+	  (*thissection).metadata["Title"].values[0] + "\n";
+	if (thissection != sections.docInfo.begin()) {
+	  previousOID = (*(thissection-1)).OID;
+	  previoustitle = (*(thissection-1)).metadata["Title"].values[0];
+	} else 
+	  previousarrow = "_document:parentarrow_";
+	
+	if (thissection != sections.docInfo.end()) {
+	  nextOID = (*(thissection+1)).OID;
+	  nexttitle = (*(thissection+1)).metadata["Title"].values[0];
+	}
+	break;
+      }
+      thissection ++;
+    }
+
+    int numpages = sections.docInfo.size();
+    //pagenum += "_document:textnumpages_(" + text_t(numpages) + ")</center></td>\n";
+    pagenum += "_document:of_" + text_t(numpages) + "</b></center></td>\n";
+    if (!found)
+      nextarrow = "<a href=\"_httpdocument_&cl=" + args["cl"] + "&d=" + sections.docInfo[0].OID + 
+	"\">" + sections.docInfo[0].metadata["Title"].values[0] + "_iconnext_</a>\n";
+    else {
+      if (!previousOID.empty())
+	previousarrow = "<a href=\"_httpdocument_&cl=" + args["cl"] + "&d=" + 
+	  previousOID + "\">_iconprev_</a>\n";
+      if (!nextOID.empty())
+	nextarrow = "<a href=\"_httpdocument_&cl=" + args["cl"] + "&d=" + 
+	  nextOID + "\">_iconnext_</a>\n";
+    }
+  
+    textout << outconvert << disp << "<table><tr valign=top>"
+	    << " <td align=right>" << previousarrow << "</td>\n"
+	    << "<td align=center>" << pagenum << "</td>\n"
+	    << "<td align=left>" << nextarrow << "</td></tr>\n"
+            << "<tr valign=middle>\n"
+            << "<td align=center valign=top colspan=3>_document:gotoform_</td>"
+	    << "</tr></table>\n";
+  }
+  else { // just output goto form
+    textout << outconvert << disp << "<center>_document:gotoform_ </center>";
+  }
+  return 0;
+}
+
+
+
Index: /trunk/cstr/src/recpt/cstrpagedbrowserclass.h
===================================================================
--- /trunk/cstr/src/recpt/cstrpagedbrowserclass.h	(revision 2486)
+++ /trunk/cstr/src/recpt/cstrpagedbrowserclass.h	(revision 2486)
@@ -0,0 +1,57 @@
+
+
+
+/**********************************************************************
+ *
+ * cstrpagedbrowserclass.h -- 
+ * Copyright (C) 1999  The New Zealand Digital Library Project
+ *
+ * A component of the Greenstone digital library software
+ * from the New Zealand Digital Library Project at the
+ * University of Waikato, New Zealand.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * 
+ *
+ *********************************************************************/
+
+
+#ifndef CSTRPAGEDBROWSERCLASS_H
+#define CSTRPAGEDBROWSERCLASS_H
+
+#include "pagedbrowserclass.h"
+
+class cstrpagedbrowserclass : public pagedbrowserclass {
+protected:
+
+public:
+
+  cstrpagedbrowserclass ();
+  virtual ~cstrpagedbrowserclass ();
+
+  int output_section_group (FilterResponse_t &sections, cgiargsclass &args,
+			    const text_t &collection, int colnumber, format_t *formatlistptr, 
+			    bool use_table, text_tset &metadata, bool &getParents,
+			    recptproto *collectproto, displayclass &disp, 
+			    outconvertclass &outconvert, ostream &textout, ostream &logout);
+
+};
+
+#endif
+
+
+
+
