source: main/trunk/greenstone2/macros/pref.dm@ 22091

Last change on this file since 22091 was 22091, checked in by davidb, 14 years ago

Changes to support sql query

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 15.7 KB
Line 
1# this file must be UTF-8 encoded
2
3package preferences
4
5# set within server
6
7# collectionoption is only set when cross-collection searching is turned on
8_collectionoption_ {}
9
10# this macro will be set to "1" when the "source docs retrived from dl/web
11# button is required - i.e. whenever PreferenceDocsFromWeb isn't set to false
12# in collect.cfg
13_PreferenceDocsFromWeb_ {}
14
15# this macro will be set to _textprefschanged_ when the "set preferences"
16# button has been pressed
17_prefschanged_ {}
18
19#######################################################################
20# global navigation links
21#######################################################################
22
23# this is overridden here as we don't want a 'preferences' link on this page
24
25_globallinks_ {_homelink_ _helplink_}
26
27#######################################################################
28# scripts
29# note that changing either the "m" or the "o" argument
30# from the preferences page necessitates reseting the "r"
31# argument to 1
32#######################################################################
33
34_ccsfunctions_ {argcc = "";
35savedccs = new Object();
36
37function initialize () \{
38 for (i = 0; i < document.links.length; i++)
39 savedhrefs[i] = document.links[i].href;
40
41 s = "_cgiargcc_";
42 a = s.split (",");
43 for (i = 0; i < a.length ;i++) \{
44 for (j = 0; j < document.PrefForm.cc.length; j++) \{
45 if (a[i] == document.PrefForm.elements["cc"][j].value) \{
46 document.PrefForm.elements["cc"][j].checked = true;
47 savedccs[a[i]] = 1;
48 argcc = argcc + "&cc=" + a[i];
49 break;
50 \} else \{
51 savedccs[a[i]] = 0;
52 \}
53 \}
54 \}
55 updatehrefs();
56\}
57
58function updatecc (collection) \{
59 if (savedccs[collection] == 1) savedccs[collection] = 0;
60 else savedccs[collection] = 1;
61
62 var i;
63 argcc = "";
64 var changed = 0;
65 for (i in savedccs)
66 if (savedccs[i] == 1) \{
67 argcc += "&cc=" + i;
68 changed = 1;
69 \}
70 if (changed == 1) argcc += "&r=1";
71 updatehrefs();
72\}
73}
74
75_standardfunctions_ {
76function initialize () \{
77 for (i = 0; i < document.links.length; i++)
78 savedhrefs[i] = document.links[i].href;
79
80\}
81
82}
83
84_getargsfunction_ {
85function getargs () \{
86 return argk + args + argaf + argm + argo + argrd + arghd + argb + argqb + argfqn + argqt_If_(_collectionoption_,_ccsargs_)_If_(_htmloptions_,_htmlargs_);
87\}
88}
89
90_ccsargs_ {+ argcc}
91_htmlargs_ {+ argel + argil + argfc + arghl}
92
93_htmlfunctions_ {argel = "";
94argil = "";
95argfc = "";
96arghl = "";
97
98function updateel () \{
99 value = document.PrefForm.el.options[document.PrefForm.el.selectedIndex].value;
100 if (value != "_cgiargel_") argel = "&el=" + value;
101 else argel = "";
102 updatehrefs();
103\}
104
105function updateil () \{
106 value = document.PrefForm.il.options[document.PrefForm.il.selectedIndex].value;
107 if (value != "_cgiargil_") argil = "&il=" + value;
108 else argil = "";
109 updatehrefs();
110\}
111
112function updatefc(value) \{
113 if (value != _cgiargfc_) argfc = "&fc=" + value + "&f=" + value;
114 else argfc = "";
115 updatehrefs();
116\}
117
118function updatehl(value) \{
119 if (value != _cgiarghl_) arghl = "&hl=" + value;
120 else arghl = "";
121 updatehrefs();
122\}
123}
124
125_pagescriptextra_ {
126// preferences scripts generated from \_preferences:pagescriptextra\_
127
128savedhrefs = new Object();
129
130argk = "";
131args = "";
132argm = "";
133argrd = "";
134argo = "";
135argb = "";
136arghd = "";
137argqb = "";
138argfqn = "";
139argqt= "";
140argaf = "";
141
142_If_(_collectionoption_,_ccsfunctions_,_standardfunctions_)
143_If_(_htmloptions_,_htmlfunctions_)
144_getargsfunction_
145function updatehrefs () \{
146 for (i = 0; i < document.links.length; i++)
147 document.links[i].href = savedhrefs[i] + getargs();
148\}
149
150function replacesavedhrefs (from,to) \{
151 for (i = 0; i < document.links.length; i++) \{
152 var orighref = savedhrefs[i];
153 var newhref = orighref.replace(from,to);
154 savedhrefs[i] = newhref;
155 \}
156\}
157
158function updatek (value) \{
159 if (value != _cgiargk_) argk = "&k=" + value;
160 else argk = "";
161 updatehrefs();
162\}
163
164function updates (value) \{
165 if (value != _cgiargs_) args = "&s=" + value;
166 else args = "";
167 updatehrefs();
168\}
169
170function updateaf (value) \{
171 if (value != _cgiargaf_) argaf = "&af=" + value;
172 else argaf = "";
173 updatehrefs();
174\}
175
176function updatem () \{
177 value = document.PrefForm.m.options[document.PrefForm.m.selectedIndex].value;
178 if (value != _cgiargm_) argm = "&r=1&m=" + value;
179 else argm = "";
180 updatehrefs();
181\}
182
183function updaterd () \{
184 if (document.PrefForm.rd.checked)
185 _If_("_cgiargrd_" eq "1",argrd="";,argrd="&rd=1";)
186 else
187 _If_("_cgiargrd_" ne "1",argrd="";,argrd="&rd=0";)
188 updatehrefs();
189\}
190
191function updateo () \{
192 value = document.PrefForm.o.options[document.PrefForm.o.selectedIndex].value;
193 if (value != _cgiargo_) argo = "&r=1&o=" + value;
194 else argo = "";
195 updatehrefs();
196\}
197
198function updateqt (value) \{
199 if (value != "_cgiargqt_") argqt = "&qt=" + value;
200 else argqt = "";
201
202 // value of 2 signifies SQL search
203 if (value == 2) \{
204 replacesavedhrefs(/([?|&])a=q(&?)/,"$1a=sqlq$2");
205 \}
206
207 updatehrefs();
208\}
209
210function updatefqn () \{
211 value = document.PrefForm.fqn.options[document.PrefForm.fqn.selectedIndex].value;
212 if (value != _cgiargfqn_) argfqn = "&fqn=" + value;
213 else argfqn = "";
214 updatehrefs();
215\}
216
217function updateb (value) \{
218 if (value != _cgiargb_) argb = "&b=" + value;
219 else argb = "";
220 updatehrefs();
221\}
222
223function updatehd() \{
224 arghd="";
225 if (document.PrefForm.hd[0].checked) \{
226 if ("_cgiarghd_" != "0") arghd = "&hd=0";
227 \}
228 else \{
229 value = document.PrefForm.hdn[document.PrefForm.hdn.selectedIndex].value;
230 if (_cgiarghd_ != value) arghd = "&hd="+value;
231 \}
232 updatehrefs();
233\}
234
235
236function updateqb() \{
237
238 value = document.PrefForm.qb.options[document.PrefForm.qb.selectedIndex].value;
239 if (value != _cgiargqb_) argqb = "&qb=" + value;
240 else argqb = "";
241 updatehrefs();
242\}
243
244function updatel () \{
245 value = document.PrefForm.l.options[document.PrefForm.l.selectedIndex].value;
246 href = location.href;
247 if (href.match(/&l=[\\w\\-]+/)) href = href.replace(/&l=[\\w\\-]+/, "&l=" + value);
248 else href += "&l=" + value;
249 if (!location.href.match(/&nl=1$/)) href += "&nl=1";
250 while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
251 location.href = href + getargs();
252\}
253
254function updatev () \{
255 value = document.PrefForm.v.options[document.PrefForm.v.selectedIndex].value;
256 href = location.href;
257 if (href.match(/&v=\\d/)) href = href.replace(/&v=\\d/, "&v=" + value);
258 else href += "&v=" + value;
259 while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
260 location.href = href + getargs();
261\}
262
263function updatew () \{
264 value = document.PrefForm.w.options[document.PrefForm.w.selectedIndex].value;
265 href = location.href;
266 if (href.match(/&nw=[^&]+/)) href = href.replace(/&nw=[^&]+/, "&nw=" + value);
267 else href += "&nw=" + value;
268 if (!location.href.match(/&nl=0$/)) href += "&nl=0";
269 while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
270 location.href = href + getargs();
271\}
272
273function updatebook () \{
274 value = document.PrefForm.book.options[document.PrefForm.book.selectedIndex].value;
275 href = location.href;
276 if (href.match(/&book=[^&]+/)) href = href.replace(/&book=[^&]+/, "&book=" + value);
277 else href += "&book=" + value;
278 while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
279 location.href = href + getargs();
280\}
281
282}
283
284#######################################################################
285# headers
286# these are overridden so we can put an onLoad event handler
287# in the <body> tag of this page
288#######################################################################
289
290
291_header_ {_cgihead_
292_htmlhead_(class="bgimage" onLoad="initialize();")_startspacer__pagebanner_
293}
294
295# this declaration ends up being the same as style=restrict, never mind
296_header_[v=1] {_cgihead_
297_htmlhead_(onLoad="initialize();")_pagebanner_
298}
299
300
301#######################################################################
302# page content
303#######################################################################
304
305_pagetitle_ {_collectionname_: _textpreferences_}
306_imagethispage_ {_textpreferences_}
307
308_htmloptions_ {}
309
310_htmloptionson_ {
311<p>
312<tr>_fcoption_</tr>
313<p>
314<tr>_hloption_</tr>
315<p>
316<tr>_extlinkoption_</tr>
317_If_(_PreferenceDocsFromWeb_,<p>
318<tr>_intlinkoption_</tr>)
319}
320
321_fcoption_ {
322<td valign=baseline>_textdoclayout_</td>
323<td><input type=radio name=fc value=1 onClick="updatefc(1);"
324 _If_(_cgiargfc_, checked)>_textlayoutnavbar_<br>
325<input type=radio name=fc value=0 onClick="updatefc(0);"
326 _If_(_cgiargfc_,, checked)>_textlayoutnonavbar_</td>
327}
328
329_hloption_ {
330<td valign=baseline>_texttermhighlight_</td>
331<td><input type=radio name=hl value=1 onClick="updatehl(1);"
332 _If_(_cgiarghl_, checked)>_texttermhighlighton_<br>
333<input type=radio name=hl value=0 onClick="updatehl(0);"
334 _If_(_cgiarghl_,, checked)>_texttermhighlightoff_</td>
335}
336
337#search pref options
338
339
340# search type option
341_searchtypeoptionplain_ {
342<td valign=baseline>_textsearchtype_</td>
343<td>_textplainsearchtype_</td>
344}
345_searchtypeoptionform_ {
346<td valign=baseline>_textsearchtype_</td>
347<td>_textformsearchtype_</td>
348}
349_searchtypeoptionboth_ {
350<td valign=baseline>_textsearchtype_</td>
351<td><input type=radio name=qt value=0 onClick="updateqt(0);"
352 _If_(_cgiargqt_,, checked)>_textplainsearchtype_<br>
353<input type=radio name=qt value=1 onClick="updateqt(1);"
354 _If_(_cgiargqt_, checked)>_textformsearchtype_
355_If_("_cgiargsqlqto_" eq "1", <br>_searchtypeoptionplussql_)
356</td>
357}
358
359_searchtypeoptionplussql_ {
360<input type=radio name=qt value=2 onClick="updateqt(2);"
361 _If_(_cgiargqt_, checked)>_textsqlformsearchtype_</td>
362}
363
364_boxsizeoption_{
365<select name="qb" onChange="updateqb();">
366 <option value="0"_If_("_cgiargqb_" eq "0", selected)>_textregularbox_
367 <option value="1"_If_("_cgiargqb_" eq "1", selected)>_textlargebox_
368</select>
369}
370
371_formnumfieldoption_ {
372<select name="fqn" onChange="updatefqn();">
373 <option value="2"_If_("_cgiargfqn_" eq "2", selected)>2
374 <option value="4"_If_("_cgiargfqn_" eq "4", selected)>4
375 <option value="6"_If_("_cgiargfqn_" eq "6", selected)>6
376 <option value="8"_If_("_cgiargfqn_" eq "8", selected)>8
377</select>
378}
379
380_sqlformnumfieldoption_ {
381<select name="sqlfqn" onChange="updatesqlfqn();">
382 <option value="2"_If_("_cgiargsqlfqn_" eq "2", selected)>2
383 <option value="4"_If_("_cgiargsqlfqn_" eq "4", selected)>4
384 <option value="6"_If_("_cgiargsqlfqn_" eq "6", selected)>6
385 <option value="8"_If_("_cgiargsqlfqn_" eq "8", selected)>8
386</select>
387}
388
389_modeoption_ {
390<td valign=baseline>_textquerymode_</td>
391<td><input type=radio name=b value=0 onClick="updateb(0);"
392 _If_(_cgiargb_,, checked)>_textsimplemode_<br>
393<input type=radio name=b value=1 onClick="updateb(1);"
394 _If_(_cgiargb_, checked)>_textadvancedmode_</td>
395}
396
397_caseoption_ {
398<td valign=baseline>_textcasediffs_</td>
399<td><input type=radio name=k value=1 onClick="updatek(1);"
400 _If_(_cgiargk_, checked)>_textignorecase_<br>
401<input type=radio name=k value=0 onClick="updatek(0);"
402 _If_(_cgiargk_,, checked)>_textmatchcase_</td>
403}
404
405_caseoption_ [l=ar] {}
406_caseoption_ [l=zh] {}
407
408_stemoption_ {
409<td valign=baseline>_textwordends_</td>
410<td><input type=radio name=s value=1 onClick="updates(1);"
411 _If_(_cgiargs_, checked)>_textstem_<br>
412<input type=radio name=s value=0 onClick="updates(0);"
413 _If_(_cgiargs_,, checked)>_textnostem_</td>
414}
415
416_stemoption_ [l=zh] {}
417
418_accentoption_ {
419<td valign=baseline>_textaccentdiffs_</td>
420<td><input type=radio name=af value=1 onClick="updateaf(1);"
421 _If_(_cgiargaf_, checked)>_textignoreaccents_<br>
422<input type=radio name=af value=0 onClick="updateaf(0);"
423 _If_(_cgiargaf_,, checked)>_textmatchaccents_</td>
424}
425
426_searchhistoryop_ {
427<td valign=baseline>_textsearchhistory_</td>
428<td><input type=radio name="hd" value=0 onClick="updatehd();"
429 _If_("_cgiarghd_" eq "0", checked)>_textnohistorydisplay_<br>
430<input type=radio name="hd" value=1 onClick="updatehd();"
431 _If_("_cgiarghd_" eq "0",, checked)>_texthistorydisplay_</td>
432}
433
434_relateddocop_ {
435<td colspan=2><nobr><input type=checkbox name="rd" value=1 onClick="updaterd();" _If_("_cgiargrd_" eq "1", checked)>
436Display related documents</nobr></td>
437}
438
439_historynumrecords_{<select name="hdn" onChange="updatehd();">
440 <option value="5"_If_("_cgiarghd_" eq "5", selected)>5
441 <option value="10"_If_("_cgiarghd_" eq "10", selected)>10
442 <option value="15"_If_("_cgiarghd_" eq "15", selected)>15
443 <option value="20"_If_("_cgiarghd_" eq "20", selected)>20
444</select>}
445
446_maxdocoption_ {
447<select name="m" onChange="updatem();">
448 <option value="50"_If_("_cgiargm_" eq "50", selected)>50
449 <option value="100"_If_("_cgiargm_" eq "100", selected)>100
450 <option value="200"_If_("_cgiargm_" eq "200", selected)>200
451 <option value="-1"_If_("_cgiargm_" eq "-1", selected)>_textall_
452</select>
453}
454
455_hitsperpageoption_ {
456<select name="o" onChange="updateo();">
457 <option value="10"_If_("_cgiargo_" eq "10", selected)>10
458 <option value="20"_If_("_cgiargo_" eq "20", selected)>20
459 <option value="50"_If_("_cgiargo_" eq "50", selected)>50
460 <option value="-1"_If_("_cgiargo_" eq "-1", selected)>_textall_
461</select>
462}
463
464_extlinkoption_ {
465<td>_textextlink_</td>
466<td><select name="el" onChange="updateel();">
467 <option value="prompt"_If_("_cgiargel_" eq "prompt", selected)>
468 _textlinkinterm_
469 <option value="direct"_If_("_cgiargel_" eq "direct", selected)>
470 _textlinkdirect_
471</select></td>
472}
473
474_intlinkoption_ {
475<td>_textintlink_</td>
476<td><select name="il" onChange="updateil();">
477 <option value="l"_If_("_cgiargil_" eq "l", selected)>
478 _textdigitlib_
479 <option value="w"_If_("_cgiargil_" eq "w", selected)>
480 _textweb_
481</select></td>
482}
483
484# set from within pageaction
485_languageoption_ {}
486_encodingoption_ {}
487
488_formatoption_ {
489<td>_textformat_</td>
490<td><select name="v" onChange="updatev();">
491 <option value="0"_If_("_cgiargv_" eq "0", selected)>_textgraphical_
492 <option value="1"_If_("_cgiargv_" eq "1", selected)>_texttextual_
493</select></td>
494}
495
496
497_bookoption_ {
498<td valign=baseline>_textbookoption_</td>
499<td><select name="book" onChange="updatebook();">
500 <option value="off"_If_("_cgiargbook_" eq "off", selected)>_textbookvieweroff_
501 <option value="on"_If_("_cgiargbook_" eq "on", selected)>_textbookvieweron_
502</select></td>
503}
504
505_content_ {
506
507_optnavigationbar_
508_If_(_prefschanged_,<p>_prefschanged_<br><div class="divbar">&nbsp;</div>)
509
510<form name=PrefForm method=get action="_gwcgi_">
511<input type="hidden" name="e" value="_decodedcompressedoptions_">
512_If_(_collectionoption_,_collectionprefs_)
513_presentationprefs_
514_searchprefs_
515</form>
516}
517
518#search prefs
519_searchprefs_ {
520<table border=0 cellpadding=0 cellspacing=0 width=_pagewidth_><tr>
521<td><h3>_textsearchprefs_</h3></td>
522<td align=right><input type=submit name="bp" value="_textsetprefs_"></td>
523</tr></table>
524<blockquote>
525
526<table>
527<tr>_modeoption_</tr>
528
529<tr>_querytypedependantoptions_</tr>
530
531_If_("_cgiargks_" eq "1",
532<tr>_caseoption_</tr>
533)
534_If_("_cgiargss_" eq "1",
535<tr>_stemoption_</tr>
536)
537_If_("_cgiargafs_" eq "1",
538<tr>_accentoption_</tr>
539)
540<tr>_searchhistoryop_</tr>
541
542<!--
543Don't include this for now
544<tr>_relateddocop_</tr>
545-->
546
547<tr><td colspan=2>_textprefop_</td></tr>
548</table>
549</blockquote>
550<div class="divbar">&nbsp;</div>
551}
552
553_querytypedependantoptions_ {
554_If_("_cgiargct_" eq "0",_searchtypeoptionplain_,_mgppqueryoptions_)
555}
556_mgppqueryoptions_ {
557_If_("_cgiargqto_" eq "1", _searchtypeoptionplain_)
558_If_("_cgiargqto_" eq "2", _searchtypeoptionform_)
559_If_("_cgiargqto_" eq "3", _searchtypeoptionboth_)
560}
561
562# should this go somewhere??
563#<noscript><tr><td colspan=2><b>_query:textnojsformwarning_</b></td></tr></noscript>
564
565_collectionprefs_ {
566<h3>_textcollectionprefs_</h3>
567<blockquote>
568_collectionoption_
569</blockquote>
570<div class="divbar">&nbsp;</div>
571}
572
573_presentationprefs_ {
574<h3>_textpresentationprefs_</h3>
575<blockquote>
576<table>
577
578_If_(_languageoption_,<tr><td>_textlanguage_</td><td>_languageoption_</td></tr>)
579
580_If_(_encodingoption_,<tr><td>_textencoding_</td><td>_encodingoption_</td></tr>)
581
582<tr>_formatoption_</tr>
583_htmloptions_
584_If_("_tidyoption_" ne "untidy",<tr>_bookoption_</tr>)
585</table>
586</blockquote>
587<div class="divbar">&nbsp;</div>
588}
589
Note: See TracBrowser for help on using the repository browser.