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

Last change on this file since 28498 was 22982, checked in by kjdon, 14 years ago

deciding which qt value should be checked is no longer 0/1 as we have a value of 2 for sqlform. So now test whether the value is equal to 0,1,2

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 15.8 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
[876]41 s = "_cgiargcc_";
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;
100 if (value != "_cgiargel_") argel = "&el=" + value;
101 else argel = "";
102 updatehrefs();
103\}
[276]104
[876]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\}
[548]111
[2496]112function updatefc(value) \{
113 if (value != _cgiargfc_) argfc = "&fc=" + value + "&f=" + value;
114 else argfc = "";
[876]115 updatehrefs();
116\}
[725]117
[2496]118function updatehl(value) \{
119 if (value != _cgiarghl_) arghl = "&hl=" + value;
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) \{
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
[12875]170function updateaf (value) \{
171 if (value != _cgiargaf_) argaf = "&af=" + value;
172 else argaf = "";
173 updatehrefs();
174\}
175
[876]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
[1950]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
[876]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
[12764]198function updateqt (value) \{
[22982]199 if (value != _cgiargqt_) argqt = "&qt=" + value;
[12764]200 else argqt = "";
[22091]201
202 // value of 2 signifies SQL search
203 if (value == 2) \{
204 replacesavedhrefs(/([?|&])a=q(&?)/,"$1a=sqlq$2");
205 \}
206
[12764]207 updatehrefs();
208\}
209
[1950]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
[876]217function updateb (value) \{
218 if (value != _cgiargb_) argb = "&b=" + value;
219 else argb = "";
220 updatehrefs();
221\}
222
[1922]223function updatehd() \{
[1950]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\}
[1946]234
[12764]235
236function updateqb() \{
237
238 value = document.PrefForm.qb.options[document.PrefForm.qb.selectedIndex].value;
239 if (value != _cgiargqb_) argqb = "&qb=" + value;
[1950]240 else argqb = "";
[12764]241 updatehrefs();
[1922]242\}
243
[876]244function updatel () \{
245 value = document.PrefForm.l.options[document.PrefForm.l.selectedIndex].value;
[2265]246 href = location.href;
[5482]247 if (href.match(/&l=[\\w\\-]+/)) href = href.replace(/&l=[\\w\\-]+/, "&l=" + value);
[2265]248 else href += "&l=" + value;
249 if (!location.href.match(/&nl=1$/)) href += "&nl=1";
[7651]250 while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
[2265]251 location.href = href + getargs();
[876]252\}
253
254function updatev () \{
255 value = document.PrefForm.v.options[document.PrefForm.v.selectedIndex].value;
[2265]256 href = location.href;
257 if (href.match(/&v=\\d/)) href = href.replace(/&v=\\d/, "&v=" + value);
258 else href += "&v=" + value;
[7651]259 while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
[2265]260 location.href = href + getargs();
[876]261\}
262
263function updatew () \{
264 value = document.PrefForm.w.options[document.PrefForm.w.selectedIndex].value;
[2265]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";
[7651]269 while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
[2265]270 location.href = href + getargs();
[876]271\}
[1922]272
[14083]273function updatebook () \{
274 value = document.PrefForm.book.options[document.PrefForm.book.selectedIndex].value;
[13971]275 href = location.href;
[14083]276 if (href.match(/&book=[^&]+/)) href = href.replace(/&book=[^&]+/, "&book=" + value);
277 else href += "&book=" + value;
[13971]278 while (href.match(/&cc=[\\w]+/)) href = href.replace(/&cc=[\\w]+/, "");
279 location.href = href + getargs();
280\}
281
[276]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_
[10872]292_htmlhead_(class="bgimage" onLoad="initialize();")_startspacer__pagebanner_
[276]293}
294
295# this declaration ends up being the same as style=restrict, never mind
[548]296_header_[v=1] {_cgihead_
[276]297_htmlhead_(onLoad="initialize();")_pagebanner_
298}
299
300
301#######################################################################
[148]302# page content
303#######################################################################
[128]304
[148]305_pagetitle_ {_collectionname_: _textpreferences_}
[11155]306_imagethispage_ {_textpreferences_}
[148]307
[876]308_htmloptions_ {}
309
310_htmloptionson_ {
311<p>
[2496]312<tr>_fcoption_</tr>
[876]313<p>
[2496]314<tr>_hloption_</tr>
[876]315<p>
[1922]316<tr>_extlinkoption_</tr>
[876]317_If_(_PreferenceDocsFromWeb_,<p>
[1922]318<tr>_intlinkoption_</tr>)
[876]319}
320
321_fcoption_ {
[20744]322<td valign=baseline>_textdoclayout_</td>
[2496]323<td><input type=radio name=fc value=1 onClick="updatefc(1);"
[20744]324 _If_(_cgiargfc_, checked)>_textlayoutnavbar_<br>
[2496]325<input type=radio name=fc value=0 onClick="updatefc(0);"
[20744]326 _If_(_cgiargfc_,, checked)>_textlayoutnonavbar_</td>
[876]327}
328
329_hloption_ {
[20744]330<td valign=baseline>_texttermhighlight_</td>
[2496]331<td><input type=radio name=hl value=1 onClick="updatehl(1);"
[20744]332 _If_(_cgiarghl_, checked)>_texttermhighlighton_<br>
[2496]333<input type=radio name=hl value=0 onClick="updatehl(0);"
[20744]334 _If_(_cgiarghl_,, checked)>_texttermhighlightoff_</td>
[876]335}
336
[1950]337#search pref options
[12764]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);"
[22982]352 _If_("_cgiargqt_" eq "0", checked)>_textplainsearchtype_<br>
[12764]353<input type=radio name=qt value=1 onClick="updateqt(1);"
[22982]354 _If_("_cgiargqt_" eq "1", checked)>_textformsearchtype_
[22091]355_If_("_cgiargsqlqto_" eq "1", <br>_searchtypeoptionplussql_)
356</td>
[12764]357}
358
[22091]359_searchtypeoptionplussql_ {
360<input type=radio name=qt value=2 onClick="updateqt(2);"
[22982]361 _If_("_cgiargqt_" eq "2", checked)>_textsqlformsearchtype_</td>
[22091]362}
363
[1950]364_boxsizeoption_{
[12764]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>
[1950]369}
370
[12764]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
[22091]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
[12764]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
[1950]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] {}
[666]406_caseoption_ [l=zh] {}
407
[128]408_stemoption_ {
[1950]409<td valign=baseline>_textwordends_</td>
410<td><input type=radio name=s value=1 onClick="updates(1);"
[876]411 _If_(_cgiargs_, checked)>_textstem_<br>
[591]412<input type=radio name=s value=0 onClick="updates(0);"
[1922]413 _If_(_cgiargs_,, checked)>_textnostem_</td>
[128]414}
415
[666]416_stemoption_ [l=zh] {}
417
[12875]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}
[1950]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_ {
[2106]435<td colspan=2><nobr><input type=checkbox name="rd" value=1 onClick="updaterd();" _If_("_cgiargrd_" eq "1", checked)>
[1950]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
[128]446_maxdocoption_ {
[591]447<select name="m" onChange="updatem();">
[180]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
[13422]451 <option value="-1"_If_("_cgiargm_" eq "-1", selected)>_textall_
[128]452</select>
453}
454
455_hitsperpageoption_ {
[591]456<select name="o" onChange="updateo();">
[180]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
[13422]460 <option value="-1"_If_("_cgiargo_" eq "-1", selected)>_textall_
[128]461</select>
462}
463
[725]464_extlinkoption_ {
[1922]465<td>_textextlink_</td>
[1950]466<td><select name="el" onChange="updateel();">
[725]467 <option value="prompt"_If_("_cgiargel_" eq "prompt", selected)>
[876]468 _textlinkinterm_
[725]469 <option value="direct"_If_("_cgiargel_" eq "direct", selected)>
[876]470 _textlinkdirect_
[1922]471</select></td>
[725]472}
473
474_intlinkoption_ {
[1922]475<td>_textintlink_</td>
[1950]476<td><select name="il" onChange="updateil();">
[725]477 <option value="l"_If_("_cgiargil_" eq "l", selected)>
[876]478 _textdigitlib_
[725]479 <option value="w"_If_("_cgiargil_" eq "w", selected)>
[876]480 _textweb_
[1922]481</select></td>
[725]482}
483
[1950]484# set from within pageaction
[876]485_languageoption_ {}
[1856]486_encodingoption_ {}
[725]487
[276]488_formatoption_ {
[1922]489<td>_textformat_</td>
[1950]490<td><select name="v" onChange="updatev();">
[644]491 <option value="0"_If_("_cgiargv_" eq "0", selected)>_textgraphical_
492 <option value="1"_If_("_cgiargv_" eq "1", selected)>_texttextual_
[1922]493</select></td>
[276]494}
495
[13971]496
497_bookoption_ {
498<td valign=baseline>_textbookoption_</td>
[14083]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>
[13971]503}
504
[128]505_content_ {
[13971]506
[7503]507_optnavigationbar_
[10872]508_If_(_prefschanged_,<p>_prefschanged_<br><div class="divbar">&nbsp;</div>)
509
[128]510<form name=PrefForm method=get action="_gwcgi_">
[13459]511<input type="hidden" name="e" value="_decodedcompressedoptions_">
[876]512_If_(_collectionoption_,_collectionprefs_)
513_presentationprefs_
[4763]514_searchprefs_
[876]515</form>
516}
517
[4763]518#search prefs
519_searchprefs_ {
[12764]520<table border=0 cellpadding=0 cellspacing=0 width=_pagewidth_><tr>
[2424]521<td><h3>_textsearchprefs_</h3></td>
522<td align=right><input type=submit name="bp" value="_textsetprefs_"></td>
[12764]523</tr></table>
[13423]524<blockquote>
[2424]525
[1950]526<table>
[12875]527<tr>_modeoption_</tr>
528
[12764]529<tr>_querytypedependantoptions_</tr>
[128]530
[12875]531_If_("_cgiargks_" eq "1",
[1950]532<tr>_caseoption_</tr>
[12875]533)
534_If_("_cgiargss_" eq "1",
[1950]535<tr>_stemoption_</tr>
[12779]536)
[12875]537_If_("_cgiargafs_" eq "1",
538<tr>_accentoption_</tr>
539)
[1950]540<tr>_searchhistoryop_</tr>
[1922]541
[2299]542<!--
543Don't include this for now
[1950]544<tr>_relateddocop_</tr>
[2299]545-->
[1950]546
547<tr><td colspan=2>_textprefop_</td></tr>
548</table>
549</blockquote>
[10872]550<div class="divbar">&nbsp;</div>
[876]551}
[725]552
[4763]553_querytypedependantoptions_ {
[12764]554_If_("_cgiargct_" eq "0",_searchtypeoptionplain_,_mgppqueryoptions_)
[4763]555}
[12764]556_mgppqueryoptions_ {
557_If_("_cgiargqto_" eq "1", _searchtypeoptionplain_)
558_If_("_cgiargqto_" eq "2", _searchtypeoptionform_)
559_If_("_cgiargqto_" eq "3", _searchtypeoptionboth_)
[4763]560}
561
[12764]562# should this go somewhere??
563#<noscript><tr><td colspan=2><b>_query:textnojsformwarning_</b></td></tr></noscript>
[4763]564
[876]565_collectionprefs_ {
566<h3>_textcollectionprefs_</h3>
[13423]567<blockquote>
[876]568_collectionoption_
[1950]569</blockquote>
[10872]570<div class="divbar">&nbsp;</div>
[876]571}
[725]572
[876]573_presentationprefs_ {
574<h3>_textpresentationprefs_</h3>
[13423]575<blockquote>
[20744]576<table>
[876]577
[1950]578_If_(_languageoption_,<tr><td>_textlanguage_</td><td>_languageoption_</td></tr>)
[276]579
[1950]580_If_(_encodingoption_,<tr><td>_textencoding_</td><td>_encodingoption_</td></tr>)
[591]581
[13971]582<tr>_formatoption_</tr>
[20744]583_htmloptions_
[13982]584_If_("_tidyoption_" ne "untidy",<tr>_bookoption_</tr>)
[13971]585</table>
[1950]586</blockquote>
[10872]587<div class="divbar">&nbsp;</div>
[128]588}
[148]589
Note: See TracBrowser for help on using the repository browser.