Ignore:
Timestamp:
2003-06-23T14:18:28+12:00 (21 years ago)
Author:
kjdon
Message:

no longer use set_gselection_macro and set_fqfselection_macro functions, set_option_macro now takes a boolean parameter display_single. If the arg has only one option, if display_single is true, create teh macro, otherwise dont. have two new cgi args: qf for query form type (used to use the b arg for this, but I've given it its own arg now), and qto for query type options. qto indicates whether there shoudl be form search, plain search or both available to the user (used on prefs page). if qto = 2, there is only form search, and qt may not be set, so now we have to chack qto as well as qt when determining whether we are doing a form search or not.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/queryaction.cpp

    r4220 r4755  
    6262  arg_ainfo.savedarginfo = cgiarginfo::must;
    6363  argsinfo.addarginfo (NULL, arg_ainfo);
    64 
     64 
     65  arg_ainfo.shortname = "xx";
     66  arg_ainfo.longname = "xx";
     67  arg_ainfo.multiplechar = true;
     68  arg_ainfo.multiplevalue = true;
     69  arg_ainfo.defaultstatus = cgiarginfo::weak;
     70  arg_ainfo.argdefault = "a";
     71  arg_ainfo.savedarginfo = cgiarginfo::must;
     72  argsinfo.addarginfo (NULL, arg_ainfo);
     73 
    6574   // "ct" - 0 = mg, 1 = mgpp
    6675  arg_ainfo.shortname = "ct";
     
    322331  argsinfo.addarginfo (NULL, arg_ainfo);
    323332
     333  // "qto" - 0 = text only, 1 = form only, 2 = text and form
     334  arg_ainfo.shortname = "qto";
     335  arg_ainfo.longname = "query type options";
     336  arg_ainfo.multiplechar = false;
     337  arg_ainfo.defaultstatus = cgiarginfo::weak;
     338  arg_ainfo.argdefault = "0";
     339  arg_ainfo.savedarginfo = cgiarginfo::must;
     340  argsinfo.addarginfo (NULL, arg_ainfo);
     341 
     342  // "qf" - 0= simple, 1 = advanced
     343  arg_ainfo.shortname = "qf";
     344  arg_ainfo.longname = "query form type";
     345  arg_ainfo.multiplechar = false;
     346  arg_ainfo.defaultstatus = cgiarginfo::weak;
     347  arg_ainfo.argdefault = "0";
     348  arg_ainfo.savedarginfo = cgiarginfo::must;
     349  argsinfo.addarginfo (NULL, arg_ainfo);
     350 
    324351  // "qb" - 0 = regular, 1 = large
    325352  arg_ainfo.shortname = "qb";
     
    614641
    615642
    616 // sets the selection box macros _hselection_, _jselection_, and _nselection_.
    617 void queryaction::set_option_macro (const text_t &macroname, text_t current_value,
     643// sets the selection box macros _hselection_, _jselection_, _nselection_ _gselection_, fqfselection_
     644void queryaction::set_option_macro (const text_t &macroname, text_t current_value, bool display_single,
    618645                    const FilterOption_t &option, displayclass &disp) {
    619646 
    620647  if (option.validValues.empty()) return;
    621   else if (option.validValues.size() == 1) {
    622     disp.setmacro (macroname + "selection", "Global", "_" + option.defaultValue + "_");
    623     return;
     648  if (option.validValues.size() == 1) {
     649    if (display_single) {
     650      disp.setmacro (macroname + "selection", "Global", "_" + option.defaultValue + "_");
     651    }
     652    return;   
    624653  }
    625654  if (option.validValues.size() < 2) return;
    626655 
    627   text_t macrovalue = "<select name=\"" + macroname + "\">\n";
     656  text_t macrovalue = "<select name=\"" + macroname + "\" onChange=\"update"+macroname+"();\">\n";
    628657 
    629658  if (current_value.empty()) current_value = option.defaultValue;
     
    643672}
    644673
    645 // sets the selection box macro _fqfselection_.
    646 void queryaction::set_fqfselection_macro (const FilterOption_t &option,
    647                      displayclass &disp) {
    648 
    649   if (option.validValues.empty()) return;
    650   text_t macrovalue = "";
    651 
    652   if (option.validValues.size() == 1) {
    653     macrovalue = "_ZZ_";
    654   }
    655   else {
    656     macrovalue += "<select name=\"fqf\" onChange=\"updatefqf();\">\n";
    657    
    658     text_tarray::const_iterator thisvalue = option.validValues.begin();
    659     text_tarray::const_iterator endvalue = option.validValues.end();
    660    
    661     /* All fields should come first, then there may be a TextOnly field.
    662        put a blank entry after these two.
    663     */
    664     assert (*thisvalue == "ZZ"); // Compulsory All fields
    665     macrovalue += "<option value=\"" + *thisvalue + "\">_";   
    666     macrovalue += *thisvalue + "_\n";
    667     thisvalue ++;
    668    
    669     if (*thisvalue == "TX") { // Optional TextOnly
    670       macrovalue += "<option value=\"" + *thisvalue + "\">_";   
    671       macrovalue += *thisvalue + "_\n";
    672       thisvalue ++;
    673     }
    674     if (thisvalue != endvalue) {
    675       // add the balnk line here
    676       macrovalue += "<option>---\n";
    677     }
    678     while (thisvalue != endvalue) {
    679       macrovalue += "<option value=\"" + *thisvalue + "\">_";   
    680       macrovalue += *thisvalue + "_\n";
    681       thisvalue ++;
    682     }
    683     macrovalue += "</select>\n";
    684   }
    685   disp.setmacro ("fqfselection", "query", macrovalue);
    686 
    687 }
    688 // sets the selection box macros _gselection_.
    689 void queryaction::set_gselection_macro (text_t current_value,
    690                     const FilterOption_t &option,
    691                     displayclass &disp) {
    692  
    693   if (option.validValues.size() <= 1) {
    694     return;
    695   }
    696  
    697   text_t macrovalue = "<select name=\"g\">\n";
    698  
    699   if (current_value.empty()) current_value = option.defaultValue;
    700  
    701   text_tarray::const_iterator thisvalue = option.validValues.begin();
    702   text_tarray::const_iterator endvalue = option.validValues.end();
    703 
    704   while (thisvalue != endvalue) {
    705     macrovalue += "<option value=\"" + *thisvalue + "\"";
    706     if (*thisvalue == current_value)
    707       macrovalue += " selected";
    708     macrovalue += ">_" + *thisvalue + "_\n";
    709     thisvalue ++;
    710   }
    711   macrovalue += "</select>\n";
    712   disp.setmacro ("gselection", "Global", macrovalue);
    713 }
     674
    714675
    715676void queryaction::define_external_macros (displayclass &disp, cgiargsclass &args,
     
    724685  // _cq2selection                the selection box for combining two queries
    725686 
    726 
     687  // _gselection_, the selection box forlevels (mgpp)
     688  // _fqfselection_, the selection box for index/fields (mgpp)
    727689  // can't do anything if collectproto is null (i.e. no collection was specified)
    728690  recptproto *collectproto = protos->getrecptproto (args["c"], logout);
     
    742704    // _hselection_ and _h2selection_ (Index)
    743705    it = response.filterOptions.find ("Index");
    744     if (it != end) set_option_macro ("h", args["h"], (*it).second, disp);
    745     if (it != end) set_option_macro ("h2", args["h2"], (*it).second, disp);
     706    if (it != end) set_option_macro ("h", args["h"], true, (*it).second, disp);
     707    if (it != end) set_option_macro ("h2", args["h2"], true,(*it).second, disp);
    746708   
    747709    // _jselection_ and _j2selection_ (Subcollection)
    748710    it = response.filterOptions.find ("Subcollection");
    749     if (it != end) set_option_macro ("j", args["j"], (*it).second, disp);
    750     if (it != end) set_option_macro ("j2", args["j2"], (*it).second, disp);
     711    if (it != end) set_option_macro ("j", args["j"], true,(*it).second, disp);
     712    if (it != end) set_option_macro ("j2", args["j2"], true,(*it).second, disp);
    751713   
    752714    // _nselection_ and _n2selection_ (Language)
    753715    it = response.filterOptions.find ("Language");
    754     if (it != end) set_option_macro ("n", args["n"], (*it).second, disp);
    755     if (it != end) set_option_macro ("n2", args["n2"], (*it).second, disp);
     716    if (it != end) set_option_macro ("n", args["n"], true,(*it).second, disp);
     717    if (it != end) set_option_macro ("n2", args["n2"], true,(*it).second, disp);
    756718
    757719    // _cq2selection_ (CombineQuery)
    758720    it = response.filterOptions.find ("CombineQuery");
    759     if (it != end) set_option_macro ("cq2", args["cq2"], (*it).second, disp);
     721    if (it != end) set_option_macro ("cq2", args["cq2"], true,(*it).second, disp);
    760722
    761723    // _gselection_ (Level) // for mgpp collections
    762724    it = response.filterOptions.find("Level");
    763     if (it!=end) set_gselection_macro(args["g"], (*it).second, disp);
    764 
    765     // should probably go into define_internal_macros
    766     // _fqfselection_
     725    if (it!=end) set_option_macro("g", args["g"], false, (*it).second, disp);
     726
     727    // _fqfselection_ field list, for mgpp collections
    767728    it = response.filterOptions.find("IndexField");
    768     if (it!=end) {
    769       set_fqfselection_macro((*it).second, disp);
    770     }
     729    if (it!=end) set_option_macro ("fqf", args["fqf"], true, (*it).second, disp);
     730   
    771731  }
    772732} // define external macros
     
    779739  // _advformlist_
    780740
    781   if (args["ct"]!="1" || args["qt"]!="1")
     741  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
    782742    return; // dont need these macros
    783743
     
    786746  int argfqn = args.getintarg("fqn");
    787747 
    788   if (args["b"] == "1") { // advanced form
     748  if (args["qf"] == "1") { // advanced form
    789749    form += "<tr>_firstadvformelement_</tr>\n";
    790750    for (int i=1; i<argfqn; i++) {     
     
    13401300                          displayclass &disp,
    13411301                          ostream &logout) {
    1342   if (args["qt"]=="0") { // normal text search
     1302  if (args["qt"]=="0" && args["qto"] != "2") { // normal text search
    13431303    formattedstring = args["q"];
     1304    // remove & | ! for simple search, insert spaces for chinese
    13441305    format_querystring (formattedstring, args.getintarg("b"));
     1306    if (args["ct"]=="1") { // mgpp - we need to add in the field info
     1307      format_field_info(formattedstring, args["fqf"]);
     1308    }
    13451309    add_dates(formattedstring, args.getintarg("ds"), args.getintarg("de"),
    13461310          args.getintarg("dsbc"), args.getintarg("debc"));
    13471311  }
    1348   else if (args["qt"]=="1" ){ // form search
    1349 
    1350     if (args["b"]=="1" && args["fqa"]=="1") { // explicit query
     1312  else if (args["qt"]=="1" || args["qto"]=="2"){ // form search
     1313
     1314    if (args["qf"]=="1" && args["fqa"]=="1") { // explicit query
    13511315      formattedstring = args["q"];
    13521316    }
    13531317    else { // form search
    1354       if (args["b"]=="0") { // regular form
     1318      if (args["qf"]=="0") { // regular form
    13551319    parse_reg_query_form(formattedstring, args);
    13561320      }
Note: See TracChangeset for help on using the changeset viewer.