public ActionResult ContentEdit(int?id, bool?snippet) { if (!id.HasValue) { throw new HttpException(404, "No ID found."); } var q = from c in CurrentDatabase.Contents where c.Id == id.Value select new { content = c, keywords = string.Join(",", c.ContentKeyWords.Select(vv => vv.Word)) }; var i = q.SingleOrDefault(); if (i == null) { throw new HttpException(404, "No ID found."); } if (snippet == true) { i.content.Snippet = true; CurrentDatabase.SubmitChanges(); } ViewBag.ContentKeywords = i.keywords; if (ContentTypeCode.IsUnlayer(i.content.TypeID)) { ViewBag.TemplateId = id; return(View("UnLayerCompose", i.content)); } return(RedirectEdit(i.content)); }
public void SaveThumbnail(string body, Content content) { #if DEBUG if (!DbUtil.DatabaseExists("CMSi_" + CurrentDatabase.Host)) { return; } #endif if (ContentTypeCode.IsTemplate(content.TypeID)) { try { var captureWebPageBytes = CaptureWebPageBytes(body, 100, 150); var ii = CurrentImageDatabase.UpdateImageFromBits(content.ThumbID, captureWebPageBytes); if (ii == null) { content.ThumbID = ImageData.Image.NewImageFromBits(captureWebPageBytes, CurrentImageDatabase).Id; } } catch (Exception ex) { var errorLog = ErrorLog.GetDefault(null); errorLog.Log(new Error(ex)); } } }
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()); }