Changeset 22981 for main


Ignore:
Timestamp:
2010-09-28T15:45:30+13:00 (14 years ago)
Author:
ak19
Message:

Additional changes to previous commit: comma separated field values went wrong in normal advanced field queries because of the special comma processing added for sql queries last time. Katherine fixed this now to deal correctly with commas for all kinds of queries.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/macros/query.dm

    r22948 r22981  
    604604function updateq() \{
    605605 
    606    argq = "";
    607    argq += format(document.QueryForm.q.value);
     606   argq = "";   
     607   _If_("_cgiarga_" eq "sqlq",argq += format(document.QueryForm.q.value, 1);)
     608   _If_("_cgiarga_" eq "q",argq += format(document.QueryForm.q.value);)
    608609\}
    609610
     
    612613\}
    613614
    614 
    615615// convert spaces to plus
    616 // also convert other illegal characters (including commas) to %xx codes
     616// also convert other illegal characters to %xx codes
    617617// This routine used to treat commas like spaces (replacing them with a plus),
    618 // but this is no longer good enough for handling sql-queries
    619 function format(string) \{
     618// but this is no longer good enough for handling sql-queries.
     619// Now if keepcommas == 1, URL encode commas, else (if undefined or 0),
     620// convert commas to plus.
     621function format(string, keepcommas) \{
    620622   var str = "" + string;
    621623   var out = "", flag = 0;
    622624   var ch = "";
    623625   var j;
    624    for (j = 0; j < str.length; j++) \{
     626   for (j = 0; j < str.length; j++) \{   
    625627       ch=str.charAt(j);
     628       
     629       if(ch == ",") \{
     630        if(keepcommas == 1) \{
     631            out += escape(ch);
     632            flag=0;
     633            continue;
     634        \}         
     635        else \{ // can be undefined or maybe 0?
     636            if (flag == 0) \{     
     637              out += "+";
     638              flag=1;
     639             \}
     640        \}
     641        continue;
     642       \}
     643       
    626644       if (ch == " ") \{
    627645           if (flag == 0) \{     
     
    631649        continue;
    632650    \}
    633     if (ch == "," || ch == ";" || ch == ":" || ch == "/" || ch == "?" ||
     651    if (ch == ";" || ch == ":" || ch == "/" || ch == "?" ||
    634652            ch == "@" || ch == "&" || ch == "=" || ch == "#" ||
    635653        ch == "%") \{
Note: See TracChangeset for help on using the changeset viewer.