Ejemplo n.º 1
0
        void ShowLoginScreen(string loginErrorMessage)
        {
            string html = WebUtility.CacheTextFile("resources/admin/login.htm");

            html = html.Replace("{basepath}", WebUtility.BasePath);
            html = html.Replace("{login-processor}", WebUtility.MakeFullPath("admin/login/process"));
            html = html.Replace("{login-error}", loginErrorMessage);
            html = html.Replace("{website-name}", "Website Administration");
            Write(html);
        }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
0
 public Result SendPasswordReminder(Guid userID)
 {
     SecurityProvider.User user = SecurityProvider.User.Load(userID);
     try
     {
         user.SendPasswordReminder(WebUtility.CacheTextFile("resources/passwordreminder.email.txt"));
         return(new Result());
     }
     catch (Exception ex)
     {
         return(new Result(ex.Message));
     }
 }
Ejemplo n.º 4
0
        void WebEvents_OnRequestedPathProcessed()
        {
            if (!HttpContext.Current.Response.ContentType.Contains("html"))
            {
                return;
            }
            if (!IsAdminRequest)
            {
                return;
            }
            if (!WebAuthentication.VerifyAccess(PermissionType.AccessAdminArea))
            {
                return;
            }
            string html = WebUtility.CacheTextFile("resources/admin/header.htm");

            HttpContext.Current.Response.Write(string.Format(html, WebUtility.BasePath));
        }
Ejemplo n.º 5
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())
                );
        }
Ejemplo n.º 6
0
        public string Render()
        {
            interfaceScripts.Sort(RankedObject.SortByRank);
            JavaScriptCollection jsc = new JavaScriptCollection();
            int scrnum = 0;

            foreach (RankedString str in interfaceScripts)
            {
                jsc.Add("sprocket-admin-script-" + scrnum++, str.Render());
            }
            headSections.Add(new RankedString(jsc.CreateScriptTags(), 1000));

            menuLinks.Sort(RankedObject.SortByRank);
            footerLinks.Sort(RankedObject.SortByRank);
            contentSections.Sort(RankedObject.SortByRank);
            headSections.Sort(RankedObject.SortByRank);
            bodyOnLoadScripts.Sort(RankedObject.SortByRank);

            StringBuilder menu = new StringBuilder();

            foreach (AdminMenuLink link in menuLinks)
            {
                menu.AppendFormat("<div id=\"main-menu\">{0}</div>", link.Render());
            }

            menuSections.Add(new RankedString(menu.ToString(), 0));
            menuSections.Sort(RankedObject.SortByRank);

            StringBuilder footer = new StringBuilder();

            foreach (AdminMenuLink link in footerLinks)
            {
                if (footer.Length > 0)
                {
                    footer.Append(" | ");
                }
                footer.Append(link.Render());
            }

            StringBuilder content = new StringBuilder();

            foreach (RankedString section in contentSections)
            {
                content.Append(section.Render());
            }

            StringBuilder head = new StringBuilder();

            foreach (RankedString section in headSections)
            {
                head.Append(section.Render());
            }

            StringBuilder left = new StringBuilder();

            foreach (RankedString section in menuSections)
            {
                left.Append(section.Render());
            }

            StringBuilder onLoad = new StringBuilder();

            foreach (RankedString script in bodyOnLoadScripts)
            {
                string scr = script.Render();
                if (!scr.Trim().EndsWith(";"))
                {
                    scr += ";";
                }
                onLoad.Append(scr);
            }

            string html = WebUtility.CacheTextFile("resources/admin/admin.htm");

            html = html.Replace("{website-name}", websiteName);
            html = html.Replace("{head}", head.ToString());
            html = html.Replace("//{onload}", onLoad.ToString());
            html = html.Replace("{main-menu}", left.ToString());
            html = html.Replace("{main-content}", content.ToString());
            html = html.Replace("{section-heading}", contentHeading);
            html = html.Replace("{footer}", footer.ToString());
            html = html.Replace("{basepath}", WebUtility.BasePath);
            return(html);
        }
Ejemplo n.º 7
0
        private Template GetTemplate(string name, Stack <string> embedStack)
        {
            if (templates.ContainsKey(name) && !ContentCache.IsContentCacheDisabled)
            {
                return(templates[name]);
            }

            Template template;

            if (embedStack == null)
            {
                embedStack = new Stack <string>();
            }
            if (embedStack.Contains(name))
            {
                template = new Template("[Circular dependency detected in template heirarchy at \"" + name + "\"]");
            }
            else
            {
                embedStack.Push(name);

                XmlElement node = (XmlElement)templatesDoc.SelectSingleNode("/Templates/Template[@Name='" + name + "']");
                if (node == null)
                {
                    embedStack.Pop();
                    template = new Template("[The requested template \"" + name + "\" was not found in template definition file]");
                }
                else
                {
                    string text = "";
                    if (node.HasAttribute("Master"))
                    {
                        text = GetTemplate(node.GetAttribute("Master"), embedStack).Text;

                        XmlNodeList nodes = node.SelectNodes("Replace");
                        foreach (XmlElement repl in nodes)
                        {
                            if (!repl.HasAttribute("PlaceHolderName"))
                            {
                                continue;
                            }

                            string phtext;
                            if (repl.HasAttribute("Template"))
                            {
                                phtext = GetTemplate(repl.GetAttribute("Template"), embedStack).Text;
                            }
                            else if (repl.HasAttribute("File"))
                            {
                                phtext = WebUtility.CacheTextFile("resources/templates/" + repl.GetAttribute("File"));
                            }
                            else if (repl.FirstChild == null)
                            {
                                phtext = "";
                            }
                            else if (repl.FirstChild.NodeType == XmlNodeType.Text || repl.FirstChild.NodeType == XmlNodeType.CDATA)
                            {
                                phtext = repl.FirstChild.Value;
                            }
                            else
                            {
                                phtext = "";
                            }

                            text = Regex.Replace(text, PlaceHolder.GetRegexPattern(repl.GetAttribute("PlaceHolderName")), phtext, RegexOptions.IgnoreCase);
                        }
                    }
                    else if (node.HasAttribute("File"))
                    {
                        string path = WebUtility.MapPath("resources/templates/" + node.GetAttribute("File"));
                        if (!File.Exists(path))
                        {
                            text = "[Template file \"" + node.GetAttribute("File") + "\" does not exist]";
                        }
                        else
                        {
                            text = WebUtility.CacheTextFile("resources/templates/" + node.GetAttribute("File"));
                        }
                    }
                    else
                    {
                        if (node.FirstChild == null)
                        {
                            text = "";
                        }
                        else if (node.FirstChild.NodeType == XmlNodeType.Text || node.FirstChild.NodeType == XmlNodeType.CDATA)
                        {
                            text = node.FirstChild.Value;
                        }
                        else
                        {
                            text = "";
                        }
                    }
                    embedStack.Pop();

                    template = new Template(text);
                }
            }
            templates[name] = template;
            return(template);
        }