source: main/trunk/greenstone2/macros/query.dm@ 28911

Last change on this file since 28911 was 28911, checked in by ak19, 10 years ago

Fourth commit for security and safe cgiargs.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 30.2 KB
RevLine 
[7343]1# this file must be UTF-8 encoded
[128]2package query
3
[276]4
[148]5#######################################################################
[276]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.
[148]8#######################################################################
[128]9
[276]10_quotedquery_ {}
11_freqmsg_ {}
[12382]12_stopwordsmsg_ {}
[276]13_resultline_ {}
14_thisfirst_ {}
15_thislast_ {}
16_nextfirst_ {}
17_nextlast_ {}
18_prevfirst_ {}
19_prevlast_ {}
[964]20_searchhistorylist_ {}
[1923]21#_histvalue0_ to _histvalue19_
22_advformlist_ {}
23_regformlist_ {}
[22053]24_sqladvformlist_ {}
25_sqlregformlist_ {}
[4765]26#_fqfselection_ {}
[128]27
[1923]28
[148]29#######################################################################
30# icons
31#######################################################################
[128]32
[10948]33_queryresultsbar_ {
34<div class="divbar">
35<p class="navbar">_texthresults_</p>
36</div>
37}
[128]38
[11209]39_searchhistorybar_ {
40<div class="divbar">
41<p class="navbar">_texticonsearchhistorybar_</p>
42</div>
43}
[1923]44
[11209]45
[276]46# _iconnext_ and _iconprev_ are overridden in this package as we
47# don't want alt text here
[12557]48_iconnext_{<img src="_httpiconmore_" width="_widthmore_" height="_heightmore_" border="0" align="top">}
[1263]49_iconnext_ [v=1] {}
[12557]50_iconprev_{<img src="_httpiconless_" width="_widthless_" height="_heightless_" border="0" align="top">}
[1263]51_iconprev_ [v=1] {}
[148]52
[1923]53# the small squares for search history
[2042]54## " " ## handmade ## mstds ##
55_httpiconmstdsqrof_ {_httpimg_/mstdsof.gif}
56_httpiconmstdsqron_ {_httpimg_/mstdson.gif}
[1923]57_widthmstdsqrx_ {13}
58_heightmstdsqrx_ {13}
59
[148]60#######################################################################
61# images
62#######################################################################
63
[11156]64# _imagethispage_ set in nav_css/nav_ns4 macro files
[148]65
[1923]66#the buttons for the search history entries
67# takes one arg - the entry number (0-num entries)
[12557]68_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>}
[148]69
[1923]70
[148]71#######################################################################
[1923]72# scripts (and some macros for the scripts)
73#######################################################################
74
[22053]75_pagescriptextra_ {_If_("_cgiargqt_" ge "1", _formpagescriptextra_, _selectpagescriptextra_)
[1923]76_If_("_cgiarghd_" ne "0",_historypagescriptextra_) }
77
[4772]78_selectpagescriptextra_{_If_("_cgiargqto_" eq "2", _formpagescriptextra_,_dummypagescriptextra_)}
[10872]79_dummypagescriptextra_{function initialize() \{
80\} }
[1923]81_formpagescriptextra_ {
82// query scripts generated by \_query:pagescriptextra\_
83
84_standardfunctions_
85_formfunctions_
86_searchfunctions_
87
88function getsearchargs () \{
89
90 var args="";
91 args = "&fqa=0&fqv="+argfqv+"&fqf="+argfqf;
[22053]92 _If_(_cgiargb_,
[28223]93 args += "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc+"&fqaf="+argfqaf;
[22053]94 )
95 _If_("_cgiarga_" eq "sqlq",args += "&sqlfqf="+argsqlfqf + "&sqlfqc="+argsqlfqc;)
[1923]96
97 return args;
98\}
99
100
101
102function getqueryargs () \{
[22876]103 var args = "&fqa=1"+"&q="+argq+"&fqv="+argfqv+"&fqf="+argfqf+
[28223]104 "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc+"&fqaf="+argfqaf;
[22876]105 _If_("_cgiarga_" eq "sqlq",args += "&sqlfqf="+argsqlfqf + "&sqlfqc="+argsqlfqc;)
106 return args;
[1923]107\}
108
109}
110
111_historypagescriptextra_{
112
[28911]113var histvalue0='_histvalue0Jssafe_';
114var histvalue1='_histvalue1Jssafe_';
115var histvalue2='_histvalue2Jssafe_';
116var histvalue3='_histvalue3Jssafe_';
117var histvalue4='_histvalue4Jssafe_';
118var histvalue5='_histvalue5Jssafe_';
119var histvalue6='_histvalue6Jssafe_';
120var histvalue7='_histvalue7Jssafe_';
121var histvalue8='_histvalue8Jssafe_';
122var histvalue9='_histvalue9Jssafe_';
123var histvalue10='_histvalue10Jssafe_';
124var histvalue11='_histvalue11Jssafe_';
125var histvalue12='_histvalue12Jssafe_';
126var histvalue13='_histvalue13Jssafe_';
127var histvalue14='_histvalue14Jssafe_';
128var histvalue15='_histvalue15Jssafe_';
129var histvalue16='_histvalue16Jssafe_';
130var histvalue17='_histvalue17Jssafe_';
131var histvalue18='_histvalue18Jssafe_';
132var histvalue19='_histvalue19Jssafe_';
[1923]133
134function inputQuery(value) \{
[28888]135 if ("_cgiargqtJssafe_" == "0") \{ // text search
[1923]136 document.QueryForm.q.value += " "+value;
[8151]137 document.QueryForm.q.focus();
[1923]138 \}
139 else \{
[28888]140 if ("_cgiargbJssafe_" == "1") \{ // advanced query
[1923]141 document.QueryForm.q.value += " "+value;
[8151]142 document.QueryForm.q.focus();
[1923]143 updateq();
144 \}
145 else \{ // simple form search
146 // do something here, what??
147 \}
148 \}
149\}
150
151}
152
153_standardfunctions_{
154
155 function getstdargs() \{
156
157 stdarg = "";
[2744]158 _If_(_gselection_,_getgarg_)
[5618]159 _If_(_jselection_,_getjarg_)
[9668]160 _If_(_nselection_,_getnarg_)
[22053]161 _If_(_sqlsfselection_,_getsqlsfarg_)
[12780]162 _If_(_sfselection_,_getsfarg_)
[22053]163
[12780]164 if (document.QueryForm.t != null) \{
165 value = document.QueryForm.t.options[document.QueryForm.t.selectedIndex].value;
[28888]166 if (value != "_cgiargtJssafe_") stdarg += "&t="+value;
[12780]167 \}
[4813]168 stdarg += "&r=1&hs=1";
[1923]169 return stdarg;
170 \}
171
172}
173
174_getgarg_{
[4813]175 if (document.QueryForm.g!= null) \{
[1923]176 value = document.QueryForm.g.options[document.QueryForm.g.selectedIndex].value;
[28888]177 if (value != "_cgiarggJssafe_") stdarg += "&g="+value;
[4813]178 \}
[1923]179}
180
181_getjarg_{
182 value = document.QueryForm.j.options[document.QueryForm.j.selectedIndex].value;
[28888]183 if (value != "_cgiargjJssafe_") stdarg += "&j="+value;
[1923]184}
185
[9668]186_getnarg_{
187 value = document.QueryForm.n.options[document.QueryForm.n.selectedIndex].value;
[28888]188 if (value != "_cgiargnJssafe_") stdarg += "&n="+value;
[9668]189}
[1923]190
[22053]191# currently only supported in lucene
[12780]192_getsfarg_{
[22053]193_If_("_cgiarga__cgiargct_" eq "q2",
[12780]194 value = document.QueryForm.sf.options[document.QueryForm.sf.selectedIndex].value;
[28888]195 if (value != "_cgiargsfJssafe_") stdarg += "&sf="+value;
[22053]196)
[12780]197}
198
[22053]199# only when in sql mode
200_getsqlsfarg_{
201_If_("_cgiarga__cgiargqt_" eq "sqlq2",
202 value = document.QueryForm.sqlsf.options[document.QueryForm.sqlsf.selectedIndex].value;
[28888]203 if (value != "_cgiargsqlsfJssafe_") stdarg += "&sqlsf="+value;
[22053]204)
205}
206
[1923]207_formfunctions_{
208
[28888]209argfqf="_cgiargfqfJssafe_";
210argfqv="_cgiargfqvJssafe_";
211argfqk="_cgiargfqkJssafe_";
212argfqs="_cgiargfqsJssafe_";
213argfqaf="_cgiargfqafJssafe_";
214argfqc="_cgiargfqcJssafe_";
[22053]215_If_("_cgiarga_" eq "sqlq",
[28888]216argsqlfqf="_cgiargsqlfqfJssafe_";
217argsqlfqc="_cgiargsqlfqcJssafe_";
[22053]218)
[1923]219argq = "";
220
221function initialize () \{
222
[12780]223 if (document.QueryForm.fqf != null) \{initfqf(); \}
224 if (document.QueryForm.fqv != null) \{initfqv(); \}
225 if (document.QueryForm.fqs != null) \{initfqs(); \}
226 if (document.QueryForm.fqk != null) \{initfqk(); \}
[28223]227 if (document.QueryForm.fqaf != null) \{initfqaf(); \}
[12780]228 if (document.QueryForm.fqc != null) \{initfqc(); \}
[22053]229_If_("_cgiarga_" eq "sqlq",
230 if (document.QueryForm.sqlfqf != null) \{initsqlfqf(); \}
231 if (document.QueryForm.sqlfqc != null) \{initsqlfqc(); \}
232)
[12780]233 if (document.QueryForm.q != null) \{initq(); \}
[1923]234\}
235
[12441]236// makes a form submit itself when enter is pressed in a text field
237function entersubmit(event) \{
238
239 if (window.event && window.event.keyCode == 13) \{
240 beginSearch();
241 \} else \{
242 if (event && event.which == 13) \{
243 beginSearch();
244 \} else \{
245 return true;
246 \}
247 \}
248\}
249
[12780]250
[1923]251// fqf - the field selection box
252function initfqf() \{
253 var i;
[7262]254 fqf = argfqf.split(",");
255 num_opts = document.QueryForm.fqf[0].options.length; // assumes all have the same options
[10661]256 for (i=0; i<fqf.length && i<document.QueryForm.fqf.length; i++) \{
257 if (fqf[i] != "")\{
[7262]258 for (j=0;j<num_opts;j++) \{
[10661]259 if (fqf[i]== document.QueryForm.fqf[i].options[j].value) \{
[1923]260 document.QueryForm.fqf[i].options[j].selected = true;
261 break;
262 \}
263 \}
[10661]264 \}
[1923]265 \}
266 if (fqf.length < document.QueryForm.fqf.length) \{ // initialize remaining ones
267 for (i=fqf.length;i<document.QueryForm.fqf.length;i++) \{
268 var z=i;
[7262]269 while (z >= num_opts) \{
270 z = z-(num_opts);
[3157]271 \}
[1923]272 document.QueryForm.fqf[i].options[z].selected = true;
273
274 \}
275 \}
276 updatefqf();
277
278\}
279
280function updatefqf() \{
281
282 var i;
283 argfqf = "";
284 var j = document.QueryForm.fqf[0].selectedIndex;
285 argfqf += document.QueryForm.fqf[0].options[j].value;
286 for (i=1; i<document.QueryForm.fqf.length;i++) \{
287 j = document.QueryForm.fqf[i].selectedIndex;
288 argfqf += "," + document.QueryForm.fqf[i].options[j].value;
289 \}
290
291\}
292
293
294function clearfqf() \{
295 var i;
296 for (i=0;i<document.QueryForm.fqf.length;i++) \{
297 var z = i;
298 if (i >= document.QueryForm.fqf[i].options.length) z = z-document.QueryForm.fqf[i].options.length;
299 document.QueryForm.fqf[i].options[z].selected = true;
300 \}
301 updatefqf();
302\}
303
[22053]304
305// sqlfqf - the field selection box
306function initsqlfqf() \{
307 var i;
308 sqlfqf = argsqlfqf.split(",");
309 num_opts = document.QueryForm.sqlfqf[0].options.length; // assumes all have the same options
310 for (i=0; i<sqlfqf.length && i<document.QueryForm.sqlfqf.length; i++) \{
311 if (sqlfqf[i] != "")\{
312 for (j=0;j<num_opts;j++) \{
313 if (sqlfqf[i]== document.QueryForm.sqlfqf[i].options[j].value) \{
314 document.QueryForm.sqlfqf[i].options[j].selected = true;
315 break;
316 \}
317 \}
318 \}
319 \}
320 if (sqlfqf.length < document.QueryForm.sqlfqf.length) \{ // initialize remaining ones
321 for (i=sqlfqf.length;i<document.QueryForm.sqlfqf.length;i++) \{
322 var z=i;
323 while (z >= num_opts) \{
324 z = z-(num_opts);
325 \}
326 document.QueryForm.sqlfqf[i].options[z].selected = true;
327
328 \}
329 \}
330 updatesqlfqf();
331
332\}
333
334function updatesqlfqf() \{
335
336 var i;
337 argsqlfqf = "";
338 var j = document.QueryForm.sqlfqf[0].selectedIndex;
339 argsqlfqf += document.QueryForm.sqlfqf[0].options[j].value;
340 for (i=1; i<document.QueryForm.sqlfqf.length;i++) \{
341 j = document.QueryForm.sqlfqf[i].selectedIndex;
342 argsqlfqf += "," + document.QueryForm.sqlfqf[i].options[j].value;
343 \}
344
345\}
346
347
348function clearsqlfqf() \{
349 var i;
350 for (i=0;i<document.QueryForm.sqlfqf.length;i++) \{
351 var z = i;
352 if (i >= document.QueryForm.sqlfqf[i].options.length) z = z-document.QueryForm.sqlfqf[i].options.length;
353 document.QueryForm.sqlfqf[i].options[z].selected = true;
354 \}
355 updatesqlfqf();
356\}
357
358
359
360
[1923]361// fqc - the boolean operator selection box
362function initfqc() \{
363 var i,j;
364 fqc = argfqc.split(",");
[28888]365 if ("_cgiargfqnJssafe_" == "2") \{ // there will only be one fqc element
[1923]366 for (j=0;j<document.QueryForm.fqc.options.length;j++) \{
367 if (fqc[0] == document.QueryForm.fqc.options[j].value) \{
368 document.QueryForm.fqc.options[j].selected = true;
369 break;
370 \}
371 \}
372 \}
373 else \{
374 for (i=0; i<fqc.length;i++) \{
375 for (j=0;j<document.QueryForm.fqc[i].options.length;j++) \{
376 if (fqc[i] == document.QueryForm.fqc[i].options[j].value) \{
377 document.QueryForm.fqc[i].options[j].selected = true;
378 break;
379 \}
380 \}
381 \}
382 \}
383 updatefqc();
384
385\}
386
387function updatefqc() \{
388
389 var i,j;
390 argfqc = "";
[28888]391 if ("_cgiargfqnJssafe_" == "2") \{
[1923]392 j = document.QueryForm.fqc.selectedIndex;
393 argfqc += document.QueryForm.fqc.options[j].value;
394 \}
395 else \{
396 j = document.QueryForm.fqc[0].selectedIndex;
397 argfqc += document.QueryForm.fqc[0].options[j].value;
398 for (i=1;i<document.QueryForm.fqc.length;i++) \{
399 j = document.QueryForm.fqc[i].selectedIndex;
400 argfqc += "," + document.QueryForm.fqc[i].options[j].value;
401 \}
402 \}
403
404\}
405
406
407function clearfqc() \{
408
409 var i;
[28888]410 if ("_cgiargfqnJssafe_" == "2") \{
[1923]411 document.QueryForm.fqc.options[0].selected = true;
412 \}
413 else \{
414 for (i=0; i<document.QueryForm.fqc.length; i++) \{
415 document.QueryForm.fqc[i].options[0].selected = true;
416 \}
417 \}
418 updatefqc();
419\}
420
[22053]421
422
423// sqlfqc - the SQL operator selection box
424function initsqlfqc() \{
425 var i,j;
426 sqlfqc = argsqlfqc.split(",");
[28888]427 if ("_cgiargsqlfqnJssafe_" == "2") \{ // there will only be one sqlfqc element
[22053]428 for (j=0;j<document.QueryForm.sqlfqc.options.length;j++) \{
429 if (sqlfqc[0] == document.QueryForm.sqlfqc.options[j].value) \{
430 document.QueryForm.sqlfqc.options[j].selected = true;
431 break;
432 \}
433 \}
434 \}
435 else \{
436 for (i=0; i<sqlfqc.length;i++) \{
437 for (j=0;j<document.QueryForm.sqlfqc[i].options.length;j++) \{
438 if (sqlfqc[i] == document.QueryForm.sqlfqc[i].options[j].value) \{
439 document.QueryForm.sqlfqc[i].options[j].selected = true;
440 break;
441 \}
442 \}
443 \}
444 \}
445 updatesqlfqc();
446
447\}
448
449function updatesqlfqc() \{
450
451 var i,j;
452 argsqlfqc = "";
[28888]453 if ("_cgiargsqlfqnJssafe_" == "2") \{
[22053]454 j = document.QueryForm.sqlfqc.selectedIndex;
455 argsqlfqc += document.QueryForm.sqlfqc.options[j].value;
456 \}
457 else \{
458 j = document.QueryForm.sqlfqc[0].selectedIndex;
459 argsqlfqc += document.QueryForm.sqlfqc[0].options[j].value;
460 for (i=1;i<document.QueryForm.sqlfqc.length;i++) \{
461 j = document.QueryForm.sqlfqc[i].selectedIndex;
462 argsqlfqc += "," + document.QueryForm.sqlfqc[i].options[j].value;
463 \}
464 \}
465
466\}
467
468
469function clearsqlfqc() \{
470
471 var i;
[28888]472 if ("_cgiargsqlfqnJssafe_" == "2") \{
[22053]473 document.QueryForm.sqlfqc.options[0].selected = true;
474 \}
475 else \{
476 for (i=0; i<document.QueryForm.sqlfqc.length; i++) \{
477 document.QueryForm.sqlfqc[i].options[0].selected = true;
478 \}
479 \}
480 updatesqlfqc();
481\}
482
483
484
485
[1923]486// fqv - the query word/phrase text box
487function initfqv() \{
488 var i;
489 fqv= argfqv.split(",");
[10661]490 for (i=0; i<fqv.length && i<document.QueryForm.fqv.length; i++) \{
[1923]491 document.QueryForm.fqv[i].value = fqv[i];
492 \}
493 updatefqv();
494
495
496\}
497
[4175]498 //argfqv += escape(format(document.QueryForm.fqv[0].value));
[1923]499
[12441]500function updatefqv() \{
[1923]501 var i;
502 argfqv="";
[4175]503 argfqv += format(document.QueryForm.fqv[0].value);
[1923]504 for (i=1; i<document.QueryForm.fqv.length;i++) \{
505 argfqv += ",";
[4175]506 argfqv += format(document.QueryForm.fqv[i].value);
[1923]507 \}
508\}
509
510function clearfqv() \{
511 var i;
512 for (i=0; i< document.QueryForm.fqv.length;i++) \{
513 document.QueryForm.fqv[i].value = "";
514 \}
515 updatefqv();
516\}
517
518// fqs - the stemming checkboxes
519function initfqs() \{
520
521 var i;
522 fqs = argfqs.split(",");
523 for (i=0; i<fqs.length; i++) \{
524 if (fqs[i]=="1") \{
525 document.QueryForm.fqs[i].checked = true;
526 \}
527 \}
528 updatefqs();
529
530\}
531
532function updatefqs() \{
533 argfqs="";
534 if (document.QueryForm.fqs[0].checked) \{
535 argfqs += "1";
536 \}
537 else \{
538 argfqs += "0";
539 \}
540 var i;
541 for (i=1; i<document.QueryForm.fqs.length; i++) \{
542 if (document.QueryForm.fqs[i].checked) \{
543 argfqs += ",1";
544 \}
545 else \{
546 argfqs += ",0";
547 \}
548 \}
549\}
550
551
552function clearfqs() \{
553 var i;
554 for (i=0; i<document.QueryForm.fqs.length; i++) \{
555 document.QueryForm.fqs[i].checked = false;
556 \}
557 updatefqs();
558\}
559
[28223]560// fqk - the casefolding checkboxes
[1923]561function initfqk() \{
562 var i;
563 fqk = argfqk.split(",");
564 for (i=0; i<fqk.length; i++) \{
565 if (fqk[i]=="1") \{
566 document.QueryForm.fqk[i].checked = true;
567 \}
568 \}
569 updatefqk();
570
571\}
572
573
574function updatefqk() \{
575 argfqk="";
576 if (document.QueryForm.fqk[0].checked) \{
577 argfqk += "1";
578 \}
579 else \{
580 argfqk += "0";
581 \}
582 var i;
583 for (i=1; i<document.QueryForm.fqk.length; i++) \{
584 if (document.QueryForm.fqk[i].checked) \{
585 argfqk += ",1";
586 \}
587 else \{
588 argfqk += ",0";
589 \}
590 \}
591\}
592
593function clearfqk() \{
594 var i;
595 for (i=0; i<document.QueryForm.fqk.length; i++) \{
596 document.QueryForm.fqk[i].checked = false;
597 \}
598 updatefqk();
599\}
600
[28223]601// fqaf - the casefolding checkboxes
602function initfqaf() \{
603 var i;
604 fqaf = argfqaf.split(",");
605 for (i=0; i<fqaf.length; i++) \{
606 if (fqaf[i]=="1") \{
607 document.QueryForm.fqaf[i].checked = true;
608 \}
609 \}
610 updatefqaf();
611
612\}
613
614
615function updatefqaf() \{
616 argfqaf="";
617 if (document.QueryForm.fqaf[0].checked) \{
618 argfqaf += "1";
619 \}
620 else \{
621 argfqaf += "0";
622 \}
623 var i;
624 for (i=1; i<document.QueryForm.fqaf.length; i++) \{
625 if (document.QueryForm.fqaf[i].checked) \{
626 argfqaf += ",1";
627 \}
628 else \{
629 argfqaf += ",0";
630 \}
631 \}
632\}
633
634function clearfqaf() \{
635 var i;
636 for (i=0; i<document.QueryForm.fqaf.length; i++) \{
637 document.QueryForm.fqaf[i].checked = false;
638 \}
639 updatefqaf();
640\}
641
[1923]642// q - the advanced query box
643function initq() \{
644 updateq();
645\}
646
647function updateq() \{
[12441]648
[22981]649 argq = "";
650 _If_("_cgiarga_" eq "sqlq",argq += format(document.QueryForm.q.value, 1);)
651 _If_("_cgiarga_" eq "q",argq += format(document.QueryForm.q.value);)
[1923]652\}
653
654function clearq() \{
655 document.QueryForm.q.value="";
[23614]656 updateq();
[1923]657\}
658
[22948]659// convert spaces to plus
[22981]660// also convert other illegal characters to %xx codes
[22948]661// This routine used to treat commas like spaces (replacing them with a plus),
[22981]662// but this is no longer good enough for handling sql-queries.
663// Now if keepcommas == 1, URL encode commas, else (if undefined or 0),
664// convert commas to plus.
665function format(string, keepcommas) \{
[1923]666 var str = "" + string;
667 var out = "", flag = 0;
[4175]668 var ch = "";
[1923]669 var j;
[22981]670 for (j = 0; j < str.length; j++) \{
[4175]671 ch=str.charAt(j);
[22981]672
673 if(ch == ",") \{
674 if(keepcommas == 1) \{
675 out += escape(ch);
676 flag=0;
677 continue;
678 \}
679 else \{ // can be undefined or maybe 0?
680 if (flag == 0) \{
681 out += "+";
682 flag=1;
683 \}
684 \}
685 continue;
686 \}
687
[22948]688 if (ch == " ") \{
[22053]689 if (flag == 0) \{
[4175]690 out += "+";
691 flag=1;
692 \}
693 continue;
[1923]694 \}
[22981]695 if (ch == ";" || ch == ":" || ch == "/" || ch == "?" ||
[22053]696 ch == "@" || ch == "&" || ch == "=" || ch == "#" ||
697 ch == "%") \{
[4175]698 out += escape(ch);
699 flag=0;
700 continue;
701 \}
702 out += str.charAt(j);
703 flag=0;
[1923]704 \}
705 return out;
706\}
707
708}
709
710#_httpquery_ has a=q&e=compressedargs
711#if adv form, need to set k=0 and s=0
[12768]712_advformargs_{_If_(_cgiargb_,&k=0&s=0)}
[1923]713
714_searchfunctions_ {
715
716function beginSearch() \{
[22053]717 window.location="_httpquery_"+getstdargs()+"_advformargs_"+getsearchargs();
[1923]718\}
719
720function runQuery() \{
[22876]721 window.location="_httpquery_"+getstdargs()+"_advformargs_"+getqueryargs();
[1923]722\}
723
724function clearForm() \{
[22053]725_If_("_cgiarga_" eq "sqlq",
[23619]726 clearsqlfqf(), clearfqf();
[22053]727)
[1923]728 clearfqv();
729
[28888]730 if ("_cgiargbJssafe_" == "1") \{
[23619]731 if (document.QueryForm.fqk != null) \{clearfqk();\}
732 if (document.QueryForm.fqs != null) \{clearfqs();\}
[28223]733 if (document.QueryForm.fqaf != null) \{clearfqaf();\}
[24095]734 if (document.QueryForm.fqc != null) \{clearfqc();\}
[22053]735_If_("_cgiarga_" eq "sqlq",
736 clearsqlfqc();
737)
[23614]738 if (document.QueryForm.q != null) \{clearq(); \}
[1923]739 \}
740
741\}
742
743}
744
745#######################################################################
746# headers
747# these are overridden so we can put an onLoad event handler
748# in the <body> tag of this page - for mgpp, form search pages
749#######################################################################
750
751#copied from prefs
752
753_header_ {_cgihead_
[10872]754_htmlhead_(class="bgimage" onLoad="initialize();")_startspacer__pagebanner_
[1923]755}
756
757# this declaration ends up being the same as style=restrict, never mind
758_header_[v=1] {_cgihead_
759_htmlhead_(onLoad="initialize();")_pagebanner_
760}
761
762#######################################################################
[148]763# page content
764#######################################################################
765
[1923]766
[276]767_pagetitle_ {_If_(_cgiargq_,_textquerytitle_,_textnoquerytitle_)}
[148]768
[1923]769
[276]770_content_ {
[14972]771
[7503]772_optnavigationbar_
[10958]773<div class="document">
774<div class="queryform">
[22053]775
776_If_("_cgiarga_" eq "sqlq",
777
778 _If_("_cgiargqt_" eq "2",_sqlfieldqueryform_,_sqlqueryform_)
779,
780 _If_(_cgiargct_,_selectqueryform_,_queryform_)
781)
782
[10958]783</div>
[12780]784
[11209]785_If_(_searchhistorylist_,<center>_searchhistorybar_</center><br>
[1923]786<center>
[942]787_searchhistorylist_
788</center>)
[10948]789_If_(_cgiargq_,_queryresultsbar_
[276]790<small>
791_freqmsg_
[12382]792_textpostprocess_
[12389]793_If_(_stopwordsmsg_,(_stopwordsmsg_))</small><br />
[128]794_resultline_
[10872]795,<div class="divbar">&nbsp;</div>)
[128]796}
797
[22053]798_selectqueryform_{_If_("_cgiargqt_" ge "1",_fieldqueryform_,_queryform_)}
[1923]799
[128]800_queryform_ {
[4765]801<!-- query form (\_query:plainqueryform\_) -->
[12557]802<form name="QueryForm" method="get" action="_gwcgi_">
[10872]803<p>
[12557]804<input type="hidden" name="a" value="q">
805<input type="hidden" name="r" value="1">
806<input type="hidden" name="hs" value="1">
[28888]807<input type="hidden" name="e" value="_decodedcompressedoptionsAttrsafe_">
[2768]808_queryformcontent_
[5634]809_optdatesearch_
[10872]810</p>
[2768]811</form>
812<!-- end of query form -->
813}
814
[22053]815
816_sqlqueryform_ {
817
818<!-- simple query box that requires you to type SQL where clause directly -->
819<!-- sqlquery form (\_query:plainqueryform\_) -->
820<form name="QueryForm" method="get" action="_gwcgi_">
821<p>
822<input type="hidden" name="a" value="sqlq">
823<input type="hidden" name="r" value="1">
824<input type="hidden" name="hs" value="1">
[28888]825<input type="hidden" name="e" value="_decodedcompressedoptionsAttrsafe_">
[22053]826_sqlqueryformcontent_
827</p>
828</form>
829<!-- end of sqlquery form -->
830}
831
832
[17929]833_ifeellucky_ { <br><input type="checkbox" name="ifl" value="1">_textifeellucky_ }
[7596]834_useifeellucky_ { } # Set this to _ifeellucky_ if you want this functionality available
835
[12780]836_allowformbreak_{</span> <span class="textselect">}
837
[10872]838_queryformcontent_{
839<span class="textselect">
840_textselect_
841</span>
842
843<span class="querybox">
[1923]844_If_(_cgiargqb_,_largequerybox_,_smallquerybox_)
[7596]845_useifeellucky_
[10872]846</span>
[1923]847}
848
[22053]849
850_sqlqueryformcontent_ {
851<span class="querybox">
852_If_(_cgiargqb_,_query:largequerybox_,_query:smallquerybox_)
853_query:useifeellucky_
854</span>
855}
856
[5634]857# Automatically set by receptionist if config file switches
858# date searching on
859_optdatesearch_ { }
860
861
[2768]862_datesearch_
863{<table><tr><td>
864 <center>
865_textstartdate_
[28888]866<input type="text" name="ds" value="_cgiargdsAttrsafe_" size="4" maxlength="4">
867<select name="dsbc" value="_cgiargdsbcAttrsafe_" size="1">
[12557]868 <option value="0"_If_(_cgiargdsbc_,, selected)>_textad_
869 <option value="1"_If_(_cgiargdsbc_, selected)>_textbc_
[2768]870</select>
871_textenddate_
[28888]872<input type="text" name="de" value="_cgiargdeAttrsafe_" size="4" maxlength="4">
[2768]873<select name="debc" size="1">
[12557]874 <option value="0" _If_(_cgiargdebc_,, selected)>_textad_
875 <option value="1" _If_(_cgiargdebc_, selected)>_textbc_
[2768]876</select>
877</center>
[13433]878</td></tr>
[2768]879<tr><td>
880_textexplaineras_
[13433]881</td></tr>
[2768]882</table>
883</center>
884}
885
[28898]886_smallquerybox_ {<nobr><input type="text" name="q" value="_cgiargq_" size="50">&nbsp;<input type="submit" value="_textbeginsearch_"></nobr>}
[1923]887
888_largequerybox_ {
[12557]889<tr><td><textarea name="q" cols="63" rows="10">
[28898]890_cgiargq_
[1923]891</textarea></td></tr>
[12557]892<tr align="right"><td><table>
[1923]893<tr><td><input type="submit" value="_textbeginsearch_"></td>
894</tr></table></td></tr>}
895
896
897_fieldqueryform_ {
[4784]898<noscript>
[14109]899<p><b>_textnojsformwarning_</b></p>
[4784]900</noscript>
[1923]901<!-- field query form (\_query:fieldqueryform\_) -->
[12557]902<form name="QueryForm" method="get" action="_gwcgi_">
[4765]903
[12780]904<table><tr><td align="left">
[22053]905
[1923]906_textformselect_
907</td></tr>
[12780]908<tr><td>
[12768]909_If_(_cgiargb_,_advancedforms_,_simpleforms_)
[13433]910</td></tr>
[1923]911</table>
[12768]912_If_(_cgiargb_,<div class="divbar">&nbsp;</div>
[12780]913_advancedformextra_)
[5634]914
[128]915</form>
[276]916<!-- end of query form -->
[128]917}
[148]918
[22053]919_sqlfieldqueryform_ {
920<noscript>
921<p><b>_textnojsformwarning_</b></p>
922</noscript>
923<!--sql field query form (\_query:fieldqueryform\_) -->
924<form name="QueryForm" method="get" action="_gwcgi_">
925
926<table><tr><td align="left">
927_textformselect_
928</td></tr>
929<tr><td>
930_If_(_cgiargb_,_sqladvancedforms_,_sqlsimpleforms_)
931</td></tr>
932</table>
933_If_(_cgiargb_,<div class="divbar">&nbsp;</div>
934_advancedformextra_)
935
936</form>
937<!-- end of sql query form -->
938}
939
[28223]940_stemcaseheader_ {
941_If_("_cgiargct_" eq "1",_If_("_cgiargks_" eq "1",<th align="center" style="font-size:smaller;">_textformcasefold_</th>)
942_If_("_cgiargafs_" eq "1",<th align="center" style="font-size:smaller;">_textformaccentfold_</th>)_If_("_cgiargss_" eq "1",<th align="center" style="font-size:smaller;">_textformstem_</th>)
[22053]943
[28223]944}
[1923]945_advancedforms_{
[12780]946<table border="0" cellspacing="0" cellpadding="0" width="90%">
[28223]947<tr><th></th><th align="left">_textwordphrase_</th>_stemcaseheader_<th align="center">&nbsp;&nbsp;_textinfield_</th></tr>
[1923]948_advformlist_
[12780]949<tr>
950<td colspan="2" align="left"><input type="button" value="_textclearform_" onClick="clearForm();"></td>
951<td colspan="3" align="right"><input type="button" value="_textbeginsearch_" onClick="beginSearch();"></td>
952</tr>
953</table>
[1923]954}
955
[22053]956_sqladvancedforms_{
957<table border="0" cellspacing="0" cellpadding="0" width="90%">
958 _sqladvformlist_
959 <tr>
960 <td colspan="2" align="left">
961 <input type="button" value="_textclearform_" onClick="clearForm();">
962 </td>
963 <td colspan="3" align="right">
964 <input type="button" value="_textbeginsearch_" onClick="beginSearch();">
965 </td>
966 </tr>
967</table>
968}
969
970
971
[1923]972_advancedformextra_{
973<table>
[12780]974<tr><td align="left">_textadvquery_</td></tr>
[28898]975<tr><td><textarea name="q" cols="57" rows="3" onChange="updateq();">_cgiargq_</textarea></td>
[12557]976<td valign="bottom">
[1923]977<input type="button" value="_textrunquery_" onClick="runQuery();"></td></tr>
978</table>
[22053]979
980
981_If_("_cgiarga_" eq "sqlq",
982<p>For example:<br>
983<i>
[22948]984 element in (\'dc.Keywords\') AND value=\'Farming\'<br>
985 element in (\'dls.Title\') AND value LIKE \'F%\'<br>
986 element in (\'dls.Title\') AND value<\'F%\'<br>
[22053]987</i>
988)
989
[1923]990}
991
992_simpleforms_{
[12780]993<table border="0" cellspacing="0" cellpadding="0" width="90%">
[12557]994<tr><th align="left">_textwordphrase_</th><th align="left">&nbsp;&nbsp;_textinfield_</th></tr>
[1923]995_regformlist_
[12780]996<tr>
997<td align="left"><input type="button" value="_textclearform_" onClick="clearForm();"></td>
998<td align="right"><input type="button" value="_textbeginsearch_" onClick="beginSearch();"></td>
[1923]999</tr>
[12780]1000</table>}
[1923]1001
[22053]1002_sqlsimpleforms_{
1003<table border="0" cellspacing="0" cellpadding="0" width="90%">
1004 _sqlregformlist_
1005 <tr>
1006 <td align="left">
1007 <input type="button" value="_textclearform_" onClick="clearForm();">
1008 </td>
1009 <td align="right">
1010 <input type="button" value="_textbeginsearch_" onClick="beginSearch();">
1011 </td>
1012 </tr>
1013</table>
1014}
1015
1016#
1017# Full-text versions
1018#
1019
[28223]1020_stemcaseboxes_ {
1021_If_("_cgiargks_" eq "1",<td align="center"><input type="checkbox" name="fqk" onClick="updatefqk();"></td>)
1022_If_("_cgiargafs_" eq "1",<td align="center"><input type="checkbox" name="fqaf" onClick="updatefqaf();"></td>)
1023_If_("_cgiargss_" eq "1",<td align="center"><input type="checkbox" name="fqs" onClick="updatefqs();"></td>)
1024}
[1923]1025_regformelement_{
[12780]1026<tr><td><input type="text" size="39" name="fqv" onChange="updatefqv();" onkeypress="updatefqv(); entersubmit(event);"></td>
1027<td>_fqfselection_</td></tr>}
[1923]1028
1029#has no and/or/not selection box
1030_firstadvformelement_{
[12780]1031<tr><td></td><td><input type="text" size="31" name="fqv" onChange="updatefqv();" onkeypress="updatefqv(); entersubmit(event);"></td>
[28223]1032_stemcaseboxes_
[12780]1033<td align="right">_fqfselection_</td></tr>}
[1923]1034
1035_advformelement_{
[12780]1036<tr><td>_fqcselection_</td>
[12557]1037<td><input type="text" size="31" name="fqv" onChange="updatefqv();" onkeypress="updatefqv(); entersubmit(event);"></td>
[28223]1038_stemcaseboxes_
[12780]1039<td align="right">_fqfselection_</td></tr>}
[1923]1040
[12780]1041
1042
[1923]1043_fqcselection_ {
1044<select name="fqc" onChange="updatefqc();">
1045<option value="and">_textand_
1046<option value="or">_textor_
1047<option value="not">_textandnot_
1048</select>}
1049
[12780]1050
[22053]1051_andorfqcselection_ {
1052<select name="fqc" onChange="updatefqc();">
1053<option value="and">_textand_
1054<option value="or">_textor_
1055</select>}
1056
1057
1058#
1059# SQL versions of regformelement, firstsqladvformelement, advformelement
1060#
1061
1062_sqlregformelement_{
1063<tr>
1064 <td>
1065 _sqlfqfselection_
1066 </td>
1067 <td>
1068 _sqlfqcselection_
1069 </td>
1070 <td>
1071 <input type="text" size="39" name="fqv" onChange="updatefqv();"
1072 onkeypress="updatefqv(); entersubmit(event);">
1073 </td>
1074</tr>
1075}
1076
1077_firstsqladvformelement_{
1078<tr>
1079 <td>
1080 </td>
1081 <td align="right">
1082 _sqlfqfselection_
1083 </td>
1084 <td>
1085 _sqlfqcselection_
1086 </td>
1087 <td>
1088 <input type="text" size="31" name="fqv" onChange="updatefqv();"
1089 onkeypress="updatefqv(); entersubmit(event);">
1090 </td>
1091</tr>
1092}
1093
1094_sqladvformelement_{
1095<tr>
1096 <td>
1097 _andorfqcselection_
1098 </td>
1099 <td align="right">
1100 _sqlfqfselection_
1101 </td>
1102 <td>
1103 _sqlfqcselection_
1104 </td>
1105 <td>
1106 <input type="text" size="31" name="fqv" onChange="updatefqv();" onkeypress="updatefqv(); entersubmit(event);">
1107 </td>
1108</tr>
1109}
1110
1111
1112_sqlfqcselection_ {
1113<select name="sqlfqc" onChange="updatesqlfqc();">
1114 <option value="=">matches
1115 <option value="&lt;">&lt;
1116 <option value="&lt;=">&lt;=
1117 <option value="LIKE">like
1118 <option value="&gt;=">&gt;=
1119 <option value="&gt;">&gt;
1120 <option value="&lt;&gt;">&lt;&gt;
1121
1122</select>}
1123
1124#
1125# end of SQL version
1126#
1127
1128_textselect_ {_If_(_cgiargb_,_chooseadvancedsearch_,_choosesimplesearch_)}
1129
1130_choosesimplesearch_ {_If_("_cgiargqt_" eq "2",_textsimplesqlsearch_,_textsimplesearch_)}
1131
[28888]1132_chooseadvancedsearch_ {_If_("_cgiargqt_" eq "2",_textadvancedsqlsearch_,_chooseadvancedsearchct_)}
[22053]1133_chooseadvancedsearchct_ {_If_(_cgiargct_,_If_("_cgiargct_" eq "2",_textadvancedlucenesearch_,_textadvancedmgppsearch_),_textadvancedsearch_}
1134
1135# formed based versions
1136_textformselect_ {_If_(_cgiargb_,_chooseformadvancedsearch_,_chooseformsimplesearch_)}
1137_chooseformsimplesearch_ {_If_("_cgiargqt_" eq "2",_textformsimplesearchsql_,_textformsimplesearch_)}
1138
1139_chooseformadvancedsearch_ {_If_("_cgiargqt_" eq "2",_textformadvancedsearchsql_,_chooseformadvancedsearchct_)}
1140_chooseformadvancedsearchct_ {_If_("_cgiargct_" eq "1",_textformadvancedsearchmgpp_)_If_("_cgiargct_" eq "2",_textformadvancedsearchlucene_)}
1141
[6541]1142# mg uses hselection for index, mgpp uses fqfselection
1143_indexselection_{_If_(_cgiargct_,_fqfselection_,_hselection_)}
[1289]1144
[276]1145# we want to put the links to previous/next pages of results
1146# in the footer
1147_pagefooterextra_ {
1148<center>
[12557]1149<table cellspacing="0" cellpadding="0" width="_pagewidth_">
[276]1150<tr>
[13424]1151<td align="left">_If_(_prevfirst_,<a href="_httpquery_&amp;r=_prevfirst_">_iconprev__textmatches__prevfirst_ - _prevlast_</a>)</td>
1152<td align="right">_If_(_nextfirst_,<a href="_httpquery_&amp;r=_nextfirst_">_textmatches__nextfirst_ - _nextlast__iconnext_</a>)</td>
[276]1153</tr></table>
1154</center>
[10958]1155
1156</div> <!-- document -->
[276]1157}
1158
[1289]1159_querytypeselection_ {
1160<select name="t">
[4765]1161<option value="1"_If_(_cgiargt_, selected)>_If_(_cgiargb_,_textranked_,_textsome_)
1162<option value="0"_If_(_cgiargt_,, selected)>_If_(_cgiargb_,_textboolean_,_textall_)
[1289]1163</select>
1164}
[1923]1165
[27059]1166_sortorderselection_ {
1167<select name="so">
1168<option value="0"_If_(_cgiargso_,, selected)>_textascending_
1169<option value="1"_If_(_cgiargso_, selected)>_textdescending_
1170</select>
1171}
[11768]1172_formquerytypesimpleselection_ {
[1923]1173<select name="t">
[11768]1174<option value="1"_If_(_cgiargt_, selected)>_textsome_
1175<option value="0"_If_(_cgiargt_,, selected)>_textall_
[1923]1176</select>
1177}
1178
[11768]1179_formquerytypeadvancedselection_ {
1180<select name="t">
1181<option value="1"_If_(_cgiargt_, selected)>_textranked_
1182<option value="0"_If_(_cgiargt_,, selected)>_textnatural_
1183</select>
1184}
[1923]1185
[12181]1186# this one is not used by english.dm any more. But I have added it back for the other languages that haven't updated the translations for their form search macros.
1187_formquerytypeselection_ {
1188<select name="t">
[12768]1189<option value="1"_If_(_cgiargt_, selected)>_If_(_cgiargb_,_textranked_,_textsome_)
1190<option value="0"_If_(_cgiargt_,, selected)>_If_(_cgiargb_,_textnatural_,_textall_)
[12181]1191</select>
1192}
[11768]1193
Note: See TracBrowser for help on using the repository browser.