Beispiel #1
0
        internal void GetParents(ApplicationDbContext db)
        {
            var ParentItems = db.SitePages.Where(x => (x.ParentId == null) && (x.Id != Id)).OrderBy(x => x.LinkText).ToList();

            SitePage NoParent = new SitePage();
            NoParent.Id = 0;
            NoParent.LinkText = "No Parent";
            ParentItems.Insert(0, NoParent);

            Parents = new SelectList(ParentItems, "Id", "LinkText");
        }
Beispiel #2
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");
            }
        }
Beispiel #3
0
        internal void GetParents(Models.XenonCMSContext db)
        {
            var ParentItems = db.SitePages.Where(x => x.ParentId == 0).OrderBy(x => x.Text).ToList();

            SitePage NoParent = new SitePage();
            NoParent.Id = 0;
            NoParent.Text = "No Parent";
            ParentItems.Insert(0, NoParent);

            Parents = new SelectList(ParentItems, "Id", "Text");
        }