Пример #1
0
        public ActionResult PreviewContent(int id)
        {
            var model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailsById(id)
            };

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

            if (model.ThePage != null)
            {
                ViewBag.IsPublished = model.IsPublished;
                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));
        }
Пример #2
0
        public ActionResult Index()
        {
            var model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailsByTitle("home")
            };

            if (model.ThePage != null)
            {
                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 ?? "";
                model.TheTemplate   = ContentLoader.GetContentTemplate(model.ThePage.Template);
                // Set the page Canonical Tag and OGURl
                ViewBag.OGUrl     = model.ThePage.OGUrl ?? GetCanonical(model.ThePage);
                ViewBag.Canonical = GetCanonical(model.ThePage);
                model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent, Context);
                ViewBag.Index     = model.ThePage.NoIndex ? "noindex" : "index";
                ViewBag.Follow    = model.ThePage.NoFollow ? "nofollow" : "follow";

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

            HttpContext.Response.StatusCode = 404;
            return(View("~/Views/Home/Error404.cshtml"));
        }
        public ActionResult ResetPasswordSuccess()
        {
            var model = new ContentViewViewModel("resetpasswordsuccess");

            if (model.ThePage != null)
            {
                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));
        }
Пример #4
0
        public ActionResult ResetPasswordSuccess()
        {
            var model = new ContentViewViewModel("resetpasswordsuccess");

            if (model.ThePage != null)
            {
                return(View(model.TheTemplate.ViewLocation, model));
            }

            HttpContext.Response.StatusCode = 404;
            return(View("~/Views/Home/Error404.cshtml"));
        }
Пример #5
0
        public ActionResult Index()
        {
            var model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailsByPermalink("home")
            };

            if (model.ThePage != null)
            {
                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 ?? "";
                model.TheTemplate   = ContentLoader.GetContentTemplate(model.ThePage.Template);
                // Set the page Canonical Tag and OGURl
                ViewBag.OGUrl     = model.ThePage.OGUrl ?? GetCanonical(model.ThePage);
                ViewBag.Canonical = GetCanonical(model.ThePage);
                model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);
                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));
        }
Пример #6
0
        public ActionResult PreviewContent(int id)
        {
            var model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailById(id)
            };

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

            if (model.ThePage != null)
            {
                ViewBag.IsPublished = model.IsPublished;
                return(View(model.TheTemplate.ViewLocation, model));
            }

            HttpContext.Response.StatusCode = 404;
            return(View("~/Views/Home/Error404.cshtml"));
        }
Пример #7
0
        private ContentViewViewModel GetSubDirectoryModel(string path)
        {
            var masterList = CachedObjects.GetCacheNavigationList(1);
            var pathPieces = path.Split('/');
            var permalink  = pathPieces.Last().ToLower();

            var currentPath       = "/" + pathPieces[0] + "/";
            var currentNavigation = masterList.FirstOrDefault(x => String.Equals(x.Href, currentPath, StringComparison.CurrentCultureIgnoreCase));

            foreach (var piece in pathPieces.Skip(1).Take(pathPieces.Count() - 2))
            {
                if (currentNavigation == null)
                {
                    break;
                }
                currentPath       = currentPath + piece + "/";
                currentNavigation =
                    currentNavigation.Children.FirstOrDefault(
                        x => String.Equals(x.Href, currentPath, StringComparison.CurrentCultureIgnoreCase));
            }

            if (currentNavigation == null)
            {
                return(null);
            }

            var thePage = CachedObjects.GetCacheContentPages().FirstOrDefault(x => x.Permalink == permalink && x.ParentNavigationItemId == currentNavigation.NavigationItemId);

            if (thePage == null)
            {
                thePage = Context.ContentPages.FirstOrDefault(x => x.Permalink == permalink && x.ParentNavigationItemId == currentNavigation.NavigationItemId);
            }

            if (thePage == null)
            {
                return(null);
            }

            var model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailById(thePage.ContentPageId)
            };

            return(model);
        }
Пример #8
0
		public ActionResult Index()
		{
		    var model = new ContentViewViewModel {ThePage = ContentLoader.GetDetailsByPermalink("home")};

		    if (model.ThePage != null)
            {
                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 ?? "";
                model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
                // Set the page Canonical Tag and OGURl
                ViewBag.OGUrl = model.ThePage.OGUrl ?? GetCanonical(model.ThePage);
                ViewBag.Canonical = GetCanonical(model.ThePage);
                model.PageData = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);
                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);
		}
Пример #9
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);
        }
Пример #10
0
        private ContentViewViewModel GetSubDirectoryModel(string path)
        {
            var masterList = CachedObjects.GetCacheNavigationList(1);
            var pathPieces = path.Split('/');
            var permalink = pathPieces.Last().ToLower();

            var currentPath = "/" + pathPieces[0] + "/";
            var currentNavigation = masterList.FirstOrDefault(x => String.Equals(x.Href, currentPath, StringComparison.CurrentCultureIgnoreCase));

            foreach (var piece in pathPieces.Skip(1).Take(pathPieces.Count() - 2))
            {
                if (currentNavigation == null) break;
                currentPath = currentPath + piece + "/";
                currentNavigation =
                    currentNavigation.Children.FirstOrDefault(
                        x => String.Equals(x.Href, currentPath, StringComparison.CurrentCultureIgnoreCase));
            }

            if (currentNavigation == null) return null;

            var thePage = CachedObjects.GetCacheContentPages().FirstOrDefault(x => x.Permalink == permalink && x.ParentNavigationItemId == currentNavigation.NavigationItemId);

            if (thePage == null)
            {
                thePage = Context.ContentPages.FirstOrDefault(x => x.Permalink == permalink && x.ParentNavigationItemId == currentNavigation.NavigationItemId);
            }

            if (thePage == null) return null;

            var model = new ContentViewViewModel { ThePage = ContentLoader.GetDetailsById(thePage.ContentPageId) };

            return model;
        }
Пример #11
0
        public ActionResult ResetPasswordSuccess()
        {
            var model = new ContentViewViewModel("resetpasswordsuccess");

            if (model.ThePage != null)
            {
                return View(model.TheTemplate.ViewLocation, model);
            }

            HttpContext.Response.StatusCode = 404;
            return View("~/Views/Home/Error404.cshtml");
        }
Пример #12
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));
        }
Пример #13
0
        public ActionResult ResetPasswordSuccess()
        {
            var model = new ContentViewViewModel("reset-password-success");

            if (model.ThePage != null)
            {
                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;
            return 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);
        }
Пример #14
0
        public ActionResult Index()
        {
            var model = new ContentViewViewModel {ThePage = ContentLoader.GetDetailsByTitle("home")};

            if (model.ThePage != null)
            {
                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 ?? "";
                model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
                // Set the page Canonical Tag and OGURl
                ViewBag.OGUrl = model.ThePage.OGUrl ?? GetCanonical(model.ThePage);
                ViewBag.Canonical = GetCanonical(model.ThePage);
                model.PageData = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);
                ViewBag.Index = model.ThePage.NoIndex ? "noindex" : "index";
                ViewBag.Follow = model.ThePage.NoFollow ? "nofollow" : "follow";

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

            HttpContext.Response.StatusCode = 404;
            return View("~/Views/Home/Error404.cshtml");
        }