Changeset 4780 for trunk/gsdl/src/recpt


Ignore:
Timestamp:
2003-06-24T13:59:16+12:00 (21 years ago)
Author:
kjdon
Message:

have a new level selection macro, gformselection, which is used only in form search forms, in place of gselection. gformselection defaults to gselection. if paragraph level is defined, this is not used for form searching, so its removed from the selection. if there is no paragraph level, the default is used - gselection.

Location:
trunk/gsdl/src/recpt
Files:
2 edited

Legend:

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

    r4771 r4780  
    712712    if (it != end) set_option_macro ("cq2", args["cq2"], true,(*it).second, disp);
    713713
    714     // _gselection_ (Level) // for mgpp collections
    715     it = response.filterOptions.find("Level");
    716     if (it!=end) set_option_macro("g", args["g"], false, (*it).second, disp);
    717 
    718     // _fqfselection_ field list, for mgpp collections
    719     it = response.filterOptions.find("IndexField");
    720     if (it!=end) set_option_macro ("fqf", args["fqf"], true, (*it).second, disp);
     714    if (args["ct"] == "1") { // mgpp collections
     715      // _gselection_ (Level)
     716      it = response.filterOptions.find("Level");
     717      if (it!=end) {
     718    set_option_macro("g", args["g"], false, (*it).second, disp);
     719    if (args["qt"]=="1") { // form search
     720      set_gformselection_macro(args["g"], (*it).second, disp);
     721    }
     722      }
     723      // _fqfselection_ field list
     724      it = response.filterOptions.find("IndexField");
     725      if (it!=end) set_option_macro ("fqf", args["fqf"], true, (*it).second, disp);
     726    }
     727  }
     728} // define external macros
    721729   
    722   }
    723 } // define external macros
    724 
     730// sets the selection box macro _gformselection_.
     731// the default for _gformselection_ is _gselection_
     732void queryaction::set_gformselection_macro (text_t current_value,
     733                    const FilterOption_t &option,
     734                    displayclass &disp) {
     735 
     736  if (option.validValues.size() <= 1) {
     737    return;
     738  }
     739  // we need to check to see if there is paragraph present
     740  text_tarray::const_iterator thisvalue = option.validValues.begin();
     741  text_tarray::const_iterator endvalue = option.validValues.end();
     742
     743  bool has_paras = false;
     744  while (thisvalue != endvalue) {
     745    if (*thisvalue == "Paragraph") {
     746      has_paras = true;
     747      break;
     748    }
     749    thisvalue++;
     750  }
     751  if (!has_paras) return; // there is no difference between the form selection and the normal one
     752
     753  if (option.validValues.size() == 2) {
     754    // we will only have one value, but we will still put it in as a text string
     755    int opt = 0;
     756    if (option.validValues[0] == "Paragraph") {
     757      opt = 1;
     758    }
     759    disp.setmacro ("gformselection", "Global", "_"+option.validValues[opt]+"_");
     760    return;
     761  }
     762
     763  // there will be a select box
     764  text_t macrovalue = "<select name=\"g\">\n";
     765
     766  if (current_value.empty()) current_value = option.defaultValue;
     767 
     768  thisvalue = option.validValues.begin();
     769 
     770  while (thisvalue != endvalue) {
     771    if (*thisvalue != "Paragraph") {
     772      macrovalue += "<option value=\"" + *thisvalue + "\"";
     773      if (*thisvalue == current_value)
     774    macrovalue += " selected";
     775      macrovalue += ">_" + *thisvalue + "_\n";
     776    }
     777    thisvalue ++;
     778  }
     779  macrovalue += "</select>\n";
     780  disp.setmacro ("gformselection", "Global", macrovalue);
     781}
    725782void queryaction::define_form_macros (displayclass &disp, cgiargsclass &args,
    726783               recptprotolistclass *protos, ostream &logout) {
  • trunk/gsdl/src/recpt/queryaction.h

    r4754 r4780  
    8888             const FilterOption_t &option, displayclass &disp);
    8989
     90  void set_gformselection_macro (text_t current_value,
     91                 const FilterOption_t &option,
     92                 displayclass &disp);
     93
    9094  void output_ccp (cgiargsclass &args, recptprotolistclass *protos,
    9195           displayclass &disp, outconvertclass &outconvert,
Note: See TracChangeset for help on using the changeset viewer.