public void Post([FromBody] HtmlTextInfo HtmlText) { if (ModelState.IsValid) { htmltext.AddHtmlText(HtmlText); } }
private async Task SaveContent() { string content = await RichTextEditorHtml.GetHtml(); content = content.Replace("/" + PageState.Alias.AliasId.ToString() + Constants.ContentUrl, Constants.ContentUrl); try { var htmltext = await HtmlTextService.GetHtmlTextAsync(ModuleState.ModuleId); if (htmltext != null) { htmltext.Content = content; await HtmlTextService.UpdateHtmlTextAsync(htmltext); } else { htmltext = new HtmlTextInfo(); htmltext.ModuleId = ModuleState.ModuleId; htmltext.Content = content; await HtmlTextService.AddHtmlTextAsync(htmltext); } await logger.LogInformation("Html/Text Content Saved {HtmlText}", htmltext); NavigationManager.NavigateTo(NavigateUrl()); } catch (Exception ex) { await logger.LogError(ex, "Error Saving Content {Error}", ex.Message); AddModuleMessage("Error Saving Content", MessageType.Error); } }
public void Put(int id, [FromBody] HtmlTextInfo HtmlText) { if (ModelState.IsValid) { htmltext.UpdateHtmlText(HtmlText); } }
private void setEditContent(HtmlTextInfo htmlText) { htmlText = htmlText == null ? new HtmlTextInfo() : htmlText; txtModuleTitle.Text = htmlText.ModuleTitle; txtContent.Text = FormatContent(htmlText.Content); txtSummary.Text = htmlText.Summary; hfEditor.Value = new JavaScriptSerializer().Serialize(htmlText); }
public HtmlTextInfo Post([FromBody] HtmlTextInfo HtmlText) { if (ModelState.IsValid) { HtmlText = htmltext.AddHtmlText(HtmlText); } return(HtmlText); }
public HtmlTextInfo Post([FromBody] HtmlTextInfo HtmlText) { if (ModelState.IsValid && HtmlText.ModuleId == EntityId) { HtmlText = htmltext.AddHtmlText(HtmlText); } return(HtmlText); }
public HtmlTextInfo Put(int id, [FromBody] HtmlTextInfo HtmlText) { if (ModelState.IsValid && HtmlText.ModuleId == EntityId) { HtmlText = htmltext.UpdateHtmlText(HtmlText); } return(HtmlText); }
protected void lvVersions_ItemDataBound(object sender, System.Web.UI.WebControls.ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { HtmlTextInfo htmlText = (HtmlTextInfo)e.Item.DataItem; Literal litVersion = (Literal)e.Item.FindControl("litVersion"); Literal litDate = (Literal)e.Item.FindControl("litDate"); Literal litTitle = (Literal)e.Item.FindControl("litTitle"); Literal litContent = (Literal)e.Item.FindControl("litContent"); Literal litDisplayName = (Literal)e.Item.FindControl("litDisplayName"); Literal litPublished = (Literal)e.Item.FindControl("litPublished"); ImageButton btnRemove = (ImageButton)e.Item.FindControl("btnRemove"); ImageButton btnPreview = (ImageButton)e.Item.FindControl("btnPreview"); ImageButton btnRollback = (ImageButton)e.Item.FindControl("btnRollback"); litVersion.Text = htmlText.Version.ToString(); DateTime lastModifiedDate = htmlText.LastModifiedOnDate > htmlText.CreatedOnDate ? htmlText.LastModifiedOnDate : htmlText.CreatedOnDate; litDate.Text = lastModifiedDate.ToString("dd/MM/yyyy hh:mm:ss"); litTitle.Text = htmlText.ModuleTitle; litContent.Text = HtmlUtils.Shorten(HtmlUtils.Clean(htmlText.Content, false), 80, "..."); int lastModifiedBy = htmlText.LastModifiedOnDate > htmlText.CreatedOnDate ? htmlText.LastModifiedByUserId : htmlText.CreatedByUserID; var objUser = DotNetNuke.Entities.Users.UserController.GetUserById(PortalId, lastModifiedBy); litDisplayName.Text = objUser != null ? objUser.DisplayName : "Default"; litPublished.Text = htmlText.IsPublished.ToString(); //set command args btnRemove.CommandArgument = htmlText.ItemId.ToString(); btnPreview.CommandArgument = htmlText.ItemId.ToString(); btnRollback.CommandArgument = htmlText.ItemId.ToString(); //hide remove button for Non-Admin string deleteMsg = Localization.GetString("DeleteVersion.Confirm", LocalResourceFile) .Replace("[VERSION]", htmlText.Version.ToString()) .Replace("[LOCALE]", htmlText.Locale); btnRemove.OnClientClick = "return confirm(\"" + deleteMsg + "\");"; btnRemove.Visible = (UserInfo.IsSuperUser || PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)); //hide rollback button for current active item if (_topHtmlTextItemId == -1) { var item = _htmlTextController.GetTopHtmlText(ModuleId, ddlLocale.SelectedValue, true); if (item != null) { _topHtmlTextItemId = item.ItemId; } } string rollbackMsg = Localization.GetString("RollbackVersion.Confirm", LocalResourceFile) .Replace("[VERSION]", htmlText.Version.ToString()) .Replace("[LOCALE]", htmlText.Locale); btnRollback.OnClientClick = "return confirm(\"" + rollbackMsg + "\");"; btnRollback.Visible = (htmlText.ItemId != _topHtmlTextItemId); } }
public void DeleteHtmlText(int moduleId) { HtmlTextInfo htmlText = _db.HtmlText.FirstOrDefault(item => item.ModuleId == moduleId); if (htmlText != null) { _db.HtmlText.Remove(htmlText); } _db.SaveChanges(); }
public HtmlTextInfo Get(int id) { HtmlTextInfo HtmlText = null; if (EntityId == id) { HtmlText = htmltext.GetHtmlText(id); } return(HtmlText); }
public string ExportModule(Module Module) { string content = ""; HtmlTextInfo htmltext = htmltexts.GetHtmlText(Module.ModuleId); if (htmltext != null) { content = WebUtility.HtmlEncode(htmltext.Content); } return content; }
protected void DisplayContent(HtmlTextInfo htmlText) { phLocale.Visible = true; setEditContent(htmlText); phEdit.Visible = true; phPreview.Visible = false; phHistory.Visible = false; btnSave.Enabled = true; btnEdit.Enabled = false; btnPreview.Enabled = true; btnHistory.Enabled = true; }
public HtmlTextInfo GetHtmlText(int HtmlTextId) { try { HtmlTextInfo HtmlText = db.HtmlText.Find(HtmlTextId); return(HtmlText); } catch { throw; } }
public void AddHtmlText(HtmlTextInfo HtmlText) { try { db.HtmlText.Add(HtmlText); db.SaveChanges(); } catch { throw; } }
public void UpdateHtmlText(HtmlTextInfo HtmlText) { try { db.Entry(HtmlText).State = EntityState.Modified; db.SaveChanges(); } catch { throw; } }
public HtmlTextInfo UpdateHtmlText(HtmlTextInfo HtmlText) { try { _db.Entry(HtmlText).State = EntityState.Modified; _db.SaveChanges(); return(HtmlText); } catch { throw; } }
public void DeleteHtmlText(int HtmlTextId) { try { HtmlTextInfo HtmlText = db.HtmlText.Find(HtmlTextId); db.HtmlText.Remove(HtmlText); db.SaveChanges(); } catch { throw; } }
public HtmlTextInfo AddHtmlText(HtmlTextInfo HtmlText) { try { db.HtmlText.Add(HtmlText); db.SaveChanges(); return(HtmlText); } catch { throw; } }
public void DeleteHtmlText(int ModuleId) { try { HtmlTextInfo HtmlText = db.HtmlText.Where(item => item.ModuleId == ModuleId).FirstOrDefault(); db.HtmlText.Remove(HtmlText); db.SaveChanges(); } catch { throw; } }
private void AddPictureToPage(int tabId, string imageUrl) { var moduleDef = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Text/HTML"); var tab = TabController.Instance.GetTab(tabId, 0); var objModule = new ModuleInfo(); objModule.Initialize(0); objModule.PortalID = 0; objModule.TabID = tab.TabID; objModule.ModuleOrder = 0; objModule.ModuleTitle = tab.Title; objModule.PaneName = "ContentPane"; objModule.ModuleDefID = moduleDef.ModuleDefID; // Text/HTML objModule.CacheTime = 1200; ModuleController.Instance.InitialModulePermission(objModule, objModule.TabID, 0); objModule.CultureCode = Null.NullString; objModule.AllTabs = false; objModule.Alignment = ""; var moduleId = ModuleController.Instance.AddModule(objModule); //creating the content object, and adding the content to the module var htmlTextController = new HtmlTextController(); var workflowStateController = new WorkflowStateController(); int workflowId = htmlTextController.GetWorkflow(moduleId, tabId, 0).Value; HtmlTextInfo htmlContent = htmlTextController.GetTopHtmlText(moduleId, false, workflowId); if (htmlContent == null) { htmlContent = new HtmlTextInfo(); htmlContent.ItemID = -1; htmlContent.StateID = workflowStateController.GetFirstWorkflowStateID(workflowId); htmlContent.WorkflowID = workflowId; htmlContent.ModuleID = moduleId; htmlContent.IsPublished = true; htmlContent.Approved = true; htmlContent.IsActive = true; } htmlContent.Content = $"<img src='/Portals/0/{imageUrl}' />"; int draftStateId = workflowStateController.GetFirstWorkflowStateID(workflowId); int nextWorkflowStateId = workflowStateController.GetNextWorkflowStateID(workflowId, htmlContent.StateID); int publishedStateId = workflowStateController.GetLastWorkflowStateID(workflowId); htmlTextController.UpdateHtmlText(htmlContent, htmlTextController.GetMaximumVersionHistory(0)); }
protected void btnHistory_Click(object sender, EventArgs e) { if (phEdit.Visible) { var editContent = new HtmlTextInfo() { Locale = ddlLocale.SelectedValue, ModuleTitle = txtModuleTitle.Text.Trim(), Content = txtContent.Text.Trim(), Summary = txtSummary.Text.Trim() }; hfEditor.Value = new JavaScriptSerializer().Serialize(editContent); } DisplayVersions(); }
protected void lvVersions_ItemCommand(object sender, ListViewCommandEventArgs e) { try { HtmlTextInfo htmlText = _htmlTextController.GetHtmlText(int.Parse(e.CommandArgument.ToString())); switch (e.CommandName.ToLower()) { case "remove": if (UserInfo.IsSuperUser || PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)) { _htmlTextController.DeleteHtmlText(htmlText); DisplayVersions(); } else { DotNetNuke.UI.Skins.Skin.AddModuleMessage(Page, "Error occurred: ", LocalizeString("AccessDenied.Text"), ModuleMessage.ModuleMessageType.RedError); } break; case "rollback": //clone a new version as rollback, just like git, we are not rewriting the history. HtmlTextInfo newVersion = new HtmlTextInfo() { ItemId = -1, ModuleId = htmlText.ModuleId, Locale = htmlText.Locale, ModuleTitle = htmlText.ModuleTitle, Content = htmlText.Content, Summary = htmlText.Summary, IsPublished = true }; _htmlTextController.UpdateHtmlText(newVersion, true, _htmlTextController.GetMaximumVersionHistory(PortalId)); DisplayVersions(); setEditContent(newVersion); break; case "preview": DisplayPreview(htmlText, true); break; } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
public void ImportModule(Module Module, string Content, string Version) { Content = WebUtility.HtmlDecode(Content); HtmlTextInfo htmltext = htmltexts.GetHtmlText(Module.ModuleId); if (htmltext != null) { htmltext.Content = Content; htmltexts.UpdateHtmlText(htmltext); } else { htmltext = new HtmlTextInfo(); htmltext.ModuleId = Module.ModuleId; htmltext.Content = Content; htmltexts.AddHtmlText(htmltext); } }
protected void btnSave_Click(object sender, EventArgs e) { try { string localeCode = ddlLocale.SelectedValue; var htmlText = _htmlTextController.GetTopHtmlText(ModuleId, localeCode, true); if (htmlText == null) { htmlText = new HtmlTextInfo(); htmlText.ItemId = -1; htmlText.ModuleId = ModuleId; htmlText.Locale = localeCode; } if (phEdit.Visible) { htmlText.ModuleTitle = txtModuleTitle.Text.Trim(); htmlText.Content = txtContent.Text.Trim(); htmlText.Summary = txtSummary.Text.Trim(); } else { var editContent = new JavaScriptSerializer().Deserialize <HtmlTextInfo>(hfEditor.Value); if (editContent != null) { htmlText.ModuleTitle = editContent.ModuleTitle; htmlText.Content = editContent.Content; htmlText.Summary = editContent.Summary; } } //for remark only, not display on public view htmlText.IsPublished = true; //always set to true, since not implementing workflow feature now _htmlTextController.UpdateHtmlText(htmlText, true, _htmlTextController.GetMaximumVersionHistory(PortalId)); } catch (Exception exc) { Exceptions.LogException(exc); DotNetNuke.UI.Skins.Skin.AddModuleMessage(Page, "Error occurred: ", exc.Message, ModuleMessage.ModuleMessageType.RedError); return; } // redirect back to portal Response.Redirect(Globals.NavigateURL(), true); }
public HtmlTextInfo Put(int id, [FromBody] HtmlTextInfo HtmlText) { try { if (ModelState.IsValid && HtmlText.ModuleId == _entityId) { HtmlText = _htmlText.UpdateHtmlText(HtmlText); _logger.Log(LogLevel.Information, this, LogFunction.Update, "Html/Text Updated {HtmlText}", HtmlText); } return(HtmlText); } catch (Exception ex) { _logger.Log(LogLevel.Error, this, LogFunction.Update, ex, "Put Error {Error}", ex.Message); throw; } }
public HtmlTextInfo Get(int id) { try { HtmlTextInfo HtmlText = null; if (_entityId == id) { HtmlText = _htmlText.GetHtmlText(id); } return(HtmlText); } catch (Exception ex) { _logger.Log(LogLevel.Error, this, LogFunction.Read, ex, "Get Error {Error}", ex.Message); throw; } }
public HtmlTextInfo Post([FromBody] HtmlTextInfo HtmlText) { try { if (ModelState.IsValid && HtmlText.ModuleId == EntityId) { HtmlText = htmltext.AddHtmlText(HtmlText); logger.Log(LogLevel.Information, this, LogFunction.Create, "Html/Text Added {HtmlText}", HtmlText); } return(HtmlText); } catch (Exception ex) { logger.Log(LogLevel.Error, this, LogFunction.Create, ex, "Post Error {Error}", ex.Message); throw; } }
public void ImportModule(Module module, string content, string version) { content = WebUtility.HtmlDecode(content); HtmlTextInfo htmltext = _htmlTexts.GetHtmlText(module.ModuleId); if (htmltext != null) { htmltext.Content = content; _htmlTexts.UpdateHtmlText(htmltext); } else { htmltext = new HtmlTextInfo(); htmltext.ModuleId = module.ModuleId; htmltext.Content = content; _htmlTexts.AddHtmlText(htmltext); } }
/// <summary> /// lblContent_UpdateLabel allows for inline editing of content /// </summary> /// <param name="source"></param> /// <param name="e"></param> private void lblContent_UpdateLabel(object source, DNNLabelEditEventArgs e) { try { // verify security if ((!new PortalSecurity().InputFilter(e.Text, PortalSecurity.FilterFlag.NoScripting).Equals(e.Text))) { throw new SecurityException(); } else if (EditorEnabled && IsEditable && PortalSettings.UserMode == PortalSettings.Mode.Edit) { // get content var htmlTextController = new HtmlTextController(); HtmlTextInfo htmlText = htmlTextController.GetTopHtmlText(ModuleId, CurrentLocaleCode, true); if (htmlText == null) { htmlText = new HtmlTextInfo(); htmlText.ItemId = -1; // use current display title for new item only htmlText.ModuleTitle = ModuleContext.Configuration.ModuleTitle; } // set content attributes htmlText.ModuleId = ModuleId; htmlText.Locale = CurrentLocaleCode; htmlText.Content = Server.HtmlEncode(e.Text); htmlText.IsPublished = true; // save the content with new version htmlTextController.UpdateHtmlText(htmlText, true, htmlTextController.GetMaximumVersionHistory(PortalId)); //refresh module cache ModuleController.SynchronizeModule(ModuleId); } else { throw new SecurityException(); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
public List <HtmlTextInfo> Get(int id) { var list = new List <HtmlTextInfo>(); try { HtmlTextInfo htmlText = null; if (_entityId == id) { htmlText = _htmlText.GetHtmlText(id); list.Add(htmlText); } } catch (Exception ex) { _logger.Log(LogLevel.Error, this, LogFunction.Read, ex, "Get Error {Error}", ex.Message); throw; } return(list); }