public static TinyMceConfiguration GetConfig()
        {
            TinyMceConfiguration config = new TinyMceConfiguration();

            try
            {
                if (
                    (HttpRuntime.Cache["CTinyConfiguration"] != null) &&
                    (HttpRuntime.Cache["CTinyConfiguration"] is TinyMceConfiguration)
                    )
                {
                    return((TinyMceConfiguration)HttpRuntime.Cache["CTinyConfiguration"]);
                }

                string pathToConfigFile = HostingEnvironment.MapPath("~/" + GetConfigFileName());

                XmlDocument configXml = new XmlDocument();
                configXml.Load(pathToConfigFile);
                config.LoadValuesFromConfigurationXml(configXml.DocumentElement);

                AggregateCacheDependency aggregateCacheDependency = new AggregateCacheDependency();

                string pathToWebConfig = HostingEnvironment.MapPath("~/Web.config");

                aggregateCacheDependency.Add(new CacheDependency(pathToWebConfig));

                HttpRuntime.Cache.Insert(
                    "CTinyConfiguration",
                    config,
                    aggregateCacheDependency,
                    DateTime.Now.AddYears(1),
                    TimeSpan.Zero,
                    CacheItemPriority.Default,
                    null);

                return((TinyMceConfiguration)HttpRuntime.Cache["CTinyConfiguration"]);
            }
            catch (HttpException ex)
            {
                log.Error(ex);
            }
            catch (XmlException ex)
            {
                log.Error(ex);
            }
            catch (ArgumentException ex)
            {
                log.Error(ex);
            }
            catch (NullReferenceException ex)
            {
                log.Error(ex);
            }

            return(config);
        }
示例#2
0
        private void InitializeEditor()
        {
            //this is true because we are using xhtml
            //Editor.UseStrictLoadingMode = true;

            config = TinyMceConfiguration.GetConfig();

            Editor.AdvancedBlockFormats = config.AdvancedFormatBlocks;

            Editor.AdvancedStyles = SiteUtils.BuildStylesListForTinyMce();
            Editor.TemplatesUrl   = SiteUtils.GetNavigationSiteRoot() + "/Services/TinyMceTemplates.ashx?cb=" + Guid.NewGuid().ToString(); //cache busting guid


            Editor.DialogType = config.DialogType;

            Editor.Height = editorHeight;
            Editor.Width  = editorWidth;

            Editor.AdvancedSourceEditorWidth  = config.AdvancedSourceEditorWidth;
            Editor.AdvancedSourceEditorHeight = config.AdvancedSourceEditorHeight;
            Editor.AdvancedToolbarLocation    = config.AdvancedToolbarLocation;
            Editor.AdvancedToolbarAlign       = config.AdvancedToolbarAlign;
            Editor.AdvancedStatusBarLocation  = config.AdvancedStatusBarLocation;
            Editor.SpellCheckerLanguages      = config.SpellCheckerLanguages;

            if (setFocusOnStart)
            {
                Editor.AutoFocus = true;
            }


            Editor.BasePath = WebConfigSettings.TinyMceBasePath;
            Editor.Skin     = WebConfigSettings.TinyMceSkin;

            //Editor.ForcedRootBlock = string.Empty;

            SetToolBar();
        }