/// <summary> /// Displays the content but hide the editor if editing is locked from the current user. /// </summary> /// <param name = "htmlContent">Content of the HTML.</param> /// <param name = "lastPublishedContent">Last content of the published.</param> private void DisplayLockedContent(HtmlTextInfo htmlContent, HtmlTextInfo lastPublishedContent) { this.txtContent.Visible = false; this.cmdSave.Visible = false; // cmdPreview.Enabled = false; this.divPublish.Visible = false; this.divSubmittedContent.Visible = true; this.lblCurrentWorkflowInUse.Text = this.GetLocalizedString(htmlContent.WorkflowName); this.lblCurrentWorkflowState.Text = this.GetLocalizedString(htmlContent.StateName); this.litCurrentContentPreview.Text = HtmlTextController.FormatHtmlText(this.ModuleId, htmlContent.Content, this.Settings, this.PortalSettings, this.Page); this.lblCurrentVersion.Text = htmlContent.Version.ToString(); this.DisplayVersions(); if (lastPublishedContent != null) { this.DisplayPreview(lastPublishedContent); // DisplayHistory(lastPublishedContent); } else { this.dnnSitePanelEditHTMLHistory.Visible = false; this.fsEditHtmlHistory.Visible = false; this.DisplayPreview(htmlContent.Content); } }
/// <summary> /// Displays the content but hide the editor if editing is locked from the current user /// </summary> /// <param name = "htmlContent">Content of the HTML.</param> /// <param name = "lastPublishedContent">Last content of the published.</param> private void DisplayLockedContent(HtmlTextInfo htmlContent, HtmlTextInfo lastPublishedContent) { txtContent.Visible = false; cmdSave.Visible = false; //cmdPreview.Visible = false; divPublish.Visible = false; divSubmittedContent.Visible = true; lblCurrentWorkflowInUse.Text = GetLocalizedString(htmlContent.WorkflowName); lblCurrentWorkflowState.Text = GetLocalizedString(htmlContent.StateName); litCurrentContentPreview.Text = HtmlTextController.FormatHtmlText(ModuleId, htmlContent.Content, Settings); lblCurrentVersion.Text = htmlContent.Version.ToString(); DisplayVersions(); if ((lastPublishedContent != null)) { DisplayPreview(lastPublishedContent); //DisplayHistory(lastPublishedContent); } else { dnnSitePanelEditHTMLHistory.Visible = false; fsEditHtmlHistory.Visible = false; DisplayPreview(htmlContent.Content); } }
/// ----------------------------------------------------------------------------- /// <summary> /// ModuleAction_Click handles all ModuleAction events raised from the action menu /// </summary> /// <remarks> /// </remarks> /// ----------------------------------------------------------------------------- private void ModuleAction_Click(object sender, ActionEventArgs e) { try { if (e.Action.CommandArgument == "publish") { // verify security if (IsEditable && PortalSettings.UserMode == PortalSettings.Mode.Edit) { // get content var objHTML = new HtmlTextController(); HtmlTextInfo objContent = objHTML.GetTopHtmlText(ModuleId, false, WorkflowID); var objWorkflow = new WorkflowStateController(); if (objContent.StateID == objWorkflow.GetFirstWorkflowStateID(WorkflowID)) { // publish content objContent.StateID = objWorkflow.GetNextWorkflowStateID(objContent.WorkflowID, objContent.StateID); // save the content objHTML.UpdateHtmlText(objContent, objHTML.GetMaximumVersionHistory(PortalId)); // refresh page Response.Redirect(Globals.NavigateURL(), true); } } } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// Displays the content preview in the preview section /// </summary> /// <param name = "htmlContent">Content of the HTML.</param> private void DisplayPreview(HtmlTextInfo htmlContent) { lblPreviewVersion.Text = htmlContent.Version.ToString(); lblPreviewWorkflowInUse.Text = GetLocalizedString(htmlContent.WorkflowName); lblPreviewWorkflowState.Text = GetLocalizedString(htmlContent.StateName); litPreview.Text = HtmlTextController.FormatHtmlText(ModuleId, htmlContent.Content, Settings); DisplayHistory(htmlContent); }
/// <summary> /// Formats the content to make it html safe. /// </summary> /// <param name = "htmlContent">Content of the HTML.</param> /// <returns></returns> private string FormatContent(string htmlContent) { var strContent = HttpUtility.HtmlDecode(htmlContent); strContent = HtmlTextController.ManageRelativePaths(strContent, this.PortalSettings.HomeDirectory, "src", this.PortalId); strContent = HtmlTextController.ManageRelativePaths(strContent, this.PortalSettings.HomeDirectory, "background", this.PortalId); return(HttpUtility.HtmlEncode(strContent)); }
public static HtmlModel Html(int moduleId) { HtmlTextController hc = new HtmlTextController(); var html = hc.GetTopHtmlText(moduleId, true, Null.NullInteger); if (html != null) return new HtmlModel { Content = HttpUtility.HtmlDecode(html.Content), Summary = html.Summary }; else return null; }
/// <summary> /// Displays the preview in the preview section /// </summary> /// <param name = "htmlContent">Content of the HTML.</param> private void DisplayPreview(string htmlContent) { litPreview.Text = HtmlTextController.FormatHtmlText(ModuleId, htmlContent, Settings); divPreviewVersion.Visible = false; divPreviewWorlflow.Visible = false; divPreviewWorkflowState.Visible = true; lblPreviewWorkflowState.Text = GetLocalizedString("EditPreviewState"); }
public static string GetHtmlText(int ModuleId) { HtmlTextController hc = new HtmlTextController(); var html = hc.GetTopHtmlText(ModuleId, true, Null.NullInteger); if (html != null) return html.Content; return ""; }
/// <summary> /// LoadSettings loads the settings from the Database and displays them /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> public override void LoadSettings() { try { if (!Page.IsPostBack) { var htmlTextController = new HtmlTextController(); var workflowStateController = new WorkflowStateController(); // get replace token settings if (ModuleSettings["HtmlText_ReplaceTokens"] != null) { chkReplaceTokens.Checked = Convert.ToBoolean(ModuleSettings["HtmlText_ReplaceTokens"]); } //get decoration setting, set to true as default. cbDecorate.Checked = !ModuleSettings.ContainsKey("HtmlText_UseDecorate") || ModuleSettings["HtmlText_UseDecorate"].ToString() == "1"; // get workflow/version settings var workflows = new ArrayList(); foreach (WorkflowStateInfo state in workflowStateController.GetWorkflows(PortalId)) { if (!state.IsDeleted) { workflows.Add(state); } } cboWorkflow.DataSource = workflows; cboWorkflow.DataBind(); var workflow = htmlTextController.GetWorkflow(ModuleId, TabId, PortalId); if ((cboWorkflow.FindItemByValue(workflow.Value.ToString()) != null)) { cboWorkflow.FindItemByValue(workflow.Value.ToString()).Selected = true; } DisplayWorkflowDetails(); if (rblApplyTo.Items.FindByValue(workflow.Key) != null) { rblApplyTo.Items.FindByValue(workflow.Key).Selected = true; } txtSearchDescLength.Text = ModuleSettings.ContainsKey("HtmlText_SearchDescLength") && !string.IsNullOrEmpty(ModuleSettings["HtmlText_SearchDescLength"].ToString()) ? ModuleSettings["HtmlText_SearchDescLength"].ToString() : HtmlTextController.MAX_DESCRIPTION_LENGTH.ToString(); } //Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// Displays the content of the master language if localized content is enabled. /// </summary> private void DisplayMasterLanguageContent() { //Get master language var objModule = ModuleController.Instance.GetModule(ModuleId, TabId, false); if (objModule.DefaultLanguageModule != null) { var masterContent = _htmlTextController.GetTopHtmlText(objModule.DefaultLanguageModule.ModuleID, false, WorkflowID); if (masterContent != null) { placeMasterContent.Controls.Add(new LiteralControl(HtmlTextController.FormatHtmlText(objModule.DefaultLanguageModule.ModuleID, FormatContent(masterContent.Content), Settings))); } } }
/// <summary> /// Displays the content of the master language if localized content is enabled. /// </summary> private void DisplayMasterLanguageContent() { // Get master language var objModule = ModuleController.Instance.GetModule(this.ModuleId, this.TabId, false); if (objModule.DefaultLanguageModule != null) { var masterContent = this._htmlTextController.GetTopHtmlText(objModule.DefaultLanguageModule.ModuleID, false, this.WorkflowID); if (masterContent != null) { this.placeMasterContent.Controls.Add(new LiteralControl(HtmlTextController.FormatHtmlText(objModule.DefaultLanguageModule.ModuleID, this.FormatContent(masterContent.Content), this.Settings, this.PortalSettings, this.Page))); } } }
/// <summary> /// Displays the content preview in the preview section. /// </summary> /// <param name = "htmlContent">Content of the HTML.</param> private void DisplayPreview(HtmlTextInfo htmlContent) { this.lblPreviewVersion.Text = htmlContent.Version.ToString(); this.lblPreviewWorkflowInUse.Text = this.GetLocalizedString(htmlContent.WorkflowName); this.lblPreviewWorkflowState.Text = this.GetLocalizedString(htmlContent.StateName); this.litPreview.Text = HtmlTextController.FormatHtmlText(this.ModuleId, htmlContent.Content, this.Settings, this.PortalSettings, this.Page); this.phEdit.Visible = false; this.phPreview.Visible = true; this.phHistory.Visible = false; this.cmdEdit.Enabled = true; this.cmdPreview.Enabled = false; this.cmdHistory.Enabled = true; this.DisplayHistory(htmlContent); this.cmdMasterContent.Visible = false; this.ddlRender.Visible = false; }
/// <summary> /// UpdateSettings saves the modified settings to the Database /// </summary> public override void UpdateSettings() { try { var htmlTextController = new HtmlTextController(); var objWorkflow = new WorkflowStateController(); // update replace token setting var objModules = new ModuleController(); objModules.UpdateModuleSetting(ModuleId, "HtmlText_ReplaceTokens", chkReplaceTokens.Checked.ToString()); objModules.UpdateModuleSetting(ModuleId, "HtmlText_UseDecorate", cbDecorate.Checked ? "1" : "0"); objModules.UpdateModuleSetting(ModuleId, "HtmlText_SearchDescLength", txtSearchDescLength.Text); // disable module caching if token replace is enabled if (chkReplaceTokens.Checked) { ModuleInfo objModule = objModules.GetModule(ModuleId, TabId, false); if (objModule.CacheTime > 0) { objModule.CacheTime = 0; objModules.UpdateModule(objModule); } } // update workflow/version settings switch (rblApplyTo.SelectedValue) { case "Module": htmlTextController.UpdateWorkflow(ModuleId, rblApplyTo.SelectedValue, Int32.Parse(cboWorkflow.SelectedValue), chkReplace.Checked); break; case "Page": htmlTextController.UpdateWorkflow(TabId, rblApplyTo.SelectedValue, Int32.Parse(cboWorkflow.SelectedValue), chkReplace.Checked); break; case "Site": htmlTextController.UpdateWorkflow(PortalId, rblApplyTo.SelectedValue, Int32.Parse(cboWorkflow.SelectedValue), chkReplace.Checked); break; } //Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// LoadSettings loads the settings from the Database and displays them. /// </summary> /// <remarks> /// </remarks> public override void LoadSettings() { try { if (!this.Page.IsPostBack) { var htmlTextController = new HtmlTextController(); var workflowStateController = new WorkflowStateController(); this.chkReplaceTokens.Checked = this.ModuleSettings.ReplaceTokens; this.cbDecorate.Checked = this.ModuleSettings.UseDecorate; // get workflow/version settings var workflows = new ArrayList(); foreach (WorkflowStateInfo state in workflowStateController.GetWorkflows(this.PortalId)) { if (!state.IsDeleted) { workflows.Add(state); } } this.cboWorkflow.DataSource = workflows; this.cboWorkflow.DataBind(); var workflow = htmlTextController.GetWorkflow(this.ModuleId, this.TabId, this.PortalId); if (this.cboWorkflow.FindItemByValue(workflow.Value.ToString()) != null) { this.cboWorkflow.FindItemByValue(workflow.Value.ToString()).Selected = true; } this.DisplayWorkflowDetails(); if (this.rblApplyTo.Items.FindByValue(workflow.Key) != null) { this.rblApplyTo.Items.FindByValue(workflow.Key).Selected = true; } this.txtSearchDescLength.Text = this.ModuleSettings.SearchDescLength.ToString(); } // Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// UpdateSettings saves the modified settings to the Database /// </summary> public override void UpdateSettings() { try { var htmlTextController = new HtmlTextController(); // update replace token setting ModuleSettings.ReplaceTokens = chkReplaceTokens.Checked; ModuleSettings.UseDecorate = cbDecorate.Checked; ModuleSettings.SearchDescLength = int.Parse(txtSearchDescLength.Text); var repo = new HtmlModuleSettingsRepository(); repo.SaveSettings(this.ModuleConfiguration, ModuleSettings); // disable module caching if token replace is enabled if (chkReplaceTokens.Checked) { ModuleInfo module = ModuleController.Instance.GetModule(ModuleId, TabId, false); if (module.CacheTime > 0) { module.CacheTime = 0; ModuleController.Instance.UpdateModule(module); } } // update workflow/version settings switch (rblApplyTo.SelectedValue) { case "Module": htmlTextController.UpdateWorkflow(ModuleId, rblApplyTo.SelectedValue, Int32.Parse(cboWorkflow.SelectedValue), chkReplace.Checked); break; case "Page": htmlTextController.UpdateWorkflow(TabId, rblApplyTo.SelectedValue, Int32.Parse(cboWorkflow.SelectedValue), chkReplace.Checked); break; case "Site": htmlTextController.UpdateWorkflow(PortalId, rblApplyTo.SelectedValue, Int32.Parse(cboWorkflow.SelectedValue), chkReplace.Checked); break; } //Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Init runs when the control is initialized /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> /// ----------------------------------------------------------------------------- protected override void OnInit(EventArgs e) { base.OnInit(e); lblContent.UpdateLabel += lblContent_UpdateLabel; EditorEnabled = PortalSettings.InlineEditorEnabled; try { WorkflowID = new HtmlTextController().GetWorkflow(ModuleId, TabId, PortalId).Value; //Add an Action Event Handler to the Skin AddActionHandler(ModuleAction_Click); } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// LoadSettings loads the settings from the Database and displays them /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> public override void LoadSettings() { try { if (!Page.IsPostBack) { var htmlTextController = new HtmlTextController(); var workflowStateController = new WorkflowStateController(); // get replace token settings if (ModuleSettings["HtmlText_ReplaceTokens"] != null) { chkReplaceTokens.Checked = Convert.ToBoolean(ModuleSettings["HtmlText_ReplaceTokens"]); } // get workflow/version settings var arrWorkflows = new ArrayList(); foreach (WorkflowStateInfo objState in workflowStateController.GetWorkflows(PortalId)) { if (!objState.IsDeleted) { arrWorkflows.Add(objState); } } cboWorkflow.DataSource = arrWorkflows; cboWorkflow.DataBind(); var workflow = htmlTextController.GetWorkflow(ModuleId, TabId, PortalId); if ((cboWorkflow.Items.FindByValue(workflow.Value.ToString()) != null)) { cboWorkflow.Items.FindByValue(workflow.Value.ToString()).Selected = true; } DisplayWorkflowDetails(); if (rblApplyTo.Items.FindByValue(workflow.Key) != null) { rblApplyTo.Items.FindByValue(workflow.Key).Selected = true; } } //Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// Displays the preview in the preview section. /// </summary> /// <param name = "htmlContent">Content of the HTML.</param> private void DisplayPreview(string htmlContent) { this.litPreview.Text = HtmlTextController.FormatHtmlText(this.ModuleId, htmlContent, this.Settings, this.PortalSettings, this.Page); this.divPreviewVersion.Visible = false; this.divPreviewWorlflow.Visible = false; this.divPreviewWorkflowState.Visible = true; this.lblPreviewWorkflowState.Text = this.GetLocalizedString("EditPreviewState"); this.phEdit.Visible = false; this.phPreview.Visible = true; this.phHistory.Visible = false; this.cmdEdit.Enabled = true; this.cmdPreview.Enabled = false; this.cmdHistory.Enabled = true; this.cmdMasterContent.Visible = false; this.ddlRender.Visible = false; }
/// ----------------------------------------------------------------------------- /// <summary> /// lblContent_UpdateLabel allows for inline editing of content /// </summary> /// <remarks> /// </remarks> /// ----------------------------------------------------------------------------- private void lblContent_UpdateLabel(object source, DNNLabelEditEventArgs e) { try { // verify security if ((!PortalSecurity.Instance.InputFilter(e.Text, PortalSecurity.FilterFlag.NoScripting).Equals(e.Text))) { throw new SecurityException(); } else if (EditorEnabled && IsEditable && PortalSettings.UserMode == PortalSettings.Mode.Edit) { // get content var objHTML = new HtmlTextController(); var objWorkflow = new WorkflowStateController(); HtmlTextInfo objContent = objHTML.GetTopHtmlText(ModuleId, false, WorkflowID); if (objContent == null) { objContent = new HtmlTextInfo(); objContent.ItemID = -1; } // set content attributes objContent.ModuleID = ModuleId; objContent.Content = Server.HtmlEncode(e.Text); objContent.WorkflowID = WorkflowID; objContent.StateID = objWorkflow.GetFirstWorkflowStateID(WorkflowID); // save the content objHTML.UpdateHtmlText(objContent, objHTML.GetMaximumVersionHistory(PortalId)); } else { throw new SecurityException(); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// LoadSettings loads the settings from the Database and displays them /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> public override void LoadSettings() { try { if (!Page.IsPostBack) { var htmlTextController = new HtmlTextController(); var workflowStateController = new WorkflowStateController(); // get replace token settings if (ModuleSettings["HtmlText_ReplaceTokens"] != null) { chkReplaceTokens.Checked = Convert.ToBoolean(ModuleSettings["HtmlText_ReplaceTokens"]); } //get decoration setting, set to true as default. cbDecorate.Checked = !ModuleSettings.ContainsKey("HtmlText_UseDecorate") || ModuleSettings["HtmlText_UseDecorate"].ToString() == "1"; // get workflow/version settings var arrWorkflows = new ArrayList(); foreach (WorkflowStateInfo objState in workflowStateController.GetWorkflows(PortalId)) { if (!objState.IsDeleted) { arrWorkflows.Add(objState); } } cboWorkflow.DataSource = arrWorkflows; cboWorkflow.DataBind(); var workflow = htmlTextController.GetWorkflow(ModuleId, TabId, PortalId); if ((cboWorkflow.FindItemByValue(workflow.Value.ToString()) != null)) { cboWorkflow.FindItemByValue(workflow.Value.ToString()).Selected = true; } DisplayWorkflowDetails(); if (rblApplyTo.Items.FindByValue(workflow.Key) != null) { rblApplyTo.Items.FindByValue(workflow.Key).Selected = true; } txtSearchDescLength.Text = ModuleSettings.ContainsKey("HtmlText_SearchDescLength") && !string.IsNullOrEmpty(ModuleSettings["HtmlText_SearchDescLength"].ToString()) ? ModuleSettings["HtmlText_SearchDescLength"].ToString() : HtmlTextController.MAX_DESCRIPTION_LENGTH.ToString(); } //Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
public EditHtml() { this._navigationManager = this.DependencyProvider.GetRequiredService <INavigationManager>(); this._htmlTextController = new HtmlTextController(this._navigationManager); }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> /// ----------------------------------------------------------------------------- protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { var objHTML = new HtmlTextController(); // edit in place if (EditorEnabled && IsEditable && PortalSettings.UserMode == PortalSettings.Mode.Edit) { EditorEnabled = true; } else { EditorEnabled = false; } // get content HtmlTextInfo htmlTextInfo = null; string contentString = ""; htmlTextInfo = objHTML.GetTopHtmlText(ModuleId, !IsEditable, WorkflowID); if ((htmlTextInfo != null)) { //don't decode yet (this is done in FormatHtmlText) contentString = htmlTextInfo.Content; } else { // get default content from resource file if (!IsPostBack) { if (PortalSettings.UserMode == PortalSettings.Mode.Edit) { if (EditorEnabled) { contentString = Localization.GetString("AddContentFromToolBar.Text", LocalResourceFile); } else { contentString = Localization.GetString("AddContentFromActionMenu.Text", LocalResourceFile); } } else { // hide the module if no content and in view mode ContainerControl.Visible = false; } } } // token replace if (EditorEnabled && Settings["HtmlText_ReplaceTokens"] != null) { EditorEnabled = !Convert.ToBoolean(Settings["HtmlText_ReplaceTokens"]); } // localize toolbar if (!IsPostBack) { if (EditorEnabled) { foreach (DNNToolBarButton button in editorDnnToobar.Buttons) { button.ToolTip = Localization.GetString(button.ToolTip + ".ToolTip", LocalResourceFile); } } else { editorDnnToobar.Visible = false; } } lblContent.EditEnabled = EditorEnabled; // add content to module lblContent.Controls.Add(new LiteralControl(HtmlTextController.FormatHtmlText(ModuleId, contentString, Settings))); //set normalCheckBox on the content wrapper to prevent form decoration if its disabled. if (Settings.ContainsKey("HtmlText_UseDecorate") && Settings["HtmlText_UseDecorate"].ToString() == "0") { lblContent.CssClass = string.Format("{0} normalCheckBox", lblContent.CssClass); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// ModuleAction_Click handles all ModuleAction events raised from the action menu /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> /// ----------------------------------------------------------------------------- private void ModuleAction_Click(object sender, ActionEventArgs e) { try { if (e.Action.CommandArgument == "publish") { // verify security if (IsEditable && PortalSettings.UserMode == PortalSettings.Mode.Edit) { // get content var objHTML = new HtmlTextController(); HtmlTextInfo objContent = objHTML.GetTopHtmlText(ModuleId, false, WorkflowID); var objWorkflow = new WorkflowStateController(); if (objContent.StateID == objWorkflow.GetFirstWorkflowStateID(WorkflowID)) { // publish content objContent.StateID = objWorkflow.GetNextWorkflowStateID(objContent.WorkflowID, objContent.StateID); // save the content objHTML.UpdateHtmlText(objContent, objHTML.GetMaximumVersionHistory(PortalId)); // refresh page Response.Redirect(Globals.NavigateURL(), true); } } } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// lblContent_UpdateLabel allows for inline editing of content /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> /// ----------------------------------------------------------------------------- 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 objHTML = new HtmlTextController(); var objWorkflow = new WorkflowStateController(); HtmlTextInfo objContent = objHTML.GetTopHtmlText(ModuleId, false, WorkflowID); if (objContent == null) { objContent = new HtmlTextInfo(); objContent.ItemID = -1; } // set content attributes objContent.ModuleID = ModuleId; objContent.Content = Server.HtmlEncode(e.Text); objContent.WorkflowID = WorkflowID; objContent.StateID = objWorkflow.GetFirstWorkflowStateID(WorkflowID); // save the content objHTML.UpdateHtmlText(objContent, objHTML.GetMaximumVersionHistory(PortalId)); } else { throw new SecurityException(); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <remarks> /// </remarks> /// ----------------------------------------------------------------------------- protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { var objHTML = new HtmlTextController(); // edit in place if (EditorEnabled && IsEditable && PortalSettings.UserMode == PortalSettings.Mode.Edit) { EditorEnabled = true; } else { EditorEnabled = false; } // get content HtmlTextInfo htmlTextInfo = null; string contentString = ""; htmlTextInfo = objHTML.GetTopHtmlText(ModuleId, !IsEditable, WorkflowID); if ((htmlTextInfo != null)) { //don't decode yet (this is done in FormatHtmlText) contentString = htmlTextInfo.Content; } else { // get default content from resource file if (PortalSettings.UserMode == PortalSettings.Mode.Edit) { if (EditorEnabled) { contentString = Localization.GetString("AddContentFromToolBar.Text", LocalResourceFile); } else { contentString = Localization.GetString("AddContentFromActionMenu.Text", LocalResourceFile); } } else { // hide the module if no content and in view mode ContainerControl.Visible = false; } } // token replace EditorEnabled = EditorEnabled && !Settings.ReplaceTokens; // localize toolbar if (EditorEnabled) { foreach (DNNToolBarButton button in editorDnnToobar.Buttons) { button.ToolTip = Localization.GetString(button.ToolTip + ".ToolTip", LocalResourceFile); } } else { editorDnnToobar.Visible = false; } lblContent.EditEnabled = EditorEnabled; // add content to module lblContent.Controls.Add(new LiteralControl(HtmlTextController.FormatHtmlText(ModuleId, contentString, Settings, PortalSettings, Page))); //set normalCheckBox on the content wrapper to prevent form decoration if its disabled. if (!Settings.UseDecorate) { lblContent.CssClass = string.Format("{0} normalCheckBox", lblContent.CssClass); } if (IsPostBack && AJAX.IsEnabled() && AJAX.GetScriptManager(Page).IsInAsyncPostBack) { var resetScript = $@" if(typeof dnn !== 'undefined' && typeof dnn.controls !== 'undefined' && typeof dnn.controls.controls !== 'undefined'){{ var control = dnn.controls.controls['{lblContent.ClientID}']; if(control && control.container !== $get('{lblContent.ClientID}')){{ dnn.controls.controls['{lblContent.ClientID}'] = null; }} }};"; ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), $"ResetHtmlModule{ClientID}", resetScript, true); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }