source: main/tags/2.70u/gsdl/macros/query.dm@ 25515

Last change on this file since 25515 was 11209, checked in by kjdon, 18 years ago

changed iconsearchhistorybar to searchhistorybar, and now its a div not an icon

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 18.2 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_queryresultsbar_ {
31<div class="divbar">
32<p class="navbar">_texthresults_</p>
33</div>
34}
35
36_searchhistorybar_ {
37<div class="divbar">
38<p class="navbar">_texticonsearchhistorybar_</p>
39</div>
40}
41
42
43# _iconnext_ and _iconprev_ are overridden in this package as we
44# don't want alt text here
45_iconnext_{<img src="_httpiconmore_" width=_widthmore_ height=_heightmore_ border=0 align=top>}
46_iconnext_ [v=1] {}
47_iconprev_{<img src="_httpiconless_" width=_widthless_ height=_heightless_ border=0 align=top>}
48_iconprev_ [v=1] {}
49
50# the small squares for search history
51## " " ## handmade ## mstds ##
52_httpiconmstdsqrof_ {_httpimg_/mstdsof.gif}
53_httpiconmstdsqron_ {_httpimg_/mstdson.gif}
54_widthmstdsqrx_ {13}
55_heightmstdsqrx_ {13}
56
57#######################################################################
58# images
59#######################################################################
60
61# _imagethispage_ set in nav_css/nav_ns4 macro files
62
63#the buttons for the search history entries
64# takes one arg - the entry number (0-num entries)
65_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>}
66
67
68#######################################################################
69# scripts (and some macros for the scripts)
70#######################################################################
71
72_pagescriptextra_ {_If_("_cgiargqt_" eq "1", _formpagescriptextra_, _selectpagescriptextra_)
73_If_("_cgiarghd_" ne "0",_historypagescriptextra_) }
74
75_selectpagescriptextra_{_If_("_cgiargqto_" eq "2", _formpagescriptextra_,_dummypagescriptextra_)}
76_dummypagescriptextra_{function initialize() \{
77\} }
78_formpagescriptextra_ {
79// query scripts generated by \_query:pagescriptextra\_
80
81_standardfunctions_
82_formfunctions_
83_searchfunctions_
84
85function getsearchargs () \{
86
87 var args="";
88 args = "&fqa=0&fqv="+argfqv+"&fqf="+argfqf;
89 _If_(_cgiargqf_,args += "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc;)
90
91 return args;
92\}
93
94
95
96function getqueryargs () \{
97 return "&fqa=1"+"&q="+argq+"&fqv="+argfqv+"&fqf="+argfqf+
98 "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc ;
99\}
100
101}
102
103_historypagescriptextra_{
104
105var histvalue0='_histvalue0_';
106var histvalue1='_histvalue1_';
107var histvalue2='_histvalue2_';
108var histvalue3='_histvalue3_';
109var histvalue4='_histvalue4_';
110var histvalue5='_histvalue5_';
111var histvalue6='_histvalue6_';
112var histvalue7='_histvalue7_';
113var histvalue8='_histvalue8_';
114var histvalue9='_histvalue9_';
115var histvalue10='_histvalue10_';
116var histvalue11='_histvalue11_';
117var histvalue12='_histvalue12_';
118var histvalue13='_histvalue13_';
119var histvalue14='_histvalue14_';
120var histvalue15='_histvalue15_';
121var histvalue16='_histvalue16_';
122var histvalue17='_histvalue17_';
123var histvalue18='_histvalue18_';
124var histvalue19='_histvalue19_';
125
126function inputQuery(value) \{
127 if ("_cgiargqt_" == "0") \{ // text search
128 document.QueryForm.q.value += " "+value;
129 document.QueryForm.q.focus();
130 \}
131 else \{
132 if ("_cgiargqf_" == "1") \{ // advanced query
133 document.QueryForm.q.value += " "+value;
134 document.QueryForm.q.focus();
135 updateq();
136 \}
137 else \{ // simple form search
138 // do something here, what??
139 \}
140 \}
141\}
142
143}
144
145_standardfunctions_{
146
147 function getstdargs() \{
148
149 stdarg = "";
150 _If_(_gselection_,_getgarg_)
151 _If_(_jselection_,_getjarg_)
152 _If_(_nselection_,_getnarg_)
153
154 value = document.QueryForm.t.options[document.QueryForm.t.selectedIndex].value;
155 if (value != "_cgiargt_") stdarg += "&t="+value;
156
157 stdarg += "&r=1&hs=1";
158 return stdarg;
159 \}
160
161}
162
163_getgarg_{
164 if (document.QueryForm.g!= null) \{
165 value = document.QueryForm.g.options[document.QueryForm.g.selectedIndex].value;
166 if (value != "_cgiargg_") stdarg += "&g="+value;
167 \}
168}
169
170_getjarg_{
171 value = document.QueryForm.j.options[document.QueryForm.j.selectedIndex].value;
172 if (value != "_cgiargj_") stdarg += "&j="+value;
173}
174
175_getnarg_{
176 value = document.QueryForm.n.options[document.QueryForm.n.selectedIndex].value;
177 if (value != "_cgiargn_") stdarg += "&n="+value;
178}
179
180_formfunctions_{
181
182argfqf="_cgiargfqf_";
183argfqv="_cgiargfqv_";
184argfqk="_cgiargfqk_";
185argfqs="_cgiargfqs_";
186argfqc="_cgiargfqc_";
187argq = "";
188
189function initialize () \{
190
191 if (document.QueryForm.fqf != null) \{initfqf();\}
192 initfqv();
193 if ( "_cgiargqf_" == "1") \{
194 initfqs();
195 initfqk();
196 initfqc();
197 initq();
198 \}
199
200\}
201
202// fqf - the field selection box
203function initfqf() \{
204 var i;
205 fqf = argfqf.split(",");
206 num_opts = document.QueryForm.fqf[0].options.length; // assumes all have the same options
207 for (i=0; i<fqf.length && i<document.QueryForm.fqf.length; i++) \{
208 if (fqf[i] != "")\{
209 for (j=0;j<num_opts;j++) \{
210 if (fqf[i]== document.QueryForm.fqf[i].options[j].value) \{
211 document.QueryForm.fqf[i].options[j].selected = true;
212 break;
213 \}
214 \}
215 \}
216 \}
217 if (fqf.length < document.QueryForm.fqf.length) \{ // initialize remaining ones
218 for (i=fqf.length;i<document.QueryForm.fqf.length;i++) \{
219 var z=i;
220 while (z >= num_opts) \{
221 z = z-(num_opts);
222 \}
223 document.QueryForm.fqf[i].options[z].selected = true;
224
225 \}
226 \}
227 updatefqf();
228
229\}
230
231function updatefqf() \{
232
233 var i;
234 argfqf = "";
235 var j = document.QueryForm.fqf[0].selectedIndex;
236 argfqf += document.QueryForm.fqf[0].options[j].value;
237 for (i=1; i<document.QueryForm.fqf.length;i++) \{
238 j = document.QueryForm.fqf[i].selectedIndex;
239 argfqf += "," + document.QueryForm.fqf[i].options[j].value;
240 \}
241
242\}
243
244
245function clearfqf() \{
246 var i;
247 for (i=0;i<document.QueryForm.fqf.length;i++) \{
248 var z = i;
249 if (i >= document.QueryForm.fqf[i].options.length) z = z-document.QueryForm.fqf[i].options.length;
250 document.QueryForm.fqf[i].options[z].selected = true;
251 \}
252 updatefqf();
253\}
254
255// fqc - the boolean operator selection box
256function initfqc() \{
257 var i,j;
258 fqc = argfqc.split(",");
259 if (_cgiargfqn_ == 2) \{ // there will only be one fqc element
260 for (j=0;j<document.QueryForm.fqc.options.length;j++) \{
261 if (fqc[0] == document.QueryForm.fqc.options[j].value) \{
262 document.QueryForm.fqc.options[j].selected = true;
263 break;
264 \}
265 \}
266 \}
267 else \{
268 for (i=0; i<fqc.length;i++) \{
269 for (j=0;j<document.QueryForm.fqc[i].options.length;j++) \{
270 if (fqc[i] == document.QueryForm.fqc[i].options[j].value) \{
271 document.QueryForm.fqc[i].options[j].selected = true;
272 break;
273 \}
274 \}
275 \}
276 \}
277 updatefqc();
278
279\}
280
281function updatefqc() \{
282
283 var i,j;
284 argfqc = "";
285 if (_cgiargfqn_ == 2) \{
286 j = document.QueryForm.fqc.selectedIndex;
287 argfqc += document.QueryForm.fqc.options[j].value;
288 \}
289 else \{
290 j = document.QueryForm.fqc[0].selectedIndex;
291 argfqc += document.QueryForm.fqc[0].options[j].value;
292 for (i=1;i<document.QueryForm.fqc.length;i++) \{
293 j = document.QueryForm.fqc[i].selectedIndex;
294 argfqc += "," + document.QueryForm.fqc[i].options[j].value;
295 \}
296 \}
297
298\}
299
300
301function clearfqc() \{
302
303 var i;
304 if (_cgiargfqn_ == 2) \{
305 document.QueryForm.fqc.options[0].selected = true;
306 \}
307 else \{
308 for (i=0; i<document.QueryForm.fqc.length; i++) \{
309 document.QueryForm.fqc[i].options[0].selected = true;
310 \}
311 \}
312 updatefqc();
313\}
314
315// fqv - the query word/phrase text box
316function initfqv() \{
317 var i;
318 fqv= argfqv.split(",");
319 for (i=0; i<fqv.length && i<document.QueryForm.fqv.length; i++) \{
320 document.QueryForm.fqv[i].value = fqv[i];
321 \}
322 updatefqv();
323
324
325\}
326
327 //argfqv += escape(format(document.QueryForm.fqv[0].value));
328
329function updatefqv() \{
330
331 var i;
332 argfqv="";
333 argfqv += format(document.QueryForm.fqv[0].value);
334 for (i=1; i<document.QueryForm.fqv.length;i++) \{
335 argfqv += ",";
336 argfqv += format(document.QueryForm.fqv[i].value);
337 \}
338\}
339
340function clearfqv() \{
341 var i;
342 for (i=0; i< document.QueryForm.fqv.length;i++) \{
343 document.QueryForm.fqv[i].value = "";
344 \}
345 updatefqv();
346\}
347
348// fqs - the stemming checkboxes
349function initfqs() \{
350
351 var i;
352 fqs = argfqs.split(",");
353 for (i=0; i<fqs.length; i++) \{
354 if (fqs[i]=="1") \{
355 document.QueryForm.fqs[i].checked = true;
356 \}
357 \}
358 updatefqs();
359
360\}
361
362function updatefqs() \{
363 argfqs="";
364 if (document.QueryForm.fqs[0].checked) \{
365 argfqs += "1";
366 \}
367 else \{
368 argfqs += "0";
369 \}
370 var i;
371 for (i=1; i<document.QueryForm.fqs.length; i++) \{
372 if (document.QueryForm.fqs[i].checked) \{
373 argfqs += ",1";
374 \}
375 else \{
376 argfqs += ",0";
377 \}
378 \}
379\}
380
381
382function clearfqs() \{
383 var i;
384 for (i=0; i<document.QueryForm.fqs.length; i++) \{
385 document.QueryForm.fqs[i].checked = false;
386 \}
387 updatefqs();
388\}
389
390// kqk - the casefolding checkboxes
391function initfqk() \{
392 var i;
393 fqk = argfqk.split(",");
394 for (i=0; i<fqk.length; i++) \{
395 if (fqk[i]=="1") \{
396 document.QueryForm.fqk[i].checked = true;
397 \}
398 \}
399 updatefqk();
400
401\}
402
403
404function updatefqk() \{
405 argfqk="";
406 if (document.QueryForm.fqk[0].checked) \{
407 argfqk += "1";
408 \}
409 else \{
410 argfqk += "0";
411 \}
412 var i;
413 for (i=1; i<document.QueryForm.fqk.length; i++) \{
414 if (document.QueryForm.fqk[i].checked) \{
415 argfqk += ",1";
416 \}
417 else \{
418 argfqk += ",0";
419 \}
420 \}
421\}
422
423function clearfqk() \{
424 var i;
425 for (i=0; i<document.QueryForm.fqk.length; i++) \{
426 document.QueryForm.fqk[i].checked = false;
427 \}
428 updatefqk();
429\}
430
431// q - the advanced query box
432function initq() \{
433 updateq();
434\}
435
436function updateq() \{
437 argq = "";
438 argq += format(document.QueryForm.q.value);
439\}
440
441function clearq() \{
442 document.QueryForm.q.value="";
443\}
444
445
446// convert commas and spaces to plus
447// also convert other illegal characters to %xx codes
448function format(string) \{
449 var str = "" + string;
450 var out = "", flag = 0;
451 var ch = "";
452 var j;
453 for (j = 0; j < str.length; j++) \{
454 ch=str.charAt(j);
455 if (ch == " "|| ch == ",") \{
456 if ( flag == 0) \{
457 out += "+";
458 flag=1;
459 \}
460 continue;
461 \}
462 if (ch == ";" || ch == ":" || ch == "/" || ch == "?" ||
463 ch == "@" || ch == "&" || ch == "=" || ch == "#") \{
464 out += escape(ch);
465 flag=0;
466 continue;
467 \}
468 out += str.charAt(j);
469 flag=0;
470 \}
471 return out;
472\}
473
474}
475
476#_httpquery_ has a=q&e=compressedargs
477#if adv form, need to set k=0 and s=0
478_advformargs_{_If_(_cgiargqf_,&k=0&s=0)}
479
480_searchfunctions_ {
481
482function beginSearch() \{
483window.location="_httpquery_"+getstdargs()+"_advformargs_"+getsearchargs();
484\}
485
486function runQuery() \{
487window.location="_httpquery_"+getstdargs()+"_advformargs_"+getqueryargs();
488\}
489
490function clearForm() \{
491 clearfqf();
492 clearfqv();
493
494 if ("_cgiargqf_" == "1") \{
495 clearfqk();
496 clearfqs();
497 clearfqc();
498 \}
499
500\}
501
502}
503
504#######################################################################
505# headers
506# these are overridden so we can put an onLoad event handler
507# in the <body> tag of this page - for mgpp, form search pages
508#######################################################################
509
510#copied from prefs
511
512_header_ {_cgihead_
513_htmlhead_(class="bgimage" onLoad="initialize();")_startspacer__pagebanner_
514}
515
516# this declaration ends up being the same as style=restrict, never mind
517_header_[v=1] {_cgihead_
518_htmlhead_(onLoad="initialize();")_pagebanner_
519}
520
521#######################################################################
522# page content
523#######################################################################
524
525
526_pagetitle_ {_If_(_cgiargq_,_textquerytitle_,_textnoquerytitle_)}
527
528
529_content_ {
530_optnavigationbar_
531
532<div class="document">
533
534<div class="queryform">
535_If_(_cgiargct_,_selectqueryform_,_queryform_)
536</div>
537_If_(_searchhistorylist_,<center>_searchhistorybar_</center><br>
538<center>
539_searchhistorylist_
540</center>)
541_If_(_cgiargq_,_queryresultsbar_
542<small>
543_freqmsg_
544_textpostprocess_</small><br>
545_resultline_
546,<div class="divbar">&nbsp;</div>)
547}
548
549_selectqueryform_{_If_("_cgiargqt_" eq "1",_fieldqueryform_,_selectqueryform2_)}
550_selectqueryform2_{_If_("_cgiargqto_" eq "2", _fieldqueryform_, _queryform_)}
551
552_queryform_ {
553<!-- query form (\_query:plainqueryform\_) -->
554<form name=QueryForm method=get action="_gwcgi_">
555<p>
556<input type=hidden name="a" value="q">
557<input type=hidden name="r" value="1">
558<input type=hidden name="hs" value="1">
559<input type=hidden name="e" value="_decodedcompressedoptions_">
560_queryformcontent_
561_optdatesearch_
562</p>
563</form>
564<!-- end of query form -->
565}
566
567_ifeellucky_ { <br><input type=checkbox name="ifl">_textifeellucky_ }
568_useifeellucky_ { } # Set this to _ifeellucky_ if you want this functionality available
569
570_queryformcontent_{
571<span class="textselect">
572_textselect_
573</span>
574
575<span class="querybox">
576_If_(_cgiargqb_,_largequerybox_,_smallquerybox_)
577_useifeellucky_
578</span>
579}
580
581# Automatically set by receptionist if config file switches
582# date searching on
583_optdatesearch_ { }
584
585
586_datesearch_
587{<table><tr><td>
588 <center>
589_textstartdate_
590<input type="text" name="ds" value = "_cgiargds_" size="4" maxlength="4">
591<select name="dsbc" value="_cgiargdsbc_" size="1">
592 <option value = "0"_If_(_cgiargdsbc_,, selected)>_textad_
593 <option value = "1"_If_(_cgiargdsbc_, selected)>_textbc_
594</select>
595_textenddate_
596<input type="text" name="de" value = "_cgiargde_" size="4" maxlength="4">
597<select name="debc" size="1">
598 <option value = "0" _If_(_cgiargdebc_,, selected)>_textad_
599 <option value = "1" _If_(_cgiargdebc_, selected)>_textbc_
600</select>
601</center>
602</tr></td>
603<tr><td>
604_textexplaineras_
605</tr></td>
606</table>
607</center>
608}
609
610_smallquerybox_ {<tr><td><nobr><input type="text" name="q" value="_cgiargq_" size="50">
611<input type="submit" value="_textbeginsearch_"></nobr>}
612
613_largequerybox_ {
614<tr><td><textarea name="q" cols=63 rows=10>
615_cgiargq_
616</textarea></td></tr>
617<tr align=right><td><table>
618<tr><td><input type="submit" value="_textbeginsearch_"></td>
619</tr></table></td></tr>}
620
621
622_fieldqueryform_ {
623<noscript>
624<p><b>_textnojsformwarning_</b><p>
625</noscript>
626<!-- field query form (\_query:fieldqueryform\_) -->
627<form name=QueryForm method=get action="_gwcgi_">
628
629<table><tr><td>
630<nobr>
631_textformselect_
632</nobr>
633</td></tr>
634_If_(_cgiargqf_,_advancedforms_,_simpleforms_)
635</table>
636_If_(_cgiargqf_,<div class="divbar">&nbsp;</div>
637<center>_advancedformextra_</center>)
638
639</form>
640<!-- end of query form -->
641}
642
643_advancedforms_{
644<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
645<tr><th></th><th align=left>_textwordphrase_</th><th colspan=2><nobr>_textfoldstem_</nobr></th><th align=center>&nbsp;&nbsp;_textinfield_</th></tr>
646_advformlist_
647<tr><td colspan=2><input type=button value="_textclearform_" onClick="clearForm();"></td>
648<td colspan=3><table>
649<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
650</tr></table></td></tr>
651</table></td></tr>
652}
653
654_advancedformextra_{
655<table>
656<tr><td>_textadvquery_</td></tr>
657<tr><td><textarea name=q cols=57 rows=3 onChange="updateq();">_cgiargq_</textarea></td>
658<td valign=bottom>
659<input type="button" value="_textrunquery_" onClick="runQuery();"></td></tr>
660</table>
661}
662
663_simpleforms_{
664<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
665<tr><th align=left>_textwordphrase_</th><th align=left>&nbsp;&nbsp;_textinfield_</th></tr>
666_regformlist_
667<tr><td><input type=button value="_textclearform_" onClick="clearForm();"></td>
668<td><table>
669<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
670</tr>
671</table></td></tr>
672</table></td></tr>}
673
674_regformelement_{
675<td><input type=text size=39 name="fqv" onChange="updatefqv();"></td>
676<td>_fqfselection_</td>}
677
678#has no and/or/not selection box
679_firstadvformelement_{
680<td></td><td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
681<td align=center><input type=checkbox name="fqk" onClick="updatefqk();"></td>
682<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
683<td align=right>_fqfselection_</td>}
684
685_advformelement_{
686<td>_fqcselection_</td>
687<td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
688<td align=center><input type=checkbox name="fqk" onClick="updatefqk();"></td>
689<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
690<td align=right>_fqfselection_</td>}
691
692_fqcselection_ {
693<select name="fqc" onChange="updatefqc();">
694<option value="and">_textand_
695<option value="or">_textor_
696<option value="not">_textandnot_
697</select>}
698
699_textselect_ {_If_(_cgiargb_,_textadvancedsearch_,_textsimplesearch_)}
700_textformselect_ {_If_(_cgiargqf_,_textformadvancedsearch_,_textformsimplesearch_)}
701# mg uses hselection for index, mgpp uses fqfselection
702_indexselection_{_If_(_cgiargct_,_fqfselection_,_hselection_)}
703
704# we want to put the links to previous/next pages of results
705# in the footer
706_pagefooterextra_ {
707<center>
708<table cellspacing=0 cellpadding=0 width="_pagewidth_">
709<tr>
710<td align=left>_If_(_prevfirst_,<a href="_httpquery_&r=_prevfirst_">_iconprev__textmatches__prevfirst_ - _prevlast_</a>)</td>
711<td align=right>_If_(_nextfirst_,<a href="_httpquery_&r=_nextfirst_">_textmatches__nextfirst_ - _nextlast__iconnext_</a>)</td>
712</tr></table>
713</center>
714
715</div> <!-- document -->
716}
717
718_querytypeselection_ {
719<select name="t">
720<option value="1"_If_(_cgiargt_, selected)>_If_(_cgiargb_,_textranked_,_textsome_)
721<option value="0"_If_(_cgiargt_,, selected)>_If_(_cgiargb_,_textboolean_,_textall_)
722</select>
723}
724
725_formquerytypeselection_ {
726<select name="t">
727<option value="1"_If_(_cgiargt_, selected)>_If_(_cgiargqf_,_textranked_,_textsome_)
728<option value="0"_If_(_cgiargt_,, selected)>_If_(_cgiargqf_,_textnatural_,_textall_)
729</select>
730}
731
732
Note: See TracBrowser for help on using the repository browser.