Ignore:
Timestamp:
2006-09-20T09:55:47+12:00 (18 years ago)
Author:
kjdon
Message:

added sort field macro for use in query form with lucene, query parsing methods arguments changed

File:
1 edited

Legend:

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

    r12771 r12786  
    672672
    673673
    674 
    675674void queryaction::define_external_macros (displayclass &disp, cgiargsclass &args,
    676675                      recptprotolistclass *protos, ostream &logout) {
     
    737736      it = response.filterOptions.find("IndexField");
    738737      if (it!=end) {
    739     if (args["qto"]=="2" || args["qt"]=="1") { // form search
    740       set_option_macro ("fqf", args["fqf"], true, true, (*it).second, disp);
    741     } else {
    742       set_option_macro ("fqf", args["fqf"], true, false, (*it).second, disp);
     738    bool form_search = false;
     739    if (args["qto"]=="2" || args["qt"]=="1") {
     740      form_search = true;
     741    }
     742    set_option_macro ("fqf", args["fqf"], true, form_search, (*it).second, disp);
     743    if (args["ct"] == "2") {// lucene
     744      // set the sort field macro
     745      set_sfselection_macro(args["sf"], (*it).second, disp);
    743746    }
    744747      }
     
    746749  }
    747750} // define external macros
    748    
     751 
     752void queryaction::set_sfselection_macro(text_t current_value,
     753                       const FilterOption_t &option,
     754                       displayclass &disp) {
     755
     756  // we need two or more options to continue
     757  if (option.validValues.size() <= 2) {
     758    return;
     759  }
     760
     761  text_t macrovalue = "<select name=\"sf\">\n";
     762 
     763  if (current_value.empty()) current_value = "";
     764 
     765  // we give a rank option first
     766  macrovalue += "<option value=\"\"";
     767  if (current_value == "") {
     768    macrovalue += " selected";
     769  }
     770  macrovalue += ">_query:textsortbyrank_\n";
     771
     772  text_tarray::const_iterator thisvalue = option.validValues.begin();
     773  text_tarray::const_iterator endvalue = option.validValues.end();
     774  int valid_count = 0;
     775  while (thisvalue != endvalue) {
     776    if (*thisvalue != "ZZ" && *thisvalue != "TX") {
     777      ++valid_count;
     778      macrovalue += "<option value=\"by" + *thisvalue + "\"";
     779      if (current_value == "by"+*thisvalue)
     780    macrovalue += " selected";
     781      macrovalue += ">_" + *thisvalue + "_\n";
     782    }
     783    ++thisvalue;
     784  }
     785  macrovalue += "</select>";
     786  if (valid_count > 0) {
     787    disp.setmacro ("sfselection", displayclass::defaultpackage, macrovalue);
     788  }
     789 
     790}
     791 
    749792// sets the selection box macro _gformselection_.
    750793// the default for _gformselection_ is _gselection_
     
    809852    return; // dont need these macros
    810853
    811   // mgpp & form query only needs the macros defined
    812854  text_t form = "";
    813855  int argfqn = args.getintarg("fqn");
    814856 
    815857  if (args["b"] == "1") { // advanced form
    816     form += "<tr>_firstadvformelement_</tr>\n";
     858    form += "_firstadvformelement_\n";
    817859    for (int i=1; i<argfqn; ++i) {     
    818     form += "<tr>_advformelement_</tr>\n";
     860    form += "_advformelement_\n";
    819861    }
    820862    disp.setmacro("advformlist", "query", form);
     
    822864  else { // simple form
    823865    for (int i=0; i<argfqn; ++i) {
    824       form += "<tr>_regformelement_</tr>\n";
     866      form += "_regformelement_\n";
    825867    }
    826868    disp.setmacro("regformlist", "query", form);
     
    13651407  text_t formattedstring = "";
    13661408  get_formatted_query_string(formattedstring, segment, args, disp, logout);
    1367 
     1409 
    13681410  if (!formattedstring.empty()) { // do the query
    13691411    // note! formattedstring is in unicode! mg and mgpp must convert!
     
    14521494    format_querystring (formattedstring, args.getintarg("b"), segment);
    14531495    if (args["ct"]!=0) { // mgpp and lucene - need to add in tag info if appropriate
    1454       format_field_info(formattedstring, args);
     1496      format_field_info(formattedstring, args["fqf"], args.getintarg("ct"),
     1497            args.getintarg("t"), args.getintarg("b"));
    14551498    }
    14561499
     
    14681511    else { // form search
    14691512      if (args["b"]=="0") { // regular form
    1470     parse_reg_query_form(formattedstring, args);
     1513    parse_reg_query_form(formattedstring, args, segment);
    14711514      }
    14721515      else  { // advanced form
    1473     parse_adv_query_form(formattedstring, args);
     1516    parse_adv_query_form(formattedstring, args, segment);
    14741517      }
    14751518      args["q"] = formattedstring;
Note: See TracChangeset for help on using the changeset viewer.