Ejemplo n.º 1
0
        public ActionResult EditContent(int id, string schema, string editContentHeading)
        {
            var model = new EditContentViewModel();

            var editContentHelper = new EditContentHelper(Context);

            editContentHelper.LoadContentViewById(id, model);

            var userName = UserUtils.CurrentMembershipUsername();
            var user     = Context.Users.First(usr => usr.Username == userName);

            model.IsBookmarked = Context.Bookmarks.Any(bookmark => bookmark.Url == Request.RawUrl && bookmark.UserId == user.UserId);

            schema = schema ?? "0";

            // If Schema is Assigned, make sure to show the Field Editor
            int schemaId = Int32.Parse(schema);

            if (schemaId > 0)
            {
                model.ShowFieldEditor = true;
            }

            if (!String.IsNullOrEmpty(editContentHeading))
            {
                model.Heading = editContentHeading;
            }

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult EditContentBasic(int id)
        {
            var model = new EditContentViewModel();

            var editContentHelper = new EditContentHelper(Context);

            editContentHelper.LoadContentViewById(id, model);

            return(View(model));
        }
Ejemplo n.º 3
0
        public JsonResult DeleteContent(int id)
        {
            var result = new JsonResult()
            {
                Data = new { success = false, message = "There was an error processing your request." }
            };

            var helper  = new EditContentHelper(Context);
            var success = helper.DeleteContentPage(id);



            if (success)
            {
                result.Data = new { success = true, message = "The page has been successfully deleted." };
            }

            return(result);
        }
Ejemplo n.º 4
0
        public ActionResult Index()
        {
            ContentViewViewModel model = null;

            //Remove query string
            var thisUri = new Uri(Request.Url.GetLeftPart(UriPartial.Path));

            // Check for content pages before returning a 404
            var fullPath = GetPageFullPath(thisUri);

            // If url has a subdirectory, try the master url list to see if it is a child page
            bool hasSubDirectory = fullPath.Contains("/");
            if (hasSubDirectory)
            {
                model = GetSubDirectoryModel(fullPath);
            }

            // If not a subdirectory try based on permalink / title
            if (model == null || model.ThePage == null)
            {
                model = new ContentViewViewModel { ThePage = ContentLoader.GetDetailsByPermalink(fullPath) };
                
            }

            // If we found a hit, return the view, otherwise 404
            if (model.ThePage != null)
            {
                model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
                model.PageData = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

                if (UserUtils.UserIsAdmin())
                {

                    var userName = UserUtils.CurrentMembershipUsername();
                    var user = Context.Users.First(usr => usr.Username == userName);

                    var pageModel = new EditContentViewModel();
                    var editContentHelper = new EditContentHelper(Context);
                    editContentHelper.LoadContentViewById(model.ThePage.ContentPageId, pageModel);

                    pageModel.BookmarkTitle = model.ThePage.Title;
                    pageModel.IsBookmarked =
                        Context.Bookmarks.Any(
                            bookmark =>
                                bookmark.Title == fullPath && bookmark.Url == Request.RawUrl &&
                                bookmark.UserId == user.UserId);
                    

                    ViewBag.PageModel = pageModel;
                }

                ViewBag.IsPage = true;
                ViewBag.PageId = model.ThePage.ContentPageId;
                ViewBag.IsPublished = model.ThePage.IsActive;
                ViewBag.OGType = model.ThePage.OGType ?? "website";
                ViewBag.MetaDesc = model.ThePage.MetaDescription ?? "";
                ViewBag.Title = model.ThePage.Title;
                ViewBag.OGTitle = model.ThePage.Title ?? model.ThePage.OGTitle;
                ViewBag.OGImage = model.ThePage.OGImage ?? "";

                // Set the page Canonical Tag and OGURl
                ViewBag.Canonical = GetCanonical(model.ThePage);
                ViewBag.OGUrl = model.ThePage.OGUrl ?? ViewBag.Canonical;

                ViewBag.Index = model.ThePage.NoIndex ? "noindex" : "index";
                ViewBag.Follow = model.ThePage.NoFollow ? "nofollow" : "follow";

                return View(model.TheTemplate.ViewLocation, model);
            }

            model = new ContentViewViewModel { ThePage = ContentLoader.GetDetailsById(Convert.ToInt16(ConfigurationManager.AppSettings["404ContentPageId"])) };

            model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
            model.PageData = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

            ViewBag.IsPage = true;
            ViewBag.PageId = model.ThePage.ContentPageId;
            ViewBag.IsPublished = model.ThePage.IsActive;
            ViewBag.Title = model.ThePage.Title;
            ViewBag.Index = "noindex";
            ViewBag.Follow = "nofollow";

            HttpContext.Response.StatusCode = 404;
            Response.TrySkipIisCustomErrors = true;
            return View(model.TheTemplate.ViewLocation, model);
        }
Ejemplo n.º 5
0
        public ActionResult Index()
        {
            ContentViewViewModel model = null;

            //Remove query string
            var thisUri = new Uri(Request.Url.GetLeftPart(UriPartial.Path));

            // Check for content pages before returning a 404
            var title = GetPageTitle(thisUri);

            // If url has a subdirectory, try the master url list to see if it is a child page
            bool hasSubDirectory = title.Contains("/");

            if (hasSubDirectory)
            {
                model = GetSubDirectoryModel(title);
            }

            // If not a subdirectory try based on permalink / title
            if (model == null || model.ThePage == null)
            {
                model = new ContentViewViewModel {
                    ThePage = ContentLoader.GetDetailsByTitle(title)
                };
            }

            // If we found a hit, return the view, otherwise 404
            if (model.ThePage != null)
            {
                model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
                model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

                if (UserUtils.UserIsAdmin())
                {
                    var userName = UserUtils.CurrentMembershipUsername();
                    var user     = Context.Users.First(usr => usr.Username == userName);

                    var pageModel         = new EditContentViewModel();
                    var editContentHelper = new EditContentHelper(Context);
                    editContentHelper.LoadContentViewById(model.ThePage.ContentPageId, pageModel);

                    pageModel.BookmarkTitle = model.ThePage.Title;
                    pageModel.IsBookmarked  =
                        Context.Bookmarks.Any(
                            bookmark =>
                            bookmark.Title == title && bookmark.Url == Request.RawUrl &&
                            bookmark.UserId == user.UserId);


                    ViewBag.PageModel = pageModel;
                }

                ViewBag.IsPage      = true;
                ViewBag.PageId      = model.ThePage.ContentPageId;
                ViewBag.IsPublished = model.ThePage.IsActive;
                ViewBag.OGType      = model.ThePage.OGType ?? "website";
                ViewBag.MetaDesc    = model.ThePage.MetaDescription ?? "";
                ViewBag.Title       = model.ThePage.Title;
                ViewBag.OGTitle     = model.ThePage.Title ?? model.ThePage.OGTitle;
                ViewBag.OGImage     = model.ThePage.OGImage ?? "";

                // Set the page Canonical Tag and OGURl
                ViewBag.Canonical = GetCanonical(model.ThePage);
                ViewBag.OGUrl     = model.ThePage.OGUrl ?? ViewBag.Canonical;

                ViewBag.Index  = model.ThePage.NoIndex ? "noindex" : "index";
                ViewBag.Follow = model.ThePage.NoFollow ? "nofollow" : "follow";

                return(View(model.TheTemplate.ViewLocation, model));
            }

            model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailsByTitle("404")
            };

            model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
            model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

            ViewBag.IsPage      = true;
            ViewBag.PageId      = model.ThePage.ContentPageId;
            ViewBag.IsPublished = model.ThePage.IsActive;
            ViewBag.Title       = model.ThePage.Title;
            ViewBag.Index       = "noindex";
            ViewBag.Follow      = "nofollow";

            HttpContext.Response.StatusCode = 404;
            Response.TrySkipIisCustomErrors = true;
            return(View(model.TheTemplate.ViewLocation, model));
        }