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

Last change on this file since 10919 was 10872, checked in by jrm21, 19 years ago

extensive modifications of generated HTML to support HTML4 and CSS.
Style sheets are the images/ directory. This should make it much easier
to make custom themes for collections, merely by modifying the style
sheet.

  • 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_{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<div class="navbar">
527<p class="navbar">
528_optnavigationbar_
529</p>
530</div>
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,<div class="divbar">&nbsp;</div>)
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<p>
553<input type=hidden name="a" value="q">
554<input type=hidden name="r" value="1">
555<input type=hidden name="hs" value="1">
556<input type=hidden name="e" value="_decodedcompressedoptions_">
557_queryformcontent_
558_optdatesearch_
559</p>
560</form>
561<!-- end of query form -->
562}
563
564_ifeellucky_ { <br><input type=checkbox name="ifl">_textifeellucky_ }
565_useifeellucky_ { } # Set this to _ifeellucky_ if you want this functionality available
566
567_queryformcontent_{
568<span class="textselect">
569_textselect_
570</span>
571
572<span class="querybox">
573_If_(_cgiargqb_,_largequerybox_,_smallquerybox_)
574_useifeellucky_
575</span>
576}
577
578# Automatically set by receptionist if config file switches
579# date searching on
580_optdatesearch_ { }
581
582
583_datesearch_
584{<table><tr><td>
585 <center>
586_textstartdate_
587<input type="text" name="ds" value = "_cgiargds_" size="4" maxlength="4">
588<select name="dsbc" value="_cgiargdsbc_" size="1">
589 <option value = "0"_If_(_cgiargdsbc_,, selected)>_textad_
590 <option value = "1"_If_(_cgiargdsbc_, selected)>_textbc_
591</select>
592_textenddate_
593<input type="text" name="de" value = "_cgiargde_" size="4" maxlength="4">
594<select name="debc" size="1">
595 <option value = "0" _If_(_cgiargdebc_,, selected)>_textad_
596 <option value = "1" _If_(_cgiargdebc_, selected)>_textbc_
597</select>
598</center>
599</tr></td>
600<tr><td>
601_textexplaineras_
602</tr></td>
603</table>
604</center>
605}
606
607_smallquerybox_ {<tr><td><nobr><input type="text" name="q" value="_cgiargq_" size="50">
608<input type="submit" value="_textbeginsearch_"></nobr>}
609
610_largequerybox_ {
611<tr><td><textarea name="q" cols=63 rows=10>
612_cgiargq_
613</textarea></td></tr>
614<tr align=right><td><table>
615<tr><td><input type="submit" value="_textbeginsearch_"></td>
616</tr></table></td></tr>}
617
618
619_fieldqueryform_ {
620<noscript>
621<p><b>_textnojsformwarning_</b><p>
622</noscript>
623<!-- field query form (\_query:fieldqueryform\_) -->
624<form name=QueryForm method=get action="_gwcgi_">
625
626<table><tr><td>
627<nobr>
628_textformselect_
629</nobr>
630</td></tr>
631_If_(_cgiargqf_,_advancedforms_,_simpleforms_)
632</table>
633_If_(_cgiargqf_,<div class="divbar">&nbsp;</div>
634<center>_advancedformextra_</center>)
635
636</form>
637<!-- end of query form -->
638}
639
640_advancedforms_{
641<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
642<tr><th></th><th align=left>_textwordphrase_</th><th colspan=2><nobr>_textfoldstem_</nobr></th><th align=center>&nbsp;&nbsp;_textinfield_</th></tr>
643_advformlist_
644<tr><td colspan=2><input type=button value="_textclearform_" onClick="clearForm();"></td>
645<td colspan=3><table>
646<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
647</tr></table></td></tr>
648</table></td></tr>
649}
650
651_advancedformextra_{
652<table>
653<tr><td>_textadvquery_</td></tr>
654<tr><td><textarea name=q cols=57 rows=3 onChange="updateq();">_cgiargq_</textarea></td>
655<td valign=bottom>
656<input type="button" value="_textrunquery_" onClick="runQuery();"></td></tr>
657</table>
658}
659
660_simpleforms_{
661<tr><td><center> <table border=0 cellspacing=0 cellpadding=0 width="90%">
662<tr><th align=left>_textwordphrase_</th><th align=left>&nbsp;&nbsp;_textinfield_</th></tr>
663_regformlist_
664<tr><td><input type=button value="_textclearform_" onClick="clearForm();"></td>
665<td><table>
666<tr><td><input type=button value="_textbeginsearch_" onClick="beginSearch();"></td>
667</tr>
668</table></td></tr>
669</table></td></tr>}
670
671_regformelement_{
672<td><input type=text size=39 name="fqv" onChange="updatefqv();"></td>
673<td>_fqfselection_</td>}
674
675#has no and/or/not selection box
676_firstadvformelement_{
677<td></td><td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
678<td align=center><input type=checkbox name="fqk" onClick="updatefqk();"></td>
679<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
680<td align=right>_fqfselection_</td>}
681
682_advformelement_{
683<td>_fqcselection_</td>
684<td><input type=text size=31 name="fqv" onChange="updatefqv();"></td>
685<td align=center><input type=checkbox name="fqk" onClick="updatefqk();"></td>
686<td align-center><input type=checkbox name="fqs" onClick="updatefqs();"></td>
687<td align=right>_fqfselection_</td>}
688
689_fqcselection_ {
690<select name="fqc" onChange="updatefqc();">
691<option value="and">_textand_
692<option value="or">_textor_
693<option value="not">_textandnot_
694</select>}
695
696_textselect_ {_If_(_cgiargb_,_textadvancedsearch_,_textsimplesearch_)}
697_textformselect_ {_If_(_cgiargqf_,_textformadvancedsearch_,_textformsimplesearch_)}
698# mg uses hselection for index, mgpp uses fqfselection
699_indexselection_{_If_(_cgiargct_,_fqfselection_,_hselection_)}
700
701# we want to put the links to previous/next pages of results
702# in the footer
703_pagefooterextra_ {
704<center>
705<table cellspacing=0 cellpadding=0 width="_pagewidth_">
706<tr>
707<td align=left>_If_(_prevfirst_,<a href="_httpquery_&r=_prevfirst_">_iconprev__textmatches__prevfirst_ - _prevlast_</a>)</td>
708<td align=right>_If_(_nextfirst_,<a href="_httpquery_&r=_nextfirst_">_textmatches__nextfirst_ - _nextlast__iconnext_</a>)</td>
709</tr></table>
710</center>
711}
712
713_querytypeselection_ {
714<select name="t">
715<option value="1"_If_(_cgiargt_, selected)>_If_(_cgiargb_,_textranked_,_textsome_)
716<option value="0"_If_(_cgiargt_,, selected)>_If_(_cgiargb_,_textboolean_,_textall_)
717</select>
718}
719
720_formquerytypeselection_ {
721<select name="t">
722<option value="1"_If_(_cgiargt_, selected)>_If_(_cgiargqf_,_textranked_,_textsome_)
723<option value="0"_If_(_cgiargt_,, selected)>_If_(_cgiargqf_,_textnatural_,_textall_)
724</select>
725}
726
727
Note: See TracBrowser for help on using the repository browser.