diff --git a/CKEditorDefaultSettings.xml b/CKEditorDefaultSettings.xml index 0aa1839..869027b 100644 --- a/CKEditorDefaultSettings.xml +++ b/CKEditorDefaultSettings.xml @@ -30,8 +30,9 @@ 0;Administrators; bmp,gif,jpeg,jpg,png,svg Portal - + + \ No newline at end of file diff --git a/CKToolbarSets.xml b/CKToolbarSets.xml index b4918b5..f3d6ee0 100644 --- a/CKToolbarSets.xml +++ b/CKToolbarSets.xml @@ -210,6 +210,7 @@ Smiley SpecialChar PageBreak + Iframe insert diff --git a/DNN 7/CKEditorOptions.ascx.cs b/DNN 7/CKEditorOptions.ascx.cs index 6b5b881..c4d2c25 100644 --- a/DNN 7/CKEditorOptions.ascx.cs +++ b/DNN 7/CKEditorOptions.ascx.cs @@ -668,6 +668,52 @@ private void FillSettings(EditorProviderSettings importedSettings, bool changeMo continue; } + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var textBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (textBox != null) + { + textBox.Text = value.ToString(); + } + } + + break; + + case "Boolean": + { + var checkBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (checkBox != null) + { + checkBox.Checked = (bool)value; + } + } + + break; + } + } + } + + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + value = wordCountInfo.GetValue(importedSettings.Config.AutoSave, null); + + if (value == null) + { + continue; + } + switch (wordCountInfo.PropertyType.Name) { case "String": @@ -2270,6 +2316,60 @@ var codeMirrorInfo in } } + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + var wordCountDescription = wordCountInfo.GetCustomAttribute(true); + + var settingNameContainer2 = new HtmlGenericControl("div"); + settingNameContainer2.Attributes.Add("class", "settingNameContainer"); + + var settingValueContainer2 = new HtmlGenericControl("div"); + settingValueContainer2.Attributes.Add("class", "settingValueContainer"); + + var settingNameLabel2 = new Label { Text = string.Format("{0} - {1}:", info.Name, wordCountInfo.Name) }; + + settingNameContainer2.Controls.Add(settingNameLabel2); + + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var settingValueInput = new TextBox { ID = wordCountInfo.Name, CssClass = "settingValueInput", TextMode = TextBoxMode.MultiLine, Rows = 5 }; + + if (description != null) + { + settingValueInput.ToolTip = wordCountDescription.Description; + } + + settingValueContainer2.Controls.Add(settingValueInput); + } + + break; + + case "Boolean": + { + var settingValueInput = new CheckBox { ID = wordCountInfo.Name }; + + if (description != null) + { + settingValueInput.ToolTip = wordCountDescription.Description; + } + + settingValueContainer2.Controls.Add(settingValueInput); + } + + break; + } + + this.EditorConfigHolder.Controls.Add(settingNameContainer2); + this.EditorConfigHolder.Controls.Add(settingValueContainer2); + } + } + break; } @@ -2441,6 +2541,51 @@ private void SaveModuleSettings() } } + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var textBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (textBox != null) + { + moduleController.UpdateModuleSetting( + this.ModuleId, + string.Format("{0}{1}", key, wordCountInfo.Name), + textBox.Text); + } + } + + break; + + case "Boolean": + { + var checkBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (checkBox != null) + { + moduleController.UpdateModuleSetting( + this.ModuleId, + string.Format("{0}{1}", key, wordCountInfo.Name), + checkBox.Checked.ToString()); + } + } + + break; + } + } + } + break; } } @@ -2784,6 +2929,49 @@ private void SavePortalOrPageSettings(string key) } } + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var textBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (textBox != null) + { + Utility.AddOrUpdateEditorHostSetting( + string.Format("{0}{1}", key, wordCountInfo.Name), + textBox.Text); + } + } + + break; + + case "Boolean": + { + var checkBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (checkBox != null) + { + Utility.AddOrUpdateEditorHostSetting( + string.Format("{0}{1}", key, wordCountInfo.Name), + checkBox.Checked.ToString()); + } + } + + break; + } + } + } + break; } } @@ -3502,6 +3690,48 @@ private EditorProviderSettings ExportSettings() } } + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var textBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (!string.IsNullOrEmpty(textBox.Text)) + { + wordCountInfo.SetValue( + exportSettings.Config.AutoSave, + textBox.Text, + null); + } + } + + break; + + case "Boolean": + { + var checkBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + wordCountInfo.SetValue( + exportSettings.Config.AutoSave, + checkBox.Checked, + null); + } + + break; + } + } + } + break; } } diff --git a/DNN 7/Install/CKReleaseNotes.html b/DNN 7/Install/CKReleaseNotes.html index ff8bca0..e12facc 100644 --- a/DNN 7/Install/CKReleaseNotes.html +++ b/DNN 7/Install/CKReleaseNotes.html @@ -6,17 +6,17 @@ CKEditor Provider Readme -

CKEditor 4.8.0 Editor Provider 2.01.13 For DNN® Platform 07.04.02 (or above)

+

CKEditor 4.9.0 Editor Provider 2.01.14 For DNN® Platform 07.04.02 (or above)

What's New

    -
  • +
  • Upgraded to CKEditor 4.9.0
changes
    -
  • FIXED #26 Uncaught ReferenceError: dnnpagesSelectBox is not defined
  • +
  • Updated the Settings for the Autosave Plugin
diff --git a/DNN 7/Install/WatchersNET.CKHtmlEditorProvider.dnn b/DNN 7/Install/WatchersNET.CKHtmlEditorProvider.dnn index 594c082..3c2ee56 100644 --- a/DNN 7/Install/WatchersNET.CKHtmlEditorProvider.dnn +++ b/DNN 7/Install/WatchersNET.CKHtmlEditorProvider.dnn @@ -1,5 +1,5 @@  - + CKEditor Editor Provider CKEditor Editor Provider for DNN ~/Providers/HtmlEditorProviders/CKEditor/LogoCKEditor.png @@ -107,7 +107,7 @@ - + CKEditor Config Manager Configuration Manager for the CKEditor Editor Provider diff --git a/DNN 7/Install/bin/WatchersNET.CKEditor.dll b/DNN 7/Install/bin/WatchersNET.CKEditor.dll index d7544ba..5194462 100644 Binary files a/DNN 7/Install/bin/WatchersNET.CKEditor.dll and b/DNN 7/Install/bin/WatchersNET.CKEditor.dll differ diff --git a/DNN 7/Objects/AutoSave.cs b/DNN 7/Objects/AutoSave.cs new file mode 100644 index 0000000..dc10f11 --- /dev/null +++ b/DNN 7/Objects/AutoSave.cs @@ -0,0 +1,95 @@ +/* CKEditor Html Editor Provider for DNN + * ======== + * https://github.com/w8tcha/dnnckeditor + * Copyright (C) Ingo Herbote + * + * The software, this file and its contents are subject to the CKEditor Provider + * License. Please read the license.txt file before using, installing, copying, + * modifying or distribute this file or part of its contents. The contents of + * this file is part of the Source Code of the CKEditor Provider. + */ + +namespace WatchersNET.CKEditor.Objects +{ + using System.ComponentModel; + using System.Xml.Serialization; + + /// + /// the Autosave Plugin Options + /// + public class AutoSave + { + /// + /// Initializes a new instance of the class. + /// + public AutoSave() + { + this.Delay = 1; + this.MessageType = "notification"; + this.SaveDetectionSelectors = "a[href^='javascript:__doPostBack'][id*='Save'],a[id*='Cancel']"; + this.NotOlderThen = 1440; + this.DiffType = "sideBySide"; + this.AutoLoad = false; + } + + /// + /// Gets or sets the delay. + /// + /// + /// The delay. + /// + [XmlAttribute("delay")] + [Description("Delay")] + public int Delay { get; set; } + + /// + /// Gets or sets the type of the message. + /// + /// + /// The type of the message. + /// + [XmlAttribute("messageType")] + [Description("Notification Type - Setting to set the if you want to show the 'Auto Saved' message, and if yes you can show as Notification or as Message in the Status bar (Default is : 'notification')")] + public string MessageType { get; set; } + + /// + /// Gets or sets the save detection selectors. + /// + /// + /// The save detection selectors. + /// + [XmlAttribute("saveDetectionSelectors")] + [Description("Setting to set the Save button to inform the plugin when the content is saved by the user and doesn't need to be stored temporary")] + public string SaveDetectionSelectors { get; set; } + + /// + /// Gets or sets the not older then. + /// + /// + /// The not older then. + /// + [XmlAttribute("NotOlderThen")] + [Description("The Default Minutes (Default is 1440 which is one day) after the auto saved content is ignored can be overidden")] + public int NotOlderThen { get; set; } + + /// + /// Gets or sets the type of the difference. + /// + /// + /// The type of the difference. + /// + [XmlAttribute("diffType")] + [Description("The Default Diff Type for the Compare Dialog, you can choose between 'sideBySide' or 'inline'. Default is 'sideBySide'")] + public string DiffType { get; set; } + + /// + /// Gets or sets a value indicating whether [automatic load]. + /// + /// + /// true if [automatic load]; otherwise, false. + /// + [XmlAttribute("autoLoad")] + [Description("autoLoad when enabled it directly loads the saved content")] + public bool AutoLoad { get; set; } + } +} \ No newline at end of file diff --git a/DNN 7/Objects/EditorConfig.cs b/DNN 7/Objects/EditorConfig.cs index 23f54ed..58ddd7e 100644 --- a/DNN 7/Objects/EditorConfig.cs +++ b/DNN 7/Objects/EditorConfig.cs @@ -13,6 +13,7 @@ namespace WatchersNET.CKEditor.Objects { using System.ComponentModel; + using System.Web.Profile; using System.Xml.Serialization; using WatchersNET.CKEditor.Constants; @@ -33,7 +34,6 @@ public EditorConfig() this.AutoGrow_MinHeight = 200; this.AutoGrow_OnStartup = false; this.AutoParagraph = true; - this.AutoSave_Delay = 25; this.AutoUpdateElement = true; this.BaseFloatZIndex = 10000; this.BasicEntities = true; @@ -135,6 +135,7 @@ public EditorConfig() this.UseComputedState = true; this.Width = "99%"; this.WordCount = new WordCountConfig(); + this.AutoSave = new AutoSave(); } /// @@ -197,16 +198,6 @@ public EditorConfig() [Description("Whether automatically create wrapping blocks around inline contents inside document body, this helps to ensure the integrality of the block enter mode.")] public bool AutoParagraph { get; set; } - /// - /// Gets or sets the auto save delay. - /// - /// - /// The auto save delay. - /// - [XmlAttribute("autosave_delay")] - [Description("Auto-save time delay (in seconds)")] - public int AutoSave_Delay { get; set; } - /// /// Gets or sets a value indicating whether [auto update element]. /// @@ -305,6 +296,14 @@ public EditorConfig() /// public CodeMirror CodeMirror { get; set; } + /// + /// Gets or sets the autosave plugin Config + /// + /// + /// The autosave plugin Config + /// + public AutoSave AutoSave { get; set; } + /// /// Gets or sets the color button_ back style. /// diff --git a/DNN 7/Utilities/SettingsUtil.cs b/DNN 7/Utilities/SettingsUtil.cs index a2ada1d..16e28dc 100644 --- a/DNN 7/Utilities/SettingsUtil.cs +++ b/DNN 7/Utilities/SettingsUtil.cs @@ -239,6 +239,37 @@ internal static EditorProviderSettings LoadPortalOrPageSettings( } } + break; + case "AutoSave": + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + if ( + editorHostSettings.Any( + s => s.Name.Equals(string.Format("{0}{1}", key, wordCountInfo.Name)))) + { + wordCountInfo.SetValue(currentSettings.Config.AutoSave, settingValue, null); + } + + break; + case "Boolean": + if ( + editorHostSettings.Any( + s => s.Name.Equals(string.Format("{0}{1}", key, wordCountInfo.Name)))) + { + wordCountInfo.SetValue( + currentSettings.Config.AutoSave, + bool.Parse(settingValue), + null); + } + + break; + } + } + break; } } @@ -930,6 +961,37 @@ var info in GetEditorConfigProperties() } } + break; + case "AutoSave": + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + if (hshModSet.ContainsKey(string.Format("{0}{1}", key, wordCountInfo.Name))) + { + wordCountInfo.SetValue( + currentSettings.Config.AutoSave, + hshModSet[string.Format("{0}{1}", key, wordCountInfo.Name)], + null); + } + + break; + case "Boolean": + if (hshModSet.ContainsKey(string.Format("{0}{1}", key, wordCountInfo.Name))) + { + wordCountInfo.SetValue( + currentSettings.Config.AutoSave, + bool.Parse( + (string)hshModSet[string.Format("{0}{1}", key, wordCountInfo.Name)]), + null); + } + + break; + } + } + break; } } diff --git a/DNN 7/WatchersNET.CKEditor - DNN7.csproj b/DNN 7/WatchersNET.CKEditor - DNN7.csproj index 6189932..27152af 100644 --- a/DNN 7/WatchersNET.CKEditor - DNN7.csproj +++ b/DNN 7/WatchersNET.CKEditor - DNN7.csproj @@ -137,6 +137,7 @@ EditorConfigManager.ascx + diff --git a/DNN 7/Web/CKEditorControl.cs b/DNN 7/Web/CKEditorControl.cs index 32d76f3..55bc1f0 100644 --- a/DNN 7/Web/CKEditorControl.cs +++ b/DNN 7/Web/CKEditorControl.cs @@ -290,6 +290,46 @@ var info in "{{ {0} }}", wordcountSettings.Remove(wordcountSettings.Length - 1, 1)); } + break; + case "AutoSave": + { + var wordcountArray = new StringBuilder(); + + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + var xmlAttribute = + wordCountInfo.GetCustomAttribute(true); + + var rawSettingValue = + wordCountInfo.GetValue(this.currentSettings.Config.AutoSave, null); + + var wordCountSettingValue = rawSettingValue.ToString(); + + if (string.IsNullOrEmpty(wordCountSettingValue)) + { + continue; + } + + switch (wordCountInfo.PropertyType.Name) + { + case "String": + wordcountArray.AppendFormat("{0}: \"{1}\",", xmlAttribute.AttributeName, wordCountSettingValue); + break; + case "Int32": + wordcountArray.AppendFormat("{0}: {1},", xmlAttribute.AttributeName, wordCountSettingValue); + break; + case "Boolean": + wordcountArray.AppendFormat("{0}: {1},", xmlAttribute.AttributeName, wordCountSettingValue.ToLower()); + break; + } + } + + var wordcountSettings = wordcountArray.ToString(); + + this._settings["autosave"] = string.Format( + "{{ {0} }}", wordcountSettings.Remove(wordcountSettings.Length - 1, 1)); + } + break; default: this._settings[xmlAttributeAttribute.AttributeName] = settingValue; diff --git a/DNN 8/CKEditorOptions.ascx.cs b/DNN 8/CKEditorOptions.ascx.cs index b41d82a..f463d94 100644 --- a/DNN 8/CKEditorOptions.ascx.cs +++ b/DNN 8/CKEditorOptions.ascx.cs @@ -636,6 +636,52 @@ private void FillSettings(EditorProviderSettings importedSettings, bool changeMo } } + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + value = wordCountInfo.GetValue(importedSettings.Config.AutoSave, null); + + if (value == null) + { + continue; + } + + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var textBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (textBox != null) + { + textBox.Text = value.ToString(); + } + } + + break; + + case "Boolean": + { + var checkBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (checkBox != null) + { + checkBox.Checked = (bool)value; + } + } + + break; + } + } + } + break; } } @@ -2211,6 +2257,60 @@ var codeMirrorInfo in } } + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + var wordCountDescription = wordCountInfo.GetCustomAttribute(true); + + var settingNameContainer2 = new HtmlGenericControl("div"); + settingNameContainer2.Attributes.Add("class", "settingNameContainer"); + + var settingValueContainer2 = new HtmlGenericControl("div"); + settingValueContainer2.Attributes.Add("class", "settingValueContainer"); + + var settingNameLabel2 = new Label { Text = string.Format("{0} - {1}:", info.Name, wordCountInfo.Name) }; + + settingNameContainer2.Controls.Add(settingNameLabel2); + + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var settingValueInput = new TextBox { ID = wordCountInfo.Name, CssClass = "settingValueInput", TextMode = TextBoxMode.MultiLine, Rows = 5 }; + + if (description != null) + { + settingValueInput.ToolTip = wordCountDescription.Description; + } + + settingValueContainer2.Controls.Add(settingValueInput); + } + + break; + + case "Boolean": + { + var settingValueInput = new CheckBox { ID = wordCountInfo.Name }; + + if (description != null) + { + settingValueInput.ToolTip = wordCountDescription.Description; + } + + settingValueContainer2.Controls.Add(settingValueInput); + } + + break; + } + + this.EditorConfigHolder.Controls.Add(settingNameContainer2); + this.EditorConfigHolder.Controls.Add(settingValueContainer2); + } + } + break; } @@ -2382,6 +2482,51 @@ private void SaveModuleSettings() } } + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var textBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (textBox != null) + { + moduleController.UpdateModuleSetting( + this.ModuleId, + string.Format("{0}{1}", key, wordCountInfo.Name), + textBox.Text); + } + } + + break; + + case "Boolean": + { + var checkBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (checkBox != null) + { + moduleController.UpdateModuleSetting( + this.ModuleId, + string.Format("{0}{1}", key, wordCountInfo.Name), + checkBox.Checked.ToString()); + } + } + + break; + } + } + } + break; } } @@ -2725,6 +2870,49 @@ private void SavePortalOrPageSettings(string key) } } + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var textBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (textBox != null) + { + Utility.AddOrUpdateEditorHostSetting( + string.Format("{0}{1}", key, wordCountInfo.Name), + textBox.Text); + } + } + + break; + + case "Boolean": + { + var checkBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (checkBox != null) + { + Utility.AddOrUpdateEditorHostSetting( + string.Format("{0}{1}", key, wordCountInfo.Name), + checkBox.Checked.ToString()); + } + } + + break; + } + } + } + break; } } @@ -3443,6 +3631,48 @@ private EditorProviderSettings ExportSettings() } } + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var textBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (!string.IsNullOrEmpty(textBox.Text)) + { + wordCountInfo.SetValue( + exportSettings.Config.AutoSave, + textBox.Text, + null); + } + } + + break; + + case "Boolean": + { + var checkBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + wordCountInfo.SetValue( + exportSettings.Config.AutoSave, + checkBox.Checked, + null); + } + + break; + } + } + } + break; } } diff --git a/DNN 8/Install/CKReleaseNotes.html b/DNN 8/Install/CKReleaseNotes.html index 390a51e..8565e58 100644 --- a/DNN 8/Install/CKReleaseNotes.html +++ b/DNN 8/Install/CKReleaseNotes.html @@ -6,17 +6,17 @@ CKEditor Provider Readme -

CKEditor 4.8.0 Editor Provider 2.01.13 For DNN® Platform 08.04.00 (or above)

+

CKEditor 4.9.0 Editor Provider 2.01.14 For DNN® Platform 08.00.04 (or above)

What's New

    -
  • +
  • Upgraded to CKEditor 4.9.0
changes
    -
  • FIXED #26 Uncaught ReferenceError: dnnpagesSelectBox is not defined
  • +
  • Updated the Settings for the Autosave Plugin
diff --git a/DNN 8/Install/WatchersNET.CKHtmlEditorProvider.dnn b/DNN 8/Install/WatchersNET.CKHtmlEditorProvider.dnn index 902f9f8..8aacd43 100644 --- a/DNN 8/Install/WatchersNET.CKHtmlEditorProvider.dnn +++ b/DNN 8/Install/WatchersNET.CKHtmlEditorProvider.dnn @@ -1,5 +1,5 @@  - + CKEditor Editor Provider CKEditor Editor Provider for DNN ~/Providers/HtmlEditorProviders/CKEditor/LogoCKEditor.png @@ -108,7 +108,7 @@ - + CKEditor Config Manager Configuration Manager for the CKEditor Editor Provider diff --git a/DNN 8/Objects/AutoSave.cs b/DNN 8/Objects/AutoSave.cs new file mode 100644 index 0000000..dc10f11 --- /dev/null +++ b/DNN 8/Objects/AutoSave.cs @@ -0,0 +1,95 @@ +/* CKEditor Html Editor Provider for DNN + * ======== + * https://github.com/w8tcha/dnnckeditor + * Copyright (C) Ingo Herbote + * + * The software, this file and its contents are subject to the CKEditor Provider + * License. Please read the license.txt file before using, installing, copying, + * modifying or distribute this file or part of its contents. The contents of + * this file is part of the Source Code of the CKEditor Provider. + */ + +namespace WatchersNET.CKEditor.Objects +{ + using System.ComponentModel; + using System.Xml.Serialization; + + /// + /// the Autosave Plugin Options + /// + public class AutoSave + { + /// + /// Initializes a new instance of the class. + /// + public AutoSave() + { + this.Delay = 1; + this.MessageType = "notification"; + this.SaveDetectionSelectors = "a[href^='javascript:__doPostBack'][id*='Save'],a[id*='Cancel']"; + this.NotOlderThen = 1440; + this.DiffType = "sideBySide"; + this.AutoLoad = false; + } + + /// + /// Gets or sets the delay. + /// + /// + /// The delay. + /// + [XmlAttribute("delay")] + [Description("Delay")] + public int Delay { get; set; } + + /// + /// Gets or sets the type of the message. + /// + /// + /// The type of the message. + /// + [XmlAttribute("messageType")] + [Description("Notification Type - Setting to set the if you want to show the 'Auto Saved' message, and if yes you can show as Notification or as Message in the Status bar (Default is : 'notification')")] + public string MessageType { get; set; } + + /// + /// Gets or sets the save detection selectors. + /// + /// + /// The save detection selectors. + /// + [XmlAttribute("saveDetectionSelectors")] + [Description("Setting to set the Save button to inform the plugin when the content is saved by the user and doesn't need to be stored temporary")] + public string SaveDetectionSelectors { get; set; } + + /// + /// Gets or sets the not older then. + /// + /// + /// The not older then. + /// + [XmlAttribute("NotOlderThen")] + [Description("The Default Minutes (Default is 1440 which is one day) after the auto saved content is ignored can be overidden")] + public int NotOlderThen { get; set; } + + /// + /// Gets or sets the type of the difference. + /// + /// + /// The type of the difference. + /// + [XmlAttribute("diffType")] + [Description("The Default Diff Type for the Compare Dialog, you can choose between 'sideBySide' or 'inline'. Default is 'sideBySide'")] + public string DiffType { get; set; } + + /// + /// Gets or sets a value indicating whether [automatic load]. + /// + /// + /// true if [automatic load]; otherwise, false. + /// + [XmlAttribute("autoLoad")] + [Description("autoLoad when enabled it directly loads the saved content")] + public bool AutoLoad { get; set; } + } +} \ No newline at end of file diff --git a/DNN 8/Objects/EditorConfig.cs b/DNN 8/Objects/EditorConfig.cs index 23f54ed..b409304 100644 --- a/DNN 8/Objects/EditorConfig.cs +++ b/DNN 8/Objects/EditorConfig.cs @@ -33,7 +33,6 @@ public EditorConfig() this.AutoGrow_MinHeight = 200; this.AutoGrow_OnStartup = false; this.AutoParagraph = true; - this.AutoSave_Delay = 25; this.AutoUpdateElement = true; this.BaseFloatZIndex = 10000; this.BasicEntities = true; @@ -135,6 +134,7 @@ public EditorConfig() this.UseComputedState = true; this.Width = "99%"; this.WordCount = new WordCountConfig(); + this.AutoSave = new AutoSave(); } /// @@ -197,16 +197,6 @@ public EditorConfig() [Description("Whether automatically create wrapping blocks around inline contents inside document body, this helps to ensure the integrality of the block enter mode.")] public bool AutoParagraph { get; set; } - /// - /// Gets or sets the auto save delay. - /// - /// - /// The auto save delay. - /// - [XmlAttribute("autosave_delay")] - [Description("Auto-save time delay (in seconds)")] - public int AutoSave_Delay { get; set; } - /// /// Gets or sets a value indicating whether [auto update element]. /// @@ -305,6 +295,14 @@ public EditorConfig() /// public CodeMirror CodeMirror { get; set; } + /// + /// Gets or sets the autosave plugin Config + /// + /// + /// The autosave plugin Config + /// + public AutoSave AutoSave { get; set; } + /// /// Gets or sets the color button_ back style. /// diff --git a/DNN 8/Utilities/SettingsUtil.cs b/DNN 8/Utilities/SettingsUtil.cs index 01f6cac..2a4a237 100644 --- a/DNN 8/Utilities/SettingsUtil.cs +++ b/DNN 8/Utilities/SettingsUtil.cs @@ -239,6 +239,37 @@ internal static EditorProviderSettings LoadPortalOrPageSettings( } } + break; + case "AutoSave": + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + if ( + editorHostSettings.Any( + s => s.Name.Equals(string.Format("{0}{1}", key, wordCountInfo.Name)))) + { + wordCountInfo.SetValue(currentSettings.Config.AutoSave, settingValue, null); + } + + break; + case "Boolean": + if ( + editorHostSettings.Any( + s => s.Name.Equals(string.Format("{0}{1}", key, wordCountInfo.Name)))) + { + wordCountInfo.SetValue( + currentSettings.Config.AutoSave, + bool.Parse(settingValue), + null); + } + + break; + } + } + break; } } @@ -930,6 +961,37 @@ var info in GetEditorConfigProperties() } } + break; + case "AutoSave": + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + if (hshModSet.ContainsKey(string.Format("{0}{1}", key, wordCountInfo.Name))) + { + wordCountInfo.SetValue( + currentSettings.Config.AutoSave, + hshModSet[string.Format("{0}{1}", key, wordCountInfo.Name)], + null); + } + + break; + case "Boolean": + if (hshModSet.ContainsKey(string.Format("{0}{1}", key, wordCountInfo.Name))) + { + wordCountInfo.SetValue( + currentSettings.Config.AutoSave, + bool.Parse( + (string)hshModSet[string.Format("{0}{1}", key, wordCountInfo.Name)]), + null); + } + + break; + } + } + break; } } diff --git a/DNN 8/WatchersNET.CKEditor - DNN8.csproj b/DNN 8/WatchersNET.CKEditor - DNN8.csproj index a068a07..41f7a02 100644 --- a/DNN 8/WatchersNET.CKEditor - DNN8.csproj +++ b/DNN 8/WatchersNET.CKEditor - DNN8.csproj @@ -145,6 +145,7 @@ EditorConfigManager.ascx + diff --git a/DNN 8/Web/CKEditorControl.cs b/DNN 8/Web/CKEditorControl.cs index e67dac8..f52110f 100644 --- a/DNN 8/Web/CKEditorControl.cs +++ b/DNN 8/Web/CKEditorControl.cs @@ -289,6 +289,46 @@ var info in "{{ {0} }}", wordcountSettings.Remove(wordcountSettings.Length - 1, 1)); } + break; + case "AutoSave": + { + var wordcountArray = new StringBuilder(); + + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + var xmlAttribute = + wordCountInfo.GetCustomAttribute(true); + + var rawSettingValue = + wordCountInfo.GetValue(this.currentSettings.Config.AutoSave, null); + + var wordCountSettingValue = rawSettingValue.ToString(); + + if (string.IsNullOrEmpty(wordCountSettingValue)) + { + continue; + } + + switch (wordCountInfo.PropertyType.Name) + { + case "String": + wordcountArray.AppendFormat("{0}: \"{1}\",", xmlAttribute.AttributeName, wordCountSettingValue); + break; + case "Int32": + wordcountArray.AppendFormat("{0}: {1},", xmlAttribute.AttributeName, wordCountSettingValue); + break; + case "Boolean": + wordcountArray.AppendFormat("{0}: {1},", xmlAttribute.AttributeName, wordCountSettingValue.ToLower()); + break; + } + } + + var wordcountSettings = wordcountArray.ToString(); + + this._settings["autosave"] = string.Format( + "{{ {0} }}", wordcountSettings.Remove(wordcountSettings.Length - 1, 1)); + } + break; default: this._settings[xmlAttributeAttribute.AttributeName] = settingValue; diff --git a/DNN 9/CKEditorOptions.ascx.cs b/DNN 9/CKEditorOptions.ascx.cs index d6de3dc..3146684 100644 --- a/DNN 9/CKEditorOptions.ascx.cs +++ b/DNN 9/CKEditorOptions.ascx.cs @@ -636,6 +636,52 @@ private void FillSettings(EditorProviderSettings importedSettings, bool changeMo } } + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + value = wordCountInfo.GetValue(importedSettings.Config.AutoSave, null); + + if (value == null) + { + continue; + } + + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var textBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (textBox != null) + { + textBox.Text = value.ToString(); + } + } + + break; + + case "Boolean": + { + var checkBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (checkBox != null) + { + checkBox.Checked = (bool)value; + } + } + + break; + } + } + } + break; } } @@ -2211,6 +2257,60 @@ var codeMirrorInfo in } } + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + var wordCountDescription = wordCountInfo.GetCustomAttribute(true); + + var settingNameContainer2 = new HtmlGenericControl("div"); + settingNameContainer2.Attributes.Add("class", "settingNameContainer"); + + var settingValueContainer2 = new HtmlGenericControl("div"); + settingValueContainer2.Attributes.Add("class", "settingValueContainer"); + + var settingNameLabel2 = new Label { Text = string.Format("{0} - {1}:", info.Name, wordCountInfo.Name) }; + + settingNameContainer2.Controls.Add(settingNameLabel2); + + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var settingValueInput = new TextBox { ID = wordCountInfo.Name, CssClass = "settingValueInput", TextMode = TextBoxMode.MultiLine, Rows = 5 }; + + if (description != null) + { + settingValueInput.ToolTip = wordCountDescription.Description; + } + + settingValueContainer2.Controls.Add(settingValueInput); + } + + break; + + case "Boolean": + { + var settingValueInput = new CheckBox { ID = wordCountInfo.Name }; + + if (description != null) + { + settingValueInput.ToolTip = wordCountDescription.Description; + } + + settingValueContainer2.Controls.Add(settingValueInput); + } + + break; + } + + this.EditorConfigHolder.Controls.Add(settingNameContainer2); + this.EditorConfigHolder.Controls.Add(settingValueContainer2); + } + } + break; } @@ -2382,6 +2482,51 @@ private void SaveModuleSettings() } } + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var textBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (textBox != null) + { + moduleController.UpdateModuleSetting( + this.ModuleId, + string.Format("{0}{1}", key, wordCountInfo.Name), + textBox.Text); + } + } + + break; + + case "Boolean": + { + var checkBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (checkBox != null) + { + moduleController.UpdateModuleSetting( + this.ModuleId, + string.Format("{0}{1}", key, wordCountInfo.Name), + checkBox.Checked.ToString()); + } + } + + break; + } + } + } + break; } } @@ -2725,6 +2870,49 @@ private void SavePortalOrPageSettings(string key) } } + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var textBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (textBox != null) + { + Utility.AddOrUpdateEditorHostSetting( + string.Format("{0}{1}", key, wordCountInfo.Name), + textBox.Text); + } + } + + break; + + case "Boolean": + { + var checkBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (checkBox != null) + { + Utility.AddOrUpdateEditorHostSetting( + string.Format("{0}{1}", key, wordCountInfo.Name), + checkBox.Checked.ToString()); + } + } + + break; + } + } + } + break; } } @@ -3443,6 +3631,48 @@ private EditorProviderSettings ExportSettings() } } + break; + case "AutoSave": + { + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + { + var textBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + if (!string.IsNullOrEmpty(textBox.Text)) + { + wordCountInfo.SetValue( + exportSettings.Config.AutoSave, + textBox.Text, + null); + } + } + + break; + + case "Boolean": + { + var checkBox = Utility.FindControl( + this.EditorConfigHolder, + wordCountInfo.Name); + + wordCountInfo.SetValue( + exportSettings.Config.AutoSave, + checkBox.Checked, + null); + } + + break; + } + } + } + break; } } diff --git a/DNN 9/Install/CKReleaseNotes.html b/DNN 9/Install/CKReleaseNotes.html index 155845b..e1f26c8 100644 --- a/DNN 9/Install/CKReleaseNotes.html +++ b/DNN 9/Install/CKReleaseNotes.html @@ -6,18 +6,18 @@ CKEditor Provider Readme -

CKEditor 4.8.0 Editor Provider 2.01.13 For DNN® Platform 09.01.01 (or above)

+

CKEditor 4.9.0 Editor Provider 2.01.14 For DNN® Platform 09.01.01 (or above)

What's New

    -
  • +
  • Upgraded to CKEditor 4.9.0
changes
    -
  • FIXED #26 Uncaught ReferenceError: dnnpagesSelectBox is not defined
  • -
-
+
  • Updated the Settings for the Autosave Plugin
  • + + diff --git a/DNN 9/Install/WatchersNET.CKHtmlEditorProvider.dnn b/DNN 9/Install/WatchersNET.CKHtmlEditorProvider.dnn index cdd0e7d..aa429ad 100644 --- a/DNN 9/Install/WatchersNET.CKHtmlEditorProvider.dnn +++ b/DNN 9/Install/WatchersNET.CKHtmlEditorProvider.dnn @@ -1,5 +1,5 @@  - + CKEditor Editor Provider CKEditor Editor Provider for DNN ~/Providers/HtmlEditorProviders/CKEditor/LogoCKEditor.png @@ -108,7 +108,7 @@ - + CKEditor Config Manager Configuration Manager for the CKEditor Editor Provider diff --git a/DNN 9/Objects/AutoSave.cs b/DNN 9/Objects/AutoSave.cs new file mode 100644 index 0000000..dc10f11 --- /dev/null +++ b/DNN 9/Objects/AutoSave.cs @@ -0,0 +1,95 @@ +/* CKEditor Html Editor Provider for DNN + * ======== + * https://github.com/w8tcha/dnnckeditor + * Copyright (C) Ingo Herbote + * + * The software, this file and its contents are subject to the CKEditor Provider + * License. Please read the license.txt file before using, installing, copying, + * modifying or distribute this file or part of its contents. The contents of + * this file is part of the Source Code of the CKEditor Provider. + */ + +namespace WatchersNET.CKEditor.Objects +{ + using System.ComponentModel; + using System.Xml.Serialization; + + /// + /// the Autosave Plugin Options + /// + public class AutoSave + { + /// + /// Initializes a new instance of the class. + /// + public AutoSave() + { + this.Delay = 1; + this.MessageType = "notification"; + this.SaveDetectionSelectors = "a[href^='javascript:__doPostBack'][id*='Save'],a[id*='Cancel']"; + this.NotOlderThen = 1440; + this.DiffType = "sideBySide"; + this.AutoLoad = false; + } + + /// + /// Gets or sets the delay. + /// + /// + /// The delay. + /// + [XmlAttribute("delay")] + [Description("Delay")] + public int Delay { get; set; } + + /// + /// Gets or sets the type of the message. + /// + /// + /// The type of the message. + /// + [XmlAttribute("messageType")] + [Description("Notification Type - Setting to set the if you want to show the 'Auto Saved' message, and if yes you can show as Notification or as Message in the Status bar (Default is : 'notification')")] + public string MessageType { get; set; } + + /// + /// Gets or sets the save detection selectors. + /// + /// + /// The save detection selectors. + /// + [XmlAttribute("saveDetectionSelectors")] + [Description("Setting to set the Save button to inform the plugin when the content is saved by the user and doesn't need to be stored temporary")] + public string SaveDetectionSelectors { get; set; } + + /// + /// Gets or sets the not older then. + /// + /// + /// The not older then. + /// + [XmlAttribute("NotOlderThen")] + [Description("The Default Minutes (Default is 1440 which is one day) after the auto saved content is ignored can be overidden")] + public int NotOlderThen { get; set; } + + /// + /// Gets or sets the type of the difference. + /// + /// + /// The type of the difference. + /// + [XmlAttribute("diffType")] + [Description("The Default Diff Type for the Compare Dialog, you can choose between 'sideBySide' or 'inline'. Default is 'sideBySide'")] + public string DiffType { get; set; } + + /// + /// Gets or sets a value indicating whether [automatic load]. + /// + /// + /// true if [automatic load]; otherwise, false. + /// + [XmlAttribute("autoLoad")] + [Description("autoLoad when enabled it directly loads the saved content")] + public bool AutoLoad { get; set; } + } +} \ No newline at end of file diff --git a/DNN 9/Objects/EditorConfig.cs b/DNN 9/Objects/EditorConfig.cs index 23f54ed..b409304 100644 --- a/DNN 9/Objects/EditorConfig.cs +++ b/DNN 9/Objects/EditorConfig.cs @@ -33,7 +33,6 @@ public EditorConfig() this.AutoGrow_MinHeight = 200; this.AutoGrow_OnStartup = false; this.AutoParagraph = true; - this.AutoSave_Delay = 25; this.AutoUpdateElement = true; this.BaseFloatZIndex = 10000; this.BasicEntities = true; @@ -135,6 +134,7 @@ public EditorConfig() this.UseComputedState = true; this.Width = "99%"; this.WordCount = new WordCountConfig(); + this.AutoSave = new AutoSave(); } /// @@ -197,16 +197,6 @@ public EditorConfig() [Description("Whether automatically create wrapping blocks around inline contents inside document body, this helps to ensure the integrality of the block enter mode.")] public bool AutoParagraph { get; set; } - /// - /// Gets or sets the auto save delay. - /// - /// - /// The auto save delay. - /// - [XmlAttribute("autosave_delay")] - [Description("Auto-save time delay (in seconds)")] - public int AutoSave_Delay { get; set; } - /// /// Gets or sets a value indicating whether [auto update element]. /// @@ -305,6 +295,14 @@ public EditorConfig() /// public CodeMirror CodeMirror { get; set; } + /// + /// Gets or sets the autosave plugin Config + /// + /// + /// The autosave plugin Config + /// + public AutoSave AutoSave { get; set; } + /// /// Gets or sets the color button_ back style. /// diff --git a/DNN 9/Utilities/SettingsUtil.cs b/DNN 9/Utilities/SettingsUtil.cs index 01f6cac..2a4a237 100644 --- a/DNN 9/Utilities/SettingsUtil.cs +++ b/DNN 9/Utilities/SettingsUtil.cs @@ -239,6 +239,37 @@ internal static EditorProviderSettings LoadPortalOrPageSettings( } } + break; + case "AutoSave": + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + if ( + editorHostSettings.Any( + s => s.Name.Equals(string.Format("{0}{1}", key, wordCountInfo.Name)))) + { + wordCountInfo.SetValue(currentSettings.Config.AutoSave, settingValue, null); + } + + break; + case "Boolean": + if ( + editorHostSettings.Any( + s => s.Name.Equals(string.Format("{0}{1}", key, wordCountInfo.Name)))) + { + wordCountInfo.SetValue( + currentSettings.Config.AutoSave, + bool.Parse(settingValue), + null); + } + + break; + } + } + break; } } @@ -930,6 +961,37 @@ var info in GetEditorConfigProperties() } } + break; + case "AutoSave": + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + switch (wordCountInfo.PropertyType.Name) + { + case "Int32": + case "String": + if (hshModSet.ContainsKey(string.Format("{0}{1}", key, wordCountInfo.Name))) + { + wordCountInfo.SetValue( + currentSettings.Config.AutoSave, + hshModSet[string.Format("{0}{1}", key, wordCountInfo.Name)], + null); + } + + break; + case "Boolean": + if (hshModSet.ContainsKey(string.Format("{0}{1}", key, wordCountInfo.Name))) + { + wordCountInfo.SetValue( + currentSettings.Config.AutoSave, + bool.Parse( + (string)hshModSet[string.Format("{0}{1}", key, wordCountInfo.Name)]), + null); + } + + break; + } + } + break; } } diff --git a/DNN 9/WatchersNET.CKEditor - DNN9.csproj b/DNN 9/WatchersNET.CKEditor - DNN9.csproj index 3ad8b9e..71d6ffe 100644 --- a/DNN 9/WatchersNET.CKEditor - DNN9.csproj +++ b/DNN 9/WatchersNET.CKEditor - DNN9.csproj @@ -145,6 +145,7 @@ EditorConfigManager.ascx + diff --git a/DNN 9/Web/CKEditorControl.cs b/DNN 9/Web/CKEditorControl.cs index 9708880..06ca683 100644 --- a/DNN 9/Web/CKEditorControl.cs +++ b/DNN 9/Web/CKEditorControl.cs @@ -220,13 +220,13 @@ var info in { var codeMirrorArray = new StringBuilder(); - foreach (var codeMirrorInfo in - typeof(CodeMirror).GetProperties()) + foreach (var codeMirrorInfo in typeof(CodeMirror).GetProperties()) { var xmlAttribute = codeMirrorInfo.GetCustomAttribute(true); var rawSettingValue = codeMirrorInfo.GetValue( - this.currentSettings.Config.CodeMirror, null); + this.currentSettings.Config.CodeMirror, + null); var codeMirrorSettingValue = rawSettingValue.ToString(); @@ -238,10 +238,16 @@ var info in switch (codeMirrorInfo.PropertyType.Name) { case "String": - codeMirrorArray.AppendFormat("{0}: '{1}',", xmlAttribute.AttributeName, codeMirrorSettingValue); + codeMirrorArray.AppendFormat( + "{0}: '{1}',", + xmlAttribute.AttributeName, + codeMirrorSettingValue); break; case "Boolean": - codeMirrorArray.AppendFormat("{0}: {1},", xmlAttribute.AttributeName, codeMirrorSettingValue.ToLower()); + codeMirrorArray.AppendFormat( + "{0}: {1},", + xmlAttribute.AttributeName, + codeMirrorSettingValue.ToLower()); break; } } @@ -249,7 +255,8 @@ var info in var codemirrorSettings = codeMirrorArray.ToString(); this._settings["codemirror"] = string.Format( - "{{ {0} }}", codemirrorSettings.Remove(codemirrorSettings.Length - 1, 1)); + "{{ {0} }}", + codemirrorSettings.Remove(codemirrorSettings.Length - 1, 1)); } break; @@ -262,8 +269,9 @@ var info in var xmlAttribute = wordCountInfo.GetCustomAttribute(true); - var rawSettingValue = - wordCountInfo.GetValue(this.currentSettings.Config.WordCount, null); + var rawSettingValue = wordCountInfo.GetValue( + this.currentSettings.Config.WordCount, + null); var wordCountSettingValue = rawSettingValue.ToString(); @@ -275,10 +283,16 @@ var info in switch (wordCountInfo.PropertyType.Name) { case "String": - wordcountArray.AppendFormat("{0}: '{1}',", xmlAttribute.AttributeName, wordCountSettingValue); + wordcountArray.AppendFormat( + "{0}: '{1}',", + xmlAttribute.AttributeName, + wordCountSettingValue); break; case "Boolean": - wordcountArray.AppendFormat("{0}: {1},", xmlAttribute.AttributeName, wordCountSettingValue.ToLower()); + wordcountArray.AppendFormat( + "{0}: {1},", + xmlAttribute.AttributeName, + wordCountSettingValue.ToLower()); break; } } @@ -286,7 +300,60 @@ var info in var wordcountSettings = wordcountArray.ToString(); this._settings["wordcount"] = string.Format( - "{{ {0} }}", wordcountSettings.Remove(wordcountSettings.Length - 1, 1)); + "{{ {0} }}", + wordcountSettings.Remove(wordcountSettings.Length - 1, 1)); + } + + break; + + case "AutoSave": + { + var wordcountArray = new StringBuilder(); + + foreach (var wordCountInfo in typeof(AutoSave).GetProperties()) + { + var xmlAttribute = + wordCountInfo.GetCustomAttribute(true); + + var rawSettingValue = wordCountInfo.GetValue( + this.currentSettings.Config.AutoSave, + null); + + var wordCountSettingValue = rawSettingValue.ToString(); + + if (string.IsNullOrEmpty(wordCountSettingValue)) + { + continue; + } + + switch (wordCountInfo.PropertyType.Name) + { + case "String": + wordcountArray.AppendFormat( + "{0}: \"{1}\",", + xmlAttribute.AttributeName, + wordCountSettingValue); + break; + case "Int32": + wordcountArray.AppendFormat( + "{0}: {1},", + xmlAttribute.AttributeName, + wordCountSettingValue); + break; + case "Boolean": + wordcountArray.AppendFormat( + "{0}: {1},", + xmlAttribute.AttributeName, + wordCountSettingValue.ToLower()); + break; + } + } + + var wordcountSettings = wordcountArray.ToString(); + + this._settings["autosave"] = string.Format( + "{{ {0} }}", + wordcountSettings.Remove(wordcountSettings.Length - 1, 1)); } break;