Beispiel #1
0
        public TemplateSectionReplacement(XmlElement xml)
        {
            sectionName = xml.GetAttribute("Section");
            if (xml.HasAttribute("File"))
            {
                filePath = WebUtility.MapPath(xml.GetAttribute("File"));
                if (!File.Exists(filePath))
                {
                    script = new SprocketScript("[Can't replace section \"" + sectionName + "\"; Path \"" + xml.GetAttribute("File") + "\" doesn't exist]",
                                                "Template Section Replacement: " + sectionName, guid.ToString());
                }
                else
                {
                    fileDate = File.GetLastWriteTime(filePath);
                    script   = new SprocketScript(File.ReadAllText(filePath), "Template Section Replacement: " + sectionName, guid.ToString());
                }
            }
            else
            {
                XmlElement inner = xml.SelectSingleNode("Body") as XmlElement;
                script = new SprocketScript(inner == null ?
                                            "[Template replacement for section \"" + sectionName + "\" must specify a File attribute or Body child element"
                                        : inner.InnerText, "Template Section Replacement: " + sectionName, guid.ToString());
            }

            XmlNodeList cfnodes = xml.SelectNodes("PageAdminSections/PageAdminSection");

            foreach (XmlElement cfnode in cfnodes)
            {
                pageAdminSections.Add(Template.ReadPageAdminSectionXml(cfnode));
            }
        }
Beispiel #2
0
 public MasterTemplate(XmlElement xml)
 {
     name = xml.GetAttribute("Name");
     if (xml.HasAttribute("File"))
     {
         sprocketPath = xml.GetAttribute("File");
         filePath     = WebUtility.MapPath(sprocketPath);
         if (!File.Exists(filePath))
         {
             script = new SprocketScript("[The template \"" + Name + "\" references a nonexistant file]", "Template: " + Name, "Template: " + Name);
         }
         else
         {
             script   = new SprocketScript(File.ReadAllText(filePath), "Template: " + Name, "Template: " + Name);
             fileDate = File.GetLastWriteTime(filePath);
         }
     }
     else
     {
         string     text;
         XmlElement body = xml.SelectSingleNode("Body") as XmlElement;
         if (body == null)
         {
             text = "Master template \"" + name + "\" does not have any body text/html. In the XML definition, either reference a file with the \"File=\" attribute, or supply a child element called \"<Body>\" and place the text there.";
         }
         else
         {
             text = body.InnerText;
         }
         script = new SprocketScript(text, "Template: " + name, "Template: " + name);
     }
     ReadPageAdminSettings(xml);
 }
Beispiel #3
0
        void WebEvents_OnLoadRequestedPath(HandleFlag handled)
        {
            if (handled.Handled)
            {
                return;
            }
            if (SprocketPath.Sections[0] == "admin")
            {
                if (!WebAuthentication.IsLoggedIn)
                {
                    HttpContext.Current.Response.Write("Access Denied.");
                    handled.Set();
                    return;
                }
                switch (SprocketPath.Value)
                {
                case "admin":
                {
                    string html = WebUtility.CacheTextFile("resources/admin/frames/admin-iframes.htm");
                    //string html = ResourceLoader.LoadTextResource("Sprocket.Web.CMS.Admin.admin-iframes.htm");
                    SprocketScript scr = new SprocketScript(html, "Admin Frames", "Admin Frames");
                    HttpContext.Current.Response.Write(scr.Execute());
                }
                break;

                case "admin/overlay":
                    RenderOverlayPage();
                    break;

                case "admin/frames":
                {
                    string html = WebUtility.CacheTextFile("resources/admin/frames/admin-frames.htm");
                    //string html = ResourceLoader.LoadTextResource("Sprocket.Web.CMS.Admin.admin-frames.htm");
                    SprocketScript scr = new SprocketScript(html, "Admin Overlay Frame", "Admin Overlay Frame");
                    HttpContext.Current.Response.Write(scr.Execute());
                }
                break;

                case "admin/addressbar":
                {
                    string html = WebUtility.CacheTextFile("resources/admin/frames/admin-address-bar.htm");
                    //string html = ResourceLoader.LoadTextResource("Sprocket.Web.CMS.Admin.admin-address-bar.htm");
                    SprocketScript scr = new SprocketScript(html, "Admin Overlay Frame", "Admin Overlay Frame");
                    HttpContext.Current.Response.Write(scr.Execute());
                }
                break;

                default:
                    return;
                }
                handled.Set();
            }
        }
Beispiel #4
0
 void Instance_OnLoadRequestedPath(System.Web.HttpApplication app, string sprocketPath, string[] pathSections, HandleFlag handled)
 {
     if (sprocketPath == "scripttest")
     {
         string         html   = Sprocket.Utility.ResourceLoader.LoadTextResource("Sprocket.Web.CMS.SprocketScript.test.htm");
         SprocketScript script = new SprocketScript(html);
         HttpContext.Current.Response.ContentType = "text/html";
         script.Execute(HttpContext.Current.Response.OutputStream);
         //string test = script.Execute();
         //HttpContext.Current.Response.Write(test);
         handled.Set();
     }
 }
 void Instance_OnLoadRequestedPath(System.Web.HttpApplication app, string sprocketPath, string[] pathSections, HandleFlag handled)
 {
     if (sprocketPath == "scripttest")
     {
         string html = Sprocket.Utility.ResourceLoader.LoadTextResource("Sprocket.Web.CMS.SprocketScript.test.htm");
         SprocketScript script = new SprocketScript(html);
         HttpContext.Current.Response.ContentType = "text/html";
         script.Execute(HttpContext.Current.Response.OutputStream);
         //string test = script.Execute();
         //HttpContext.Current.Response.Write(test);
         handled.Set();
     }
 }
Beispiel #6
0
 public MasterTemplate(XmlElement xml)
 {
     name = xml.GetAttribute("Name");
     if (xml.HasAttribute("File"))
     {
         filePath = WebUtility.MapPath(xml.GetAttribute("File"));
         if (!File.Exists(filePath))
         {
             script = new SprocketScript("[The template \"" + Name + "\" references a nonexistant file]", "Template: " + Name, "Template: " + Name);
         }
         else
         {
             script   = new SprocketScript(File.ReadAllText(filePath), "Template: " + Name, "Template: " + Name);
             fileDate = File.GetLastWriteTime(filePath);
         }
     }
     else
     {
         script = new SprocketScript(xml.InnerText, "Template: " + name, "Template: " + name);
     }
 }
Beispiel #7
0
        void RenderOverlayPage()
        {
            //string html = ResourceLoader.LoadTextResource("Sprocket.Web.CMS.Admin.admin-iframe-overlay.htm");
            List <IAdminMenuItem> items = new List <IAdminMenuItem>();

            foreach (Type t in Core.Modules.GetInterfaceImplementations(typeof(IAdminMenuItem)))
            {
                items.Add((IAdminMenuItem)Activator.CreateInstance(t));
            }
            items.Sort(delegate(IAdminMenuItem a, IAdminMenuItem b)
            {
                int f = a.Priority.CompareTo(b.Priority);
                if (f != 0)
                {
                    return(f);
                }
                return(a.MenuLinkText.CompareTo(b.MenuLinkText));
            });
            StringBuilder links = new StringBuilder();
            StringBuilder head  = new StringBuilder();

            foreach (IAdminMenuItem item in items)
            {
                links.AppendFormat("<span class=\"divider\"> | </span><a class=\"tab\" href=\"javascript:void(0)\" onclick=\"{0}\">{1}</a>",
                                   item.MenuLinkOnClick, item.MenuLinkText);
                head.Append(item.HeadContent);
            }

            string         html = WebUtility.CacheTextFile("resources/admin/frames/admin-iframe-overlay.htm");
            SprocketScript scr  = new SprocketScript(html, "Admin Overlay Frame", "Admin Overlay Frame");

            HttpContext.Current.Response.Write(
                scr.Execute()
                .Replace("[head-content]", head.ToString())
                .Replace("[menu-links]", links.ToString())
                );
        }
Beispiel #8
0
 public TemplateSectionReplacement(XmlElement xml)
 {
     sectionName = xml.GetAttribute("Section");
     if (xml.HasAttribute("File"))
     {
         filePath = WebUtility.MapPath(xml.GetAttribute("File"));
         if (!File.Exists(filePath))
         {
             script = new SprocketScript("[Can't replace section \"" + sectionName + "\"; Path \"" + xml.GetAttribute("File") + "\" doesn't exist]",
                                         "Template Section Replacement: " + sectionName, guid.ToString());
         }
         else
         {
             fileDate = File.GetLastWriteTime(filePath);
             script   = new SprocketScript(File.ReadAllText(filePath), "Template Section Replacement: " + sectionName, guid.ToString());
         }
     }
     //else if (xml.HasAttribute("Template"))
     //    templateName = xml.GetAttribute("Template");
     else
     {
         script = new SprocketScript(xml.InnerText, "Template Section Replacement: " + sectionName, guid.ToString());
     }
 }
Beispiel #9
0
 public AdminSection(SprocketScript script, ObjectRank rank)
 {
     this.script = script;
     this.rank   = rank;
 }