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

Last change on this file since 5738 was 5634, checked in by davidb, 21 years ago

Date search now uses _optdatesearch_ (set by receptionist) to
control whether or not to show fields for date searching.

  • 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 for (i=0; i<fqf.length; i++) \{
197 for (j=0;j<document.QueryForm.fqf[i].options.length;j++) \{
198 if (fqf[i] != "" && fqf[i]== document.QueryForm.fqf[i].options[j].value) \{
199 document.QueryForm.fqf[i].options[j].selected = true;
200 break;
201 \}
202 \}
203 \}
204 if (fqf.length < document.QueryForm.fqf.length) \{ // initialize remaining ones
205 for (i=fqf.length;i<document.QueryForm.fqf.length;i++) \{
206 var z=i;
207 while (z >= document.QueryForm.fqf[i].options.length-1) \{
208 z = z-(document.QueryForm.fqf[i].options.length-1);
209 \}
210 document.QueryForm.fqf[i].options[z].selected = true;
211
212 \}
213 \}
214 updatefqf();
215
216\}
217
218function updatefqf() \{
219
220 var i;
221 argfqf = "";
222 var j = document.QueryForm.fqf[0].selectedIndex;
223 argfqf += document.QueryForm.fqf[0].options[j].value;
224 for (i=1; i<document.QueryForm.fqf.length;i++) \{
225 j = document.QueryForm.fqf[i].selectedIndex;
226 argfqf += "," + document.QueryForm.fqf[i].options[j].value;
227 \}
228
229\}
230
231
232function clearfqf() \{
233 var i;
234 for (i=0;i<document.QueryForm.fqf.length;i++) \{
235 var z = i;
236 if (i >= document.QueryForm.fqf[i].options.length) z = z-document.QueryForm.fqf[i].options.length;
237 document.QueryForm.fqf[i].options[z].selected = true;
238 \}
239 updatefqf();
240\}
241
242// fqc - the boolean operator selection box
243function initfqc() \{
244 var i,j;
245 fqc = argfqc.split(",");
246 if (_cgiargfqn_ == 2) \{ // there will only be one fqc element
247 for (j=0;j<document.QueryForm.fqc.options.length;j++) \{
248 if (fqc[0] == document.QueryForm.fqc.options[j].value) \{
249 document.QueryForm.fqc.options[j].selected = true;
250 break;
251 \}
252 \}
253 \}
254 else \{
255 for (i=0; i<fqc.length;i++) \{
256 for (j=0;j<document.QueryForm.fqc[i].options.length;j++) \{
257 if (fqc[i] == document.QueryForm.fqc[i].options[j].value) \{
258 document.QueryForm.fqc[i].options[j].selected = true;
259 break;
260 \}
261 \}
262 \}
263 \}
264 updatefqc();
265
266\}
267
268function updatefqc() \{
269
270 var i,j;
271 argfqc = "";
272 if (_cgiargfqn_ == 2) \{
273 j = document.QueryForm.fqc.selectedIndex;
274 argfqc += document.QueryForm.fqc.options[j].value;
275 \}
276 else \{
277 j = document.QueryForm.fqc[0].selectedIndex;
278 argfqc += document.QueryForm.fqc[0].options[j].value;
279 for (i=1;i<document.QueryForm.fqc.length;i++) \{
280 j = document.QueryForm.fqc[i].selectedIndex;
281 argfqc += "," + document.QueryForm.fqc[i].options[j].value;
282 \}
283 \}
284
285\}
286
287
288function clearfqc() \{
289
290 var i;
291 if (_cgiargfqn_ == 2) \{
292 document.QueryForm.fqc.options[0].selected = true;
293 \}
294 else \{
295 for (i=0; i<document.QueryForm.fqc.length; i++) \{
296 document.QueryForm.fqc[i].options[0].selected = true;
297 \}
298 \}
299 updatefqc();
300\}
301
302// fqv - the query word/phrase text box
303function initfqv() \{
304
305 var i;
306 fqv= argfqv.split(",");
307 for (i=0; i<fqv.length; i++) \{
308 document.QueryForm.fqv[i].value = fqv[i];
309 \}
310 updatefqv();
311
312
313\}
314
315 //argfqv += escape(format(document.QueryForm.fqv[0].value));
316
317function updatefqv() \{
318
319 var i;
320 argfqv="";
321 argfqv += format(document.QueryForm.fqv[0].value);
322 for (i=1; i<document.QueryForm.fqv.length;i++) \{
323 argfqv += ",";
324 argfqv += format(document.QueryForm.fqv[i].value);
325 \}
326\}
327
328function clearfqv() \{
329 var i;
330 for (i=0; i< document.QueryForm.fqv.length;i++) \{
331 document.QueryForm.fqv[i].value = "";
332 \}
333 updatefqv();
334\}
335
336// fqs - the stemming checkboxes
337function initfqs() \{
338
339 var i;
340 fqs = argfqs.split(",");
341 for (i=0; i<fqs.length; i++) \{
342 if (fqs[i]=="1") \{
343 document.QueryForm.fqs[i].checked = true;
344 \}
345 \}
346 updatefqs();
347
348\}
349
350function updatefqs() \{
351 argfqs="";
352 if (document.QueryForm.fqs[0].checked) \{
353 argfqs += "1";
354 \}
355 else \{
356 argfqs += "0";
357 \}
358 var i;
359 for (i=1; i<document.QueryForm.fqs.length; i++) \{
360 if (document.QueryForm.fqs[i].checked) \{
361 argfqs += ",1";
362 \}
363 else \{
364 argfqs += ",0";
365 \}
366 \}
367\}
368
369
370function clearfqs() \{
371 var i;
372 for (i=0; i<document.QueryForm.fqs.length; i++) \{
373 document.QueryForm.fqs[i].checked = false;
374 \}
375 updatefqs();
376\}
377
378// kqk - the casefolding checkboxes
379function initfqk() \{
380 var i;
381 fqk = argfqk.split(",");
382 for (i=0; i<fqk.length; i++) \{
383 if (fqk[i]=="1") \{
384 document.QueryForm.fqk[i].checked = true;
385 \}
386 \}
387 updatefqk();
388
389\}
390
391
392function updatefqk() \{
393 argfqk="";
394 if (document.QueryForm.fqk[0].checked) \{
395 argfqk += "1";
396 \}
397 else \{
398 argfqk += "0";
399 \}
400 var i;
401 for (i=1; i<document.QueryForm.fqk.length; i++) \{
402 if (document.QueryForm.fqk[i].checked) \{
403 argfqk += ",1";
404 \}
405 else \{
406 argfqk += ",0";
407 \}
408 \}
409\}
410
411function clearfqk() \{
412 var i;
413 for (i=0; i<document.QueryForm.fqk.length; i++) \{
414 document.QueryForm.fqk[i].checked = false;
415 \}
416 updatefqk();
417\}
418
419// q - the advanced query box
420function initq() \{
421 updateq();
422\}
423
424function updateq() \{
425 argq = "";
426 argq += format(document.QueryForm.q.value);
427\}
428
429function clearq() \{
430 document.QueryForm.q.value="";
431\}
432
433
434// convert commas and spaces to plus
435// also convert other illegal characters to %xx codes
436function format(string) \{
437 var str = "" + string;
438 var out = "", flag = 0;
439 var ch = "";
440 var j;
441 for (j = 0; j < str.length; j++) \{
442 ch=str.charAt(j);
443 if (ch == " "|| ch == ",") \{
444 if ( flag == 0) \{
445 out += "+";
446 flag=1;
447 \}
448 continue;
449 \}
450 if (ch == ";" || ch == ":" || ch == "/" || ch == "?" ||
451 ch == "@" || ch == "&" || ch == "=" || ch == "#") \{
452 out += escape(ch);
453 flag=0;
454 continue;
455 \}
456 out += str.charAt(j);
457 flag=0;
458 \}
459 return out;
460\}
461
462}
463
464#_httpquery_ has a=q&e=compressedargs
465#if adv form, need to set k=0 and s=0
466_advformargs_{_If_(_cgiargqf_,&k=0&s=0)}
467
468_searchfunctions_ {
469
470function beginSearch() \{
471window.location="_httpquery_"+getstdargs()+"_advformargs_"+getsearchargs();
472\}
473
474function runQuery() \{
475window.location="_httpquery_"+getstdargs()+"_advformargs_"+getqueryargs();
476\}
477
478function clearForm() \{
479 clearfqf();
480 clearfqv();
481
482 if ("_cgiargqf_" == "1") \{
483 clearfqk();
484 clearfqs();
485 clearfqc();
486 \}
487
488\}
489
490}
491
492#######################################################################
493# headers
494# these are overridden so we can put an onLoad event handler
495# in the <body> tag of this page - for mgpp, form search pages
496#######################################################################
497
498#copied from prefs
499
500_header_ {_cgihead_
501_htmlhead_(background="_httpiconchalk_" onLoad="initialize();")_startspacer__pagebanner_
502}
503
504# this declaration ends up being the same as style=restrict, never mind
505_header_[v=1] {_cgihead_
506_htmlhead_(onLoad="initialize();")_pagebanner_
507}
508
509#######################################################################
510# page content
511#######################################################################
512
513
514_pagetitle_ {_If_(_cgiargq_,_textquerytitle_,_textnoquerytitle_)}
515
516
517_content_ {
518<center>
519_navigationbar_
520</center>
521<center>
522_If_(_cgiargct_,_selectqueryform_,_queryform_)
523</center>
524_If_(_searchhistorylist_,<center>_iconsearchhistorybar_</center><br>
525<center>
526_searchhistorylist_
527</center>)
528_If_(_cgiargq_,<center>_iconqueryresultsbar_</center><br>
529<small>
530_freqmsg_
531_textpostprocess_</small><br>
532_resultline_
533,<center>_iconblankbar_</center>)<br>
534}
535
536_selectqueryform_{_If_("_cgiargqt_" eq "1",_fieldqueryform_,_selectqueryform2_)}
537_selectqueryform2_{_If_("_cgiargqto_" eq "2", _fieldqueryform_, _queryform_)}
538
539_queryform_ {
540<!-- query form (\_query:plainqueryform\_) -->
541<form name=QueryForm method=get action="_gwcgi_">
542<input type=hidden name="a" value="q">
543<input type=hidden name="r" value="1">
544<input type=hidden name="hs" value="1">
545<input type=hidden name="e" value="_decodedcompressedoptions_">
546_queryformcontent_
547_optdatesearch_
548
549</form>
550<!-- end of query form -->
551}
552
553_queryformcontent_{<table><tr><td>
554<nobr>_textselect_</nobr>
555</td></tr>
556<tr><td>
557_If_(_cgiargqb_,_largequerybox_,_smallquerybox_)
558</td></tr></table>
559}
560
561# Automatically set by receptionist if config file switches
562# date searching on
563_optdatesearch_ { }
564
565
566_datesearch_
567{<table><tr><td>
568 <center>
569_textstartdate_
570<input type="text" name="ds" value = "_cgiargds_" size="4" maxlength="4">
571<select name="dsbc" value="_cgiargdsbc_" size="1">
572 <option value = "0"_If_(_cgiargdsbc_,, selected)>_textad_
573 <option value = "1"_If_(_cgiargdsbc_, selected)>_textbc_
574</select>
575_textenddate_
576<input type="text" name="de" value = "_cgiargde_" size="4" maxlength="4">
577<select name="debc" size="1">
578 <option value = "0" _If_(_cgiargdebc_,, selected)>_textad_
579 <option value = "1" _If_(_cgiargdebc_, selected)>_textbc_
580</select>
581</center>
582</tr></td>
583<tr><td>
584_textexplaineras_
585</tr></td>
586</table>
587</center>
588}
589
590_smallquerybox_ {<tr><td><nobr><input type="text" name="q" value="_cgiargq_" size="50">
591<input type="submit" value="_textbeginsearch_"></nobr>}
592
593_largequerybox_ {
594<tr><td><textarea name="q" cols=63 rows=10>
595_cgiargq_
596</textarea></td></tr>
597<tr align=right><td><table>
598<tr><td><input type="submit" value="_textbeginsearch_"></td>
599</tr></table></td></tr>}
600
601
602_fieldqueryform_ {
603<noscript>
604<p><b>_textnojsformwarning_</b><p>
605</noscript>
606<!-- field query form (\_query:fieldqueryform\_) -->
607<form name=QueryForm method=get action="_gwcgi_">
608
609<table><tr><td>
610<nobr>
611_textformselect_
612</nobr>
613</td></tr>
614_If_(_cgiargqf_,_advancedforms_,_simpleforms_)
615</table>
616_If_(_cgiargqf_,<center>_iconblankbar_</center><br>
617<center>_advancedformextra_</center>)
618
619</form>
620<!-- end of query form -->
621}
622
623_advancedforms_{
624<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
625<tr><th></th><th align=left>_textwordphrase_</th><th colspan=2><nobr>_textfoldstem_</nobr></th><th align=center>&nbsp;&nbsp;_textinfield_</th></tr>
626_advformlist_
627<tr><td colspan=2><input type=button value="_textclearform_" onClick="clearForm();"></td>
628<td colspan=3><table>
629<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
630</tr></table></td></tr>
631</table></td></tr>
632}
633
634_advancedformextra_{
635<table>
636<tr><td>_textadvquery_</td></tr>
637<tr><td><textarea name=q cols=57 rows=3 onChange="updateq();">_cgiargq_</textarea></td>
638<td valign=bottom>
639<input type="button" value="_textrunquery_" onClick="runQuery();"></td></tr>
640</table>
641}
642
643_simpleforms_{
644<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
645<tr><th align=left>_textwordphrase_</th><th align=left>&nbsp;&nbsp;_textinfield_</th></tr>
646_regformlist_
647<tr><td><input type=button value="_textclearform_" onClick="clearForm();"></td>
648<td><table>
649<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
650</tr>
651</table></td></tr>
652</table></td></tr>}
653
654_regformelement_{
655<td><input type=text size=39 name="fqv" onChange="updatefqv();"></td>
656<td>_fqfselection_</td>}
657
658#has no and/or/not selection box
659_firstadvformelement_{
660<td></td><td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
661<td align=center><input type=checkbox name="fqk" onClick="updatefqk();"></td>
662<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
663<td align=right>_fqfselection_</td>}
664
665_advformelement_{
666<td>_fqcselection_</td>
667<td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
668<td align=center><input type=checkbox name="fqk" onClick="updatefqk();"></td>
669<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
670<td align=right>_fqfselection_</td>}
671
672_fqcselection_ {
673<select name="fqc" onChange="updatefqc();">
674<option value="and">_textand_
675<option value="or">_textor_
676<option value="not">_textandnot_
677</select>}
678
679_textselect_ {_If_(_cgiargct_, _textmgppselect_, _textmgselect_)}
680_textmgselect_ {_If_(_cgiargb_,_textadvancedsearch_,_textsimplesearch_)}
681_textmgppselect_ { _If_(_cgiargb_,_textadvancedsearchmgpp_, _textsimplesearchmgpp_)}
682_textformselect_ {_If_(_cgiargqf_,_textformadvancedsearch_,_textformsimplesearch_)}
683
684# we want to put the links to previous/next pages of results
685# in the footer
686_pagefooterextra_ {
687<center>
688<table cellspacing=0 cellpadding=0 width=_pagewidth_>
689<tr>
690<td align=left>_If_(_prevfirst_,<a href="_httpquery_&r=_prevfirst_">_iconprev__textmatches__prevfirst_ - _prevlast_</a>)</td>
691<td align=right>_If_(_nextfirst_,<a href="_httpquery_&r=_nextfirst_">_textmatches__nextfirst_ - _nextlast__iconnext_</a>)</td>
692</tr></table>
693</center>
694}
695
696_querytypeselection_ {
697<select name="t">
698<option value="1"_If_(_cgiargt_, selected)>_If_(_cgiargb_,_textranked_,_textsome_)
699<option value="0"_If_(_cgiargt_,, selected)>_If_(_cgiargb_,_textboolean_,_textall_)
700</select>
701}
702
703_formquerytypeselection_ {
704<select name="t">
705<option value="1"_If_(_cgiargt_, selected)>_If_(_cgiargqf_,_textranked_,_textsome_)
706<option value="0"_If_(_cgiargt_,, selected)>_If_(_cgiargqf_,_textnatural_,_textall_)
707</select>
708}
709
710
Note: See TracBrowser for help on using the repository browser.