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

Last change on this file since 11142 was 11094, checked in by jrm21, 18 years ago

move the div tags around the navigation bar into the _optnavigationbar_
macro

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