Branch: Tag:

1999-07-02

1999-07-02 16:53:46 by Mattias Andersson <matan@lysator.liu.se>

Added a function loc_encode() to use in wizard_tag_var(). Just give the argument quote=foo.

Rev: server/base_server/wizard.pike:1.87

1: - /* $Id: wizard.pike,v 1.86 1999/05/07 04:34:20 mast Exp $ + /* $Id: wizard.pike,v 1.87 1999/07/02 16:53:46 mattias Exp $    * name="Wizard generator";    * doc="This file generats all the nice wizards";    */
71:   #define DEBUGMSG(msg) do {} while (0)   #endif    +  + string loc_encode(string val, void|mapping args, void|string def) + { +  string quote = args->quote || def || "html"; +  +  switch (quote) { +  case "html": return html_encode_string(val); break; +  case "none": return val; break; +  } +  return val; + } +  +    string wizard_tag_var(string n, mapping m, mixed a, mixed b)   {    object id;
99:    if((m->type != "password") && (m->type != "hidden"))    m->type = "string";    m_delete(m,"default"); -  m->value = current||m->value||""; +  m->value = loc_encode(current||m->value||"", m, "none");    if(!m->size)m->size="60,1";    return make_tag("input", m);   
112:    m_delete(m,"default");    foreach((current||"")/"\0"-({""}), string v)    { -  res+="<tr><td>"+v+"</td><td><font size=-2>"; +  res+="<tr><td>"+loc_encode(v, m, "html")+"</td><td><font size=-2>";    m->name="_delete_"+n+":"+v;    m->value = " Remove ";    m->type = "submit";
135:    m_delete(m, "value");    if(!m->rows)m->rows="6";    if(!m->cols)m->cols="40"; -  return make_container("textarea", m, html_encode_string(current||"")); +  return make_container("textarea", m, loc_encode(current||"", m, "html"));       case "radio":    m_delete(m,"default");
330:    ({"__CoMma__", "__CoLon__"}));       return make_container("select", m2, Array.map(m->choices/",", -  lambda(string s, string c) { +  lambda(string s, string c, mapping m) {    string t;    if(sscanf(s, "%s:%s", s, t) != 2)    t = s;
339:    t=replace(t,({"__CoMma__",    "__CoLon__"}),({",",":"}));    -  return "<option value='"+s+"' "+(s==c?" selected":"")+">"+html_encode_string(t)+"\n"; -  },current)*""); +  return "<option value='"+s+"' "+(s==c?" selected":"")+">"+loc_encode(t, m, "html")+"\n"; +  },current,m)*"");          case "select_multiple":
358:    ({"__CoMma__", "__CoLon__"}));       return make_container("select", m2, Array.map(m->choices/",", -  lambda(string s, array c) { +  lambda(string s, array c, mapping m) {    string t;    if(sscanf(s, "%s:%s", s, t) != 2)    t = s;
367:    t=replace(t,({"__CoMma__",    "__CoLon__"}),({",",":"}));    -  return "<option value='"+s+"' "+(search(c,s)!=-1?"selected":"")+">"+html_encode_string(t)+"\n"; -  },(current||"")/"\0")*""); +  return "<option value='"+s+"' "+(search(c,s)!=-1?"selected":"")+">"+loc_encode(t, m, "html")+"\n"; +  },(current||"")/"\0",m)*"");    }   }