source: main/tags/2.51-fiji/gsdl/macros/query.dm@ 24538

Last change on this file since 24538 was 7596, checked in by mdewsnip, 20 years ago

Added a couple of macros for the "I'm feeling lucky" (a la Google) functionality.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 18.3 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_ifeellucky_ { <br><input type=checkbox name="ifl">_textifeellucky_ }
556_useifeellucky_ { } # Set this to _ifeellucky_ if you want this functionality available
557
558_queryformcontent_{<table><tr><td>
559<nobr>_textselect_</nobr>
560</td></tr>
561<tr><td>
562_If_(_cgiargqb_,_largequerybox_,_smallquerybox_)
563_useifeellucky_
564</td></tr></table>
565}
566
567# Automatically set by receptionist if config file switches
568# date searching on
569_optdatesearch_ { }
570
571
572_datesearch_
573{<table><tr><td>
574 <center>
575_textstartdate_
576<input type="text" name="ds" value = "_cgiargds_" size="4" maxlength="4">
577<select name="dsbc" value="_cgiargdsbc_" size="1">
578 <option value = "0"_If_(_cgiargdsbc_,, selected)>_textad_
579 <option value = "1"_If_(_cgiargdsbc_, selected)>_textbc_
580</select>
581_textenddate_
582<input type="text" name="de" value = "_cgiargde_" size="4" maxlength="4">
583<select name="debc" size="1">
584 <option value = "0" _If_(_cgiargdebc_,, selected)>_textad_
585 <option value = "1" _If_(_cgiargdebc_, selected)>_textbc_
586</select>
587</center>
588</tr></td>
589<tr><td>
590_textexplaineras_
591</tr></td>
592</table>
593</center>
594}
595
596_smallquerybox_ {<tr><td><nobr><input type="text" name="q" value="_cgiargq_" size="50">
597<input type="submit" value="_textbeginsearch_"></nobr>}
598
599_largequerybox_ {
600<tr><td><textarea name="q" cols=63 rows=10>
601_cgiargq_
602</textarea></td></tr>
603<tr align=right><td><table>
604<tr><td><input type="submit" value="_textbeginsearch_"></td>
605</tr></table></td></tr>}
606
607
608_fieldqueryform_ {
609<noscript>
610<p><b>_textnojsformwarning_</b><p>
611</noscript>
612<!-- field query form (\_query:fieldqueryform\_) -->
613<form name=QueryForm method=get action="_gwcgi_">
614
615<table><tr><td>
616<nobr>
617_textformselect_
618</nobr>
619</td></tr>
620_If_(_cgiargqf_,_advancedforms_,_simpleforms_)
621</table>
622_If_(_cgiargqf_,<center>_iconblankbar_</center><br>
623<center>_advancedformextra_</center>)
624
625</form>
626<!-- end of query form -->
627}
628
629_advancedforms_{
630<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
631<tr><th></th><th align=left>_textwordphrase_</th><th colspan=2><nobr>_textfoldstem_</nobr></th><th align=center>&nbsp;&nbsp;_textinfield_</th></tr>
632_advformlist_
633<tr><td colspan=2><input type=button value="_textclearform_" onClick="clearForm();"></td>
634<td colspan=3><table>
635<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
636</tr></table></td></tr>
637</table></td></tr>
638}
639
640_advancedformextra_{
641<table>
642<tr><td>_textadvquery_</td></tr>
643<tr><td><textarea name=q cols=57 rows=3 onChange="updateq();">_cgiargq_</textarea></td>
644<td valign=bottom>
645<input type="button" value="_textrunquery_" onClick="runQuery();"></td></tr>
646</table>
647}
648
649_simpleforms_{
650<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
651<tr><th align=left>_textwordphrase_</th><th align=left>&nbsp;&nbsp;_textinfield_</th></tr>
652_regformlist_
653<tr><td><input type=button value="_textclearform_" onClick="clearForm();"></td>
654<td><table>
655<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
656</tr>
657</table></td></tr>
658</table></td></tr>}
659
660_regformelement_{
661<td><input type=text size=39 name="fqv" onChange="updatefqv();"></td>
662<td>_fqfselection_</td>}
663
664#has no and/or/not selection box
665_firstadvformelement_{
666<td></td><td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
667<td align=center><input type=checkbox name="fqk" onClick="updatefqk();"></td>
668<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
669<td align=right>_fqfselection_</td>}
670
671_advformelement_{
672<td>_fqcselection_</td>
673<td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
674<td align=center><input type=checkbox name="fqk" onClick="updatefqk();"></td>
675<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
676<td align=right>_fqfselection_</td>}
677
678_fqcselection_ {
679<select name="fqc" onChange="updatefqc();">
680<option value="and">_textand_
681<option value="or">_textor_
682<option value="not">_textandnot_
683</select>}
684
685_textselect_ {_If_(_cgiargb_,_textadvancedsearch_,_textsimplesearch_)}
686_textformselect_ {_If_(_cgiargqf_,_textformadvancedsearch_,_textformsimplesearch_)}
687# mg uses hselection for index, mgpp uses fqfselection
688_indexselection_{_If_(_cgiargct_,_fqfselection_,_hselection_)}
689
690# we want to put the links to previous/next pages of results
691# in the footer
692_pagefooterextra_ {
693<center>
694<table cellspacing=0 cellpadding=0 width=_pagewidth_>
695<tr>
696<td align=left>_If_(_prevfirst_,<a href="_httpquery_&r=_prevfirst_">_iconprev__textmatches__prevfirst_ - _prevlast_</a>)</td>
697<td align=right>_If_(_nextfirst_,<a href="_httpquery_&r=_nextfirst_">_textmatches__nextfirst_ - _nextlast__iconnext_</a>)</td>
698</tr></table>
699</center>
700}
701
702_querytypeselection_ {
703<select name="t">
704<option value="1"_If_(_cgiargt_, selected)>_If_(_cgiargb_,_textranked_,_textsome_)
705<option value="0"_If_(_cgiargt_,, selected)>_If_(_cgiargb_,_textboolean_,_textall_)
706</select>
707}
708
709_formquerytypeselection_ {
710<select name="t">
711<option value="1"_If_(_cgiargt_, selected)>_If_(_cgiargqf_,_textranked_,_textsome_)
712<option value="0"_If_(_cgiargt_,, selected)>_If_(_cgiargqf_,_textnatural_,_textall_)
713</select>
714}
715
716
Note: See TracBrowser for help on using the repository browser.