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

Last change on this file since 4793 was 4789, checked in by kjdon, 21 years ago

removed the ZZ macro - its now defined in the gdbm db

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