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

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

moved _imagethispage_ definitions into the nav_css/nav_ns4 macro files
so we can switch between text titles and image titles.

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