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

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

changed the textsome, textall macros - took the test on cgiargb out of the text macros, so the text only has text in it, like textsome {some}. Note: have to change all the other languages to reflect this. qf now used for form search type instead of b. mgpp now only has one index, so removed the hselection stuff from the search form

  • 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" or "_cgiargqto_" eq "2",_formpagescriptextra_,_dummypagescriptextra_)
68_If_("_cgiarghd_" ne "0",_historypagescriptextra_) }
69
70_dummypagescriptextra_{
71function initialize() \{
72\}
73}
74_formpagescriptextra_ {
75// query scripts generated by \_query:pagescriptextra\_
76
77_standardfunctions_
78_formfunctions_
79_searchfunctions_
80
81function getsearchargs () \{
82
83 var args="";
84 args = "&fqa=0&fqv="+argfqv+"&fqf="+argfqf;
85 _If_(_cgiargqf_,args += "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc;)
86
87 return args;
88\}
89
90
91
92function getqueryargs () \{
93 return "&fqa=1"+"&q="+argq+"&fqv="+argfqv+"&fqf="+argfqf+
94 "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc ;
95\}
96
97}
98
99_historypagescriptextra_{
100
101var histvalue0='_histvalue0_';
102var histvalue1='_histvalue1_';
103var histvalue2='_histvalue2_';
104var histvalue3='_histvalue3_';
105var histvalue4='_histvalue4_';
106var histvalue5='_histvalue5_';
107var histvalue6='_histvalue6_';
108var histvalue7='_histvalue7_';
109var histvalue8='_histvalue8_';
110var histvalue9='_histvalue9_';
111var histvalue10='_histvalue10_';
112var histvalue11='_histvalue11_';
113var histvalue12='_histvalue12_';
114var histvalue13='_histvalue13_';
115var histvalue14='_histvalue14_';
116var histvalue15='_histvalue15_';
117var histvalue16='_histvalue16_';
118var histvalue17='_histvalue17_';
119var histvalue18='_histvalue18_';
120var histvalue19='_histvalue19_';
121
122function inputQuery(value) \{
123 if ("_cgiargqt_" == "0") \{ // text search
124 document.QueryForm.q.value += " "+value;
125 \}
126 else \{
127 if ("_cgiargqf_" == "1") \{ // advanced query
128 document.QueryForm.q.value += " "+value;
129 updateq();
130 \}
131 else \{ // simple form search
132 // do something here, what??
133 \}
134 \}
135\}
136
137}
138
139_standardfunctions_{
140
141 function getstdargs() \{
142
143 stdarg = "";
144 _If_(_gselection_,_getgarg_)
145 _If_(_cgiargj_,_getjarg_)
146
147 value = document.QueryForm.t.options[document.QueryForm.t.selectedIndex].value;
148 if (value != "_cgiargt_") stdarg += "&t="+value;
149
150 stdarg += "&r=1&hs=1"; // &h=idx
151 return stdarg;
152 \}
153
154}
155
156#h will always be the same now
157#some macros to go with getstdargs()
158#_getharg_{
159# value = document.QueryForm.h.options[document.QueryForm.h.selectedIndex].value;
160# if (value != "_cgiargh_") stdarg += "&h="+value;
161#}
162
163_getgarg_{
164 value = document.QueryForm.g.options[document.QueryForm.g.selectedIndex].value;
165 if (value != "_cgiargg_") stdarg += "&g="+value;
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
174_formfunctions_{
175
176argfqf="_cgiargfqf_";
177argfqv="_cgiargfqv_";
178argfqk="_cgiargfqk_";
179argfqs="_cgiargfqs_";
180argfqc="_cgiargfqc_";
181argq = "";
182
183function initialize () \{
184
185 if (document.QueryForm.fqf != null) \{initfqf();\}
186 initfqv();
187 if ( "_cgiargqf_" == "1") \{
188 initfqs();
189 initfqk();
190 initfqc();
191 initq();
192 \}
193
194\}
195
196// fqf - the field selection box
197function initfqf() \{
198 var i;
199 fqf = argfqf.split(",");
200 for (i=0; i<fqf.length; i++) \{
201 for (j=0;j<document.QueryForm.fqf[i].options.length;j++) \{
202 if (fqf[i] != "" && fqf[i]== document.QueryForm.fqf[i].options[j].value) \{
203 document.QueryForm.fqf[i].options[j].selected = true;
204 break;
205 \}
206 \}
207 \}
208 if (fqf.length < document.QueryForm.fqf.length) \{ // initialize remaining ones
209 for (i=fqf.length;i<document.QueryForm.fqf.length;i++) \{
210 var z=i;
211 while (z >= document.QueryForm.fqf[i].options.length-1) \{
212 z = z-(document.QueryForm.fqf[i].options.length-1);
213 \}
214 document.QueryForm.fqf[i].options[z].selected = true;
215
216 \}
217 \}
218 updatefqf();
219
220\}
221
222function updatefqf() \{
223
224 var i;
225 argfqf = "";
226 var j = document.QueryForm.fqf[0].selectedIndex;
227 argfqf += document.QueryForm.fqf[0].options[j].value;
228 for (i=1; i<document.QueryForm.fqf.length;i++) \{
229 j = document.QueryForm.fqf[i].selectedIndex;
230 argfqf += "," + document.QueryForm.fqf[i].options[j].value;
231 \}
232
233\}
234
235
236function clearfqf() \{
237 var i;
238 for (i=0;i<document.QueryForm.fqf.length;i++) \{
239 var z = i;
240 if (i >= document.QueryForm.fqf[i].options.length) z = z-document.QueryForm.fqf[i].options.length;
241 document.QueryForm.fqf[i].options[z].selected = true;
242 \}
243 updatefqf();
244\}
245
246// fqc - the boolean operator selection box
247function initfqc() \{
248 var i,j;
249 fqc = argfqc.split(",");
250 if (_cgiargfqn_ == 2) \{ // there will only be one fqc element
251 for (j=0;j<document.QueryForm.fqc.options.length;j++) \{
252 if (fqc[0] == document.QueryForm.fqc.options[j].value) \{
253 document.QueryForm.fqc.options[j].selected = true;
254 break;
255 \}
256 \}
257 \}
258 else \{
259 for (i=0; i<fqc.length;i++) \{
260 for (j=0;j<document.QueryForm.fqc[i].options.length;j++) \{
261 if (fqc[i] == document.QueryForm.fqc[i].options[j].value) \{
262 document.QueryForm.fqc[i].options[j].selected = true;
263 break;
264 \}
265 \}
266 \}
267 \}
268 updatefqc();
269
270\}
271
272function updatefqc() \{
273
274 var i,j;
275 argfqc = "";
276 if (_cgiargfqn_ == 2) \{
277 j = document.QueryForm.fqc.selectedIndex;
278 argfqc += document.QueryForm.fqc.options[j].value;
279 \}
280 else \{
281 j = document.QueryForm.fqc[0].selectedIndex;
282 argfqc += document.QueryForm.fqc[0].options[j].value;
283 for (i=1;i<document.QueryForm.fqc.length;i++) \{
284 j = document.QueryForm.fqc[i].selectedIndex;
285 argfqc += "," + document.QueryForm.fqc[i].options[j].value;
286 \}
287 \}
288
289\}
290
291
292function clearfqc() \{
293
294 var i;
295 if (_cgiargfqn_ == 2) \{
296 document.QueryForm.fqc.options[0].selected = true;
297 \}
298 else \{
299 for (i=0; i<document.QueryForm.fqc.length; i++) \{
300 document.QueryForm.fqc[i].options[0].selected = true;
301 \}
302 \}
303 updatefqc();
304\}
305
306// fqv - the query word/phrase text box
307function initfqv() \{
308
309 var i;
310 fqv= argfqv.split(",");
311 for (i=0; i<fqv.length; i++) \{
312 document.QueryForm.fqv[i].value = fqv[i];
313 \}
314 updatefqv();
315
316
317\}
318
319 //argfqv += escape(format(document.QueryForm.fqv[0].value));
320
321function updatefqv() \{
322
323 var i;
324 argfqv="";
325 argfqv += format(document.QueryForm.fqv[0].value);
326 for (i=1; i<document.QueryForm.fqv.length;i++) \{
327 argfqv += ",";
328 argfqv += format(document.QueryForm.fqv[i].value);
329 \}
330\}
331
332function clearfqv() \{
333 var i;
334 for (i=0; i< document.QueryForm.fqv.length;i++) \{
335 document.QueryForm.fqv[i].value = "";
336 \}
337 updatefqv();
338\}
339
340// fqs - the stemming checkboxes
341function initfqs() \{
342
343 var i;
344 fqs = argfqs.split(",");
345 for (i=0; i<fqs.length; i++) \{
346 if (fqs[i]=="1") \{
347 document.QueryForm.fqs[i].checked = true;
348 \}
349 \}
350 updatefqs();
351
352\}
353
354function updatefqs() \{
355 argfqs="";
356 if (document.QueryForm.fqs[0].checked) \{
357 argfqs += "1";
358 \}
359 else \{
360 argfqs += "0";
361 \}
362 var i;
363 for (i=1; i<document.QueryForm.fqs.length; i++) \{
364 if (document.QueryForm.fqs[i].checked) \{
365 argfqs += ",1";
366 \}
367 else \{
368 argfqs += ",0";
369 \}
370 \}
371\}
372
373
374function clearfqs() \{
375 var i;
376 for (i=0; i<document.QueryForm.fqs.length; i++) \{
377 document.QueryForm.fqs[i].checked = false;
378 \}
379 updatefqs();
380\}
381
382// kqk - the casefolding checkboxes
383function initfqk() \{
384 var i;
385 fqk = argfqk.split(",");
386 for (i=0; i<fqk.length; i++) \{
387 if (fqk[i]=="1") \{
388 document.QueryForm.fqk[i].checked = true;
389 \}
390 \}
391 updatefqk();
392
393\}
394
395
396function updatefqk() \{
397 argfqk="";
398 if (document.QueryForm.fqk[0].checked) \{
399 argfqk += "1";
400 \}
401 else \{
402 argfqk += "0";
403 \}
404 var i;
405 for (i=1; i<document.QueryForm.fqk.length; i++) \{
406 if (document.QueryForm.fqk[i].checked) \{
407 argfqk += ",1";
408 \}
409 else \{
410 argfqk += ",0";
411 \}
412 \}
413\}
414
415function clearfqk() \{
416 var i;
417 for (i=0; i<document.QueryForm.fqk.length; i++) \{
418 document.QueryForm.fqk[i].checked = false;
419 \}
420 updatefqk();
421\}
422
423// q - the advanced query box
424function initq() \{
425 updateq();
426\}
427
428//argq += escape(document.QueryForm.q.value);
429
430function updateq() \{
431 argq = "";
432 argq += format(document.QueryForm.q.value);
433\}
434
435function clearq() \{
436 document.QueryForm.q.value="";
437\}
438
439
440// convert commas and spaces to plus
441// also convert other illegal characters to %xx codes
442function format(string) \{
443 var str = "" + string;
444 var out = "", flag = 0;
445 var ch = "";
446 var j;
447 for (j = 0; j < str.length; j++) \{
448 ch=str.charAt(j);
449 if (ch == " "|| ch == ",") \{
450 if ( flag == 0) \{
451 out += "+";
452 flag=1;
453 \}
454 continue;
455 \}
456 if (ch == ";" || ch == ":" || ch == "/" || ch == "?" ||
457 ch == "@" || ch == "&" || ch == "=" || ch == "#") \{
458 out += escape(ch);
459 flag=0;
460 continue;
461 \}
462 out += str.charAt(j);
463 flag=0;
464 \}
465 return out;
466\}
467
468}
469
470#_httpquery_ has a=q&e=compressedargs
471#if adv form, need to set k=0 and s=0
472_advformargs_{_If_(_cgiargqf_,&k=0&s=0)}
473
474_searchfunctions_ {
475
476function beginSearch() \{
477window.location="_httpquery_"+getstdargs()+"_advformargs_"+getsearchargs();
478\}
479
480function runQuery() \{
481window.location="_httpquery_"+getstdargs()+"_advformargs_"+getqueryargs();
482\}
483
484function clearForm() \{
485 clearfqf();
486 clearfqv();
487
488 if ("_cgiargqf_" == "1") \{
489 clearfqk();
490 clearfqs();
491 clearfqc();
492 \}
493
494\}
495
496}
497
498#######################################################################
499# headers
500# these are overridden so we can put an onLoad event handler
501# in the <body> tag of this page - for mgpp, form search pages
502#######################################################################
503
504#copied from prefs
505
506_header_ {_cgihead_
507_htmlhead_(background="_httpiconchalk_" onLoad="initialize();")_startspacer__pagebanner_
508}
509
510# this declaration ends up being the same as style=restrict, never mind
511_header_[v=1] {_cgihead_
512_htmlhead_(onLoad="initialize();")_pagebanner_
513}
514
515#######################################################################
516# page content
517#######################################################################
518
519
520_pagetitle_ {_If_(_cgiargq_,_textquerytitle_,_textnoquerytitle_)}
521
522
523_content_ {
524<center>
525_navigationbar_
526</center>
527<center>
528_If_(_cgiargct_,_selectqueryform_,_queryform_)
529</center>
530_If_(_searchhistorylist_,<center>_iconsearchhistorybar_</center><br>
531<center>
532_searchhistorylist_
533</center>)
534_If_(_cgiargq_,<center>_iconqueryresultsbar_</center><br>
535<small>
536_freqmsg_
537_textpostprocess_</small><br>
538_resultline_
539,<center>_iconblankbar_</center>)<br>
540}
541
542_selectqueryform_{_If_("_cgiargqt_" eq "1",_fieldqueryform_,_selectqueryform2_)}
543_selectqueryform2_{_If_("_cgiargqto_" eq "2", _fieldqueryform_, _queryform_)}
544
545_queryform_ {
546<!-- query form (\_query:plainqueryform\_) -->
547<form name=QueryForm method=get action="_gwcgi_">
548<input type=hidden name="a" value="q">
549<input type=hidden name="r" value="1">
550<input type=hidden name="hs" value="1">
551<input type=hidden name="e" value="_decodedcompressedoptions_">
552_queryformcontent_
553
554</form>
555<!-- end of query form -->
556}
557
558_queryformcontent_{<table><tr><td>
559<nobr>_textselect_</nobr>
560</td></tr>
561<tr><td>
562_If_(_cgiargqb_,_largequerybox_,_smallquerybox_)
563</td></tr></table>
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<!-- field query form (\_query:fieldqueryform\_) -->
604<form name=QueryForm method=get action="_gwcgi_">
605
606<table><tr><td>
607<nobr>
608_textformselect_
609</nobr>
610</td></tr>
611_If_(_cgiargqf_,_advancedforms_,_simpleforms_)
612</table>
613_If_(_cgiargqf_,<center>_iconblankbar_</center><br>
614<center>_advancedformextra_</center>)
615</form>
616<!-- end of query form -->
617}
618
619_advancedforms_{
620<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
621<tr><th></th><th align=left>_textwordphrase_</th><th colspan=2><nobr>_textfoldstem_</nobr></th><th align=center>&nbsp;&nbsp;_textinfield_</th></tr>
622_advformlist_
623<tr><td colspan=2><input type=button value="_textclearform_" onClick="clearForm();"></td>
624<td colspan=3><table>
625<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
626</tr></table></td></tr>
627</table></td></tr>
628}
629
630_advancedformextra_{
631<table>
632<tr><td>_textadvquery_</td></tr>
633<tr><td><textarea name=q cols=57 rows=3 onChange="updateq();">_cgiargq_</textarea></td>
634<td valign=bottom>
635<input type="button" value="_textrunquery_" onClick="runQuery();"></td></tr>
636</table>
637}
638
639_simpleforms_{
640<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
641<tr><th align=left>_textwordphrase_</th><th align=left>&nbsp;&nbsp;_textinfield_</th></tr>
642_regformlist_
643<tr><td><input type=button value="_textclearform_" onClick="clearForm();"></td>
644<td><table>
645<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
646</tr>
647</table></td></tr>
648</table></td></tr>}
649
650_regformelement_{
651<td><input type=text size=39 name="fqv" onChange="updatefqv();"></td>
652<td>_fqfselection_</td>}
653
654#has no and/or/not selection box
655_firstadvformelement_{
656<td></td><td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
657<td align=center><input type=checkbox name="fqk" onClick="updatefqk();""></td>
658<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
659<td align=right>_fqfselection_</td>}
660
661_advformelement_{
662<td>_fqcselection_</td>
663<td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
664<td align=center><input type=checkbox name="fqk" onClick="updatefqk();"></td>
665<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
666<td align=right>_fqfselection_</td>}
667
668_fqcselection_ {
669<select name="fqc" onChange="updatefqc();">
670<option value="and">_textand_
671<option value="or">_textor_
672<option value="not">_textandnot_
673</select>}
674
675_textselect_ {_If_(_cgiargct_, _textmgppselect_, _textmgselect_)}
676_textmgselect_ {_If_(_cgiargb_,_textadvancedsearch_,_textsimplesearch_)}
677_textmgppselect_ { _If_(_cgiargb_,_textadvancedsearchmgpp_, _textsimplesearchmgpp_)}
678_textformselect_ {_If_(_cgiargqf_,_textformadvancedsearch_,_textformsimplesearch_)}
679
680_ZZ_{_textallfields_}
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.