示例#1
0
        public ActionResult EmailBody(string id, bool? useUnlayer)
        {
            var i = id.ToInt();
            var c = ViewExtensions2.GetContent(i);
            if (c == null)
            {
                return new EmptyResult();
            }

            var design = string.Empty;
            var body = string.Empty;

            if (c.TypeID == ContentTypeCode.TypeUnlayerSavedDraft)
            {
                dynamic payload = JsonConvert.DeserializeObject(c.Body);
                design = payload.design;
                body = payload.rawHtml;
            }
            else
                body = c.Body;
            
            var doc = new HtmlDocument();
            doc.LoadHtml(body);
            var bvedits = doc.DocumentNode.SelectNodes("//div[contains(@class,'bvedit') or @bvedit]");
            if (bvedits == null || !bvedits.Any())
            {
                body = $"<div bvedit='discardthis'>{body}</div>";
            }

            ViewBag.body = body;
            ViewBag.design = design;
            ViewBag.useUnlayer = useUnlayer;
            return View();
        }
示例#2
0
        public ActionResult EmailBody(string id)
        {
            if (id == "0") // used for unlayer, force using a blank empty template with only "click here to edit content"
            {
                ViewBag.body       = "<div class='bvedit'>Click here to edit content</div>";
                ViewBag.design     = "";
                ViewBag.useUnlayer = true;
                return(View());
            }
            var i = id.ToInt();
            var c = ViewExtensions2.GetContent(i);

            if (c == null)
            {
                return(new EmptyResult());
            }

            var design = string.Empty;
            var body   = string.Empty;

            if (ContentTypeCode.IsUnlayer(c.TypeID))
            {
                if (!c.Body.HasValue())
                {
                    c.Body = "<div class='bvedit'>Click here to edit content</div>";
                }
                else
                {
                    dynamic payload = JsonConvert.DeserializeObject(c.Body);
                    design = payload.design;
                    body   = payload.rawHtml;
                }
            }
            else
            {
                body = c.Body;
            }

            var doc = new HtmlDocument();

            doc.LoadHtml(body);
            var bvedits = doc.DocumentNode.SelectNodes("//div[contains(@class,'bvedit') or @bvedit]");

            if (bvedits == null || !bvedits.Any())
            {
                body = $"<div bvedit='discardthis'>{body}</div>";
            }

            ViewBag.body       = body;
            ViewBag.design     = design;
            ViewBag.useUnlayer = true;
            return(View());
        }
示例#3
0
        public ActionResult CloneDraft(int id, string name, Guid queryId)
        {
            var content = ViewExtensions2.GetContent(id);
            var clone = new Content
            {
                Name = name.HasValue()
                    ? name
                    : "new draft " + DateTime.Now.FormatDateTm(),
                TypeID = content.TypeID,
                RoleID = content.RoleID,
                OwnerID = Util.UserId,
                Title = content.Title,
                Body = content.Body,
                Archived = null,
                ArchivedFromId = null,
                DateCreated = DateTime.Now
            };

            CurrentDatabase.Contents.InsertOnSubmit(clone);
            CurrentDatabase.SubmitChanges();
            return RedirectToAction("Index", new {id = queryId});
        }
示例#4
0
        public ActionResult EmailBody(string id)
        {
            var i = id.ToInt();
            var c = ViewExtensions2.GetContent(i);

            if (c == null)
            {
                return(new EmptyResult());
            }

            var doc = new HtmlDocument();

            doc.LoadHtml(c.Body);
            var bvedits = doc.DocumentNode.SelectNodes("//div[contains(@class,'bvedit') or @bvedit]");

            if (bvedits == null || !bvedits.Any())
            {
                c.Body = $"<div bvedit='discardthis'>{c.Body}</div>";
            }

            ViewBag.content = c;
            return(View());
        }