source: main/tags/2.62/gsdl/macros/query.dm@ 32110

Last change on this file since 32110 was 10661, checked in by kjdon, 19 years ago

fixed a couple of bugs in updatefqv and updatefqf

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