Exemplo n.º 1
0
        public ActionResult Page(string lang,string path)
        {
            if (string.IsNullOrEmpty(lang))
            {
                if (this.HttpContext.Request.UserLanguages != null && this.HttpContext.Request.UserLanguages.Any())
                {
                   lang = this.HttpContext.Request.UserLanguages[0];
                }
            }
            Amphiprion.Data.Entities.Page page = null;
            if (string.IsNullOrEmpty(path))
            {
                page = _pageService.GetHomePage();
            }
            else
            {
                 page = _pageService.GetPage("/" + path);
                if (page.IsHomePage)
                    return new PermanentRedirect("~/");
            }

            if (page == null  || !page.IsPagePublished)
            {
               return new HttpNotFoundResult();
            }
            var url =   Url.Content("~" + page.Path);;
            var cp = new ContentPage(lang, page,url);
              //  cp.IsRenderingInPreviewMode = (!permissions.CanEdit || !permissions.CanPublish);
            return View(cp);
        }
        public ActionResult Add(PageCreateEditModel model)
        {
            var canPublish = _cmsAuthorization.RequestPermission(CMSPermissions.PublishPage);

            if (ModelState.IsValid)
            {
                if (model.IsApproved)
                    model.IsApproved = canPublish;

                var p = MapPage(model);
                var slug = _pageService.CreateAndValidateSlug(p, false);
                if (!string.IsNullOrEmpty(slug))
                {
                    _pageService.CreatePage(p);
                    var url = Url.Content("~" + p.Path);
                    var contentModel = new ContentPage(p,url);
                    if (Request.IsAjaxRequest())
                        return Json(contentModel);
                }
                else
                {
                    ModelState.AddModelError("","The title specified would result in a duplicate page.  Choose another parent page or modify the slug property.");
                }
            }

            return View(model);
        }