Ejemplo n.º 1
0
        public ActionResult Index(string pageId, string pageContentId)
        {
            var principal = SecurityService.GetCurrentPrincipal();

            var allRoles = new List<string>(RootModuleConstants.UserRoles.AllRoles);
            if (!string.IsNullOrEmpty(cmsConfiguration.Security.FullAccessRoles))
            {
                allRoles.Add(cmsConfiguration.Security.FullAccessRoles);
            }

            GetPageToRenderRequest request = new GetPageToRenderRequest
                {
                    PageId = pageId.ToGuidOrDefault(),
                    PreviewPageContentId = pageContentId.ToGuidOrDefault(),
                    IsPreview = true,
                    HasContentAccess = SecurityService.IsAuthorized(principal, RootModuleConstants.UserRoles.MultipleRoles(allRoles.ToArray()))
                };

            var model = GetCommand<GetPageToRenderCommand>().ExecuteCommand(request);

            if (model != null && model.RenderPage != null)
            {
                // Render page with hierarchical master pages
                var html = this.RenderPageToString(model.RenderPage);
                html = PageHtmlRenderer.ReplaceRegionRepresentationHtml(html, string.Empty);

                return Content(html);
            }

            return HttpNotFound();
        }
Ejemplo n.º 2
0
        public ActionResult Index(string pageId, string pageContentId)
        {
            GetPageToRenderRequest request = new GetPageToRenderRequest
                {
                    PageId = pageId.ToGuidOrDefault(),
                    PreviewPageContentId = pageContentId.ToGuidOrDefault(),
                    IsPreview = true
                };

            var model = GetCommand<GetPageToRenderCommand>().ExecuteCommand(request);

            if (model.RenderPage != null)
            {
                return View(model.RenderPage);
            }

            return HttpNotFound();
        }
Ejemplo n.º 3
0
        private CmsRequestViewModel GetRequestModel(string virtualPath)
        {
            CmsRequestViewModel model;
            if (virtualPath.Trim() != "/")
            {
                switch (cmsConfiguration.UrlMode)
                {
                    case TrailingSlashBehaviorType.TrailingSlash:
                        virtualPath = VirtualPathUtility.AppendTrailingSlash(virtualPath);
                        break;
                    case TrailingSlashBehaviorType.NoTrailingSlash:
                        virtualPath = VirtualPathUtility.RemoveTrailingSlash(virtualPath);
                        break;
                }
            }

            var principal = SecurityService.GetCurrentPrincipal();

            var allRoles = new List<string>(RootModuleConstants.UserRoles.AllRoles);
            if (!string.IsNullOrEmpty(cmsConfiguration.Security.FullAccessRoles))
            {
                allRoles.Add(cmsConfiguration.Security.FullAccessRoles);
            }
            var canManageContent = SecurityService.IsAuthorized(principal, RootModuleConstants.UserRoles.MultipleRoles(allRoles.ToArray()));

            var useCaching = cmsConfiguration.Cache.Enabled && !canManageContent;
            var request = new GetPageToRenderRequest {
                                                         PageUrl = virtualPath,
                                                         CanManageContent = canManageContent,
                                                         HasContentAccess = canManageContent,
                                                         IsAuthenticated = principal != null && principal.Identity.IsAuthenticated
                                                     };

            if (useCaching)
            {
                string cacheKey = "CMS_" + CalculateHash(virtualPath) + "_050cc001f75942648e57e58359140d1a";
                model = cacheService.Get(cacheKey, cmsConfiguration.Cache.Timeout, () => GetCommand<GetPageToRenderCommand>().ExecuteCommand(request));
            }
            else
            {
                var command = GetCommand<GetPageToRenderCommand>();
                model = command.Execute(request);
            }

            return model;
        }
Ejemplo n.º 4
0
        private CmsRequestViewModel GetRequestModel(string virtualPath)
        {
            CmsRequestViewModel model;
            virtualPath = VirtualPathUtility.AppendTrailingSlash(virtualPath);
            var principal = SecurityService.GetCurrentPrincipal();

            var canManageContent = SecurityService.IsAuthorized(
                principal,
                RootModuleConstants.UserRoles.MultipleRoles(SecurityService.GetAllRoles()));

            var useCaching = cmsConfiguration.Cache.Enabled && !canManageContent;
            var request = new GetPageToRenderRequest {
                                                         PageUrl = virtualPath,
                                                         CanManageContent = canManageContent,
                                                         IsAuthenticated = principal != null && principal.Identity.IsAuthenticated
                                                     };
            if (useCaching)
            {
                string cacheKey = "CMS_" + CalculateHash(virtualPath) + "_050cc001f75942648e57e58359140d1a";

                model = cacheService.Get(cacheKey, cmsConfiguration.Cache.Timeout, () => GetCommand<GetPageToRenderCommand>().ExecuteCommand(request));
            }
            else
            {
                var command = GetCommand<GetPageToRenderCommand>();
                model = command.Execute(request);
            }

            return model;
        }