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

Last change on this file since 8444 was 8151, checked in by kjdon, 20 years ago

shift the focus to the query box after clicking on an old query to add it in to the query box.

  • 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 document.QueryForm.q.focus();
128 \}
129 else \{
130 if ("_cgiargqf_" == "1") \{ // advanced query
131 document.QueryForm.q.value += " "+value;
132 document.QueryForm.q.focus();
133 updateq();
134 \}
135 else \{ // simple form search
136 // do something here, what??
137 \}
138 \}
139\}
140
141}
142
143_standardfunctions_{
144
145 function getstdargs() \{
146
147 stdarg = "";
148 _If_(_gselection_,_getgarg_)
149 _If_(_jselection_,_getjarg_)
150
151 value = document.QueryForm.t.options[document.QueryForm.t.selectedIndex].value;
152 if (value != "_cgiargt_") stdarg += "&t="+value;
153
154 stdarg += "&r=1&hs=1";
155 return stdarg;
156 \}
157
158}
159
160_getgarg_{
161 if (document.QueryForm.g!= null) \{
162 value = document.QueryForm.g.options[document.QueryForm.g.selectedIndex].value;
163 if (value != "_cgiargg_") stdarg += "&g="+value;
164 \}
165}
166
167_getjarg_{
168 value = document.QueryForm.j.options[document.QueryForm.j.selectedIndex].value;
169 if (value != "_cgiargj_") stdarg += "&j="+value;
170}
171
172
173_formfunctions_{
174
175argfqf="_cgiargfqf_";
176argfqv="_cgiargfqv_";
177argfqk="_cgiargfqk_";
178argfqs="_cgiargfqs_";
179argfqc="_cgiargfqc_";
180argq = "";
181
182function initialize () \{
183
184 if (document.QueryForm.fqf != null) \{initfqf();\}
185 initfqv();
186 if ( "_cgiargqf_" == "1") \{
187 initfqs();
188 initfqk();
189 initfqc();
190 initq();
191 \}
192
193\}
194
195// fqf - the field selection box
196function initfqf() \{
197 var i;
198 fqf = argfqf.split(",");
199 num_opts = document.QueryForm.fqf[0].options.length; // assumes all have the same options
200 for (i=0; i<fqf.length; i++) \{
201 for (j=0;j<num_opts;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 >= num_opts) \{
212 z = z-(num_opts);
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
428function updateq() \{
429 argq = "";
430 argq += format(document.QueryForm.q.value);
431\}
432
433function clearq() \{
434 document.QueryForm.q.value="";
435\}
436
437
438// convert commas and spaces to plus
439// also convert other illegal characters to %xx codes
440function format(string) \{
441 var str = "" + string;
442 var out = "", flag = 0;
443 var ch = "";
444 var j;
445 for (j = 0; j < str.length; j++) \{
446 ch=str.charAt(j);
447 if (ch == " "|| ch == ",") \{
448 if ( flag == 0) \{
449 out += "+";
450 flag=1;
451 \}
452 continue;
453 \}
454 if (ch == ";" || ch == ":" || ch == "/" || ch == "?" ||
455 ch == "@" || ch == "&" || ch == "=" || ch == "#") \{
456 out += escape(ch);
457 flag=0;
458 continue;
459 \}
460 out += str.charAt(j);
461 flag=0;
462 \}
463 return out;
464\}
465
466}
467
468#_httpquery_ has a=q&e=compressedargs
469#if adv form, need to set k=0 and s=0
470_advformargs_{_If_(_cgiargqf_,&k=0&s=0)}
471
472_searchfunctions_ {
473
474function beginSearch() \{
475window.location="_httpquery_"+getstdargs()+"_advformargs_"+getsearchargs();
476\}
477
478function runQuery() \{
479window.location="_httpquery_"+getstdargs()+"_advformargs_"+getqueryargs();
480\}
481
482function clearForm() \{
483 clearfqf();
484 clearfqv();
485
486 if ("_cgiargqf_" == "1") \{
487 clearfqk();
488 clearfqs();
489 clearfqc();
490 \}
491
492\}
493
494}
495
496#######################################################################
497# headers
498# these are overridden so we can put an onLoad event handler
499# in the <body> tag of this page - for mgpp, form search pages
500#######################################################################
501
502#copied from prefs
503
504_header_ {_cgihead_
505_htmlhead_(background="_httpiconchalk_" onLoad="initialize();")_startspacer__pagebanner_
506}
507
508# this declaration ends up being the same as style=restrict, never mind
509_header_[v=1] {_cgihead_
510_htmlhead_(onLoad="initialize();")_pagebanner_
511}
512
513#######################################################################
514# page content
515#######################################################################
516
517
518_pagetitle_ {_If_(_cgiargq_,_textquerytitle_,_textnoquerytitle_)}
519
520
521_content_ {
522<center>
523_optnavigationbar_
524</center>
525<center>
526_If_(_cgiargct_,_selectqueryform_,_queryform_)
527</center>
528_If_(_searchhistorylist_,<center>_iconsearchhistorybar_</center><br>
529<center>
530_searchhistorylist_
531</center>)
532_If_(_cgiargq_,<center>_iconqueryresultsbar_</center><br>
533<small>
534_freqmsg_
535_textpostprocess_</small><br>
536_resultline_
537,<center>_iconblankbar_</center>)<br>
538}
539
540_selectqueryform_{_If_("_cgiargqt_" eq "1",_fieldqueryform_,_selectqueryform2_)}
541_selectqueryform2_{_If_("_cgiargqto_" eq "2", _fieldqueryform_, _queryform_)}
542
543_queryform_ {
544<!-- query form (\_query:plainqueryform\_) -->
545<form name=QueryForm method=get action="_gwcgi_">
546<input type=hidden name="a" value="q">
547<input type=hidden name="r" value="1">
548<input type=hidden name="hs" value="1">
549<input type=hidden name="e" value="_decodedcompressedoptions_">
550_queryformcontent_
551_optdatesearch_
552
553</form>
554<!-- end of query form -->
555}
556
557_ifeellucky_ { <br><input type=checkbox name="ifl">_textifeellucky_ }
558_useifeellucky_ { } # Set this to _ifeellucky_ if you want this functionality available
559
560_queryformcontent_{<table><tr><td>
561<nobr>_textselect_</nobr>
562</td></tr>
563<tr><td>
564_If_(_cgiargqb_,_largequerybox_,_smallquerybox_)
565_useifeellucky_
566</td></tr></table>
567}
568
569# Automatically set by receptionist if config file switches
570# date searching on
571_optdatesearch_ { }
572
573
574_datesearch_
575{<table><tr><td>
576 <center>
577_textstartdate_
578<input type="text" name="ds" value = "_cgiargds_" size="4" maxlength="4">
579<select name="dsbc" value="_cgiargdsbc_" size="1">
580 <option value = "0"_If_(_cgiargdsbc_,, selected)>_textad_
581 <option value = "1"_If_(_cgiargdsbc_, selected)>_textbc_
582</select>
583_textenddate_
584<input type="text" name="de" value = "_cgiargde_" size="4" maxlength="4">
585<select name="debc" size="1">
586 <option value = "0" _If_(_cgiargdebc_,, selected)>_textad_
587 <option value = "1" _If_(_cgiargdebc_, selected)>_textbc_
588</select>
589</center>
590</tr></td>
591<tr><td>
592_textexplaineras_
593</tr></td>
594</table>
595</center>
596}
597
598_smallquerybox_ {<tr><td><nobr><input type="text" name="q" value="_cgiargq_" size="50">
599<input type="submit" value="_textbeginsearch_"></nobr>}
600
601_largequerybox_ {
602<tr><td><textarea name="q" cols=63 rows=10>
603_cgiargq_
604</textarea></td></tr>
605<tr align=right><td><table>
606<tr><td><input type="submit" value="_textbeginsearch_"></td>
607</tr></table></td></tr>}
608
609
610_fieldqueryform_ {
611<noscript>
612<p><b>_textnojsformwarning_</b><p>
613</noscript>
614<!-- field query form (\_query:fieldqueryform\_) -->
615<form name=QueryForm method=get action="_gwcgi_">
616
617<table><tr><td>
618<nobr>
619_textformselect_
620</nobr>
621</td></tr>
622_If_(_cgiargqf_,_advancedforms_,_simpleforms_)
623</table>
624_If_(_cgiargqf_,<center>_iconblankbar_</center><br>
625<center>_advancedformextra_</center>)
626
627</form>
628<!-- end of query form -->
629}
630
631_advancedforms_{
632<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
633<tr><th></th><th align=left>_textwordphrase_</th><th colspan=2><nobr>_textfoldstem_</nobr></th><th align=center>&nbsp;&nbsp;_textinfield_</th></tr>
634_advformlist_
635<tr><td colspan=2><input type=button value="_textclearform_" onClick="clearForm();"></td>
636<td colspan=3><table>
637<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
638</tr></table></td></tr>
639</table></td></tr>
640}
641
642_advancedformextra_{
643<table>
644<tr><td>_textadvquery_</td></tr>
645<tr><td><textarea name=q cols=57 rows=3 onChange="updateq();">_cgiargq_</textarea></td>
646<td valign=bottom>
647<input type="button" value="_textrunquery_" onClick="runQuery();"></td></tr>
648</table>
649}
650
651_simpleforms_{
652<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
653<tr><th align=left>_textwordphrase_</th><th align=left>&nbsp;&nbsp;_textinfield_</th></tr>
654_regformlist_
655<tr><td><input type=button value="_textclearform_" onClick="clearForm();"></td>
656<td><table>
657<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
658</tr>
659</table></td></tr>
660</table></td></tr>}
661
662_regformelement_{
663<td><input type=text size=39 name="fqv" onChange="updatefqv();"></td>
664<td>_fqfselection_</td>}
665
666#has no and/or/not selection box
667_firstadvformelement_{
668<td></td><td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
669<td align=center><input type=checkbox name="fqk" onClick="updatefqk();"></td>
670<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
671<td align=right>_fqfselection_</td>}
672
673_advformelement_{
674<td>_fqcselection_</td>
675<td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
676<td align=center><input type=checkbox name="fqk" onClick="updatefqk();"></td>
677<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
678<td align=right>_fqfselection_</td>}
679
680_fqcselection_ {
681<select name="fqc" onChange="updatefqc();">
682<option value="and">_textand_
683<option value="or">_textor_
684<option value="not">_textandnot_
685</select>}
686
687_textselect_ {_If_(_cgiargb_,_textadvancedsearch_,_textsimplesearch_)}
688_textformselect_ {_If_(_cgiargqf_,_textformadvancedsearch_,_textformsimplesearch_)}
689# mg uses hselection for index, mgpp uses fqfselection
690_indexselection_{_If_(_cgiargct_,_fqfselection_,_hselection_)}
691
692# we want to put the links to previous/next pages of results
693# in the footer
694_pagefooterextra_ {
695<center>
696<table cellspacing=0 cellpadding=0 width=_pagewidth_>
697<tr>
698<td align=left>_If_(_prevfirst_,<a href="_httpquery_&r=_prevfirst_">_iconprev__textmatches__prevfirst_ - _prevlast_</a>)</td>
699<td align=right>_If_(_nextfirst_,<a href="_httpquery_&r=_nextfirst_">_textmatches__nextfirst_ - _nextlast__iconnext_</a>)</td>
700</tr></table>
701</center>
702}
703
704_querytypeselection_ {
705<select name="t">
706<option value="1"_If_(_cgiargt_, selected)>_If_(_cgiargb_,_textranked_,_textsome_)
707<option value="0"_If_(_cgiargt_,, selected)>_If_(_cgiargb_,_textboolean_,_textall_)
708</select>
709}
710
711_formquerytypeselection_ {
712<select name="t">
713<option value="1"_If_(_cgiargt_, selected)>_If_(_cgiargqf_,_textranked_,_textsome_)
714<option value="0"_If_(_cgiargt_,, selected)>_If_(_cgiargqf_,_textnatural_,_textall_)
715</select>
716}
717
718
Note: See TracBrowser for help on using the repository browser.