Changeset 4755
- Timestamp:
- 2003-06-23T14:18:28+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/queryaction.cpp
r4220 r4755 62 62 arg_ainfo.savedarginfo = cgiarginfo::must; 63 63 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 65 74 // "ct" - 0 = mg, 1 = mgpp 66 75 arg_ainfo.shortname = "ct"; … … 322 331 argsinfo.addarginfo (NULL, arg_ainfo); 323 332 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 324 351 // "qb" - 0 = regular, 1 = large 325 352 arg_ainfo.shortname = "qb"; … … 614 641 615 642 616 // sets the selection box macros _hselection_, _jselection_, and _nselection_.617 void queryaction::set_option_macro (const text_t ¯oname, text_t current_value, 643 // sets the selection box macros _hselection_, _jselection_, _nselection_ _gselection_, fqfselection_ 644 void queryaction::set_option_macro (const text_t ¯oname, text_t current_value, bool display_single, 618 645 const FilterOption_t &option, displayclass &disp) { 619 646 620 647 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; 624 653 } 625 654 if (option.validValues.size() < 2) return; 626 655 627 text_t macrovalue = "<select name=\"" + macroname + "\" >\n";656 text_t macrovalue = "<select name=\"" + macroname + "\" onChange=\"update"+macroname+"();\">\n"; 628 657 629 658 if (current_value.empty()) current_value = option.defaultValue; … … 643 672 } 644 673 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 714 675 715 676 void queryaction::define_external_macros (displayclass &disp, cgiargsclass &args, … … 724 685 // _cq2selection the selection box for combining two queries 725 686 726 687 // _gselection_, the selection box forlevels (mgpp) 688 // _fqfselection_, the selection box for index/fields (mgpp) 727 689 // can't do anything if collectproto is null (i.e. no collection was specified) 728 690 recptproto *collectproto = protos->getrecptproto (args["c"], logout); … … 742 704 // _hselection_ and _h2selection_ (Index) 743 705 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); 746 708 747 709 // _jselection_ and _j2selection_ (Subcollection) 748 710 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); 751 713 752 714 // _nselection_ and _n2selection_ (Language) 753 715 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); 756 718 757 719 // _cq2selection_ (CombineQuery) 758 720 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); 760 722 761 723 // _gselection_ (Level) // for mgpp collections 762 724 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 767 728 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 771 731 } 772 732 } // define external macros … … 779 739 // _advformlist_ 780 740 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 782 742 return; // dont need these macros 783 743 … … 786 746 int argfqn = args.getintarg("fqn"); 787 747 788 if (args[" b"] == "1") { // advanced form748 if (args["qf"] == "1") { // advanced form 789 749 form += "<tr>_firstadvformelement_</tr>\n"; 790 750 for (int i=1; i<argfqn; i++) { … … 1340 1300 displayclass &disp, 1341 1301 ostream &logout) { 1342 if (args["qt"]=="0" ) { // normal text search1302 if (args["qt"]=="0" && args["qto"] != "2") { // normal text search 1343 1303 formattedstring = args["q"]; 1304 // remove & | ! for simple search, insert spaces for chinese 1344 1305 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 } 1345 1309 add_dates(formattedstring, args.getintarg("ds"), args.getintarg("de"), 1346 1310 args.getintarg("dsbc"), args.getintarg("debc")); 1347 1311 } 1348 else if (args["qt"]=="1" ){ // form search1349 1350 if (args[" b"]=="1" && args["fqa"]=="1") { // explicit query1312 else if (args["qt"]=="1" || args["qto"]=="2"){ // form search 1313 1314 if (args["qf"]=="1" && args["fqa"]=="1") { // explicit query 1351 1315 formattedstring = args["q"]; 1352 1316 } 1353 1317 else { // form search 1354 if (args[" b"]=="0") { // regular form1318 if (args["qf"]=="0") { // regular form 1355 1319 parse_reg_query_form(formattedstring, args); 1356 1320 }
Note:
See TracChangeset
for help on using the changeset viewer.