/// <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> /// 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); } }
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 ""; }
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> /// 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> /// 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); } }
/// ----------------------------------------------------------------------------- /// <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); } }