Exemplo n.º 1
0
        private void HandleGetSimpleBootstrap3SettingsXml(ZipArchive zip, XenonCMSContext DB)
        {
            string RequestDomain = Globals.GetRequestDomain(ControllerContext.RequestContext.HttpContext);

            // Handle the Bootstrap3Settings.xml file
            var Bootstrap3SettingsXmlFile = GetSimpleGetXmlDocuments(zip, "other/Bootstrap3Settings.xml");
            foreach (var KVP in Bootstrap3SettingsXmlFile)
            {
                var Site = DB.Sites.Single(x => x.Domain == RequestDomain);
                Site.ContactEmail = KVP.Value.DocumentElement.SelectSingleNode("ContactEmail").InnerText;
                // TODO GetSimple has DisplayOtherThemes
                Site.NavBarInverted = (KVP.Value.DocumentElement.SelectSingleNode("InvertNavigationBar").InnerText == "true");
                Site.Theme = KVP.Value.DocumentElement.SelectSingleNode("SelectedTheme").InnerText;
                // TODO GetSimple has TrackingId
                DB.SaveChanges();
                DatabaseCache.ResetSite(ControllerContext.RequestContext.HttpContext);
            }
        }
Exemplo n.º 2
0
        private void HandleGetSimpleWebsiteXml(ZipArchive zip, XenonCMSContext DB)
        {
            string RequestDomain = Globals.GetRequestDomain(ControllerContext.RequestContext.HttpContext);

            // Handle the Bootstrap3Settings.xml file
            var Bootstrap3SettingsXmlFile = GetSimpleGetXmlDocuments(zip, "other/website.xml");
            foreach (var KVP in Bootstrap3SettingsXmlFile)
            {
                var Site = DB.Sites.Single(x => x.Domain == RequestDomain);
                Site.Title = HttpUtility.HtmlDecode(KVP.Value.DocumentElement.SelectSingleNode("SITENAME").InnerText);
                DB.SaveChanges();
                DatabaseCache.ResetSite(ControllerContext.RequestContext.HttpContext);
            }
        }
Exemplo n.º 3
0
        private void HandleGetSimpleNewsManagerPosts(ZipArchive zip, XenonCMSContext DB)
        {
            string RequestDomain = Globals.GetRequestDomain(ControllerContext.RequestContext.HttpContext);
            int SiteId = DB.Sites.Single(x => x.Domain == RequestDomain).Id;

            // Handle the NewsManager posts files
            var PostsFiles = GetSimpleGetXmlDocuments(zip, "posts/");
            foreach (var KVP in PostsFiles)
            {
                // Update existing or add new post
                // TODO GetSimple has a "tags" tag
                string Slug = Path.GetFileNameWithoutExtension(KVP.Key);
                var SBP = DB.SiteBlogPosts.SingleOrDefault(x => (x.Site.Domain == RequestDomain) && (x.Slug == Slug)) ?? new SiteBlogPost();
                SBP.DateLastUpdated = Convert.ToDateTime(KVP.Value.DocumentElement.SelectSingleNode("date").InnerText);
                SBP.DatePosted = Convert.ToDateTime(KVP.Value.DocumentElement.SelectSingleNode("date").InnerText);
                SBP.FullPostText = HttpUtility.HtmlDecode(KVP.Value.DocumentElement.SelectSingleNode("content").InnerText);
                SBP.SiteId = SiteId;
                SBP.Slug = Slug;
                SBP.Title = HttpUtility.HtmlDecode(KVP.Value.DocumentElement.SelectSingleNode("title").InnerText);
                if (SBP.Id <= 0) DB.SiteBlogPosts.Add(SBP);
                DB.SaveChanges();
                DatabaseCache.ResetBlogIndex(ControllerContext.RequestContext.HttpContext);
            }
        }
Exemplo n.º 4
0
        private void HandleGetSimplePages(ZipArchive zip, XenonCMSContext DB)
        {
            string RequestDomain = Globals.GetRequestDomain(ControllerContext.RequestContext.HttpContext);
            int SiteId = DB.Sites.Single(x => x.Domain == RequestDomain).Id;

            // Handle the pages files
            var PagesFiles = GetSimpleGetXmlDocuments(zip, "pages/");
            foreach (var KVP in PagesFiles)
            {
                // Get slug so we can skip built-in pages
                string Parent = KVP.Value.DocumentElement.SelectSingleNode("parent").InnerText;
                string Url = KVP.Value.DocumentElement.SelectSingleNode("url").InnerText;
                string Slug = string.IsNullOrWhiteSpace(Parent) ? Url : Parent + "/" + Url;
                if (Slug == "index") Slug = "home";
                if ((Slug == "blog") || (Slug == "contact") || (Slug == "news"))
                {
                    // TODO Skipping these built-ins
                }
                else
                {
                    // Update existing or add new page
                    // TODO GetSimple has a "meta" tag,
                    var SP = DB.SitePages.SingleOrDefault(x => (x.Site.Domain == RequestDomain) && (x.Slug == Slug)) ?? new SitePage();
                    SP.DateAdded = Convert.ToDateTime(KVP.Value.DocumentElement.SelectSingleNode("pubDate").InnerText);
                    SP.DateLastUpdated = Convert.ToDateTime(KVP.Value.DocumentElement.SelectSingleNode("pubDate").InnerText);
                    SP.DisplayOrder = Convert.ToInt32(KVP.Value.DocumentElement.SelectSingleNode("menuOrder").InnerText);
                    SP.Html = HttpUtility.HtmlDecode(KVP.Value.DocumentElement.SelectSingleNode("content").InnerText);
                    SP.Layout = "NormalNoSidebar"; // TODO there is a "template" tag
                    SP.ParentId = 0; // TODO there is a "parent" tag
                    SP.RequireAdmin = false; // TODO "private" tag
                    SP.RightAlign = false;
                    SP.ShowInMenu = (KVP.Value.DocumentElement.SelectSingleNode("menuStatus").InnerText == "Y");
                    SP.ShowTitleOnPage = true;
                    SP.SiteId = SiteId;
                    SP.Slug = Slug;
                    SP.Text = HttpUtility.HtmlDecode(KVP.Value.DocumentElement.SelectSingleNode("menu").InnerText); // TODO Rename text to something more intuitive
                    SP.Title = HttpUtility.HtmlDecode(KVP.Value.DocumentElement.SelectSingleNode("title").InnerText);
                    if (SP.Id <= 0) DB.SitePages.Add(SP);
                    DB.SaveChanges();
                    DatabaseCache.ResetNavMenuItems(ControllerContext.RequestContext.HttpContext);
                    DatabaseCache.RemoveSitePage(ControllerContext.RequestContext.HttpContext, Slug);
                }
            }
        }
Exemplo n.º 5
0
        public ActionResult Install(Install model)
        {
            if (Globals.IsNewSite(ControllerContext.RequestContext.HttpContext))
            {
                if (ModelState.IsValid)
                {
                    using (XenonCMSContext DB = new XenonCMSContext())
                    {
                        string RequestDomain = Globals.GetRequestDomain(ControllerContext.RequestContext.HttpContext);
                        Site Site = new Site();
                        Site.AdminIPs = new List<SiteAdminIP>();
                        Site.BlogPosts = new List<SiteBlogPost>();
                        Site.Pages = new List<SitePage>();

                        SiteAdminIP NewAdminIP = new SiteAdminIP();
                        NewAdminIP.Address = ControllerContext.RequestContext.HttpContext.Request.UserHostAddress;
                        Site.AdminIPs.Add(NewAdminIP);

                        SiteBlogPost NewBlogPost = new SiteBlogPost();
                        NewBlogPost.DateLastUpdated = DateTime.Now;
                        NewBlogPost.DatePosted = DateTime.Now;
                        NewBlogPost.FullPostText = "XenonCMS has been successfully installed and is ready for use on " + RequestDomain + "!";
                        NewBlogPost.Slug = "xenoncms-installed";
                        NewBlogPost.Title = "XenonCMS Installed";
                        Site.BlogPosts.Add(NewBlogPost);

                        Site.ContactEmail = "contact@" + RequestDomain;
                        Site.Domain = RequestDomain;
                        Site.NavBarInverted = false;

                        SitePage NewPageHome = new SitePage();
                        NewPageHome.DateAdded = DateTime.Now;
                        NewPageHome.DateLastUpdated = DateTime.Now;
                        NewPageHome.DisplayOrder = 1;
                        NewPageHome.Html = "XenonCMS has been successfully installed and is ready for use on " + RequestDomain + "!";
                        NewPageHome.Layout = "JumbotronNoSidebar";
                        NewPageHome.Text = "Home";
                        NewPageHome.Slug = "home";
                        NewPageHome.ParentId = 0;
                        NewPageHome.RequireAdmin = false;
                        NewPageHome.RightAlign = false;
                        NewPageHome.ShowInMenu = true;
                        NewPageHome.ShowTitleOnPage = true;
                        NewPageHome.Title = "XenonCMS Installed";
                        Site.Pages.Add(NewPageHome);

                        SitePage NewPageBlog = new SitePage();
                        NewPageBlog.DateAdded = DateTime.Now;
                        NewPageBlog.DateLastUpdated = DateTime.Now;
                        NewPageBlog.DisplayOrder = 2;
                        NewPageBlog.Html = "N/A";
                        NewPageBlog.Layout = "NormalSidebar";
                        NewPageBlog.Text = "Blog";
                        NewPageBlog.Slug = "blog";
                        NewPageBlog.ParentId = 0;
                        NewPageBlog.RequireAdmin = false;
                        NewPageBlog.RightAlign = false;
                        NewPageBlog.ShowInMenu = true;
                        NewPageBlog.ShowTitleOnPage = true;
                        NewPageBlog.Title = "Blog";
                        Site.Pages.Add(NewPageBlog);

                        SitePage NewPageContact = new SitePage();
                        NewPageContact.DateAdded = DateTime.Now;
                        NewPageContact.DateLastUpdated = DateTime.Now;
                        NewPageContact.DisplayOrder = 3;
                        NewPageContact.Html = "N/A";
                        NewPageContact.Layout = "NormalSidebar";
                        NewPageContact.Text = "Contact";
                        NewPageContact.Slug = "contact";
                        NewPageContact.ParentId = 0;
                        NewPageContact.RequireAdmin = false;
                        NewPageContact.RightAlign = false;
                        NewPageContact.ShowInMenu = true;
                        NewPageContact.ShowTitleOnPage = true;
                        NewPageContact.Title = "Contact";
                        Site.Pages.Add(NewPageContact);

                        Site.Sidebar = "<div class=\"panel panel-default\"><div class=\"panel-heading\"><h3 class=\"panel-title\">XenonCMS Installed</h3></div><div class=\"panel-body\">XenonCMS has been successfully installed and is ready for use on " + RequestDomain + "!</div></div>";
                        Site.Theme = "Cerulean";
                        Site.Title = RequestDomain;

                        DB.Sites.Add(Site);
                        DB.SaveChanges();

                        DatabaseCache.AddSite(ControllerContext.RequestContext.HttpContext, Site);
                        DatabaseCache.ResetAdminIPs(ControllerContext.RequestContext.HttpContext);
                        DatabaseCache.ResetBlogPosts(ControllerContext.RequestContext.HttpContext);
                        DatabaseCache.ResetNavMenuItems(ControllerContext.RequestContext.HttpContext);
                        DatabaseCache.ResetSidebars(ControllerContext.RequestContext.HttpContext);
                    }

                    return RedirectToAction("Index");
                }
                else
                {
                    return View(model);
                }
            }
            else
            {
                return RedirectToAction("Index");
            }
        }