Ignore:
Timestamp:
2001-02-07T14:11:27+13:00 (23 years ago)
Author:
kjm18
Message:

new mgpp form search query pages. search history revamped.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/macros/query.dm

    r1289 r1923  
    1717_prevlast_ {}
    1818_searchhistorylist_ {}
     19#_histvalue0_ to _histvalue19_
     20_advformlist_ {}
     21_regformlist_ {}
     22_fqfselection_ {}
     23
    1924
    2025#######################################################################
     
    2732_iconqueryresultsbar_ {<img src="_httpiconqryresb_" width="_widthqryresb_" height="_heightqryresb_" alt="_texticonqueryresultsbar_">}
    2833_iconqueryresultsbar_[v=1] {_texticonqueryresultsbar_}
     34
     35_iconsearchhistorybar_ {<img src="_httpiconsrchhistb_" width="_widthsrchhistb_" height="_heightsrchhistb_" alt="_texticonsearchhistorybar_">}
     36_iconsearchhistorybar_[v=1] {_texticonsearchhistorybar_}
    2937
    3038# _iconnext_ and _iconprev_ are overridden in this package as we
     
    3543_iconprev_ [v=1] {}
    3644
     45# the small squares for search history
     46## " " ## handmade ## mstdsqr ##
     47_httpiconmstdsqrof_ {_httpimg_/mstdsqrof.gif}
     48_httpiconmstdsqron_ {_httpimg_/mstdsqron.gif}
     49_widthmstdsqrx_ {13}
     50_heightmstdsqrx_ {13}
     51
    3752#######################################################################
    3853# images
     
    4156_imagethispage_ {_iconthispage_}
    4257
     58#the buttons for the search history entries
     59# takes one arg - the entry number (0-num entries)
     60_imagehistbutton_ {<a  href="_httpquery_" onMouseover="roll('histbutton_1_',1);" onMouseOut="roll('histbutton_1_',0);" onClick="inputQuery(histvalue_1_); return false;"><img name="histbutton_1_" src="_httpiconmstdsqrof_" onLoad="gbutton(this,'_httpiconmstdsqron_');" border=0></a>}
     61
     62
     63#######################################################################
     64# scripts (and some macros for the scripts)
     65#######################################################################
     66
     67_pagescriptextra_ {_If_("_cgiargct_" eq "1" && "_cgiargqt_" eq "1",_formpagescriptextra_,_dummypagescriptextra_)
     68_If_("_cgiarghd_" ne "0",_historypagescriptextra_) }
     69
     70_dummypagescriptextra_{
     71function initialize() \{
     72\}
     73}
     74_formpagescriptextra_ {
     75// query scripts generated by \_query:pagescriptextra\_
     76
     77_standardfunctions_
     78_formfunctions_
     79_searchfunctions_
     80
     81function getsearchargs () \{
     82
     83  var args="";
     84  args = "&fqa=0&fqv="+argfqv+"&fqf="+argfqf;
     85  _If_(_cgiargb_,args += "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc;)
     86
     87  return args;
     88\}
     89
     90
     91
     92function getqueryargs () \{
     93  return "&fqa=1"+"&q="+argq+"&fqv="+argfqv+"&fqf="+argfqf+
     94     "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc ;
     95\}
     96
     97}
     98
     99_historypagescriptextra_{
     100
     101var histvalue0='_histvalue0_';
     102var histvalue1='_histvalue1_';
     103var histvalue2='_histvalue2_';
     104var histvalue3='_histvalue3_';
     105var histvalue4='_histvalue4_';
     106var histvalue5='_histvalue5_';
     107var histvalue6='_histvalue6_';
     108var histvalue7='_histvalue7_';
     109var histvalue8='_histvalue8_';
     110var histvalue9='_histvalue9_';
     111var histvalue10='_histvalue10_';
     112var histvalue11='_histvalue11_';
     113var histvalue12='_histvalue12_';
     114var histvalue13='_histvalue13_';
     115var histvalue14='_histvalue14_';
     116var histvalue15='_histvalue15_';
     117var histvalue16='_histvalue16_';
     118var histvalue17='_histvalue17_';
     119var histvalue18='_histvalue18_';
     120var histvalue19='_histvalue19_';
     121
     122function inputQuery(value) \{
     123  if ("_cgiargqt_" == "0") \{ // text search
     124     document.QueryForm.q.value += " "+value;
     125  \}
     126  else \{
     127     if ("_cgiargb_" == "1") \{ // advanced query
     128        document.QueryForm.q.value += " "+value;
     129    updateq();
     130     \}
     131     else \{ // simple form search
     132      // do something here, what??
     133     \}
     134  \}
     135\}
     136
     137}
     138
     139_standardfunctions_{
     140
     141 function getstdargs() \{
     142   
     143    stdarg = "";
     144    _If_(_cgiargh_,_getharg_)
     145    _If_(_cgiargg_,_getgarg_)
     146    _If_(_cgiargj_,_getjarg_)
     147
     148    value = document.QueryForm.t.options[document.QueryForm.t.selectedIndex].value;
     149    if (value != "_cgiargt_") stdarg += "&t="+value;
     150
     151    stdarg += "&r=1&hs=1";   
     152    return stdarg;
     153  \}
     154
     155}
     156
     157#some macros to go with getstdargs()
     158_getharg_{
     159    value = document.QueryForm.h.options[document.QueryForm.h.selectedIndex].value;
     160    if (value != "_cgiargh_") stdarg += "&h="+value;
     161}
     162
     163_getgarg_{
     164    value = document.QueryForm.g.options[document.QueryForm.g.selectedIndex].value;
     165    if (value != "_cgiargg_") stdarg += "&g="+value;
     166}
     167
     168_getjarg_{
     169    value = document.QueryForm.j.options[document.QueryForm.j.selectedIndex].value;
     170    if (value != "_cgiargj_") stdarg += "&j="+value;
     171}
     172
     173
     174_formfunctions_{
     175
     176argfqf="_cgiargfqf_";   
     177argfqv="_cgiargfqv_";
     178argfqk="_cgiargfqk_";
     179argfqs="_cgiargfqs_";
     180argfqc="_cgiargfqc_";
     181argq = "";
     182
     183function initialize () \{
     184
     185   initfqf();
     186   initfqv();
     187   if ( "_cgiargb_" == "1") \{
     188      initfqs();       
     189      initfqk();
     190      initfqc();
     191      initq();
     192   \}
     193   
     194\}
     195
     196// fqf - the field selection box
     197function initfqf() \{
     198   var i;
     199   fqf = argfqf.split(",");   
     200   for (i=0; i<fqf.length; i++) \{
     201       for (j=0;j<document.QueryForm.fqf[i].options.length;j++) \{
     202       if (fqf[i] == document.QueryForm.fqf[i].options[j].value) \{
     203          document.QueryForm.fqf[i].options[j].selected = true;
     204          break;   
     205       \}
     206    \}
     207   \}
     208   if (fqf.length < document.QueryForm.fqf.length) \{ // initialize remaining ones
     209      for (i=fqf.length;i<document.QueryForm.fqf.length;i++) \{
     210      var z=i;
     211      if (i >= document.QueryForm.fqf[i].options.length)
     212         z = z-document.QueryForm.fqf[i].options.length;
     213
     214      document.QueryForm.fqf[i].options[z].selected = true;
     215     
     216      \}
     217   \}
     218   updatefqf();
     219
     220\}
     221
     222function updatefqf() \{
     223
     224   var i;
     225   argfqf = "";
     226   var j = document.QueryForm.fqf[0].selectedIndex;
     227   argfqf += document.QueryForm.fqf[0].options[j].value;
     228   for (i=1; i<document.QueryForm.fqf.length;i++) \{
     229      j = document.QueryForm.fqf[i].selectedIndex;
     230      argfqf += "," + document.QueryForm.fqf[i].options[j].value;
     231   \}
     232
     233\}
     234
     235
     236function clearfqf() \{
     237   var i;
     238   for (i=0;i<document.QueryForm.fqf.length;i++) \{
     239       var z = i;
     240       if (i >= document.QueryForm.fqf[i].options.length) z = z-document.QueryForm.fqf[i].options.length;
     241       document.QueryForm.fqf[i].options[z].selected = true;
     242   \}
     243   updatefqf();
     244\}
     245
     246// fqc - the boolean operator selection box
     247function initfqc() \{
     248   var i,j;
     249   fqc = argfqc.split(",");
     250   if (_cgiargfqn_ == 2) \{ // there will only be one fqc element
     251       for (j=0;j<document.QueryForm.fqc.options.length;j++) \{
     252       if (fqc[0] == document.QueryForm.fqc.options[j].value) \{
     253          document.QueryForm.fqc.options[j].selected = true;
     254          break;
     255       \}
     256       \}   
     257   \}
     258   else \{   
     259   for (i=0; i<fqc.length;i++) \{
     260       for (j=0;j<document.QueryForm.fqc[i].options.length;j++) \{
     261       if (fqc[i] == document.QueryForm.fqc[i].options[j].value) \{
     262          document.QueryForm.fqc[i].options[j].selected = true;
     263          break;
     264       \}
     265       \}
     266   \}
     267   \}
     268   updatefqc();
     269
     270\}
     271
     272function updatefqc() \{
     273 
     274   var i,j;
     275   argfqc = "";
     276   if (_cgiargfqn_ == 2) \{
     277      j = document.QueryForm.fqc.selectedIndex;
     278      argfqc += document.QueryForm.fqc.options[j].value;
     279   \}
     280   else \{
     281    j = document.QueryForm.fqc[0].selectedIndex;
     282    argfqc += document.QueryForm.fqc[0].options[j].value;
     283    for (i=1;i<document.QueryForm.fqc.length;i++) \{
     284        j = document.QueryForm.fqc[i].selectedIndex;
     285        argfqc += "," + document.QueryForm.fqc[i].options[j].value;
     286    \}
     287   \}
     288
     289\}
     290
     291
     292function clearfqc() \{
     293   
     294   var i;
     295   if (_cgiargfqn_ == 2) \{
     296       document.QueryForm.fqc.options[0].selected = true;
     297   \}
     298   else \{
     299    for (i=0; i<document.QueryForm.fqc.length; i++) \{
     300        document.QueryForm.fqc[i].options[0].selected = true;
     301    \}
     302   \}
     303   updatefqc();
     304\}
     305
     306// fqv - the query word/phrase text box       
     307function initfqv() \{
     308
     309   var i;
     310   fqv= argfqv.split(",");
     311   for (i=0; i<fqv.length; i++) \{
     312       document.QueryForm.fqv[i].value = fqv[i];
     313   \}
     314   updatefqv();
     315
     316
     317\}
     318
     319
     320function updatefqv() \{
     321
     322   var i;
     323   argfqv="";
     324   argfqv += escape(format(document.QueryForm.fqv[0].value));
     325   for (i=1; i<document.QueryForm.fqv.length;i++) \{
     326       argfqv += ",";
     327       argfqv +=  escape(format(document.QueryForm.fqv[i].value));
     328   \}
     329\}
     330
     331function clearfqv() \{
     332   var i;
     333   for (i=0; i< document.QueryForm.fqv.length;i++) \{
     334       document.QueryForm.fqv[i].value = "";
     335   \}
     336   updatefqv();
     337\}
     338
     339// fqs - the stemming checkboxes
     340function initfqs() \{
     341
     342   var i;
     343   fqs = argfqs.split(",");
     344   for (i=0; i<fqs.length; i++) \{
     345       if (fqs[i]=="1") \{
     346      document.QueryForm.fqs[i].checked = true;
     347       \}
     348   \}
     349   updatefqs();
     350
     351\}
     352
     353function updatefqs() \{
     354   argfqs="";
     355   if (document.QueryForm.fqs[0].checked) \{
     356      argfqs += "1";
     357   \}
     358   else \{
     359      argfqs += "0";   
     360   \}
     361   var i;
     362   for (i=1; i<document.QueryForm.fqs.length; i++) \{
     363       if (document.QueryForm.fqs[i].checked) \{
     364      argfqs += ",1";
     365    \}
     366    else \{
     367      argfqs += ",0";
     368    \}
     369   \}
     370\}
     371
     372
     373function clearfqs() \{
     374   var i;
     375   for (i=0; i<document.QueryForm.fqs.length; i++) \{
     376       document.QueryForm.fqs[i].checked = false;
     377   \}
     378   updatefqs();
     379\}
     380
     381// kqk - the casefolding checkboxes
     382function initfqk() \{
     383   var i;
     384   fqk = argfqk.split(",");
     385   for (i=0; i<fqk.length; i++) \{
     386       if (fqk[i]=="1") \{
     387      document.QueryForm.fqk[i].checked = true;
     388       \}
     389   \}
     390   updatefqk();
     391
     392\}
     393
     394
     395function updatefqk() \{
     396   argfqk="";
     397   if (document.QueryForm.fqk[0].checked) \{
     398      argfqk += "1";
     399   \}
     400   else \{
     401      argfqk += "0";   
     402   \}
     403   var i;
     404   for (i=1; i<document.QueryForm.fqk.length; i++) \{
     405       if (document.QueryForm.fqk[i].checked) \{
     406      argfqk += ",1";
     407    \}
     408    else \{
     409      argfqk += ",0";
     410    \}
     411   \}
     412\}
     413
     414function clearfqk() \{
     415   var i;
     416   for (i=0; i<document.QueryForm.fqk.length; i++) \{
     417       document.QueryForm.fqk[i].checked = false;
     418   \}
     419   updatefqk();
     420\}
     421
     422// q - the advanced query box
     423function initq() \{
     424   updateq();
     425\}
     426
     427function updateq() \{
     428   argq = "";
     429   argq += escape(document.QueryForm.q.value);
     430\}
     431
     432function clearq() \{
     433   document.QueryForm.q.value="";
     434\}
     435
     436
     437// convert commas and spaces to plus
     438function format(string) \{
     439   var str = "" + string;
     440   var out = "", flag = 0;
     441   var j;
     442   for (j = 0; j < str.length; j++) \{
     443       if (str.charAt(j) == " "|| str.charAt(j) == ",") \{
     444       if ( flag == 0) \{
     445      out += "+";
     446      flag=1;
     447      \}
     448    \}
     449       else \{
     450          out += str.charAt(j);
     451      flag=0;
     452       \}
     453   \}
     454   return out;
     455\}
     456
     457}
     458
     459#_httpquery_ has a=q&e=compressedargs
     460#if adv form, need to set k=0 and s=0
     461_advformargs_{_If_(_cgiargb_,&k=0&s=0)}
     462
     463_searchfunctions_ {
     464
     465function beginSearch() \{
     466window.location="_httpquery_"+getstdargs()+"_advformargs_"+getsearchargs();
     467\}
     468
     469function runQuery() \{
     470window.location="_httpquery_"+getstdargs()+"_advformargs_"+getqueryargs();
     471\}
     472
     473function clearForm() \{
     474   clearfqf();
     475   clearfqv();
     476
     477   if ("_cgiargb_" == "1") \{
     478      clearfqk();
     479      clearfqs();
     480      clearfqc();
     481   \}
     482
     483\}
     484
     485}
     486
     487#######################################################################
     488# headers
     489# these are overridden so we can put an onLoad event handler
     490# in the <body> tag of this page - for mgpp, form search pages
     491#######################################################################
     492
     493#copied from prefs
     494
     495_header_ {_cgihead_
     496_htmlhead_(background="_httpiconchalk_" onLoad="initialize();")_startspacer__pagebanner_
     497}
     498
     499# this declaration ends up being the same as style=restrict, never mind
     500_header_[v=1] {_cgihead_
     501_htmlhead_(onLoad="initialize();")_pagebanner_
     502}
    43503
    44504#######################################################################
     
    46506#######################################################################
    47507
     508
    48509_pagetitle_ {_If_(_cgiargq_,_textquerytitle_,_textnoquerytitle_)}
     510
    49511
    50512_content_ {
     
    52514_navigationbar_
    53515</center>
    54 _queryform_
    55 _If_(_searchhistorylist_,<center>
     516<center>
     517_If_(_cgiargct_,_selectqueryform_,_queryform_)
     518</center>
     519_If_(_searchhistorylist_,<center>_iconsearchhistorybar_</center><br>
     520<center>
    56521_searchhistorylist_
    57522</center>)
     
    64529}
    65530
     531_selectqueryform_{_If_(_cgiargqt_,_fieldqueryform_,_queryform_)}
     532
    66533_queryform_ {
    67 <!-- query form -->
     534<!-- query form (\_query:queryform\_) -->
    68535<form name=QueryForm method=get action="_gwcgi_">
    69536
    70537<input type=hidden name="a" value="q">
    71 <input type=hidden name="e" value="_decodedcompressedoptions_">
    72538<input type=hidden name="r" value="1">
    73539<input type=hidden name="hs" value="1">
    74 
    75 <center>
     540<input type=hidden name="e" value="_decodedcompressedoptions_">
     541
     542<table><tr><td>
     543<nobr>_textselect_</nobr>
     544</td></tr>
     545<tr><td>
     546_If_(_cgiargqb_,_largequerybox_,_smallquerybox_)
     547</td></tr></table>
     548</form>
     549<!-- end of query form -->
     550}
     551
     552_smallquerybox_ {<tr><td><nobr><input type="text" name="q" value="_cgiargq_" size="50">
     553<input type="submit" value="_textbeginsearch_"></nobr>}
     554
     555_largequerybox_ {
     556<tr><td><textarea name="q" cols=63 rows=10>
     557_cgiargq_
     558</textarea></td></tr>
     559<tr align=right><td><table>
     560<tr><td><input type="submit" value="_textbeginsearch_"></td>
     561</tr></table></td></tr>}
     562
     563
     564_fieldqueryform_ {
     565<!-- field query form (\_query:fieldqueryform\_) -->
     566<form name=QueryForm method=get action="_gwcgi_">
    76567<table><tr><td>
    77568<nobr>
    78 _textselect_<br>
     569_textformselect_
    79570</nobr>
    80 </td></tr><tr><td>
    81 <nobr>
    82 <input type="text" name="q" value="_cgiargq_" size="50">
    83 <input type="submit" value="_textbeginsearch_">
    84 </nobr>
    85 </td></tr></table>
    86 </center>
     571</td></tr>
     572_If_(_cgiargb_,_advancedforms_,_simpleforms_)
     573</table>
     574_If_(_cgiargb_,<center>_iconblankbar_</center><br>
     575<center>_advancedformextra_</center>)
    87576</form>
    88577<!-- end of query form -->
    89578}
    90579
     580_advancedforms_{
     581<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
     582<tr><th></th><th align=left>_textwordphrase_</th><th colspan=2><nobr>_textfoldstem_</nobr></th><th align=center>&nbsp;&nbsp;_textinfield_</th></tr>
     583_advformlist_
     584<tr><td colspan=2><input type=button value="_textclearform_" onClick="clearForm();"></td>
     585<td colspan=3><table>
     586<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
     587</tr></table></td></tr>
     588</table></td></tr>
     589}
     590
     591_advancedformextra_{
     592<table>
     593<tr><td>_textadvquery_</td></tr>
     594<tr><td><textarea name=q cols=57 rows=3 onChange="updateq();">_cgiargq_</textarea></td>
     595<td valign=bottom>
     596<input type="button" value="_textrunquery_" onClick="runQuery();"></td></tr>
     597</table>
     598}
     599
     600_simpleforms_{
     601<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
     602<tr><th align=left>_textwordphrase_</th><th align=left>&nbsp;&nbsp;_textinfield_</th></tr> 
     603_regformlist_
     604<tr><td><input type=button value="_textclearform_" onClick="clearForm();"></td>
     605<td><table>
     606<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
     607</tr>
     608</table></td></tr>
     609</table></td></tr>}
     610
     611_regformelement_{
     612<td><input type=text size=39 name="fqv" onChange="updatefqv();"></td>
     613<td>_fqfselection_</td>}
     614
     615#has no and/or/not selection box
     616_firstadvformelement_{
     617<td></td><td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
     618<td align=center><input type=checkbox name="fqk" onClick="updatefqk();""></td>
     619<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
     620<td align=right>_fqfselection_</td>}
     621
     622_advformelement_{
     623<td>_fqcselection_</td>
     624<td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
     625<td align=center><input type=checkbox name="fqk" onClick="updatefqk();"></td>
     626<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
     627<td align=right>_fqfselection_</td>}
     628
     629_fqcselection_ {
     630<select name="fqc" onChange="updatefqc();">
     631<option value="and">_textand_
     632<option value="or">_textor_
     633<option value="not">_textandnot_
     634</select>}
     635
    91636_textselect_ {_If_(_cgiargb_,_textadvancedsearch_,_textsimplesearch_)}
     637_textformselect_ {_If_(_cgiargb_,_textformadvancedsearch_,_textformsimplesearch_)}
     638
     639_ZZ_{_textallfields_}
    92640
    93641# we want to put the links to previous/next pages of results
     
    109657</select>
    110658}
     659
     660_formquerytypeselection_ {
     661<select name="t">
     662<option value="1"_If_(_cgiargt_, selected)>_textformsome_
     663<option value="0"_If_(_cgiargt_,, selected)>_textformall_
     664</select>
     665}
     666
     667
Note: See TracChangeset for help on using the changeset viewer.