Exemple #1
0
        public string render_tag_esc(XmlElement e, string t_val, Hashtable t_att, string g_att, Hashtable h)
        {
            string r;
            string format = e.GetAttribute("t-format");

            if (t_val == "0")
            {
                r = h["0"] as string;
            }
            else
            {
                r = QU.eval(t_val, h);
            }
            if (format.Length != 0)
            {
                if (format == "ucfirst")
                {
                    r = char.ToUpper(r[0]) + r.Substring(1);
                }
                else if (format == "upper")
                {
                    r = r.ToUpper();
                }
                else if (format == "lower")
                {
                    r = r.ToLower();
                }
                else
                {
                    r = String.Format(format, r);
                }
            }
            return(HttpUtility.HtmlEncode(r));
        }
Exemple #2
0
        public string render_node(XmlNode n, Hashtable h)
        {
            string r = "";

            if (n.NodeType == XmlNodeType.Text || n.NodeType == XmlNodeType.Whitespace || n.NodeType == XmlNodeType.CDATA)
            {
                r = n.Value;
            }
            else if (n.NodeType == XmlNodeType.Element)
            {
                XmlElement e           = n as XmlElement;
                string     g_att       = "";
                string     t_att_first = null;
                Hashtable  t_att       = new Hashtable();
                foreach (XmlAttribute a in e.Attributes)
                {
                    if (a.Name.StartsWith("t-"))
                    {
                        if (a.Name.StartsWith("t-att"))
                        {
                            string myval = QU.eval(a.Value, h);
                            g_att += " " + a.Name.Substring(6) + "=\"" + HttpUtility.HtmlEncode(myval) + "\"";
                        }
                        else
                        {
                            t_att[a.Name.Substring(2)] = a.Value;
                            if (t_att_first == null)
                            {
                                t_att_first = a.Name.Substring(2);
                            }
                        }
                    }
                    else
                    {
                        g_att += " " + a.Name + "=\"" + HttpUtility.HtmlEncode(a.Value) + "\"";
                    }
                }
                if (t_att.Count > 0)
                {
                    string val;
                    if ((val = t_att["raw"] as string) != null)
                    {
                        r = render_tag_raw(e, val, t_att, g_att, h);
                    }
                    else if ((val = t_att["esc"] as string) != null)
                    {
                        r = render_tag_esc(e, val, t_att, g_att, h);
                    }
                    else if ((val = t_att["foreach"] as string) != null)
                    {
                        r = render_tag_foreach(e, val, t_att, g_att, h);
                    }
                    else if ((val = t_att["if"] as string) != null)
                    {
                        r = render_tag_if(e, val, t_att, g_att, h);
                    }
                    else if ((val = t_att["call"] as string) != null)
                    {
                        r = render_tag_call(e, val, t_att, g_att, h);
                    }
                    else if ((val = t_att["set"] as string) != null)
                    {
                        r = render_tag_set(e, val, t_att, g_att, h);
                    }
                    else if ((val = t_att["type"] as string) != null)
                    {
                        r = render_tag_type(e, val, t_att, g_att, h);
                    }
                    else if ((val = t_att["select"] as string) != null)
                    {
                        r = render_tag_select(e, val, t_att, g_att, h);
                    }
                    else if ((val = t_att["name"] as string) != null)
                    {
                        r = render_tag_name(e, val, t_att, g_att, h);
                    }
                    else if ((val = t_att["error"] as string) != null)
                    {
                        r = render_tag_error(e, val, t_att, g_att, h);
                    }
                    else if ((val = t_att["invalid"] as string) != null)
                    {
                        r = render_tag_invalid(e, val, t_att, g_att, h);
                    }
                    else
                    {
                        val         = t_att[t_att_first] as string;
                        t_att_first = t_att_first.Replace("-", "_");
                        if (t_att_first.StartsWith("ext_"))
                        {
                            foreach (Object ex in ext)
                            {
                                if (ex.GetType().GetMethod(t_att_first) != null)
                                {
                                    Object o = ex.GetType().GetMethod(t_att_first).Invoke(ex, new Object[] { this, e, val, t_att, g_att, h });
                                    if (o is string)
                                    {
                                        r = (string)o;
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    r = render_element(e, g_att, h);
                }
            }
            return(r);
        }
Exemple #3
0
 public string render_tag_href(XmlElement e, string t_val, Hashtable t_att, string g_att, Hashtable h)
 {
     return(QU.eval(t_val, h));
 }