public void LoadV4FromConfigurationXml(XmlNode documentNode)
        {
            if (documentNode == null) { return; }

            foreach (XmlNode node in documentNode.ChildNodes)
            {
                if (node.Name == "Editor")
                {
                    XmlAttributeCollection attributeCollection = node.Attributes;
                    TinyMceSettings editor = new TinyMceSettings();

                    if (attributeCollection["Name"] != null)
                    {
                        editor.Name = attributeCollection["Name"].Value;
                    }

                    if (attributeCollection["AutoFocus"] != null)
                    {
                        try
                        {
                            editor.AutoFocus = Convert.ToBoolean(attributeCollection["AutoFocus"].Value);
                        }
                        catch (FormatException) { }
                    }

                    if (attributeCollection["PromptOnNavigationWithUnsavedChanges"] != null)
                    {
                        try
                        {
                            editor.PromptOnNavigationWithUnsavedChanges = Convert.ToBoolean(attributeCollection["PromptOnNavigationWithUnsavedChanges"].Value);
                        }
                        catch (FormatException) { }
                    }

                    if (attributeCollection["AutoLocalize"] != null)
                    {
                        try
                        {
                            editor.AutoLocalize = Convert.ToBoolean(attributeCollection["AutoLocalize"].Value);
                        }
                        catch (FormatException) { }
                    }

                    if (attributeCollection["DisableMenuBar"] != null)
                    {
                        try
                        {
                            editor.DisableMenuBar = Convert.ToBoolean(attributeCollection["DisableMenuBar"].Value);
                        }
                        catch (FormatException) { }
                    }

                    if (attributeCollection["UnDoLevels"] != null)
                    {
                        try
                        {
                            editor.UnDoLevels = Convert.ToInt32(attributeCollection["UnDoLevels"].Value);
                        }
                        catch (FormatException) { }
                    }

                    if (attributeCollection["Menubar"] != null)
                    {
                        editor.Menubar = attributeCollection["Menubar"].Value;
                    }

                    if (attributeCollection["Theme"] != null)
                    {
                        editor.Theme = attributeCollection["Theme"].Value;
                    }

                    if (attributeCollection["Skin"] != null)
                    {
                        editor.Skin = attributeCollection["Skin"].Value;
                    }

                    if (attributeCollection["EnableObjectResizing"] != null)
                    {
                        try
                        {
                            editor.EnableObjectResizing = Convert.ToBoolean(attributeCollection["EnableObjectResizing"].Value);
                        }
                        catch (FormatException) { }
                    }

                    if (attributeCollection["Plugins"] != null)
                    {
                        editor.Plugins = attributeCollection["Plugins"].Value;
                    }

                    if (attributeCollection["Toolbar1Buttons"] != null)
                    {
                        editor.Toolbar1Buttons = attributeCollection["Toolbar1Buttons"].Value;
                    }

                    if (attributeCollection["Toolbar2Buttons"] != null)
                    {
                        editor.Toolbar2Buttons = attributeCollection["Toolbar2Buttons"].Value;
                    }

                    if (attributeCollection["Toolbar3Buttons"] != null)
                    {
                        editor.Toolbar3Buttons = attributeCollection["Toolbar3Buttons"].Value;
                    }

                    if (attributeCollection["ExtendedValidElements"] != null)
                    {
                        editor.ExtendedValidElements = attributeCollection["ExtendedValidElements"].Value;
                    }

                    if (attributeCollection["ForcePasteAsPlainText"] != null)
                    {
                        try
                        {
                            editor.ForcePasteAsPlainText = Convert.ToBoolean(attributeCollection["ForcePasteAsPlainText"].Value);
                        }
                        catch (FormatException) { }
                    }

                    if (attributeCollection["ConvertUrls"] != null)
                    {
                        try
                        {
                            editor.ConvertUrls = Convert.ToBoolean(attributeCollection["ConvertUrls"].Value);
                        }
                        catch (FormatException) { }
                    }

                    if (attributeCollection["Language"] != null)
                    {
                        editor.Language = attributeCollection["Language"].Value;
                    }

                    if (attributeCollection["TextDirection"] != null)
                    {
                        editor.TextDirection = attributeCollection["TextDirection"].Value;
                    }

                    if (attributeCollection["EnableBrowserSpellCheck"] != null)
                    {
                        try
                        {
                            editor.EnableBrowserSpellCheck = Convert.ToBoolean(attributeCollection["EnableBrowserSpellCheck"].Value);
                        }
                        catch (FormatException) { }
                    }

                    if (attributeCollection["EditorBodyCssClass"] != null)
                    {
                        editor.EditorBodyCssClass = attributeCollection["EditorBodyCssClass"].Value;
                    }

                    if (attributeCollection["NoWrap"] != null)
                    {
                        try
                        {
                            editor.NoWrap = Convert.ToBoolean(attributeCollection["NoWrap"].Value);
                        }
                        catch (FormatException) { }
                    }

                    if (attributeCollection["RemovedMenuItems"] != null)
                    {
                        editor.RemovedMenuItems = attributeCollection["RemovedMenuItems"].Value;
                    }

                    if (attributeCollection["FileDialogHeight"] != null)
                    {
                        try
                        {
                            editor.FileDialogHeight = Convert.ToInt32(attributeCollection["FileDialogHeight"].Value);
                        }
                        catch (FormatException) { }
                    }

                    if (attributeCollection["FileDialogWidth"] != null)
                    {
                        try
                        {
                            editor.FileDialogWidth = Convert.ToInt32(attributeCollection["FileDialogWidth"].Value);
                        }
                        catch (FormatException) { }
                    }

                    if (attributeCollection["EnableImageAdvancedTab"] != null)
                    {
                        try
                        {
                            editor.EnableImageAdvancedTab = Convert.ToBoolean(attributeCollection["EnableImageAdvancedTab"].Value);
                        }
                        catch (FormatException) { }
                    }

                    if (attributeCollection["ShowStatusbar"] != null)
                    {
                        try
                        {
                            editor.ShowStatusbar = Convert.ToBoolean(attributeCollection["ShowStatusbar"].Value);
                        }
                        catch (FormatException) { }
                    }

                    editorDefinitions.Add(editor);

                }
            }
        }
Example #2
0
        private void SetToolBar()
        {
            /*
             http://wiki.moxiecode.com/index.php/TinyMCE:Control_reference
             */

            switch (toolBar)
            {
                case ToolBar.Full:

                    editorSettings = config.GetEditorSettings("Full");

                    string siteRoot = SiteUtils.GetNavigationSiteRoot();
                    Editor.FileManagerUrl = siteRoot + WebConfigSettings.FileDialogRelativeUrl;
                    Editor.DropFileUploadUrl = Editor.ResolveUrl(siteRoot + "/Services/FileService.ashx?cmd=uploadfromeditor&rz=true&ko=" + WebConfigSettings.KeepFullSizeImagesDroppedInEditor.ToString().ToLower()
                    + "&t=" + Global.FileSystemToken.ToString());
                    //Editor.EnableFileBrowser = true;
                    Editor.StyleFormats = SiteUtils.BuildStylesListForTinyMce4();

                    break;

                case ToolBar.FullWithTemplates:

                    editorSettings = config.GetEditorSettings("FullWithTemplates");

                    string sRoot = SiteUtils.GetNavigationSiteRoot();
                    Editor.FileManagerUrl = sRoot + WebConfigSettings.FileDialogRelativeUrl;
                    Editor.DropFileUploadUrl = Editor.ResolveUrl(sRoot + "/Services/FileService.ashx?cmd=uploadfromeditor&rz=true&ko=" + WebConfigSettings.KeepFullSizeImagesDroppedInEditor.ToString().ToLower()
                    + "&t=" + Global.FileSystemToken.ToString());

                    //Editor.EnableFileBrowser = true;
                    Editor.StyleFormats = SiteUtils.BuildStylesListForTinyMce4();
                    Editor.TemplatesUrl = SiteUtils.GetNavigationSiteRoot() + "/Services/TinyMceTemplates.ashx?cb=" + Guid.NewGuid().ToString(); //cache busting guid

                    break;

                case ToolBar.Newsletter:

                    editorSettings = config.GetEditorSettings("Newsletter");

                    string snRoot = SiteUtils.GetNavigationSiteRoot();
                    Editor.FileManagerUrl = snRoot + WebConfigSettings.FileDialogRelativeUrl;
                    //Editor.EnableFileBrowser = true;

                    break;

                case ToolBar.ForumWithImages:

                    editorSettings = config.GetEditorSettings("ForumWithImages");

                    Editor.FileManagerUrl = SiteUtils.GetNavigationSiteRoot() + WebConfigSettings.FileDialogRelativeUrl;
                    //Editor.EnableFileBrowser = true;

                    break;

                case ToolBar.Forum:

                    editorSettings = config.GetEditorSettings("Forum");

                    break;

                case ToolBar.AnonymousUser:

                    editorSettings = config.GetEditorSettings("Anonymous");

                    break;

                case ToolBar.SimpleWithSource:

                    Editor.Plugins = "paste,searchreplace,fullscreen,emoticons,directionality,table,image";

                    Editor.Toolbar1Buttons = "code,cut,copy,pastetext,separator,blockquote,bold,italic,separator,bullist,numlist,separator,link,unlink,emoticons";

                    Editor.Toolbar2Buttons = "";

                    Editor.Toolbar3Buttons = "";

                    Editor.DisableMenuBar = true;

                    break;
            }

            Editor.Plugins = editorSettings.Plugins;
            Editor.Toolbar1Buttons = editorSettings.Toolbar1Buttons;
            Editor.Toolbar2Buttons = editorSettings.Toolbar2Buttons;
            Editor.Toolbar3Buttons = editorSettings.Toolbar3Buttons;
            Editor.ExtendedValidElements = editorSettings.ExtendedValidElements;
            Editor.ForcePasteAsPlainText = editorSettings.ForcePasteAsPlainText;
            Editor.DisableMenuBar = editorSettings.DisableMenuBar;
            Editor.Menubar = editorSettings.Menubar;
            Editor.UnDoLevels = editorSettings.UnDoLevels;
            Editor.EnableObjectResizing = editorSettings.EnableObjectResizing;
            Editor.Theme = editorSettings.Theme;
            Editor.Skin = editorSettings.Skin;
            Editor.AutoLocalize = editorSettings.AutoLocalize;
            Editor.Language = editorSettings.Language;
            Editor.TextDirection = editorSettings.TextDirection;
            Editor.EnableBrowserSpellCheck = editorSettings.EnableBrowserSpellCheck;
            Editor.EditorBodyCssClass = editorSettings.EditorBodyCssClass;
            Editor.NoWrap = editorSettings.NoWrap;
            Editor.RemovedMenuItems = editorSettings.RemovedMenuItems;
            Editor.FileDialogWidth = editorSettings.FileDialogWidth;
            Editor.FileDialogHeight = editorSettings.FileDialogHeight;
            Editor.EnableImageAdvancedTab = editorSettings.EnableImageAdvancedTab;
            Editor.ShowStatusbar = editorSettings.ShowStatusbar;
        }