Example #1
0
        private void SendStyleTemplateXml(HttpContext context)
        {
            context.Response.Expires     = -1;
            context.Response.ContentType = "application/xml";
            Encoding encoding = new UTF8Encoding();

            context.Response.ContentEncoding = encoding;

            using (XmlTextWriter xmlTextWriter = new XmlTextWriter(context.Response.OutputStream, encoding))
            {
                xmlTextWriter.Formatting = Formatting.Indented;
                xmlTextWriter.WriteStartDocument();

                xmlTextWriter.WriteStartElement("Styles");

                if (WebConfigSettings.AddSystemStyleTemplatesAboveSiteTemplates)
                {
                    RenderSystemStyles(context, xmlTextWriter);
                }

                SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
                if (siteSettings != null)
                {
                    using (IDataReader reader = ContentStyle.GetAllActive(siteSettings.SiteGuid))
                    {
                        while (reader.Read())
                        {
                            xmlTextWriter.WriteStartElement("Style");
                            xmlTextWriter.WriteAttributeString("name", reader["Name"].ToString());
                            xmlTextWriter.WriteAttributeString("element", reader["Element"].ToString());
                            xmlTextWriter.WriteStartElement("Attribute");
                            xmlTextWriter.WriteAttributeString("name", "class");
                            xmlTextWriter.WriteAttributeString("value", reader["CssClass"].ToString());
                            xmlTextWriter.WriteEndElement(); //Attribute
                            xmlTextWriter.WriteEndElement(); //Style
                        }
                    }
                }

                if (WebConfigSettings.AddSystemStyleTemplatesBelowSiteTemplates)
                {
                    RenderSystemStyles(context, xmlTextWriter);
                }

                xmlTextWriter.WriteEndElement(); //Styles

                //end of document
                xmlTextWriter.WriteEndDocument();
            }
        }
Example #2
0
        private void RenderJsonList(HttpContext context)
        {
            context.Response.ContentType = "text/javascript";
            Encoding encoding = new UTF8Encoding();

            context.Response.ContentEncoding = encoding;

            context.Response.Write("try{CKEDITOR.addStylesSet('mojo',[");

            if (WebConfigSettings.AddSystemStyleTemplatesAboveSiteTemplates)
            {
                RenderSystemStyles(context);
            }

            using (IDataReader reader = ContentStyle.GetAllActive(siteSettings.SiteGuid))
            {
                while (reader.Read())
                {
                    context.Response.Write(comma);
                    context.Response.Write("{\"name\":\"" + reader["Name"].ToString().JsonEscape() + "\"");
                    context.Response.Write(",\"element\":\"" + reader["Element"].ToString().JsonEscape() + "\"");
                    context.Response.Write(",\"attributes\":{\"class\":\"" + reader["CssClass"].ToString().JsonEscape() + "\"}");
                    context.Response.Write("}");

                    comma = ",";
                }
            }


            if (WebConfigSettings.AddSystemStyleTemplatesBelowSiteTemplates)
            {
                RenderSystemStyles(context);
            }

            context.Response.Write("]);\r\n}catch(err){}");
        }
        private void RenderJsonList(HttpContext context)
        {
            context.Response.ContentType = "text/javascript";
            Encoding encoding = new UTF8Encoding();

            context.Response.ContentEncoding = encoding;

            context.Response.Write("CKEDITOR.addStylesSet('C',[");

            if (WebConfigSettings.AddSystemStyleTemplatesAboveSiteTemplates)
            {
                RenderSystemStyles(context);
            }

            using (IDataReader reader = ContentStyle.GetAllActive(siteSettings.SiteGuid))
            {
                while (reader.Read())
                {
                    context.Response.Write(comma);
                    context.Response.Write("{name:'" + reader["Name"].ToString() + "'");
                    context.Response.Write(",element:'" + reader["Element"].ToString() + "'");
                    context.Response.Write(",attributes:{'class':'" + reader["CssClass"].ToString() + "'}");
                    context.Response.Write("}");

                    comma = ",";
                }
            }


            if (WebConfigSettings.AddSystemStyleTemplatesBelowSiteTemplates)
            {
                RenderSystemStyles(context);
            }

            context.Response.Write("]);\r\n");
        }