source: main/tags/2.51-jcdl/gsdl/macros/query.dm@ 25200

Last change on this file since 25200 was 7503, checked in by davidb, 20 years ago

Modification made to navigation bar so its position in the default location
of the page is optional. Useful when you want to include the navigation
bar somewhere else. It's straightforward enough to add text that include
the navigation bar in the a new place, but without this modification there
is a lot of editing to do to supress it also appearing in its default position.

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