Index: main/trunk/greenstone2/runtime-src/src/recpt/queryaction.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/queryaction.cpp	(revision 23365)
+++ main/trunk/greenstone2/runtime-src/src/recpt/queryaction.cpp	(revision 23378)
@@ -908,4 +908,44 @@
   }
 
+  // check the main coll
+  text_t main_collection = args["c"];
+  recptproto *collectproto = protos->getrecptproto (main_collection, logout);
+  if (collectproto == NULL) {
+    logout << outconvert << "queryaction::search_multiple_collection: " << main_collection
+	   << " collection has a NULL collectproto\n";
+
+    // Display the "this collection is not installed on this system" page
+    disp.setmacro("cvariable", displayclass::defaultpackage, main_collection);
+    disp.setmacro("content", "query", "<p>_textbadcollection_<p>");
+
+    textout << outconvert << disp << "_query:header_\n"
+	    << "_query:content_\n" << "_query:footer_\n";
+    return true;
+  }
+
+  ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr (collectproto, main_collection, logout);
+  if (cinfo == NULL) {
+    logout << "ERROR (query_action::search_multiple_collections): get_collectinfo_ptr returned NULL for '"<<main_collection<<"'\n";
+    return false;
+  }
+
+  // get the formatted query string
+  // what to do about segmentation for multiple colls??
+  // TODO
+  bool segment = false;
+  text_t formattedstring = "";
+  get_formatted_query_string(formattedstring, segment, args, disp, logout);
+
+  if (formattedstring.empty()) {
+    // dont bother doing a query if no query string
+    define_history_macros (disp, args, protos, logout);
+    textout << outconvert << disp << "_query:header_\n"
+	  << "_query:content_";
+    textout << outconvert << disp << "_query:footer_";
+
+    return true;
+  }
+
+
   // queryaction uses "VList" browser to display results,
   // a queries clasification is "Search"
@@ -916,6 +956,4 @@
   map<text_t, colinfo_t, lttext_t> colinfomap;
 
-  ColInfoResponse_t *cinfo = NULL;
-  recptproto *collectproto = NULL;
   comerror_t err;
   FilterRequest_t request;
@@ -926,18 +964,5 @@
   isapprox isApprox = Exact;
 
-  // what to do about segmentation for multiple colls??
-  bool segment = false;
-  text_t formattedstring = "";
-  get_formatted_query_string(formattedstring, segment, args, disp, logout);
-
-  if (formattedstring.empty()) {
-    // dont bother doing a query if no query string
-    define_history_macros (disp, args, protos, logout);
-    textout << outconvert << disp << "_query:header_\n"
-	  << "_query:content_";
-    textout << outconvert << disp << "_query:footer_";
-
-    return true;
-  }
+
   bool syntax_error = false;
 
@@ -954,25 +979,13 @@
   option.value = args["m"];
   request.filterOptions.push_back (option);
-
-  text_tarray::iterator col_here = collections.begin();
-  text_tarray::iterator col_end = collections.end();
-
-  map<text_t, int, lttext_t> termfreqs;
-  
-  // just check the main col for formatting info - use individual format statements, or the main one?
-  
-  browserclass *bptr = browsers->getbrowser (browsertype);
-  
-  text_t main_col = args["c"];
-  cinfo = recpt->get_collectinfo_ptr (collectproto, main_col, logout);
-  if (cinfo == NULL) {
-    logout << "ERROR (query_action::search_multiple_collections): get_collectinfo_ptr returned NULL for '"<<main_col<<"'\n";
-    return false;
-  }
-  
+  
+  // check the main collection for uniform formatting info - do we use 
+  // individual format statements, or just the main one?
   bool use_main_col_format = false;
   if (cinfo->ccsOptions & CCSUniformSearchResultsFormatting) {
     use_main_col_format = true;
   }
+
+  browserclass *bptr = browsers->getbrowser (browsertype);
  
   request.fields.erase (request.fields.begin(), request.fields.end());
@@ -992,8 +1005,14 @@
   }
   
+  text_tarray::iterator col_here = collections.begin();
+  text_tarray::iterator col_end = collections.end();
+
+  map<text_t, int, lttext_t> termfreqs;
+
   while (col_here != col_end) {
 
     collectproto = protos->getrecptproto (*col_here, logout);
     if (collectproto == NULL) {
+      // skip this collection
       logout << outconvert << "queryaction::search_multiple_collections: " << *col_here 
 	     << " collection has a NULL collectproto, ignoring\n";
@@ -1003,9 +1022,10 @@
     cinfo = recpt->get_collectinfo_ptr (collectproto, *col_here, logout);
     if (cinfo == NULL) {
+      // skip this collection
       logout << "ERROR (query_action::search_multiple_collections): get_collectinfo_ptr returned NULL\n";
       ++col_here;
       continue;
     }
-
+    
     if (!use_main_col_format) {
       request.fields.erase (request.fields.begin(), request.fields.end());
@@ -1013,7 +1033,5 @@
       bptr->load_metadata_defaults (request.fields);
       
-    //browserclass *bptr = browsers->getbrowser (browsertype);
-
-    // get the formatstring if there is one 
+      // get the formatstring if there is one 
       if (!get_formatstring (classification, browsertype, 
 			     cinfo->format, formatstring)) {
@@ -1076,5 +1094,5 @@
       while (doc_here != doc_end) {
 	thisresult.doc = *doc_here;
-	results.insert (thisresult);
+	results.insert (thisresult); // this is ordering based on doc rank
 	++doc_here;
       }
@@ -1151,191 +1169,5 @@
 }
 
-bool queryaction::search_single_collection (cgiargsclass &args, const text_t &collection,
-					    recptprotolistclass *protos, browsermapclass *browsers, 
-					    displayclass &disp, outconvertclass &outconvert, 
-					    ostream &textout, ostream &logout) {
-
-  recptproto *collectproto = protos->getrecptproto (collection, logout);
-  if (collectproto == NULL) {
-    logout << outconvert << "queryaction::search_single_collection: " << collection
-	   << " collection has a NULL collectproto\n";
-
-    // Display the "this collection is not installed on this system" page
-    disp.setmacro("cvariable", displayclass::defaultpackage, collection);
-    disp.setmacro("content", "query", "<p>_textbadcollection_<p>");
-
-    textout << outconvert << disp << "_query:header_\n"
-	    << "_query:content_\n" << "_query:footer_\n";
-    return true;
-  }
-
-  // queryaction uses "VList" browser to display results,
-  // a queries clasification is "Search"
-  text_t browsertype = "VList";
-  text_t classification = "Search";
-
-  comerror_t err;
-  ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr (collectproto, collection, logout);
-
-  if (cinfo == NULL) {
-    logout << "ERROR (query_action::search_single_collection): get_collectinfo_ptr returned NULL\n";
-    return false;
-  }
-    
-  bool segment = cinfo->isSegmented;
-  browserclass *bptr = browsers->getbrowser (browsertype);
-
-  // get the formatstring if there is one 
-  text_t formatstring;
-  if (!get_formatstring (classification, browsertype, 
-			 cinfo->format, formatstring)) {
-    formatstring = bptr->get_default_formatstring();
-  }
-  FilterRequest_t request;
-  FilterResponse_t response;
-
-  text_t hits_per_page_old = args["o"];
-  text_t start_results_from_old = args["r"];  
-
-  // if the "ifl" argument is set to 1, we only want to get one document
-  // this may be the first search result (from "I feel lucky") or maybe a 
-  // specified search result (from next/prev search result link)
-  if (args["ifl"] == "1") {
-    args["r"] = args["ifln"]; // the document number we want
-    args["o"] = "1";
-  }
-
-  bptr->set_filter_options (request, args);
-  bptr->load_metadata_defaults (request.fields);
-
-  format_t *formatlistptr = new format_t();
-  parse_formatstring (formatstring, formatlistptr, request.fields, request.getParents);
-    
-  // do the query
-  request.filterResultOptions = FROID | FRmetadata | FRtermFreq;
-  text_t formattedstring = "";
-  get_formatted_query_string(formattedstring, segment, args, disp, logout);
-
-
-  if (!formattedstring.empty()) { // do the query
-    // note! formattedstring is in unicode! mg and mgpp must convert!
-    set_queryfilter_options (request, formattedstring, args);
-
-    collectproto->filter (collection, request, response, err, logout);
-
-    if (err != noError) {
-      outconvertclass text_t2ascii;
-      logout << text_t2ascii
-	     << "queryaction::search_single_collections: call to QueryFilter failed "
-	     << "for " << collection << " collection (" << get_comerror_string (err) << ")\n";
-     
-    }
-
-    // Perform the "I'm feeling lucky" trick if the "ifl" argument is set
-    if (err == noError && !args["ifl"].empty()) {
-      //Restore the "r" and "o" arg
-      args["r"] = start_results_from_old;
-      args["o"] = hits_per_page_old;
-      
-      //Find whether DocumentSearchResultLinks is enabled
-      bool show_links = false;
-      text_tmap::const_iterator format_here = cinfo->format.begin();
-      text_tmap::const_iterator format_end = cinfo->format.end();
-      
-      while (format_here != format_end) {
-	if (((*format_here).first == "DocumentSearchResultLinks") && 
-	    ((*format_here).second == "true")){
-	  show_links = true;
-	  break;
-	}
-	++format_here;
-      } 
-      
-      if (args["ifl"] == 1 || (args["ifl"] == 2 && response.numDocs == 1)) {
-	
-	// The first search result is the one we want
-	if (response.docInfo.begin() != response.docInfo.end()) {
-	  
-	  ResultDocInfo_tarray::iterator section = response.docInfo.begin();
-	  
-	  // We still need to set "srn" and "srp" values (next and prev search result numbers) if we are showing them
-	  int srn = 0;
-	  int srp = 0;
-	  if (show_links) {
-	    int ifln = args["ifln"].getint();
-	    srn = ifln + 1;
-	    if (srn > response.numDocs) {
-	      srn = 0;
-	    }
-	    srp = ifln - 1;
-	    if (srp < 0) {
-	      srp = 0;
-	    }
-	  }
-	  
-	  textout << outconvert << disp 
-		  << "Location: _gwcgi_?e=_compressedoptions_&a=d&c=" 
-		  << collection << "&cl=search&d=" << (*section).OID 
-		  << "&srn=" << srn << "&srp=" << srp << "\n\n";
-	  textout << flush;
-	  
-	  return true;
-	}
-      }
-    
-      // There weren't enough (or any) matching documents
-      // We'll just carry on as if ifl wasn't set. The only catch is that get_cgihead_info won't have
-      // done the right thing (because ifl was set), so we need to make sure the output is html
-      textout << "Content-type: text/html\n\n";
-      
-    }
-
-    if (err != noError) {
-      disp.setmacro("resultline", "query", "_textnodocs_");
-      if (err == syntaxError) {
-	disp.setmacro ("freqmsg", "query", "_textinvalidquery_");
-      } else {
-	disp.setmacro ("freqmsg", "query", "");
-      }
-    } else {
-      
-      define_query_macros (args, disp, response.numDocs, response.isApprox);
-      define_single_query_macros(args, disp, response);
-      // save the query if appropriate
-      save_search_history(args, response.numDocs, response.isApprox);
-    }
-
-    // If Lucene threw a TooManyClauses exception, tell the user about it
-    if (args["ct"] == 2 && response.error_message == "TOO_MANY_CLAUSES") {
-      disp.setmacro ("freqmsg", "query", "_textlucenetoomanyclauses_");
-    }
-  }
-  
-  //Restore the "r" and "o" arg in case they have been changed and we still get here
-  args["r"] = start_results_from_old;
-  args["o"] = hits_per_page_old;
-
-  define_history_macros (disp, args, protos, logout);
-
-  textout << outconvert << disp << "_query:header_\n"
-	  << "_query:content_";
-  
-  if (err == noError) {
-    // output the results
-    text_t numdocs_t = response.numDocs;  
-    args["nmd"] = numdocs_t;
-    bool use_table = is_table_content (formatlistptr);
-    bptr->output_section_group (response, args, collection, 0, formatlistptr, 
-				use_table, request.fields, request.getParents, 
-				collectproto, disp, outconvert, textout, logout);
-  }
-
-  textout << outconvert << disp << "_query:footer_";
-  
-  delete (formatlistptr);
-  
-  return true;
-}
- 
+
 // does the formatting of the query string - either uses q for a text search
 // or the form values for an form search
Index: main/trunk/greenstone2/runtime-src/src/recpt/queryaction.h
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/queryaction.h	(revision 23365)
+++ main/trunk/greenstone2/runtime-src/src/recpt/queryaction.h	(revision 23378)
@@ -89,13 +89,4 @@
 				    ostream &logout);
   
-  virtual bool search_single_collection (cgiargsclass &args, 
-					 const text_t &collection,
-					 recptprotolistclass *protos, 
-					 browsermapclass *browsers, 
-					 displayclass &disp, 
-					 outconvertclass &outconvert, 
-					 ostream &textout, ostream &logout);
-
-
   virtual bool save_search_history(cgiargsclass &args, int numdocs, 
 				   isapprox isApprox);
