root/main/trunk/greenstone2/macros/pref.dm @ 32220

Revision 28898, 15.9 KB (checked in by ak19, 6 years ago)

1. The cgiargq query variable is now no longer escaped in the 3 simply or large forms that use it. fqv and other js escaped fields are unchanged, since the jssafe now ensures that backslashes are escaped for macro files, so these resolve correctly in query.dm. 2. securitytools.cpp and .h updated to additionally escape back slashes for macro files when javascript escaping. This is done by default, since jssafe variants of cgiargs are all that are used, and they're used in macro files. 3. Encoded versions of decodedcompressedoptions are now used in all macro files. They're always used in attributes, so the attrsafe version which is set in receptionist.cpp is used.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
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 = "_cgiargccJssafe_";
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 != "_cgiargelJssafe_") 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 != "_cgiargilJssafe_") argil = "&il=" + value;
108  else argil = "";
109  updatehrefs();
110\}
111
112function updatefc(value) \{
113  if (value != "_cgiargfcJssafe_") argfc = "&fc=" + value + "&f=" + value;
114  else argfc = "";
115  updatehrefs();
116\}
117
118function updatehl(value) \{
119  if (value != "_cgiarghlJssafe_") 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 != "_cgiargkJssafe_") argk = "&k=" + value;
160  else argk = "";
161  updatehrefs();
162\}
163
164function updates (value) \{
165  if (value != "_cgiargsJssafe_") args = "&s=" + value;
166  else args = "";
167  updatehrefs();
168\}
169
170function updateaf (value) \{
171  if (value != "_cgiargafJssafe_") 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 != "_cgiargmJssafe_") argm = "&r=1&m=" + value;
179  else argm = "";
180  updatehrefs();
181\}
182
183
184function updaterd () \{
185  if (document.PrefForm.rd.checked)
186    _If_("_cgiargrd_" eq "1",argrd="";,argrd="&rd=1";)
187  else
188    _If_("_cgiargrd_" ne "1",argrd="";,argrd="&rd=0";)
189  updatehrefs();
190\}
191
192function updateo () \{
193  value = document.PrefForm.o.options[document.PrefForm.o.selectedIndex].value; 
194  //if (value != cgiargo ) argo = "&r=1&o=" + value;
195  if (value != "_cgiargoJssafe_") argo = "&r=1&o=" + value; 
196  else argo = "";
197  updatehrefs();
198\}
199
200function updateqt (value) \{
201  if (value != "_cgiargqtJssafe_") argqt = "&qt=" + value;
202  else argqt = "";
203
204  // value of 2 signifies SQL search
205  if (value == 2) \{
206    replacesavedhrefs(/([?|&])a=q(&?)/,"$1a=sqlq$2");
207  \}
208 
209  updatehrefs();
210\}
211
212function updatefqn () \{
213  value = document.PrefForm.fqn.options[document.PrefForm.fqn.selectedIndex].value;
214  if (value != "_cgiargfqnJssafe_") argfqn = "&fqn=" + value;
215  else argfqn = "";
216  updatehrefs();
217\}
218
219function updateb (value) \{
220  if (value != "_cgiargbJssafe_") argb = "&b=" + value;
221  else argb = "";
222  updatehrefs();
223\}
224
225function updatehd() \{
226  arghd="";
227  if (document.PrefForm.hd[0].checked) \{
228     if ("_cgiarghdJssafe_" != "0") arghd = "&hd=0";
229  \}
230  else \{
231     value = document.PrefForm.hdn[document.PrefForm.hdn.selectedIndex].value;
232     if ("_cgiarghdJssafe_" != value) arghd = "&hd="+value;
233  \}
234  updatehrefs();
235\}
236
237
238function updateqb() \{
239
240   value = document.PrefForm.qb.options[document.PrefForm.qb.selectedIndex].value;
241   if (value != "_cgiargqbJssafe_") argqb = "&qb=" + value;
242  else argqb = "";
243   updatehrefs();
244\}
245
246function updatel () \{
247  value = document.PrefForm.l.options[document.PrefForm.l.selectedIndex].value;
248  href = location.href;
249  if (href.match(/&l=[\\w\\-]+/)) href = href.replace(/&l=[\\w\\-]+/, "&l=" + value);
250  else href += "&l=" + value;
251  if (!location.href.match(/&nl=1$/)) href += "&nl=1";
252  while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
253  location.href = href + getargs();
254\}
255
256function updatev () \{
257  value = document.PrefForm.v.options[document.PrefForm.v.selectedIndex].value;
258  href = location.href;
259  if (href.match(/&v=\\d/)) href = href.replace(/&v=\\d/, "&v=" + value);
260  else href += "&v=" + value;
261  while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
262  location.href = href + getargs();
263\}
264
265function updatew () \{
266  value = document.PrefForm.w.options[document.PrefForm.w.selectedIndex].value;
267  href = location.href;
268  if (href.match(/&nw=[^&]+/)) href = href.replace(/&nw=[^&]+/, "&nw=" + value);
269  else href += "&nw=" + value;
270  if (!location.href.match(/&nl=0$/)) href += "&nl=0";
271  while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
272  location.href = href + getargs();
273\}
274
275function updatebook () \{
276  value = document.PrefForm.book.options[document.PrefForm.book.selectedIndex].value;
277  href = location.href;
278  if (href.match(/&book=[^&]+/)) href = href.replace(/&book=[^&]+/, "&book=" + value);
279  else href += "&book=" + value;
280  while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
281  location.href = href + getargs();
282\}
283
284}
285
286#######################################################################
287# headers
288# these are overridden so we can put an onLoad event handler
289# in the <body> tag of this page
290#######################################################################
291
292
293_header_ {_cgihead_
294_htmlhead_(class="bgimage" onLoad="initialize();")_startspacer__pagebanner_
295}
296
297# this declaration ends up being the same as style=restrict, never mind
298_header_[v=1] {_cgihead_
299_htmlhead_(onLoad="initialize();")_pagebanner_
300}
301
302
303#######################################################################
304# page content
305#######################################################################
306
307_pagetitle_ {_collectionname_: _textpreferences_}
308_imagethispage_ {_textpreferences_}
309
310_htmloptions_ {}
311
312_htmloptionson_ {
313<p>
314<tr>_fcoption_</tr>
315<p>
316<tr>_hloption_</tr>
317<p>
318<tr>_extlinkoption_</tr>
319_If_(_PreferenceDocsFromWeb_,<p>
320<tr>_intlinkoption_</tr>)
321}
322
323_fcoption_ {
324<td valign=baseline>_textdoclayout_</td>
325<td><input type=radio name=fc value=1 onClick="updatefc(1);"
326        _If_(_cgiargfc_, checked)>_textlayoutnavbar_<br>
327<input type=radio name=fc value=0 onClick="updatefc(0);"
328        _If_(_cgiargfc_,, checked)>_textlayoutnonavbar_</td>
329}
330
331_hloption_ {
332<td valign=baseline>_texttermhighlight_</td>
333<td><input type=radio name=hl value=1 onClick="updatehl(1);"
334        _If_(_cgiarghl_, checked)>_texttermhighlighton_<br>
335<input type=radio name=hl value=0 onClick="updatehl(0);"
336        _If_(_cgiarghl_,, checked)>_texttermhighlightoff_</td>
337}
338
339#search pref options
340
341
342# search type option
343_searchtypeoptionplain_ {
344<td valign=baseline>_textsearchtype_</td>
345<td>_textplainsearchtype_</td>
346}
347_searchtypeoptionform_ {
348<td valign=baseline>_textsearchtype_</td>
349<td>_textformsearchtype_</td>
350}
351_searchtypeoptionboth_ {
352<td valign=baseline>_textsearchtype_</td>
353<td><input type=radio name=qt value=0 onClick="updateqt(0);"
354        _If_("_cgiargqt_" eq "0", checked)>_textplainsearchtype_<br>
355<input type=radio name=qt value=1 onClick="updateqt(1);"
356        _If_("_cgiargqt_" eq "1", checked)>_textformsearchtype_
357_If_("_cgiargsqlqto_" eq "1", <br>_searchtypeoptionplussql_)
358</td>
359}
360
361_searchtypeoptionplussql_ {
362<input type=radio name=qt value=2 onClick="updateqt(2);"
363        _If_("_cgiargqt_" eq "2", checked)>_textsqlformsearchtype_</td>
364}
365
366_boxsizeoption_{
367<select name="qb" onChange="updateqb();">
368  <option value="0"_If_("_cgiargqb_" eq "0", selected)>_textregularbox_
369  <option value="1"_If_("_cgiargqb_" eq "1", selected)>_textlargebox_
370</select>
371}
372
373_formnumfieldoption_ {
374<select name="fqn" onChange="updatefqn();">
375  <option value="2"_If_("_cgiargfqn_" eq "2", selected)>2 
376  <option value="4"_If_("_cgiargfqn_" eq "4", selected)>4
377  <option value="6"_If_("_cgiargfqn_" eq "6", selected)>6
378  <option value="8"_If_("_cgiargfqn_" eq "8", selected)>8
379</select>
380}
381
382_sqlformnumfieldoption_ {
383<select name="sqlfqn" onChange="updatesqlfqn();">
384  <option value="2"_If_("_cgiargsqlfqn_" eq "2", selected)>2 
385  <option value="4"_If_("_cgiargsqlfqn_" eq "4", selected)>4
386  <option value="6"_If_("_cgiargsqlfqn_" eq "6", selected)>6
387  <option value="8"_If_("_cgiargsqlfqn_" eq "8", selected)>8
388</select>
389}
390
391_modeoption_ {
392<td valign=baseline>_textquerymode_</td>
393<td><input type=radio name=b value=0 onClick="updateb(0);"
394        _If_(_cgiargb_,, checked)>_textsimplemode_<br>
395<input type=radio name=b value=1 onClick="updateb(1);"
396        _If_(_cgiargb_, checked)>_textadvancedmode_</td>
397}
398
399_caseoption_ {
400<td valign=baseline>_textcasediffs_</td>
401<td><input type=radio name=k value=1 onClick="updatek(1);"
402        _If_(_cgiargk_, checked)>_textignorecase_<br>
403<input type=radio name=k value=0 onClick="updatek(0);"
404        _If_(_cgiargk_,, checked)>_textmatchcase_</td>
405}
406
407_caseoption_ [l=ar] {}
408_caseoption_ [l=zh] {}
409
410_stemoption_ {
411<td valign=baseline>_textwordends_</td>
412<td><input type=radio name=s value=1 onClick="updates(1);"
413  _If_(_cgiargs_, checked)>_textstem_<br>
414<input type=radio name=s value=0 onClick="updates(0);"
415  _If_(_cgiargs_,, checked)>_textnostem_</td>
416}
417
418_stemoption_ [l=zh] {}
419
420_accentoption_ {
421<td valign=baseline>_textaccentdiffs_</td>
422<td><input type=radio name=af value=1 onClick="updateaf(1);"
423  _If_(_cgiargaf_, checked)>_textignoreaccents_<br>
424<input type=radio name=af value=0 onClick="updateaf(0);"
425  _If_(_cgiargaf_,, checked)>_textmatchaccents_</td>
426}
427
428_searchhistoryop_ {
429<td valign=baseline>_textsearchhistory_</td>
430<td><input type=radio name="hd" value=0 onClick="updatehd();"
431                _If_("_cgiarghd_" eq "0", checked)>_textnohistorydisplay_<br>
432<input type=radio name="hd" value=1 onClick="updatehd();"
433        _If_("_cgiarghd_" eq "0",, checked)>_texthistorydisplay_</td>   
434}
435
436_relateddocop_ {
437<td colspan=2><nobr><input type=checkbox name="rd" value=1 onClick="updaterd();" _If_("_cgiargrd_" eq "1", checked)>
438Display related documents</nobr></td>
439}
440
441_historynumrecords_{<select name="hdn" onChange="updatehd();">
442    <option value="5"_If_("_cgiarghd_" eq "5", selected)>5
443    <option value="10"_If_("_cgiarghd_" eq "10", selected)>10
444    <option value="15"_If_("_cgiarghd_" eq "15", selected)>15
445    <option value="20"_If_("_cgiarghd_" eq "20", selected)>20
446</select>}
447
448_maxdocoption_ {
449<select name="m" onChange="updatem();">
450  <option value="50"_If_("_cgiargm_" eq "50", selected)>50
451  <option value="100"_If_("_cgiargm_" eq "100", selected)>100
452  <option value="200"_If_("_cgiargm_" eq "200", selected)>200
453  <option value="-1"_If_("_cgiargm_" eq "-1", selected)>_textall_
454</select>
455}
456
457_hitsperpageoption_ {
458<select name="o" onChange="updateo();">
459  <option value="10"_If_("_cgiargo_" eq "10", selected)>10 
460  <option value="20"_If_("_cgiargo_" eq "20", selected)>20
461  <option value="50"_If_("_cgiargo_" eq "50", selected)>50
462  <option value="-1"_If_("_cgiargo_" eq "-1", selected)>_textall_
463</select>
464}
465
466_extlinkoption_ {
467<td>_textextlink_</td>
468<td><select name="el" onChange="updateel();">
469  <option value="prompt"_If_("_cgiargel_" eq "prompt", selected)>
470     _textlinkinterm_
471  <option value="direct"_If_("_cgiargel_" eq "direct", selected)>
472     _textlinkdirect_
473</select></td>
474}
475
476_intlinkoption_ {
477<td>_textintlink_</td>
478<td><select name="il" onChange="updateil();">
479  <option value="l"_If_("_cgiargil_" eq "l", selected)>
480     _textdigitlib_
481  <option value="w"_If_("_cgiargil_" eq "w", selected)>
482     _textweb_
483</select></td>
484}
485
486# set from within pageaction
487_languageoption_ {}
488_encodingoption_ {}
489
490_formatoption_ {
491<td>_textformat_</td>
492<td><select name="v" onChange="updatev();">
493  <option value="0"_If_("_cgiargv_" eq "0", selected)>_textgraphical_
494  <option value="1"_If_("_cgiargv_" eq "1", selected)>_texttextual_
495</select></td>
496}
497
498
499_bookoption_ {
500<td valign=baseline>_textbookoption_</td>
501<td><select name="book" onChange="updatebook();">
502    <option value="off"_If_("_cgiargbook_" eq "off", selected)>_textbookvieweroff_
503    <option value="on"_If_("_cgiargbook_" eq "on", selected)>_textbookvieweron_
504</select></td>
505}
506
507_content_ {
508
509_optnavigationbar_
510_If_(_prefschanged_,<p>_prefschanged_<br><div class="divbar">&nbsp;</div>)
511
512<form name=PrefForm method=get action="_gwcgi_">
513<input type="hidden" name="e" value="_decodedcompressedoptionsAttrsafe_">
514_If_(_collectionoption_,_collectionprefs_)
515_presentationprefs_
516_searchprefs_
517</form>
518}
519
520#search prefs
521_searchprefs_ {
522<table border=0 cellpadding=0 cellspacing=0 width=_pagewidth_><tr>
523<td><h3>_textsearchprefs_</h3></td>
524<td align=right><input type=submit name="bp" value="_textsetprefs_"></td>
525</tr></table>
526<blockquote>
527
528<table>
529<tr>_modeoption_</tr>
530
531<tr>_querytypedependantoptions_</tr>
532
533_If_("_cgiargks_" eq "1",
534<tr>_caseoption_</tr>
535)
536_If_("_cgiargss_" eq "1",
537<tr>_stemoption_</tr>
538)
539_If_("_cgiargafs_" eq "1",
540<tr>_accentoption_</tr>
541)
542<tr>_searchhistoryop_</tr>
543
544<!--
545Don't include this for now
546<tr>_relateddocop_</tr>
547-->
548
549<tr><td colspan=2>_textprefop_</td></tr>
550</table>
551</blockquote>
552<div class="divbar">&nbsp;</div>
553}
554
555_querytypedependantoptions_ {
556_If_("_cgiargct_" eq "0",_searchtypeoptionplain_,_mgppqueryoptions_)
557}
558_mgppqueryoptions_ {
559_If_("_cgiargqto_" eq "1", _searchtypeoptionplain_)
560_If_("_cgiargqto_" eq "2", _searchtypeoptionform_)
561_If_("_cgiargqto_" eq "3", _searchtypeoptionboth_)
562}
563
564# should this go somewhere??
565#<noscript><tr><td colspan=2><b>_query:textnojsformwarning_</b></td></tr></noscript>
566
567_collectionprefs_ {
568<h3>_textcollectionprefs_</h3>
569<blockquote>
570_collectionoption_
571</blockquote>
572<div class="divbar">&nbsp;</div>
573}
574
575_presentationprefs_ {
576<h3>_textpresentationprefs_</h3>
577<blockquote>
578<table>
579
580_If_(_languageoption_,<tr><td>_textlanguage_</td><td>_languageoption_</td></tr>)
581
582_If_(_encodingoption_,<tr><td>_textencoding_</td><td>_encodingoption_</td></tr>)
583
584<tr>_formatoption_</tr>
585_htmloptions_
586_If_("_tidyoption_" ne "untidy",<tr>_bookoption_</tr>)
587</table>
588</blockquote>
589<div class="divbar">&nbsp;</div>
590}
591
Note: See TracBrowser for help on using the browser.