Index: /trunk/gsdl/src/recpt/queryaction.cpp
===================================================================
--- /trunk/gsdl/src/recpt/queryaction.cpp	(revision 4754)
+++ /trunk/gsdl/src/recpt/queryaction.cpp	(revision 4755)
@@ -62,5 +62,14 @@
   arg_ainfo.savedarginfo = cgiarginfo::must;
   argsinfo.addarginfo (NULL, arg_ainfo);
-
+  
+  arg_ainfo.shortname = "xx";
+  arg_ainfo.longname = "xx";
+  arg_ainfo.multiplechar = true;
+  arg_ainfo.multiplevalue = true;
+  arg_ainfo.defaultstatus = cgiarginfo::weak;
+  arg_ainfo.argdefault = "a";
+  arg_ainfo.savedarginfo = cgiarginfo::must;
+  argsinfo.addarginfo (NULL, arg_ainfo);
+  
    // "ct" - 0 = mg, 1 = mgpp
   arg_ainfo.shortname = "ct";
@@ -322,4 +331,22 @@
   argsinfo.addarginfo (NULL, arg_ainfo);
 
+  // "qto" - 0 = text only, 1 = form only, 2 = text and form
+  arg_ainfo.shortname = "qto";
+  arg_ainfo.longname = "query type options";
+  arg_ainfo.multiplechar = false;
+  arg_ainfo.defaultstatus = cgiarginfo::weak;
+  arg_ainfo.argdefault = "0";
+  arg_ainfo.savedarginfo = cgiarginfo::must;
+  argsinfo.addarginfo (NULL, arg_ainfo);
+  
+  // "qf" - 0= simple, 1 = advanced
+  arg_ainfo.shortname = "qf";
+  arg_ainfo.longname = "query form type";
+  arg_ainfo.multiplechar = false;
+  arg_ainfo.defaultstatus = cgiarginfo::weak;
+  arg_ainfo.argdefault = "0";
+  arg_ainfo.savedarginfo = cgiarginfo::must;
+  argsinfo.addarginfo (NULL, arg_ainfo);
+  
   // "qb" - 0 = regular, 1 = large
   arg_ainfo.shortname = "qb";
@@ -614,16 +641,18 @@
 
 
-// sets the selection box macros _hselection_, _jselection_, and _nselection_.
-void queryaction::set_option_macro (const text_t &macroname, text_t current_value,
+// sets the selection box macros _hselection_, _jselection_, _nselection_ _gselection_, fqfselection_ 
+void queryaction::set_option_macro (const text_t &macroname, text_t current_value, bool display_single,
 				    const FilterOption_t &option, displayclass &disp) {
   
   if (option.validValues.empty()) return;
-  else if (option.validValues.size() == 1) {
-    disp.setmacro (macroname + "selection", "Global", "_" + option.defaultValue + "_");
-    return;
+  if (option.validValues.size() == 1) {
+    if (display_single) {
+      disp.setmacro (macroname + "selection", "Global", "_" + option.defaultValue + "_");
+    }
+    return;    
   } 
   if (option.validValues.size() < 2) return;
   
-  text_t macrovalue = "<select name=\"" + macroname + "\">\n";
+  text_t macrovalue = "<select name=\"" + macroname + "\" onChange=\"update"+macroname+"();\">\n";
   
   if (current_value.empty()) current_value = option.defaultValue;
@@ -643,73 +672,5 @@
 }
 
-// sets the selection box macro _fqfselection_.
-void queryaction::set_fqfselection_macro (const FilterOption_t &option, 
-					 displayclass &disp) {
-
-  if (option.validValues.empty()) return;
-  text_t macrovalue = "";
-
-  if (option.validValues.size() == 1) {
-    macrovalue = "_ZZ_";
-  }
-  else {
-    macrovalue += "<select name=\"fqf\" onChange=\"updatefqf();\">\n";
-    
-    text_tarray::const_iterator thisvalue = option.validValues.begin();
-    text_tarray::const_iterator endvalue = option.validValues.end();
-    
-    /* All fields should come first, then there may be a TextOnly field.
-       put a blank entry after these two.
-    */
-    assert (*thisvalue == "ZZ"); // Compulsory All fields
-    macrovalue += "<option value=\"" + *thisvalue + "\">_";    
-    macrovalue += *thisvalue + "_\n";
-    thisvalue ++;
-    
-    if (*thisvalue == "TX") { // Optional TextOnly
-      macrovalue += "<option value=\"" + *thisvalue + "\">_";    
-      macrovalue += *thisvalue + "_\n";
-      thisvalue ++;
-    }
-    if (thisvalue != endvalue) {
-      // add the balnk line here 
-      macrovalue += "<option>---\n";
-    }
-    while (thisvalue != endvalue) {
-      macrovalue += "<option value=\"" + *thisvalue + "\">_";    
-      macrovalue += *thisvalue + "_\n";
-      thisvalue ++;
-    }
-    macrovalue += "</select>\n";
-  }
-  disp.setmacro ("fqfselection", "query", macrovalue);
-
-}
-// sets the selection box macros _gselection_.
-void queryaction::set_gselection_macro (text_t current_value,
-					const FilterOption_t &option, 
-					displayclass &disp) {
-  
-  if (option.validValues.size() <= 1) {
-    return;
-  } 
-  
-  text_t macrovalue = "<select name=\"g\">\n";
-  
-  if (current_value.empty()) current_value = option.defaultValue;
-  
-  text_tarray::const_iterator thisvalue = option.validValues.begin();
-  text_tarray::const_iterator endvalue = option.validValues.end();
-
-  while (thisvalue != endvalue) {
-    macrovalue += "<option value=\"" + *thisvalue + "\"";
-    if (*thisvalue == current_value)
-      macrovalue += " selected";
-    macrovalue += ">_" + *thisvalue + "_\n";
-    thisvalue ++;
-  }
-  macrovalue += "</select>\n";
-  disp.setmacro ("gselection", "Global", macrovalue);
-}
+
 
 void queryaction::define_external_macros (displayclass &disp, cgiargsclass &args, 
@@ -724,5 +685,6 @@
   // _cq2selection                the selection box for combining two queries
   
-
+  // _gselection_, the selection box forlevels (mgpp)
+  // _fqfselection_, the selection box for index/fields (mgpp)
   // can't do anything if collectproto is null (i.e. no collection was specified)
   recptproto *collectproto = protos->getrecptproto (args["c"], logout);
@@ -742,31 +704,29 @@
     // _hselection_ and _h2selection_ (Index)
     it = response.filterOptions.find ("Index");
-    if (it != end) set_option_macro ("h", args["h"], (*it).second, disp);
-    if (it != end) set_option_macro ("h2", args["h2"], (*it).second, disp);
+    if (it != end) set_option_macro ("h", args["h"], true, (*it).second, disp);
+    if (it != end) set_option_macro ("h2", args["h2"], true,(*it).second, disp);
     
     // _jselection_ and _j2selection_ (Subcollection)
     it = response.filterOptions.find ("Subcollection");
-    if (it != end) set_option_macro ("j", args["j"], (*it).second, disp);
-    if (it != end) set_option_macro ("j2", args["j2"], (*it).second, disp);
+    if (it != end) set_option_macro ("j", args["j"], true,(*it).second, disp);
+    if (it != end) set_option_macro ("j2", args["j2"], true,(*it).second, disp);
     
     // _nselection_ and _n2selection_ (Language)
     it = response.filterOptions.find ("Language");
-    if (it != end) set_option_macro ("n", args["n"], (*it).second, disp);
-    if (it != end) set_option_macro ("n2", args["n2"], (*it).second, disp);
+    if (it != end) set_option_macro ("n", args["n"], true,(*it).second, disp);
+    if (it != end) set_option_macro ("n2", args["n2"], true,(*it).second, disp);
 
     // _cq2selection_ (CombineQuery)
     it = response.filterOptions.find ("CombineQuery");
-    if (it != end) set_option_macro ("cq2", args["cq2"], (*it).second, disp);
+    if (it != end) set_option_macro ("cq2", args["cq2"], true,(*it).second, disp);
 
     // _gselection_ (Level) // for mgpp collections
     it = response.filterOptions.find("Level");
-    if (it!=end) set_gselection_macro(args["g"], (*it).second, disp);
-
-    // should probably go into define_internal_macros
-    // _fqfselection_
+    if (it!=end) set_option_macro("g", args["g"], false, (*it).second, disp);
+
+    // _fqfselection_ field list, for mgpp collections
     it = response.filterOptions.find("IndexField");
-    if (it!=end) {
-      set_fqfselection_macro((*it).second, disp);
-    }
+    if (it!=end) set_option_macro ("fqf", args["fqf"], true, (*it).second, disp);
+    
   }
 } // define external macros
@@ -779,5 +739,5 @@
   // _advformlist_
 
-  if (args["ct"]!="1" || args["qt"]!="1") 
+  if (args["ct"]=="0" || args["qto"]=="1" || (args["qto"]=="3" && args["qt"] == "0") ) // mg, or mgpp with plain only, or mgpp with both, but set to plain
     return; // dont need these macros
 
@@ -786,5 +746,5 @@
   int argfqn = args.getintarg("fqn");
   
-  if (args["b"] == "1") { // advanced form
+  if (args["qf"] == "1") { // advanced form
     form += "<tr>_firstadvformelement_</tr>\n";
     for (int i=1; i<argfqn; i++) {      
@@ -1340,17 +1300,21 @@
 					      displayclass &disp,
 					      ostream &logout) {
-  if (args["qt"]=="0") { // normal text search
+  if (args["qt"]=="0" && args["qto"] != "2") { // normal text search
     formattedstring = args["q"];
+    // remove & | ! for simple search, insert spaces for chinese
     format_querystring (formattedstring, args.getintarg("b"));
+    if (args["ct"]=="1") { // mgpp - we need to add in the field info
+      format_field_info(formattedstring, args["fqf"]);
+    }
     add_dates(formattedstring, args.getintarg("ds"), args.getintarg("de"),
 	      args.getintarg("dsbc"), args.getintarg("debc"));
   }
-  else if (args["qt"]=="1" ){ // form search
-
-    if (args["b"]=="1" && args["fqa"]=="1") { // explicit query
+  else if (args["qt"]=="1" || args["qto"]=="2"){ // form search
+
+    if (args["qf"]=="1" && args["fqa"]=="1") { // explicit query
       formattedstring = args["q"];
     }
     else { // form search
-      if (args["b"]=="0") { // regular form
+      if (args["qf"]=="0") { // regular form
 	parse_reg_query_form(formattedstring, args);
       }
