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

Last change on this file since 10510 was 9668, checked in by kjdon, 19 years ago

added n arg (language subcoll) to teh getstdargs function

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