Index: /trunk/gsdl/src/recpt/documentaction.cpp
===================================================================
--- /trunk/gsdl/src/recpt/documentaction.cpp	(revision 869)
+++ /trunk/gsdl/src/recpt/documentaction.cpp	(revision 870)
@@ -28,4 +28,7 @@
 /*
    $Log$
+   Revision 1.32  2000/01/25 22:39:15  sjboddie
+   added DocumentUseHTML - tidied some things up (and messed up some others)
+
    Revision 1.31  1999/11/13 08:57:00  sjboddie
    fixed bug in last changes
@@ -250,4 +253,24 @@
   arg_ainfo.defaultstatus = cgiarginfo::weak;
   arg_ainfo.argdefault = "0";
+  arg_ainfo.savedarginfo = cgiarginfo::must;
+  argsinfo.addarginfo (NULL, arg_ainfo);
+
+  // f arg is set to 1 if document is to 
+  // be displayed in a frame
+  arg_ainfo.shortname = "f";
+  arg_ainfo.longname = "frame";
+  arg_ainfo.multiplechar = false;
+  arg_ainfo.defaultstatus = cgiarginfo::weak;
+  arg_ainfo.argdefault = "0";
+  arg_ainfo.savedarginfo = cgiarginfo::mustnot;
+  argsinfo.addarginfo (NULL, arg_ainfo);
+
+  // fc arg is "1" if search bar is to be included (i.e. if "fc" == 1
+  // the httpdocument macro will include "&f=1"
+  arg_ainfo.shortname = "fc";
+  arg_ainfo.longname = "include search bar";
+  arg_ainfo.multiplechar = false;
+  arg_ainfo.defaultstatus = cgiarginfo::weak;
+  arg_ainfo.argdefault = "1";
   arg_ainfo.savedarginfo = cgiarginfo::must;
   argsinfo.addarginfo (NULL, arg_ainfo);
@@ -444,4 +467,9 @@
   //                     bar
   
+  // _httpdocument_      has '&f=1' added if displaying document inside a frame
+
+  // _gsdltop_           macro to replace _top targets with
+
+  // _httppagehome_      overridden home url if html collections have own homepage
 
   // must have a valid collection server to continue
@@ -456,4 +484,32 @@
   FilterResponse_t response;
   text_tset metadata;
+
+
+  // get info on current collection and load up formatinfo
+  // I'd prefer not to do this here as we're getting 
+  // collection info every time (and probably also getting
+  // it in other places some of the time) - One day I'll
+  // fix it ... maybe - Stefan.
+  ColInfoResponse_t cinfo;
+  collectproto->get_collectinfo (collection, cinfo, err, logout);
+  load_formatinfo (cinfo.format, args.getintarg("gt"));
+
+  if (formatinfo.DocumentUseHTML) {
+
+    // frame stuff
+    if (args["fc"] == "1") {
+      text_t httpdocument;
+      disp.expandstring ("Global", "_httpdocument_", httpdocument);
+      httpdocument += "&f=1";
+      disp.setmacro ("httpdocument", "Global", httpdocument);
+      disp.setmacro ("gsdltop", "Global", "documenttop");
+    }
+    text_tmap::iterator it = cinfo.format.find ("homepage");
+    if (it != cinfo.format.end()) {
+      text_t httppagehome;
+      if (get_link (args, protos, (*it).second, httppagehome, logout))
+	disp.setmacro ("httppagehome", "Global", httppagehome);
+    } 
+  }
 
   // don't want navigation bar if page is 'detached'
@@ -481,4 +537,50 @@
     }
   }
+}
+
+bool documentaction::get_link (cgiargsclass &args, recptprotolistclass *protos,
+			       const text_t &inlink, text_t &outlink, ostream &logout) {
+
+  FilterResponse_t response;
+  text_tset metadata;
+  metadata.insert ("section");
+  
+  // check current collection first
+  recptproto *collectproto = protos->getrecptproto (args["c"], logout);
+
+  if (get_info (inlink, args["c"], metadata, false, collectproto, response, logout)) {
+    if (!response.docInfo[0].metadata["section"].values[0].empty()) {
+      outlink = "_httpdocument_&d=" + response.docInfo[0].metadata["section"].values[0];
+      return true;
+    }
+  }
+
+  // check all the other enabled collections
+
+  if (args["ccs"] == "1" && !args["cc"].empty()) {
+    text_tarray collections;
+    splitchar (args["cc"].begin(), args["cc"].end(), ',', collections);
+    
+    text_tarray::const_iterator col_here = collections.begin();
+    text_tarray::const_iterator col_end = collections.end();
+
+    while (col_here != col_end) {
+	  
+      // don't need to check current collection again
+      if (*col_here == args["c"]) {col_here ++; continue;}
+	  
+      collectproto = protos->getrecptproto (*col_here, logout);
+      
+      if (get_info (inlink, *col_here, metadata, false, collectproto, response, logout)) {
+	if (!response.docInfo[0].metadata["section"].values[0].empty()) {
+	  outlink = "_httpdocument_&c=" + *col_here + "&d=" +
+	    response.docInfo[0].metadata["section"].values[0];
+	  return true;
+	}
+      }
+      col_here ++;
+    }
+  }
+  return false;
 }
 
@@ -509,13 +611,15 @@
     else if ((*format_here).first == "DocumentText") 
       formatinfo.DocumentText = (*format_here).second;
+    else if (((*format_here).first == "DocumentUseHTML") && 
+	     ((*format_here).second == "true"))
+      formatinfo.DocumentUseHTML = true;
     else 
       formatinfo.formatstrings[(*format_here).first] = (*format_here).second;
-
+    
     format_here ++;
   }
 
   // never want arrows when text is expanded
-  if (gt)
-    formatinfo.DocumentArrowsBottom = false;
+  if (gt) formatinfo.DocumentArrowsBottom = false;
 }
 
@@ -582,5 +686,4 @@
   //                        to the archivedir metadata element
 
-
   // must have a valid collection server to continue
   text_t &collection = args["c"];
@@ -593,11 +696,4 @@
   text_t &arg_d = args["d"];
   text_t &arg_cl = args["cl"];
-  int gt = args.getintarg("gt");
-
-  // get info on current collection and load up formatinfo
-  ColInfoResponse_t cinfo;
-  comerror_t err;
-  collectproto->get_collectinfo (collection, cinfo, err, logout);
-  load_formatinfo (cinfo.format, gt);
 
   if (!formatinfo.DocumentArrowsBottom)
@@ -628,5 +724,5 @@
       if (!response.docInfo[0].metadata["Title"].values[0].empty())
 	pagetitlearray.push_back (response.docInfo[0].metadata["Title"].values[0]);
-      if (!gt) {
+      if (args["gt"] != "1") {
 	MetadataInfo_t *parenttitle = response.docInfo[0].metadata["Title"].parent;
 	while (parenttitle != NULL) {
@@ -710,11 +806,33 @@
     }
 
+    if (formatinfo.DocumentUseHTML) {
+      
+      if (!args["d"].empty()) {
+	if (args["f"] == "1") {
+	  textout << outconvert << disp 
+		  << "<html><head></head>\n"
+		  << "<frameset rows=\"68,*\" noresize border=0>\n"
+		  << "<frame scrolling=no frameborder=0 src=\"_gwcgi_?e=_compressedoptions_&a=p&p=nav\">\n"
+		  << "<frame name=\"documenttop\" frameborder=0 src=\"_gwcgi_?e=_compressedoptions_&a=d&d=" 
+		  << args["d"] << "\">"
+		  << "<noframes>\n"
+		  << "<p>You must have a frame enabled browser to view this.</p>\n"
+		  << "</noframes>\n"
+		  << "</frameset>\n"
+		  << "</html>\n";
+	} else {
+	  output_document (OID, args, collectproto, disp, outconvert, textout, logout);	
+	}
+	return true;
+      }
+    }
+
     textout << outconvert << disp << "_document:header_\n"
 	    << "_document:content_\n";
-    
+      
     // output the table of contents
     output_toc (args, browsers, formatinfo, collectproto, 
 		disp, outconvert, textout, logout);
-
+    
     // output the document text
     textout << "<p>\n";
Index: /trunk/gsdl/src/recpt/documentaction.h
===================================================================
--- /trunk/gsdl/src/recpt/documentaction.h	(revision 869)
+++ /trunk/gsdl/src/recpt/documentaction.h	(revision 870)
@@ -40,4 +40,7 @@
 
   receptionist *recpt;
+
+  bool get_link (cgiargsclass &args, recptprotolistclass *protos,
+		 const text_t &inlink, text_t &outlink, ostream &logout);
 
   void load_formatinfo (const text_tmap &colformat, int gt);
