source: trunk/gsdl/macros/query.dm@ 12389

Last change on this file since 12389 was 12389, checked in by mdewsnip, 18 years ago

The "the following words were too common and were ignored" message (for Lucene stopwords) was being displayed always, rather than just when it was appropriate.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 18.8 KB
Line 
1# this file must be UTF-8 encoded
2package query
3
4
5#######################################################################
6# Macros whose values are set from within the server at runtime. These
7# are here only for reference and to set default values if required.
8#######################################################################
9
10_quotedquery_ {}
11_freqmsg_ {}
12_stopwordsmsg_ {}
13_resultline_ {}
14_thisfirst_ {}
15_thislast_ {}
16_nextfirst_ {}
17_nextlast_ {}
18_prevfirst_ {}
19_prevlast_ {}
20_searchhistorylist_ {}
21#_histvalue0_ to _histvalue19_
22_advformlist_ {}
23_regformlist_ {}
24#_fqfselection_ {}
25
26
27#######################################################################
28# icons
29#######################################################################
30
31_queryresultsbar_ {
32<div class="divbar">
33<p class="navbar">_texthresults_</p>
34</div>
35}
36
37_searchhistorybar_ {
38<div class="divbar">
39<p class="navbar">_texticonsearchhistorybar_</p>
40</div>
41}
42
43
44# _iconnext_ and _iconprev_ are overridden in this package as we
45# don't want alt text here
46_iconnext_{<img src="_httpiconmore_" width=_widthmore_ height=_heightmore_ border=0 align=top>}
47_iconnext_ [v=1] {}
48_iconprev_{<img src="_httpiconless_" width=_widthless_ height=_heightless_ border=0 align=top>}
49_iconprev_ [v=1] {}
50
51# the small squares for search history
52## " " ## handmade ## mstds ##
53_httpiconmstdsqrof_ {_httpimg_/mstdsof.gif}
54_httpiconmstdsqron_ {_httpimg_/mstdson.gif}
55_widthmstdsqrx_ {13}
56_heightmstdsqrx_ {13}
57
58#######################################################################
59# images
60#######################################################################
61
62# _imagethispage_ set in nav_css/nav_ns4 macro files
63
64#the buttons for the search history entries
65# takes one arg - the entry number (0-num entries)
66_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 alt="_textusequery_" title="_textusequery_"></a>}
67
68
69#######################################################################
70# scripts (and some macros for the scripts)
71#######################################################################
72
73_pagescriptextra_ {_If_("_cgiargqt_" eq "1", _formpagescriptextra_, _selectpagescriptextra_)
74_If_("_cgiarghd_" ne "0",_historypagescriptextra_) }
75
76_selectpagescriptextra_{_If_("_cgiargqto_" eq "2", _formpagescriptextra_,_dummypagescriptextra_)}
77_dummypagescriptextra_{function initialize() \{
78\} }
79_formpagescriptextra_ {
80// query scripts generated by \_query:pagescriptextra\_
81
82_standardfunctions_
83_formfunctions_
84_searchfunctions_
85
86function getsearchargs () \{
87
88 var args="";
89 args = "&fqa=0&fqv="+argfqv+"&fqf="+argfqf;
90 _If_(_cgiargqf_,args += "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc;)
91
92 return args;
93\}
94
95
96
97function getqueryargs () \{
98 return "&fqa=1"+"&q="+argq+"&fqv="+argfqv+"&fqf="+argfqf+
99 "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc ;
100\}
101
102}
103
104_historypagescriptextra_{
105
106var histvalue0='_histvalue0_';
107var histvalue1='_histvalue1_';
108var histvalue2='_histvalue2_';
109var histvalue3='_histvalue3_';
110var histvalue4='_histvalue4_';
111var histvalue5='_histvalue5_';
112var histvalue6='_histvalue6_';
113var histvalue7='_histvalue7_';
114var histvalue8='_histvalue8_';
115var histvalue9='_histvalue9_';
116var histvalue10='_histvalue10_';
117var histvalue11='_histvalue11_';
118var histvalue12='_histvalue12_';
119var histvalue13='_histvalue13_';
120var histvalue14='_histvalue14_';
121var histvalue15='_histvalue15_';
122var histvalue16='_histvalue16_';
123var histvalue17='_histvalue17_';
124var histvalue18='_histvalue18_';
125var histvalue19='_histvalue19_';
126
127function inputQuery(value) \{
128 if ("_cgiargqt_" == "0") \{ // text search
129 document.QueryForm.q.value += " "+value;
130 document.QueryForm.q.focus();
131 \}
132 else \{
133 if ("_cgiargqf_" == "1") \{ // advanced query
134 document.QueryForm.q.value += " "+value;
135 document.QueryForm.q.focus();
136 updateq();
137 \}
138 else \{ // simple form search
139 // do something here, what??
140 \}
141 \}
142\}
143
144}
145
146_standardfunctions_{
147
148 function getstdargs() \{
149
150 stdarg = "";
151 _If_(_gselection_,_getgarg_)
152 _If_(_jselection_,_getjarg_)
153 _If_(_nselection_,_getnarg_)
154
155 value = document.QueryForm.t.options[document.QueryForm.t.selectedIndex].value;
156 if (value != "_cgiargt_") stdarg += "&t="+value;
157
158 stdarg += "&r=1&hs=1";
159 return stdarg;
160 \}
161
162}
163
164_getgarg_{
165 if (document.QueryForm.g!= null) \{
166 value = document.QueryForm.g.options[document.QueryForm.g.selectedIndex].value;
167 if (value != "_cgiargg_") stdarg += "&g="+value;
168 \}
169}
170
171_getjarg_{
172 value = document.QueryForm.j.options[document.QueryForm.j.selectedIndex].value;
173 if (value != "_cgiargj_") stdarg += "&j="+value;
174}
175
176_getnarg_{
177 value = document.QueryForm.n.options[document.QueryForm.n.selectedIndex].value;
178 if (value != "_cgiargn_") stdarg += "&n="+value;
179}
180
181_formfunctions_{
182
183argfqf="_cgiargfqf_";
184argfqv="_cgiargfqv_";
185argfqk="_cgiargfqk_";
186argfqs="_cgiargfqs_";
187argfqc="_cgiargfqc_";
188argq = "";
189
190function initialize () \{
191
192 if (document.QueryForm.fqf != null) \{initfqf();\}
193 initfqv();
194 if ( "_cgiargqf_" == "1") \{
195 initfqs();
196 initfqk();
197 initfqc();
198 initq();
199 \}
200
201\}
202
203// fqf - the field selection box
204function initfqf() \{
205 var i;
206 fqf = argfqf.split(",");
207 num_opts = document.QueryForm.fqf[0].options.length; // assumes all have the same options
208 for (i=0; i<fqf.length && i<document.QueryForm.fqf.length; i++) \{
209 if (fqf[i] != "")\{
210 for (j=0;j<num_opts;j++) \{
211 if (fqf[i]== document.QueryForm.fqf[i].options[j].value) \{
212 document.QueryForm.fqf[i].options[j].selected = true;
213 break;
214 \}
215 \}
216 \}
217 \}
218 if (fqf.length < document.QueryForm.fqf.length) \{ // initialize remaining ones
219 for (i=fqf.length;i<document.QueryForm.fqf.length;i++) \{
220 var z=i;
221 while (z >= num_opts) \{
222 z = z-(num_opts);
223 \}
224 document.QueryForm.fqf[i].options[z].selected = true;
225
226 \}
227 \}
228 updatefqf();
229
230\}
231
232function updatefqf() \{
233
234 var i;
235 argfqf = "";
236 var j = document.QueryForm.fqf[0].selectedIndex;
237 argfqf += document.QueryForm.fqf[0].options[j].value;
238 for (i=1; i<document.QueryForm.fqf.length;i++) \{
239 j = document.QueryForm.fqf[i].selectedIndex;
240 argfqf += "," + document.QueryForm.fqf[i].options[j].value;
241 \}
242
243\}
244
245
246function clearfqf() \{
247 var i;
248 for (i=0;i<document.QueryForm.fqf.length;i++) \{
249 var z = i;
250 if (i >= document.QueryForm.fqf[i].options.length) z = z-document.QueryForm.fqf[i].options.length;
251 document.QueryForm.fqf[i].options[z].selected = true;
252 \}
253 updatefqf();
254\}
255
256// fqc - the boolean operator selection box
257function initfqc() \{
258 var i,j;
259 fqc = argfqc.split(",");
260 if (_cgiargfqn_ == 2) \{ // there will only be one fqc element
261 for (j=0;j<document.QueryForm.fqc.options.length;j++) \{
262 if (fqc[0] == document.QueryForm.fqc.options[j].value) \{
263 document.QueryForm.fqc.options[j].selected = true;
264 break;
265 \}
266 \}
267 \}
268 else \{
269 for (i=0; i<fqc.length;i++) \{
270 for (j=0;j<document.QueryForm.fqc[i].options.length;j++) \{
271 if (fqc[i] == document.QueryForm.fqc[i].options[j].value) \{
272 document.QueryForm.fqc[i].options[j].selected = true;
273 break;
274 \}
275 \}
276 \}
277 \}
278 updatefqc();
279
280\}
281
282function updatefqc() \{
283
284 var i,j;
285 argfqc = "";
286 if (_cgiargfqn_ == 2) \{
287 j = document.QueryForm.fqc.selectedIndex;
288 argfqc += document.QueryForm.fqc.options[j].value;
289 \}
290 else \{
291 j = document.QueryForm.fqc[0].selectedIndex;
292 argfqc += document.QueryForm.fqc[0].options[j].value;
293 for (i=1;i<document.QueryForm.fqc.length;i++) \{
294 j = document.QueryForm.fqc[i].selectedIndex;
295 argfqc += "," + document.QueryForm.fqc[i].options[j].value;
296 \}
297 \}
298
299\}
300
301
302function clearfqc() \{
303
304 var i;
305 if (_cgiargfqn_ == 2) \{
306 document.QueryForm.fqc.options[0].selected = true;
307 \}
308 else \{
309 for (i=0; i<document.QueryForm.fqc.length; i++) \{
310 document.QueryForm.fqc[i].options[0].selected = true;
311 \}
312 \}
313 updatefqc();
314\}
315
316// fqv - the query word/phrase text box
317function initfqv() \{
318 var i;
319 fqv= argfqv.split(",");
320 for (i=0; i<fqv.length && i<document.QueryForm.fqv.length; i++) \{
321 document.QueryForm.fqv[i].value = fqv[i];
322 \}
323 updatefqv();
324
325
326\}
327
328 //argfqv += escape(format(document.QueryForm.fqv[0].value));
329
330function updatefqv() \{
331
332 var i;
333 argfqv="";
334 argfqv += format(document.QueryForm.fqv[0].value);
335 for (i=1; i<document.QueryForm.fqv.length;i++) \{
336 argfqv += ",";
337 argfqv += format(document.QueryForm.fqv[i].value);
338 \}
339\}
340
341function clearfqv() \{
342 var i;
343 for (i=0; i< document.QueryForm.fqv.length;i++) \{
344 document.QueryForm.fqv[i].value = "";
345 \}
346 updatefqv();
347\}
348
349// fqs - the stemming checkboxes
350function initfqs() \{
351
352 var i;
353 fqs = argfqs.split(",");
354 for (i=0; i<fqs.length; i++) \{
355 if (fqs[i]=="1") \{
356 document.QueryForm.fqs[i].checked = true;
357 \}
358 \}
359 updatefqs();
360
361\}
362
363function updatefqs() \{
364 argfqs="";
365 if (document.QueryForm.fqs[0].checked) \{
366 argfqs += "1";
367 \}
368 else \{
369 argfqs += "0";
370 \}
371 var i;
372 for (i=1; i<document.QueryForm.fqs.length; i++) \{
373 if (document.QueryForm.fqs[i].checked) \{
374 argfqs += ",1";
375 \}
376 else \{
377 argfqs += ",0";
378 \}
379 \}
380\}
381
382
383function clearfqs() \{
384 var i;
385 for (i=0; i<document.QueryForm.fqs.length; i++) \{
386 document.QueryForm.fqs[i].checked = false;
387 \}
388 updatefqs();
389\}
390
391// kqk - the casefolding checkboxes
392function initfqk() \{
393 var i;
394 fqk = argfqk.split(",");
395 for (i=0; i<fqk.length; i++) \{
396 if (fqk[i]=="1") \{
397 document.QueryForm.fqk[i].checked = true;
398 \}
399 \}
400 updatefqk();
401
402\}
403
404
405function updatefqk() \{
406 argfqk="";
407 if (document.QueryForm.fqk[0].checked) \{
408 argfqk += "1";
409 \}
410 else \{
411 argfqk += "0";
412 \}
413 var i;
414 for (i=1; i<document.QueryForm.fqk.length; i++) \{
415 if (document.QueryForm.fqk[i].checked) \{
416 argfqk += ",1";
417 \}
418 else \{
419 argfqk += ",0";
420 \}
421 \}
422\}
423
424function clearfqk() \{
425 var i;
426 for (i=0; i<document.QueryForm.fqk.length; i++) \{
427 document.QueryForm.fqk[i].checked = false;
428 \}
429 updatefqk();
430\}
431
432// q - the advanced query box
433function initq() \{
434 updateq();
435\}
436
437function updateq() \{
438 argq = "";
439 argq += format(document.QueryForm.q.value);
440\}
441
442function clearq() \{
443 document.QueryForm.q.value="";
444\}
445
446
447// convert commas and spaces to plus
448// also convert other illegal characters to %xx codes
449function format(string) \{
450 var str = "" + string;
451 var out = "", flag = 0;
452 var ch = "";
453 var j;
454 for (j = 0; j < str.length; j++) \{
455 ch=str.charAt(j);
456 if (ch == " "|| ch == ",") \{
457 if ( flag == 0) \{
458 out += "+";
459 flag=1;
460 \}
461 continue;
462 \}
463 if (ch == ";" || ch == ":" || ch == "/" || ch == "?" ||
464 ch == "@" || ch == "&" || ch == "=" || ch == "#") \{
465 out += escape(ch);
466 flag=0;
467 continue;
468 \}
469 out += str.charAt(j);
470 flag=0;
471 \}
472 return out;
473\}
474
475}
476
477#_httpquery_ has a=q&e=compressedargs
478#if adv form, need to set k=0 and s=0
479_advformargs_{_If_(_cgiargqf_,&k=0&s=0)}
480
481_searchfunctions_ {
482
483function beginSearch() \{
484window.location="_httpquery_"+getstdargs()+"_advformargs_"+getsearchargs();
485\}
486
487function runQuery() \{
488window.location="_httpquery_"+getstdargs()+"_advformargs_"+getqueryargs();
489\}
490
491function clearForm() \{
492 clearfqf();
493 clearfqv();
494
495 if ("_cgiargqf_" == "1") \{
496 clearfqk();
497 clearfqs();
498 clearfqc();
499 \}
500
501\}
502
503}
504
505#######################################################################
506# headers
507# these are overridden so we can put an onLoad event handler
508# in the <body> tag of this page - for mgpp, form search pages
509#######################################################################
510
511#copied from prefs
512
513_header_ {_cgihead_
514_htmlhead_(class="bgimage" onLoad="initialize();")_startspacer__pagebanner_
515}
516
517# this declaration ends up being the same as style=restrict, never mind
518_header_[v=1] {_cgihead_
519_htmlhead_(onLoad="initialize();")_pagebanner_
520}
521
522#######################################################################
523# page content
524#######################################################################
525
526
527_pagetitle_ {_If_(_cgiargq_,_textquerytitle_,_textnoquerytitle_)}
528
529
530_content_ {
531_optnavigationbar_
532
533<div class="document">
534<div class="queryform">
535_If_(_cgiargct_,_selectqueryform_,_queryform_)
536</div>
537_If_(_searchhistorylist_,<center>_searchhistorybar_</center><br>
538<center>
539_searchhistorylist_
540</center>)
541_If_(_cgiargq_,_queryresultsbar_
542<small>
543_freqmsg_
544_textpostprocess_
545_If_(_stopwordsmsg_,(_stopwordsmsg_))</small><br />
546_resultline_
547,<div class="divbar">&nbsp;</div>)
548}
549
550_selectqueryform_{_If_("_cgiargqt_" eq "1",_fieldqueryform_,_queryform_)}
551
552_queryform_ {
553<!-- query form (\_query:plainqueryform\_) -->
554<form name=QueryForm method=get action="_gwcgi_">
555<p>
556<input type=hidden name="a" value="q">
557<input type=hidden name="r" value="1">
558<input type=hidden name="hs" value="1">
559<input type=hidden name="e" value="_decodedcompressedoptions_">
560_queryformcontent_
561_optdatesearch_
562</p>
563</form>
564<!-- end of query form -->
565}
566
567_ifeellucky_ { <br><input type=checkbox name="ifl">_textifeellucky_ }
568_useifeellucky_ { } # Set this to _ifeellucky_ if you want this functionality available
569
570_queryformcontent_{
571<span class="textselect">
572_textselect_
573</span>
574
575<span class="querybox">
576_If_(_cgiargqb_,_largequerybox_,_smallquerybox_)
577_useifeellucky_
578</span>
579}
580
581# Automatically set by receptionist if config file switches
582# date searching on
583_optdatesearch_ { }
584
585
586_datesearch_
587{<table><tr><td>
588 <center>
589_textstartdate_
590<input type="text" name="ds" value = "_cgiargds_" size="4" maxlength="4">
591<select name="dsbc" value="_cgiargdsbc_" size="1">
592 <option value = "0"_If_(_cgiargdsbc_,, selected)>_textad_
593 <option value = "1"_If_(_cgiargdsbc_, selected)>_textbc_
594</select>
595_textenddate_
596<input type="text" name="de" value = "_cgiargde_" size="4" maxlength="4">
597<select name="debc" size="1">
598 <option value = "0" _If_(_cgiargdebc_,, selected)>_textad_
599 <option value = "1" _If_(_cgiargdebc_, selected)>_textbc_
600</select>
601</center>
602</tr></td>
603<tr><td>
604_textexplaineras_
605</tr></td>
606</table>
607</center>
608}
609
610_smallquerybox_ {<tr><td><nobr><input type="text" name="q" value="_cgiargq_" size="50">
611<input type="submit" value="_textbeginsearch_"></nobr>}
612
613_largequerybox_ {
614<tr><td><textarea name="q" cols=63 rows=10>
615_cgiargq_
616</textarea></td></tr>
617<tr align=right><td><table>
618<tr><td><input type="submit" value="_textbeginsearch_"></td>
619</tr></table></td></tr>}
620
621
622_fieldqueryform_ {
623<noscript>
624<p><b>_textnojsformwarning_</b><p>
625</noscript>
626<!-- field query form (\_query:fieldqueryform\_) -->
627<form name=QueryForm method=get action="_gwcgi_">
628
629<table><tr><td>
630<nobr>
631_textformselect_
632</nobr>
633</td></tr>
634_If_(_cgiargqf_,_advancedforms_,_simpleforms_)
635</table>
636_If_(_cgiargqf_,<div class="divbar">&nbsp;</div>
637<center>_advancedformextra_</center>)
638
639</form>
640<!-- end of query form -->
641}
642
643_advancedforms_{
644<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
645<tr><th></th><th align=left>_textwordphrase_</th><th colspan=2><nobr>_textfoldstem_</nobr></th><th align=center>&nbsp;&nbsp;_textinfield_</th></tr>
646_advformlist_
647<tr><td colspan=2><input type=button value="_textclearform_" onClick="clearForm();"></td>
648<td colspan=3><table>
649<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
650</tr></table></td></tr>
651</table></td></tr>
652}
653
654_advancedformextra_{
655<table>
656<tr><td>_textadvquery_</td></tr>
657<tr><td><textarea name=q cols=57 rows=3 onChange="updateq();">_cgiargq_</textarea></td>
658<td valign=bottom>
659<input type="button" value="_textrunquery_" onClick="runQuery();"></td></tr>
660</table>
661}
662
663_simpleforms_{
664<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
665<tr><th align=left>_textwordphrase_</th><th align=left>&nbsp;&nbsp;_textinfield_</th></tr>
666_regformlist_
667<tr><td><input type=button value="_textclearform_" onClick="clearForm();"></td>
668<td><table>
669<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
670</tr>
671</table></td></tr>
672</table></td></tr>}
673
674_regformelement_{
675<td><input type=text size=39 name="fqv" onChange="updatefqv();"></td>
676<td>_fqfselection_</td>}
677
678#has no and/or/not selection box
679_firstadvformelement_{
680<td></td><td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
681<td align=center><input type=checkbox name="fqk" onClick="updatefqk();"></td>
682<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
683<td align=right>_fqfselection_</td>}
684
685_advformelement_{
686<td>_fqcselection_</td>
687<td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
688<td align=center><input type=checkbox name="fqk" onClick="updatefqk();"></td>
689<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
690<td align=right>_fqfselection_</td>}
691
692_fqcselection_ {
693<select name="fqc" onChange="updatefqc();">
694<option value="and">_textand_
695<option value="or">_textor_
696<option value="not">_textandnot_
697</select>}
698
699_textselect_ {_If_(_cgiargb_,_chooseadvancedsearch_,_textsimplesearch_)}
700_chooseadvancedsearch_ {_If_(_cgiargct_,_If_(_cgiargct_ eq "2",_textadvancedlucenesearch_,_textadvancedmgppsearch_),_textadvancedsearch_}
701_textformselect_ {_If_(_cgiargqf_,_textformadvancedsearch_,_textformsimplesearch_)}
702# mg uses hselection for index, mgpp uses fqfselection
703_indexselection_{_If_(_cgiargct_,_fqfselection_,_hselection_)}
704
705# we want to put the links to previous/next pages of results
706# in the footer
707_pagefooterextra_ {
708<center>
709<table cellspacing=0 cellpadding=0 width="_pagewidth_">
710<tr>
711<td align=left>_If_(_prevfirst_,<a href="_httpquery_&r=_prevfirst_">_iconprev__textmatches__prevfirst_ - _prevlast_</a>)</td>
712<td align=right>_If_(_nextfirst_,<a href="_httpquery_&r=_nextfirst_">_textmatches__nextfirst_ - _nextlast__iconnext_</a>)</td>
713</tr></table>
714</center>
715
716</div> <!-- document -->
717}
718
719_querytypeselection_ {
720<select name="t">
721<option value="1"_If_(_cgiargt_, selected)>_If_(_cgiargb_,_textranked_,_textsome_)
722<option value="0"_If_(_cgiargt_,, selected)>_If_(_cgiargb_,_textboolean_,_textall_)
723</select>
724}
725
726
727_formquerytypesimpleselection_ {
728<select name="t">
729<option value="1"_If_(_cgiargt_, selected)>_textsome_
730<option value="0"_If_(_cgiargt_,, selected)>_textall_
731</select>
732}
733
734_formquerytypeadvancedselection_ {
735<select name="t">
736<option value="1"_If_(_cgiargt_, selected)>_textranked_
737<option value="0"_If_(_cgiargt_,, selected)>_textnatural_
738</select>
739}
740
741# this one is not used by english.dm any more. But I have added it back for the other languages that haven't updated the translations for their form search macros.
742_formquerytypeselection_ {
743<select name="t">
744<option value="1"_If_(_cgiargt_, selected)>_If_(_cgiargqf_,_textranked_,_textsome_)
745<option value="0"_If_(_cgiargt_,, selected)>_If_(_cgiargqf_,_textnatural_,_textall_)
746</select>
747}
748
Note: See TracBrowser for help on using the repository browser.