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

Last change on this file since 28898 was 28898, checked in by ak19, 10 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
File size: 15.9 KB
RevLine 
[7343]1# this file must be UTF-8 encoded
2
[128]3package preferences
4
[876]5# set within server
[128]6
[876]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
[2415]15# this macro will be set to _textprefschanged_ when the "set preferences"
16# button has been pressed
17_prefschanged_ {}
[876]18
[148]19#######################################################################
[10872]20# global navigation links
[283]21#######################################################################
22
[10872]23# this is overridden here as we don't want a 'preferences' link on this page
[283]24
[10872]25_globallinks_ {_homelink_ _helplink_}
[283]26
27#######################################################################
[276]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
[876]34_ccsfunctions_ {argcc = "";
35savedccs = new Object();
[276]36
[876]37function initialize () \{
38 for (i = 0; i < document.links.length; i++)
39 savedhrefs[i] = document.links[i].href;
[276]40
[28888]41 s = "_cgiargccJssafe_";
[876]42 a = s.split (",");
[1950]43 for (i = 0; i < a.length ;i++) \{
[876]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;
[14083]48 argcc = argcc + "&cc=" + a[i];
[876]49 break;
50 \} else \{
51 savedccs[a[i]] = 0;
52 \}
53 \}
54 \}
55 updatehrefs();
56\}
[276]57
[876]58function updatecc (collection) \{
59 if (savedccs[collection] == 1) savedccs[collection] = 0;
60 else savedccs[collection] = 1;
[1950]61
[876]62 var i;
63 argcc = "";
[1717]64 var changed = 0;
[876]65 for (i in savedccs)
[1950]66 if (savedccs[i] == 1) \{
67 argcc += "&cc=" + i;
68 changed = 1;
69 \}
[1717]70 if (changed == 1) argcc += "&r=1";
[876]71 updatehrefs();
72\}
73}
[276]74
[876]75_standardfunctions_ {
76function initialize () \{
77 for (i = 0; i < document.links.length; i++)
78 savedhrefs[i] = document.links[i].href;
[4763]79
[876]80\}
[4763]81
[876]82}
[276]83
[876]84_getargsfunction_ {
85function getargs () \{
[12875]86 return argk + args + argaf + argm + argo + argrd + arghd + argb + argqb + argfqn + argqt_If_(_collectionoption_,_ccsargs_)_If_(_htmloptions_,_htmlargs_);
[876]87\}
88}
[276]89
[876]90_ccsargs_ {+ argcc}
91_htmlargs_ {+ argel + argil + argfc + arghl}
[276]92
[876]93_htmlfunctions_ {argel = "";
94argil = "";
95argfc = "";
96arghl = "";
[276]97
[876]98function updateel () \{
99 value = document.PrefForm.el.options[document.PrefForm.el.selectedIndex].value;
[28888]100 if (value != "_cgiargelJssafe_") argel = "&el=" + value;
[876]101 else argel = "";
102 updatehrefs();
103\}
[276]104
[876]105function updateil () \{
106 value = document.PrefForm.il.options[document.PrefForm.il.selectedIndex].value;
[28888]107 if (value != "_cgiargilJssafe_") argil = "&il=" + value;
[876]108 else argil = "";
109 updatehrefs();
110\}
[548]111
[2496]112function updatefc(value) \{
[28888]113 if (value != "_cgiargfcJssafe_") argfc = "&fc=" + value + "&f=" + value;
[2496]114 else argfc = "";
[876]115 updatehrefs();
116\}
[725]117
[2496]118function updatehl(value) \{
[28888]119 if (value != "_cgiarghlJssafe_") arghl = "&hl=" + value;
[2496]120 else arghl = "";
[876]121 updatehrefs();
122\}
123}
[725]124
[876]125_pagescriptextra_ {
126// preferences scripts generated from \_preferences:pagescriptextra\_
[591]127
[876]128savedhrefs = new Object();
129
130argk = "";
131args = "";
132argm = "";
[1950]133argrd = "";
[876]134argo = "";
135argb = "";
[942]136arghd = "";
[1922]137argqb = "";
138argfqn = "";
[12764]139argqt= "";
[12875]140argaf = "";
[1922]141
[901]142_If_(_collectionoption_,_ccsfunctions_,_standardfunctions_)
[876]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
[22091]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
[876]158function updatek (value) \{
[28888]159 if (value != "_cgiargkJssafe_") argk = "&k=" + value;
[876]160 else argk = "";
161 updatehrefs();
162\}
163
164function updates (value) \{
[28888]165 if (value != "_cgiargsJssafe_") args = "&s=" + value;
[876]166 else args = "";
167 updatehrefs();
168\}
169
[12875]170function updateaf (value) \{
[28888]171 if (value != "_cgiargafJssafe_") argaf = "&af=" + value;
[12875]172 else argaf = "";
173 updatehrefs();
174\}
175
[876]176function updatem () \{
177 value = document.PrefForm.m.options[document.PrefForm.m.selectedIndex].value;
[28888]178 if (value != "_cgiargmJssafe_") argm = "&r=1&m=" + value;
[876]179 else argm = "";
180 updatehrefs();
181\}
182
[28888]183
[1950]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
[876]192function updateo () \{
[28888]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;
[876]196 else argo = "";
197 updatehrefs();
198\}
199
[12764]200function updateqt (value) \{
[28888]201 if (value != "_cgiargqtJssafe_") argqt = "&qt=" + value;
[12764]202 else argqt = "";
[22091]203
204 // value of 2 signifies SQL search
205 if (value == 2) \{
206 replacesavedhrefs(/([?|&])a=q(&?)/,"$1a=sqlq$2");
207 \}
208
[12764]209 updatehrefs();
210\}
211
[1950]212function updatefqn () \{
213 value = document.PrefForm.fqn.options[document.PrefForm.fqn.selectedIndex].value;
[28888]214 if (value != "_cgiargfqnJssafe_") argfqn = "&fqn=" + value;
[1950]215 else argfqn = "";
216 updatehrefs();
217\}
218
[876]219function updateb (value) \{
[28888]220 if (value != "_cgiargbJssafe_") argb = "&b=" + value;
[876]221 else argb = "";
222 updatehrefs();
223\}
224
[1922]225function updatehd() \{
[1950]226 arghd="";
227 if (document.PrefForm.hd[0].checked) \{
[28888]228 if ("_cgiarghdJssafe_" != "0") arghd = "&hd=0";
[1950]229 \}
230 else \{
231 value = document.PrefForm.hdn[document.PrefForm.hdn.selectedIndex].value;
[28888]232 if ("_cgiarghdJssafe_" != value) arghd = "&hd="+value;
[1950]233 \}
234 updatehrefs();
235\}
[1946]236
[12764]237
238function updateqb() \{
239
240 value = document.PrefForm.qb.options[document.PrefForm.qb.selectedIndex].value;
[28888]241 if (value != "_cgiargqbJssafe_") argqb = "&qb=" + value;
[1950]242 else argqb = "";
[12764]243 updatehrefs();
[1922]244\}
245
[876]246function updatel () \{
247 value = document.PrefForm.l.options[document.PrefForm.l.selectedIndex].value;
[2265]248 href = location.href;
[5482]249 if (href.match(/&l=[\\w\\-]+/)) href = href.replace(/&l=[\\w\\-]+/, "&l=" + value);
[2265]250 else href += "&l=" + value;
251 if (!location.href.match(/&nl=1$/)) href += "&nl=1";
[7651]252 while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
[2265]253 location.href = href + getargs();
[876]254\}
255
256function updatev () \{
257 value = document.PrefForm.v.options[document.PrefForm.v.selectedIndex].value;
[2265]258 href = location.href;
259 if (href.match(/&v=\\d/)) href = href.replace(/&v=\\d/, "&v=" + value);
260 else href += "&v=" + value;
[7651]261 while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
[2265]262 location.href = href + getargs();
[876]263\}
264
265function updatew () \{
266 value = document.PrefForm.w.options[document.PrefForm.w.selectedIndex].value;
[2265]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";
[7651]271 while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
[2265]272 location.href = href + getargs();
[876]273\}
[1922]274
[14083]275function updatebook () \{
276 value = document.PrefForm.book.options[document.PrefForm.book.selectedIndex].value;
[13971]277 href = location.href;
[14083]278 if (href.match(/&book=[^&]+/)) href = href.replace(/&book=[^&]+/, "&book=" + value);
279 else href += "&book=" + value;
[13971]280 while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
281 location.href = href + getargs();
282\}
283
[276]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_
[10872]294_htmlhead_(class="bgimage" onLoad="initialize();")_startspacer__pagebanner_
[276]295}
296
297# this declaration ends up being the same as style=restrict, never mind
[548]298_header_[v=1] {_cgihead_
[276]299_htmlhead_(onLoad="initialize();")_pagebanner_
300}
301
302
303#######################################################################
[148]304# page content
305#######################################################################
[128]306
[148]307_pagetitle_ {_collectionname_: _textpreferences_}
[11155]308_imagethispage_ {_textpreferences_}
[148]309
[876]310_htmloptions_ {}
311
312_htmloptionson_ {
313<p>
[2496]314<tr>_fcoption_</tr>
[876]315<p>
[2496]316<tr>_hloption_</tr>
[876]317<p>
[1922]318<tr>_extlinkoption_</tr>
[876]319_If_(_PreferenceDocsFromWeb_,<p>
[1922]320<tr>_intlinkoption_</tr>)
[876]321}
322
323_fcoption_ {
[20744]324<td valign=baseline>_textdoclayout_</td>
[2496]325<td><input type=radio name=fc value=1 onClick="updatefc(1);"
[20744]326 _If_(_cgiargfc_, checked)>_textlayoutnavbar_<br>
[2496]327<input type=radio name=fc value=0 onClick="updatefc(0);"
[20744]328 _If_(_cgiargfc_,, checked)>_textlayoutnonavbar_</td>
[876]329}
330
331_hloption_ {
[20744]332<td valign=baseline>_texttermhighlight_</td>
[2496]333<td><input type=radio name=hl value=1 onClick="updatehl(1);"
[20744]334 _If_(_cgiarghl_, checked)>_texttermhighlighton_<br>
[2496]335<input type=radio name=hl value=0 onClick="updatehl(0);"
[20744]336 _If_(_cgiarghl_,, checked)>_texttermhighlightoff_</td>
[876]337}
338
[1950]339#search pref options
[12764]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);"
[22982]354 _If_("_cgiargqt_" eq "0", checked)>_textplainsearchtype_<br>
[12764]355<input type=radio name=qt value=1 onClick="updateqt(1);"
[22982]356 _If_("_cgiargqt_" eq "1", checked)>_textformsearchtype_
[22091]357_If_("_cgiargsqlqto_" eq "1", <br>_searchtypeoptionplussql_)
358</td>
[12764]359}
360
[22091]361_searchtypeoptionplussql_ {
362<input type=radio name=qt value=2 onClick="updateqt(2);"
[22982]363 _If_("_cgiargqt_" eq "2", checked)>_textsqlformsearchtype_</td>
[22091]364}
365
[1950]366_boxsizeoption_{
[12764]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>
[1950]371}
372
[12764]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
[22091]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
[12764]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
[1950]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] {}
[666]408_caseoption_ [l=zh] {}
409
[128]410_stemoption_ {
[1950]411<td valign=baseline>_textwordends_</td>
412<td><input type=radio name=s value=1 onClick="updates(1);"
[876]413 _If_(_cgiargs_, checked)>_textstem_<br>
[591]414<input type=radio name=s value=0 onClick="updates(0);"
[1922]415 _If_(_cgiargs_,, checked)>_textnostem_</td>
[128]416}
417
[666]418_stemoption_ [l=zh] {}
419
[12875]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}
[1950]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_ {
[2106]437<td colspan=2><nobr><input type=checkbox name="rd" value=1 onClick="updaterd();" _If_("_cgiargrd_" eq "1", checked)>
[1950]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
[128]448_maxdocoption_ {
[591]449<select name="m" onChange="updatem();">
[180]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
[13422]453 <option value="-1"_If_("_cgiargm_" eq "-1", selected)>_textall_
[128]454</select>
455}
456
457_hitsperpageoption_ {
[591]458<select name="o" onChange="updateo();">
[180]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
[13422]462 <option value="-1"_If_("_cgiargo_" eq "-1", selected)>_textall_
[128]463</select>
464}
465
[725]466_extlinkoption_ {
[1922]467<td>_textextlink_</td>
[1950]468<td><select name="el" onChange="updateel();">
[725]469 <option value="prompt"_If_("_cgiargel_" eq "prompt", selected)>
[876]470 _textlinkinterm_
[725]471 <option value="direct"_If_("_cgiargel_" eq "direct", selected)>
[876]472 _textlinkdirect_
[1922]473</select></td>
[725]474}
475
476_intlinkoption_ {
[1922]477<td>_textintlink_</td>
[1950]478<td><select name="il" onChange="updateil();">
[725]479 <option value="l"_If_("_cgiargil_" eq "l", selected)>
[876]480 _textdigitlib_
[725]481 <option value="w"_If_("_cgiargil_" eq "w", selected)>
[876]482 _textweb_
[1922]483</select></td>
[725]484}
485
[1950]486# set from within pageaction
[876]487_languageoption_ {}
[1856]488_encodingoption_ {}
[725]489
[276]490_formatoption_ {
[1922]491<td>_textformat_</td>
[1950]492<td><select name="v" onChange="updatev();">
[644]493 <option value="0"_If_("_cgiargv_" eq "0", selected)>_textgraphical_
494 <option value="1"_If_("_cgiargv_" eq "1", selected)>_texttextual_
[1922]495</select></td>
[276]496}
497
[13971]498
499_bookoption_ {
500<td valign=baseline>_textbookoption_</td>
[14083]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>
[13971]505}
506
[128]507_content_ {
[13971]508
[7503]509_optnavigationbar_
[10872]510_If_(_prefschanged_,<p>_prefschanged_<br><div class="divbar">&nbsp;</div>)
511
[128]512<form name=PrefForm method=get action="_gwcgi_">
[28898]513<input type="hidden" name="e" value="_decodedcompressedoptionsAttrsafe_">
[876]514_If_(_collectionoption_,_collectionprefs_)
515_presentationprefs_
[4763]516_searchprefs_
[876]517</form>
518}
519
[4763]520#search prefs
521_searchprefs_ {
[12764]522<table border=0 cellpadding=0 cellspacing=0 width=_pagewidth_><tr>
[2424]523<td><h3>_textsearchprefs_</h3></td>
524<td align=right><input type=submit name="bp" value="_textsetprefs_"></td>
[12764]525</tr></table>
[13423]526<blockquote>
[2424]527
[1950]528<table>
[12875]529<tr>_modeoption_</tr>
530
[12764]531<tr>_querytypedependantoptions_</tr>
[128]532
[12875]533_If_("_cgiargks_" eq "1",
[1950]534<tr>_caseoption_</tr>
[12875]535)
536_If_("_cgiargss_" eq "1",
[1950]537<tr>_stemoption_</tr>
[12779]538)
[12875]539_If_("_cgiargafs_" eq "1",
540<tr>_accentoption_</tr>
541)
[1950]542<tr>_searchhistoryop_</tr>
[1922]543
[2299]544<!--
545Don't include this for now
[1950]546<tr>_relateddocop_</tr>
[2299]547-->
[1950]548
549<tr><td colspan=2>_textprefop_</td></tr>
550</table>
551</blockquote>
[10872]552<div class="divbar">&nbsp;</div>
[876]553}
[725]554
[4763]555_querytypedependantoptions_ {
[12764]556_If_("_cgiargct_" eq "0",_searchtypeoptionplain_,_mgppqueryoptions_)
[4763]557}
[12764]558_mgppqueryoptions_ {
559_If_("_cgiargqto_" eq "1", _searchtypeoptionplain_)
560_If_("_cgiargqto_" eq "2", _searchtypeoptionform_)
561_If_("_cgiargqto_" eq "3", _searchtypeoptionboth_)
[4763]562}
563
[12764]564# should this go somewhere??
565#<noscript><tr><td colspan=2><b>_query:textnojsformwarning_</b></td></tr></noscript>
[4763]566
[876]567_collectionprefs_ {
568<h3>_textcollectionprefs_</h3>
[13423]569<blockquote>
[876]570_collectionoption_
[1950]571</blockquote>
[10872]572<div class="divbar">&nbsp;</div>
[876]573}
[725]574
[876]575_presentationprefs_ {
576<h3>_textpresentationprefs_</h3>
[13423]577<blockquote>
[20744]578<table>
[876]579
[1950]580_If_(_languageoption_,<tr><td>_textlanguage_</td><td>_languageoption_</td></tr>)
[276]581
[1950]582_If_(_encodingoption_,<tr><td>_textencoding_</td><td>_encodingoption_</td></tr>)
[591]583
[13971]584<tr>_formatoption_</tr>
[20744]585_htmloptions_
[13982]586_If_("_tidyoption_" ne "untidy",<tr>_bookoption_</tr>)
[13971]587</table>
[1950]588</blockquote>
[10872]589<div class="divbar">&nbsp;</div>
[128]590}
[148]591
Note: See TracBrowser for help on using the repository browser.