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

Last change on this file since 7284 was 7262, checked in by kjdon, 20 years ago

fixed a small bug with the initfqf function

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