Beispiel #1
0
        public override ActionResult Edit(Page newModel, string old_key)
        {
            JsonResultEntry result = new JsonResultEntry();

            try
            {
                newModel.Site     = Site;
                newModel.UserName = User.Identity.Name;

                var old = Manager.Get(Site, old_key);

                SavePosition(newModel);

                var saveAsDraft = this.Request.Form["SaveAsDraft"];

                result.RedirectUrl = GetReturnUrl();

                if (!string.IsNullOrEmpty(saveAsDraft) && saveAsDraft.ToLower() == "true")
                {
                    Manager.PageProvider.SaveAsDraft(newModel);
                    result.Model = new { preview = true };
                    //result.RedirectUrl = Url.Action("Draft", ControllerContext.RequestContext.AllRouteValues());
                }
                else
                {
                    var setPublished = Request.Form["SetPublished"];
                    if (!string.IsNullOrEmpty(setPublished))
                    {
                        var published = false;
                        bool.TryParse(setPublished, out published);
                        newModel.Published = published;
                    }
                    else
                    {
                        result.RedirectUrl = null;
                        result.AddMessage("The item has been saved.".Localize());
                    }
                    Manager.Update(Site, newModel, old);
                }

                if (string.IsNullOrEmpty(result.RedirectUrl))
                {
                    result.Model = FrontUrlHelper.Preview(Url, Kooboo.CMS.Sites.Models.Site.Current, newModel, null).ToString();
                }
            }
            catch (Exception e)
            {
                result.AddException(e);
            }

            return(Json(result));
        }
Beispiel #2
0
        public override IHtmlString RenderItemColumn(System.Web.Mvc.ViewContext viewContext)
        {
            var isStaticPage = Kooboo.CMS.Sites.Services.ServiceFactory.PageManager.IsStaticPage(Kooboo.CMS.Sites.Models.Site.Current, (Page)DataItem);

            UrlHelper urlHelper = new UrlHelper(viewContext.RequestContext);
            var       href      = FrontUrlHelper.Preview(urlHelper, Kooboo.CMS.Sites.Models.Site.Current, (Page)DataItem, null);

            if (!isStaticPage)
            {
                return(new HtmlString(PropertyValue == null ? "" : PropertyValue.ToString()));
            }

            return(new HtmlString(string.Format(@"<a href=""{0}"" target=""_blank"" class=""o-icon preview"" title=""{2}"">{1}</a>", href, PropertyValue, PropertyValue)));
        }
Beispiel #3
0
        public IHtmlString Render(object dataItem, object value, ViewContext viewContext)
        {
            var isStaticPage = Kooboo.CMS.Sites.Services.ServiceFactory.PageManager.IsStaticPage(Kooboo.CMS.Sites.Models.Site.Current, (Page)dataItem);

            UrlHelper urlHelper = new UrlHelper(viewContext.RequestContext);
            var       href      = FrontUrlHelper.Preview(urlHelper, Kooboo.CMS.Sites.Models.Site.Current, (Page)dataItem, null);

            if (!isStaticPage)
            {
                return(new HtmlString(""));
            }

            return(new HtmlString(string.Format(@"<a href=""{0}"" target=""_blank"" class=""o-icon preview"" title=""{2}"">{1}</a>", href, "Preview".Localize(), "Preview".Localize())));
        }