Changeset 22053
- Timestamp:
- 2010-05-06T13:07:08+12:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/macros/query.dm
r17929 r22053 22 22 _advformlist_ {} 23 23 _regformlist_ {} 24 _sqladvformlist_ {} 25 _sqlregformlist_ {} 24 26 #_fqfselection_ {} 25 27 … … 71 73 ####################################################################### 72 74 73 _pagescriptextra_ {_If_("_cgiargqt_" eq"1", _formpagescriptextra_, _selectpagescriptextra_)75 _pagescriptextra_ {_If_("_cgiargqt_" ge "1", _formpagescriptextra_, _selectpagescriptextra_) 74 76 _If_("_cgiarghd_" ne "0",_historypagescriptextra_) } 75 77 … … 88 90 var args=""; 89 91 args = "&fqa=0&fqv="+argfqv+"&fqf="+argfqf; 90 _If_(_cgiargb_,args += "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc;) 92 _If_(_cgiargb_, 93 args += "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc; 94 ) 95 _If_("_cgiarga_" eq "sqlq",args += "&sqlfqf="+argsqlfqf + "&sqlfqc="+argsqlfqc;) 91 96 92 97 return args; … … 97 102 function getqueryargs () \{ 98 103 return "&fqa=1"+"&q="+argq+"&fqv="+argfqv+"&fqf="+argfqf+ 99 "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc ; 104 "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc+ 105 "&sqlfqf="+argsqlfqf + "&sqlfqc="+argsqlfqc ; 100 106 \} 101 107 … … 152 158 _If_(_jselection_,_getjarg_) 153 159 _If_(_nselection_,_getnarg_) 160 _If_(_sqlsfselection_,_getsqlsfarg_) 154 161 _If_(_sfselection_,_getsfarg_) 162 155 163 if (document.QueryForm.t != null) \{ 156 164 value = document.QueryForm.t.options[document.QueryForm.t.selectedIndex].value; … … 180 188 } 181 189 190 # currently only supported in lucene 182 191 _getsfarg_{ 192 _If_("_cgiarga__cgiargct_" eq "q2", 183 193 value = document.QueryForm.sf.options[document.QueryForm.sf.selectedIndex].value; 184 194 if (value != "_cgiargsf_") stdarg += "&sf="+value; 195 ) 196 } 197 198 # only when in sql mode 199 _getsqlsfarg_{ 200 _If_("_cgiarga__cgiargqt_" eq "sqlq2", 201 value = document.QueryForm.sqlsf.options[document.QueryForm.sqlsf.selectedIndex].value; 202 if (value != "_cgiargsqlsf_") stdarg += "&sqlsf="+value; 203 ) 185 204 } 186 205 … … 192 211 argfqs="_cgiargfqs_"; 193 212 argfqc="_cgiargfqc_"; 213 _If_("_cgiarga_" eq "sqlq", 214 argsqlfqf="_cgiargsqlfqf_"; 215 argsqlfqc="_cgiargsqlfqc_"; 216 ) 194 217 argq = ""; 195 218 … … 201 224 if (document.QueryForm.fqk != null) \{initfqk(); \} 202 225 if (document.QueryForm.fqc != null) \{initfqc(); \} 226 _If_("_cgiarga_" eq "sqlq", 227 if (document.QueryForm.sqlfqf != null) \{initsqlfqf(); \} 228 if (document.QueryForm.sqlfqc != null) \{initsqlfqc(); \} 229 ) 203 230 if (document.QueryForm.q != null) \{initq(); \} 204 231 \} … … 272 299 \} 273 300 301 302 // sqlfqf - the field selection box 303 function initsqlfqf() \{ 304 var i; 305 sqlfqf = argsqlfqf.split(","); 306 num_opts = document.QueryForm.sqlfqf[0].options.length; // assumes all have the same options 307 for (i=0; i<sqlfqf.length && i<document.QueryForm.sqlfqf.length; i++) \{ 308 if (sqlfqf[i] != "")\{ 309 for (j=0;j<num_opts;j++) \{ 310 if (sqlfqf[i]== document.QueryForm.sqlfqf[i].options[j].value) \{ 311 document.QueryForm.sqlfqf[i].options[j].selected = true; 312 break; 313 \} 314 \} 315 \} 316 \} 317 if (sqlfqf.length < document.QueryForm.sqlfqf.length) \{ // initialize remaining ones 318 for (i=sqlfqf.length;i<document.QueryForm.sqlfqf.length;i++) \{ 319 var z=i; 320 while (z >= num_opts) \{ 321 z = z-(num_opts); 322 \} 323 document.QueryForm.sqlfqf[i].options[z].selected = true; 324 325 \} 326 \} 327 updatesqlfqf(); 328 329 \} 330 331 function updatesqlfqf() \{ 332 333 var i; 334 argsqlfqf = ""; 335 var j = document.QueryForm.sqlfqf[0].selectedIndex; 336 argsqlfqf += document.QueryForm.sqlfqf[0].options[j].value; 337 for (i=1; i<document.QueryForm.sqlfqf.length;i++) \{ 338 j = document.QueryForm.sqlfqf[i].selectedIndex; 339 argsqlfqf += "," + document.QueryForm.sqlfqf[i].options[j].value; 340 \} 341 342 \} 343 344 345 function clearsqlfqf() \{ 346 var i; 347 for (i=0;i<document.QueryForm.sqlfqf.length;i++) \{ 348 var z = i; 349 if (i >= document.QueryForm.sqlfqf[i].options.length) z = z-document.QueryForm.sqlfqf[i].options.length; 350 document.QueryForm.sqlfqf[i].options[z].selected = true; 351 \} 352 updatesqlfqf(); 353 \} 354 355 356 357 274 358 // fqc - the boolean operator selection box 275 359 function initfqc() \{ … … 332 416 \} 333 417 418 419 420 // sqlfqc - the SQL operator selection box 421 function initsqlfqc() \{ 422 var i,j; 423 sqlfqc = argsqlfqc.split(","); 424 if (_cgiargsqlfqn_ == 2) \{ // there will only be one sqlfqc element 425 for (j=0;j<document.QueryForm.sqlfqc.options.length;j++) \{ 426 if (sqlfqc[0] == document.QueryForm.sqlfqc.options[j].value) \{ 427 document.QueryForm.sqlfqc.options[j].selected = true; 428 break; 429 \} 430 \} 431 \} 432 else \{ 433 for (i=0; i<sqlfqc.length;i++) \{ 434 for (j=0;j<document.QueryForm.sqlfqc[i].options.length;j++) \{ 435 if (sqlfqc[i] == document.QueryForm.sqlfqc[i].options[j].value) \{ 436 document.QueryForm.sqlfqc[i].options[j].selected = true; 437 break; 438 \} 439 \} 440 \} 441 \} 442 updatesqlfqc(); 443 444 \} 445 446 function updatesqlfqc() \{ 447 448 var i,j; 449 argsqlfqc = ""; 450 if (_cgiargsqlfqn_ == 2) \{ 451 j = document.QueryForm.sqlfqc.selectedIndex; 452 argsqlfqc += document.QueryForm.sqlfqc.options[j].value; 453 \} 454 else \{ 455 j = document.QueryForm.sqlfqc[0].selectedIndex; 456 argsqlfqc += document.QueryForm.sqlfqc[0].options[j].value; 457 for (i=1;i<document.QueryForm.sqlfqc.length;i++) \{ 458 j = document.QueryForm.sqlfqc[i].selectedIndex; 459 argsqlfqc += "," + document.QueryForm.sqlfqc[i].options[j].value; 460 \} 461 \} 462 463 \} 464 465 466 function clearsqlfqc() \{ 467 468 var i; 469 if (_cgiargsqlfqn_ == 2) \{ 470 document.QueryForm.sqlfqc.options[0].selected = true; 471 \} 472 else \{ 473 for (i=0; i<document.QueryForm.sqlfqc.length; i++) \{ 474 document.QueryForm.sqlfqc[i].options[0].selected = true; 475 \} 476 \} 477 updatesqlfqc(); 478 \} 479 480 481 482 334 483 // fqv - the query word/phrase text box 335 484 function initfqv() \{ … … 473 622 ch=str.charAt(j); 474 623 if (ch == " "|| ch == ",") \{ 475 if ( 624 if (flag == 0) \{ 476 625 out += "+"; 477 626 flag=1; … … 480 629 \} 481 630 if (ch == ";" || ch == ":" || ch == "/" || ch == "?" || 482 ch == "@" || ch == "&" || ch == "=" || ch == "#") \{ 631 ch == "@" || ch == "&" || ch == "=" || ch == "#" || 632 ch == "%") \{ 483 633 out += escape(ch); 484 634 flag=0; … … 500 650 501 651 function beginSearch() \{ 502 window.location="_httpquery_"+getstdargs()+"_advformargs_"+getsearchargs();652 window.location="_httpquery_"+getstdargs()+"_advformargs_"+getsearchargs(); 503 653 \} 504 654 … … 509 659 function clearForm() \{ 510 660 clearfqf(); 661 _If_("_cgiarga_" eq "sqlq", 662 clearsqlfqf(); 663 ) 511 664 clearfqv(); 512 665 … … 515 668 clearfqs(); 516 669 clearfqc(); 670 _If_("_cgiarga_" eq "sqlq", 671 clearsqlfqc(); 672 ) 517 673 \} 518 674 … … 551 707 <div class="document"> 552 708 <div class="queryform"> 553 _If_(_cgiargct_,_selectqueryform_,_queryform_) 709 710 _If_("_cgiarga_" eq "sqlq", 711 712 _If_("_cgiargqt_" eq "2",_sqlfieldqueryform_,_sqlqueryform_) 713 , 714 _If_(_cgiargct_,_selectqueryform_,_queryform_) 715 ) 716 554 717 </div> 555 718 … … 567 730 } 568 731 569 _selectqueryform_{_If_("_cgiargqt_" eq"1",_fieldqueryform_,_queryform_)}732 _selectqueryform_{_If_("_cgiargqt_" ge "1",_fieldqueryform_,_queryform_)} 570 733 571 734 _queryform_ { … … 584 747 } 585 748 749 750 _sqlqueryform_ { 751 752 <!-- simple query box that requires you to type SQL where clause directly --> 753 <!-- sqlquery form (\_query:plainqueryform\_) --> 754 <form name="QueryForm" method="get" action="_gwcgi_"> 755 <p> 756 <input type="hidden" name="a" value="sqlq"> 757 <input type="hidden" name="r" value="1"> 758 <input type="hidden" name="hs" value="1"> 759 <input type="hidden" name="e" value="_decodedcompressedoptions_"> 760 _sqlqueryformcontent_ 761 </p> 762 </form> 763 <!-- end of sqlquery form --> 764 } 765 766 586 767 _ifeellucky_ { <br><input type="checkbox" name="ifl" value="1">_textifeellucky_ } 587 768 _useifeellucky_ { } # Set this to _ifeellucky_ if you want this functionality available … … 597 778 _If_(_cgiargqb_,_largequerybox_,_smallquerybox_) 598 779 _useifeellucky_ 780 </span> 781 } 782 783 784 _sqlqueryformcontent_ { 785 <span class="querybox"> 786 _If_(_cgiargqb_,_query:largequerybox_,_query:smallquerybox_) 787 _query:useifeellucky_ 599 788 </span> 600 789 } … … 648 837 649 838 <table><tr><td align="left"> 839 650 840 _textformselect_ 651 841 </td></tr> … … 660 850 <!-- end of query form --> 661 851 } 852 853 _sqlfieldqueryform_ { 854 sf = _cgiargsf_ <br> 855 sqlsf = _cgiargsqlsf_ <br> 856 857 <noscript> 858 <p><b>_textnojsformwarning_</b></p> 859 </noscript> 860 <!--sql field query form (\_query:fieldqueryform\_) --> 861 <form name="QueryForm" method="get" action="_gwcgi_"> 862 863 <table><tr><td align="left"> 864 _textformselect_ 865 </td></tr> 866 <tr><td> 867 _If_(_cgiargb_,_sqladvancedforms_,_sqlsimpleforms_) 868 </td></tr> 869 </table> 870 _If_(_cgiargb_,<div class="divbar"> </div> 871 _advancedformextra_) 872 873 </form> 874 <!-- end of sql query form --> 875 } 876 877 662 878 663 879 _advancedforms_{ … … 672 888 } 673 889 890 _sqladvancedforms_{ 891 <table border="0" cellspacing="0" cellpadding="0" width="90%"> 892 <tr> 893 <th></th> 894 <th align="left">_textfieldphrase_</th> 895 <th></th> 896 <th align="center"> _textinwords_</th> 897 </tr> 898 _sqladvformlist_ 899 <tr> 900 <td colspan="2" align="left"> 901 <input type="button" value="_textclearform_" onClick="clearForm();"> 902 </td> 903 <td colspan="3" align="right"> 904 <input type="button" value="_textbeginsearch_" onClick="beginSearch();"> 905 </td> 906 </tr> 907 </table> 908 } 909 910 911 674 912 _advancedformextra_{ 675 913 <table> … … 679 917 <input type="button" value="_textrunquery_" onClick="runQuery();"></td></tr> 680 918 </table> 919 920 921 _If_("_cgiarga_" eq "sqlq", 922 <p>For example:<br> 923 <i> 924 element in ('dc.Keywords') AND value='Farming'<br> 925 element in ('dls.Title') AND value LIKE 'F%'<br> 926 element in ('dls.Title') AND value<'F%'<br> 927 </i> 928 ) 929 681 930 } 682 931 … … 691 940 </table>} 692 941 942 _sqlsimpleforms_{ 943 <table border="0" cellspacing="0" cellpadding="0" width="90%"> 944 <tr> 945 <th align="left">_textfieldphrase_</th> 946 <th></th> 947 <th align="left"> _textinwords_</th> 948 </tr> 949 _sqlregformlist_ 950 <tr> 951 <td align="left"> 952 <input type="button" value="_textclearform_" onClick="clearForm();"> 953 </td> 954 <td align="right"> 955 <input type="button" value="_textbeginsearch_" onClick="beginSearch();"> 956 </td> 957 </tr> 958 </table> 959 } 960 961 # 962 # Full-text versions 963 # 964 693 965 _regformelement_{ 694 966 <tr><td><input type="text" size="39" name="fqv" onChange="updatefqv();" onkeypress="updatefqv(); entersubmit(event);"></td> … … 718 990 </select>} 719 991 720 _textselect_ {_If_(_cgiargb_,_chooseadvancedsearch_,_textsimplesearch_)} 721 _chooseadvancedsearch_ {_If_(_cgiargct_,_If_("_cgiargct_" eq "2",_textadvancedlucenesearch_,_textadvancedmgppsearch_),_textadvancedsearch_} 722 _textformselect_ {_If_(_cgiargb_,_chooseformadvancedsearch_,_textformsimplesearch_)} 723 _chooseformadvancedsearch_ {_If_("_cgiargct_" eq "1",_textformadvancedsearchmgpp_)_If_("_cgiargct_" eq "2",_textformadvancedsearchlucene_)} 992 993 _andorfqcselection_ { 994 <select name="fqc" onChange="updatefqc();"> 995 <option value="and">_textand_ 996 <option value="or">_textor_ 997 </select>} 998 999 1000 # 1001 # SQL versions of regformelement, firstsqladvformelement, advformelement 1002 # 1003 1004 _sqlregformelement_{ 1005 <tr> 1006 <td> 1007 _sqlfqfselection_ 1008 </td> 1009 <td> 1010 _sqlfqcselection_ 1011 </td> 1012 <td> 1013 <input type="text" size="39" name="fqv" onChange="updatefqv();" 1014 onkeypress="updatefqv(); entersubmit(event);"> 1015 </td> 1016 </tr> 1017 } 1018 1019 _firstsqladvformelement_{ 1020 <tr> 1021 <td> 1022 </td> 1023 <td align="right"> 1024 _sqlfqfselection_ 1025 </td> 1026 <td> 1027 _sqlfqcselection_ 1028 </td> 1029 <td> 1030 <input type="text" size="31" name="fqv" onChange="updatefqv();" 1031 onkeypress="updatefqv(); entersubmit(event);"> 1032 </td> 1033 </tr> 1034 } 1035 1036 _sqladvformelement_{ 1037 <tr> 1038 <td> 1039 _andorfqcselection_ 1040 </td> 1041 <td align="right"> 1042 _sqlfqfselection_ 1043 </td> 1044 <td> 1045 _sqlfqcselection_ 1046 </td> 1047 <td> 1048 <input type="text" size="31" name="fqv" onChange="updatefqv();" onkeypress="updatefqv(); entersubmit(event);"> 1049 </td> 1050 </tr> 1051 } 1052 1053 1054 _sqlfqcselection_ { 1055 <select name="sqlfqc" onChange="updatesqlfqc();"> 1056 <option value="=">matches 1057 <option value="<">< 1058 <option value="<="><= 1059 <option value="LIKE">like 1060 <option value=">=">>= 1061 <option value=">">> 1062 <option value="<>"><> 1063 1064 </select>} 1065 1066 # 1067 # end of SQL version 1068 # 1069 1070 _textselect_ {_If_(_cgiargb_,_chooseadvancedsearch_,_choosesimplesearch_)} 1071 1072 _choosesimplesearch_ {_If_("_cgiargqt_" eq "2",_textsimplesqlsearch_,_textsimplesearch_)} 1073 1074 _chooseadvancedsearch_ {_If_("_cgiarqt_" eq "2",_textadvancedsqlsearch_,_choosesimplesearchct_)} 1075 _chooseadvancedsearchct_ {_If_(_cgiargct_,_If_("_cgiargct_" eq "2",_textadvancedlucenesearch_,_textadvancedmgppsearch_),_textadvancedsearch_} 1076 1077 # formed based versions 1078 _textformselect_ {_If_(_cgiargb_,_chooseformadvancedsearch_,_chooseformsimplesearch_)} 1079 _chooseformsimplesearch_ {_If_("_cgiargqt_" eq "2",_textformsimplesearchsql_,_textformsimplesearch_)} 1080 1081 _chooseformadvancedsearch_ {_If_("_cgiargqt_" eq "2",_textformadvancedsearchsql_,_chooseformadvancedsearchct_)} 1082 _chooseformadvancedsearchct_ {_If_("_cgiargct_" eq "1",_textformadvancedsearchmgpp_)_If_("_cgiargct_" eq "2",_textformadvancedsearchlucene_)} 724 1083 725 1084 # mg uses hselection for index, mgpp uses fqfselection
Note:
See TracChangeset
for help on using the changeset viewer.