"); - - if (PortalSecurity.IsInRoles(this._portalSettings.AdministratorRoleName)) - { - var editorUrl = Globals.NavigateURL( - "CKEditorOptions", - "ModuleId=" + this.parentModulId, - "minc=" + this.ID, - "PortalID=" + this._portalSettings.PortalId, - "langCode=" + CultureInfo.CurrentCulture.Name, - "popUp=true"); - - outWriter.Write( - "{2}", - HttpUtility.HtmlAttributeEncode(HttpUtility.JavaScriptStringEncode(editorUrl, true)), - string.Format("{0}_ckoptions", this.ClientID.Replace("-", string.Empty).Replace(".", string.Empty)), - Localization.GetString("Options.Text", SResXFile)); - } - - outWriter.Write("
"); - ///////////////// - } - - ///{1}",
+ Globals.ResolveUrl("~/Providers/HtmlEditorProviders/DNNConnect.CKE/CKEditor/"),
+ postedValue);
+ }
+
+ if (postedValue.Contains("") && !postedValue.Contains("MathJax.js"))
+ {
+ // Add MathJax Plugin
+ postedValue =
+ string.Format(
+ "{0}",
+ postedValue);
+ }
+ }
+
+ this.Value = postedValue;
+
+ return true;
+ }
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+
+ return false;
+ }
+
+ ///
+ /// The raise post data changed event.
+ ///
+ public void RaisePostDataChangedEvent()
+ {
+ // Do nothing
+ }
+
+ ///
+ /// Update the Editor after the Post back
+ /// And Create Main Script to Render the Editor.
+ ///
+ /// An object that contains the event data.
+ protected override void OnPreRender(EventArgs e)
+ {
+ base.OnPreRender(e);
+
+ // if (HasMsAjax)
+ // {
+ // return;
+ // }
+
+ // RegisterCKEditorLibrary();
+
+ // GenerateEditorLoadScript();
+ }
+
+ ///
+ /// The render.
+ ///
+ ///
+ /// The out writer.
+ ///
+ protected override void Render(HtmlTextWriter outWriter)
+ {
+ outWriter.Write("");
+ outWriter.Write("");
+ outWriter.Write("");
+
+ outWriter.Write(outWriter.NewLine);
+
+ var styleWidth = !string.IsNullOrEmpty(this.currentSettings.Config.Width)
+ ? string.Format(" style=\"width:{0};\"", this.currentSettings.Config.Width)
+ : string.Empty;
+
+ outWriter.Write("", styleWidth);
+
+ // Write text area
+ outWriter.AddAttribute("id", this.ClientID.Replace("-", string.Empty).Replace(".", string.Empty));
+ outWriter.AddAttribute("name", this.UniqueID);
+
+ outWriter.AddAttribute("cols", "80");
+ outWriter.AddAttribute("rows", "10");
+
+ outWriter.AddAttribute("class", "editor");
+ outWriter.AddAttribute("aria-label", "editor");
+
+ outWriter.AddAttribute("style", "visibility: hidden; display: none;");
+
+ outWriter.RenderBeginTag("textarea");
+
+ if (string.IsNullOrEmpty(this.Value))
+ {
+ if (!string.IsNullOrEmpty(this.currentSettings.BlankText))
+ {
+ outWriter.Write(this.Context.Server.HtmlEncode(this.currentSettings.BlankText));
+ }
+ }
+ else
+ {
+ outWriter.Write(this.Context.Server.HtmlEncode(this.Value));
+ }
+
+ outWriter.RenderEndTag();
+
+ outWriter.Write("");
+
+ this.IsRendered = true;
+
+ /////////////////
+
+ if (!this.HasRenderedTextArea(this.Page))
+ {
+ return;
+ }
+
+ outWriter.Write("");
+
+ if (PortalSecurity.IsInRoles(this.portalSettings.AdministratorRoleName))
+ {
+ var editorUrl = Globals.NavigateURL(
+ "CKEditorOptions",
+ "ModuleId=" + this.parentModulId,
+ "minc=" + this.ID,
+ "PortalID=" + this.portalSettings.PortalId,
+ "langCode=" + CultureInfo.CurrentCulture.Name,
+ "popUp=true");
+
+ outWriter.Write(
+ "{2}",
+ HttpUtility.HtmlAttributeEncode(HttpUtility.JavaScriptStringEncode(editorUrl, true)),
+ string.Format("{0}_ckoptions", this.ClientID.Replace("-", string.Empty).Replace(".", string.Empty)),
+ Localization.GetString("Options.Text", SResXFile));
+ }
+
+ outWriter.Write("
");
+ /////////////////
+ }
+
+ ///
+ /// Re-Formats Url from the Url Control.
+ ///
+ /// The input Url.
+ ///
+ /// Returns the Formatted Url.
+ ///
+ private string ReFormatURL(string inputUrl)
+ {
+ if (inputUrl.StartsWith("http://") || inputUrl.StartsWith("FileID="))
+ {
+ return inputUrl;
+ }
+
+ return string.Format("FileID={0}", Utility.ConvertFilePathToFileId(inputUrl, this.portalSettings.PortalId));
+ }
+
+ /// Gets the container source.
+ /// The container source path.
+ private string GetContainerSource()
+ {
+ var containerSource = this.portalSettings.ActiveTab.ContainerSrc ?? this.portalSettings.DefaultPortalContainer;
+ containerSource = this.ResolveSourcePath(containerSource);
+ return containerSource;
+ }
+
+ /// Gets the skin source.
+ /// The skin source path.
+ private string GetSkinSource()
+ {
+ var skinSource = this.portalSettings.ActiveTab.SkinSrc ?? this.portalSettings.DefaultPortalSkin;
+ skinSource = this.ResolveSourcePath(skinSource);
+ return skinSource;
+ }
+
+ /// Resolves the source path.
+ /// The source.
+ /// The source path of the select resource.
+ private string ResolveSourcePath(string source)
+ {
+ source = "~" + source;
+ return source;
+ }
+
+ ///
+ /// Initializes the Editor.
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void CKEditorInit(object sender, EventArgs e)
+ {
+ this.Page?.RegisterRequiresPostBack(this); // Ensures that postback is handled
+
+ this.myParModule = (PortalModuleBase)FindModuleInstance(this);
+
+ if (this.myParModule == null || this.myParModule.ModuleId == -1)
+ {
+ // Get Parent ModuleID From this ClientID
+ string sClientId = this.ClientID.Substring(this.ClientID.IndexOf("ctr") + 3);
+
+ sClientId = sClientId.Remove(this.ClientID.IndexOf("_"));
+
+ if (!int.TryParse(sClientId, out this.parentModulId))
+ {
+ // The is no real module, then use the "User Accounts" module (Profile editor)
+ ModuleController db = new ModuleController();
+ ModuleInfo objm = db.GetModuleByDefinition(this.portalSettings.PortalId, "User Accounts");
+
+ this.parentModulId = objm.TabModuleID;
+ }
+ }
+ else
+ {
+ this.parentModulId = this.myParModule.ModuleId;
+ }
+
+ this.CheckFileBrowser();
+
+ this.LoadAllSettings();
+
+ ////if (!HasMsAjax)
+ ////{
+ //// return;
+ ////}
+
+ this.RegisterCKEditorLibrary();
+
+ this.GenerateEditorLoadScript();
+ }
+
+ ///
+ /// The check file browser.
+ ///
+ private void CheckFileBrowser()
+ {
+ ProviderConfiguration providerConfiguration = ProviderConfiguration.GetProviderConfiguration(ProviderType);
+ Provider objProvider = (Provider)providerConfiguration.Providers[providerConfiguration.DefaultProvider];
+
+ if (objProvider == null || string.IsNullOrEmpty(objProvider.Attributes["ck_browser"]))
+ {
+ return;
+ }
+
+ switch (objProvider.Attributes["ck_browser"])
+ {
+ case "ckfinder":
+ this.currentSettings.BrowserMode = BrowserType.CKFinder;
+ break;
+ case "standard":
+ this.currentSettings.BrowserMode = BrowserType.StandardBrowser;
+ break;
+ case "none":
+ this.currentSettings.BrowserMode = BrowserType.None;
+ break;
+ }
+ }
+
+ ///
+ /// Load Portal/Page/Module Settings.
+ ///
+ private void LoadAllSettings()
+ {
+ var settingsDictionary = EditorController.GetEditorHostSettings();
+ var portalRoles = RoleController.Instance.GetRoles(this.portalSettings.PortalId);
+
+ // Load Default Settings
+ this.currentSettings = SettingsUtil.GetDefaultSettings(
+ this.portalSettings,
+ this.portalSettings.HomeDirectoryMapPath,
+ this.settings["configFolder"],
+ portalRoles);
+
+ // Set Current Mode to Default
+ this.currentSettings.SettingMode = SettingsMode.Default;
+
+ const string hostKey = "DNNCKH#";
+ var portalKey = string.Format("DNNCKP#{0}#", this.portalSettings.PortalId);
+ var pageKey = string.Format("DNNCKT#{0}#", this.portalSettings.ActiveTab.TabID);
+ var moduleKey = string.Format("DNNCKMI#{0}#INS#{1}#", this.parentModulId, this.ID);
+
+ // Load Host Settings ?!
+ if (SettingsUtil.CheckSettingsExistByKey(settingsDictionary, hostKey))
+ {
+ var hostPortalRoles = RoleController.Instance.GetRoles(Host.HostPortalID);
+ this.currentSettings = SettingsUtil.LoadEditorSettingsByKey(
+ this.portalSettings,
+ this.currentSettings,
+ settingsDictionary,
+ hostKey,
+ hostPortalRoles);
+
+ // Set Current Mode to Host
+ this.currentSettings.SettingMode = SettingsMode.Host;
+
+ // reset the roles to the correct portal
+ if (this.portalSettings.PortalId != Host.HostPortalID)
+ {
+ foreach (var toolbarRole in this.currentSettings.ToolBarRoles)
+ {
+ var roleName = hostPortalRoles.FirstOrDefault(role => role.RoleID == toolbarRole.RoleId)?.RoleName ?? string.Empty;
+ var roleId = portalRoles.FirstOrDefault(role => role.RoleName.Equals(roleName))?.RoleID ?? Null.NullInteger;
+ toolbarRole.RoleId = roleId;
+ }
+
+ foreach (var uploadRoles in this.currentSettings.UploadSizeRoles)
+ {
+ var roleName = hostPortalRoles.FirstOrDefault(role => role.RoleID == uploadRoles.RoleId)?.RoleName ?? string.Empty;
+ var roleId = portalRoles.FirstOrDefault(role => role.RoleName.Equals(roleName))?.RoleID ?? Null.NullInteger;
+ uploadRoles.RoleId = roleId;
+ }
+ }
+ }
+
+ // Load Portal Settings ?!
+ if (SettingsUtil.CheckSettingsExistByKey(settingsDictionary, portalKey))
+ {
+ /* throw new ApplicationException(settingsDictionary.FirstOrDefault(
+ setting => setting.Name.Equals(string.Format("{0}{1}", portalKey, "StartupMode"))).Value);*/
+
+ this.currentSettings = SettingsUtil.LoadEditorSettingsByKey(
+ this.portalSettings,
+ this.currentSettings,
+ settingsDictionary,
+ portalKey,
+ portalRoles);
+
+ // Set Current Mode to Portal
+ this.currentSettings.SettingMode = SettingsMode.Portal;
+ }
+
+ // Load Page Settings ?!
+ if (SettingsUtil.CheckSettingsExistByKey(settingsDictionary, pageKey))
+ {
+ this.currentSettings = SettingsUtil.LoadEditorSettingsByKey(
+ this.portalSettings, this.currentSettings, settingsDictionary, pageKey, portalRoles);
+
+ // Set Current Mode to Page
+ this.currentSettings.SettingMode = SettingsMode.Page;
+ }
+
+ // Load Module Settings ?!
+ if (!SettingsUtil.CheckExistsModuleInstanceSettings(moduleKey, this.parentModulId))
+ {
+ return;
+ }
+
+ this.currentSettings = SettingsUtil.LoadModuleSettings(
+ this.portalSettings, this.currentSettings, moduleKey, this.parentModulId, portalRoles);
+
+ // Set Current Mode to Module Instance
+ this.currentSettings.SettingMode = SettingsMode.ModuleInstance;
+ }
+
+ ///
+ /// Format the URL from FileID to File Path URL.
+ ///
+ ///
+ /// The Input URL.
+ ///
+ ///
+ /// The formatted URL.
+ ///
+ private string FormatUrl(string inputUrl)
+ {
+ var formattedUrl = string.Empty;
+
+ if (string.IsNullOrEmpty(inputUrl))
+ {
+ return formattedUrl;
+ }
+
+ if (inputUrl.StartsWith("http://") || inputUrl.StartsWith("https://") || inputUrl.StartsWith("//"))
+ {
+ formattedUrl = inputUrl;
+ }
+ else if (inputUrl.StartsWith("FileID="))
+ {
+ var fileId = int.Parse(inputUrl.Substring(7));
+
+ var objFileInfo = FileManager.Instance.GetFile(fileId);
+
+ formattedUrl = this.portalSettings.HomeDirectory + objFileInfo.Folder + objFileInfo.FileName;
+ }
+ else
+ {
+ formattedUrl = this.portalSettings.HomeDirectory + inputUrl;
+ }
+
+ return formattedUrl;
+ }
+
+ ///
+ /// Load the Settings from the web.config file.
+ ///
+ private void LoadConfigSettings()
+ {
+ this.settings = new NameValueCollection();
+
+ var providerConfiguration = ProviderConfiguration.GetProviderConfiguration(ProviderType);
+ if (providerConfiguration.Providers.ContainsKey(providerConfiguration.DefaultProvider))
+ {
+ var objProvider = (Provider)providerConfiguration.Providers[providerConfiguration.DefaultProvider];
+
+ foreach (string key in objProvider.Attributes)
+ {
+ if (key.IndexOf("ck_", StringComparison.OrdinalIgnoreCase) == 0)
+ {
+ string sAdjustedKey = key.Substring(3, key.Length - 3);
+
+ // Do not ToLower settingKey, because CKConfig is case-Sensitive, exp: image2_prefillDimension
+ ////.ToLower();
+
+ if (!string.IsNullOrEmpty(sAdjustedKey))
+ {
+ this.settings[sAdjustedKey] = objProvider.Attributes[key];
+ }
+ }
+ }
+ }
+ else
+ {
+ throw new ConfigurationErrorsException(string.Format(
+ "Configuration error: default provider {0} doesn't exist in {1} providers",
+ providerConfiguration.DefaultProvider,
+ ProviderType));
+ }
+ }
+
+ ///
+ /// This registers a startup JavaScript with compatibility with the Microsoft Ajax.
+ ///
+ ///
+ /// The key.
+ ///
+ ///
+ /// The script.
+ ///
+ ///
+ /// The add Script Tags.
+ ///
+ private void RegisterStartupScript(string key, string script, bool addScriptTags)
+ {
+ ScriptManager.RegisterStartupScript(this, this.GetType(), key, script, addScriptTags);
+ }
+
+ private void RegisterScript(string key, string script, bool addScriptTags)
+ {
+ ScriptManager.RegisterClientScriptBlock(this, this.GetType(), key, script, addScriptTags);
+ }
+
+ ///
+ /// Registers the on submit statement.
+ ///
+ /// The type.
+ /// The key.
+ /// The script.
+ private void RegisterOnSubmitStatement(Type type, string key, string script)
+ {
+ ScriptManager.RegisterOnSubmitStatement(this, type, key, script);
+ }
+
+ ///
+ /// Set Toolbar based on Current User.
+ ///
+ ///
+ /// The alternate config sub folder.
+ ///
+ ///
+ /// Toolbar Name.
+ ///
+ private string SetUserToolbar(string alternateConfigSubFolder)
+ {
+ string toolbarName = this.CanUseFullToolbarAsDefault() ? "Full" : "Basic";
+
+ var listToolbarSets = ToolbarUtil.GetToolbars(
+ this.portalSettings.HomeDirectoryMapPath, alternateConfigSubFolder);
+
+ var listUserToolbarSets = new List();
+
+ if (this.currentSettings.ToolBarRoles.Count <= 0)
+ {
+ return toolbarName;
+ }
+
+ foreach (var roleToolbar in this.currentSettings.ToolBarRoles)
+ {
+ if (roleToolbar.RoleId.Equals(-1) && !HttpContext.Current.Request.IsAuthenticated)
+ {
+ return roleToolbar.Toolbar;
+ }
+
+ if (roleToolbar.RoleId.Equals(-1))
+ {
+ continue;
+ }
+
+ // Role
+ var role = RoleController.Instance.GetRoleById(this.portalSettings.PortalId, roleToolbar.RoleId);
+
+ if (role == null)
+ {
+ continue;
+ }
+
+ if (!PortalSecurity.IsInRole(role.RoleName))
+ {
+ continue;
+ }
+
+ // Handle Different Roles
+ if (!listToolbarSets.Any(toolbarSel => toolbarSel.Name.Equals(roleToolbar.Toolbar)))
+ {
+ continue;
+ }
+
+ var toolbar = listToolbarSets.Find(toolbarSel => toolbarSel.Name.Equals(roleToolbar.Toolbar));
+
+ listUserToolbarSets.Add(toolbar);
+ }
+
+ if (listUserToolbarSets.Count <= 0)
+ {
+ return toolbarName;
+ }
+
+ // Compare The User Toolbars if the User is more then One Role, and apply the Toolbar with the Highest Priority
+ int iHighestPrio = listUserToolbarSets.Max(toolb => toolb.Priority);
+
+ return ToolbarUtil.FindHighestToolbar(listUserToolbarSets, iHighestPrio).Name;
+ }
+
+ private bool CanUseFullToolbarAsDefault()
+ {
+ if (!HttpContext.Current.Request.IsAuthenticated)
+ {
+ return false;
+ }
+
+ var currentUser = UserController.Instance.GetCurrentUserInfo();
+ return currentUser.IsSuperUser || PortalSecurity.IsInRole(this.portalSettings.AdministratorRoleName);
+ }
+
+ ///
+ /// Registers the CKEditor library.
+ ///
+ private void RegisterCKEditorLibrary()
+ {
+ ClientResourceManager.RegisterStyleSheet(this.Page, Globals.ResolveUrl("~/Providers/HtmlEditorProviders/DNNConnect.CKE/css/CKEditorToolBars.css"));
+ ClientResourceManager.RegisterStyleSheet(this.Page, Globals.ResolveUrl("~/Providers/HtmlEditorProviders/DNNConnect.CKE/css/CKEditorOverride.css"));
+ ClientResourceManager.RegisterStyleSheet(this.Page, Globals.ResolveUrl("~/Providers/HtmlEditorProviders/DNNConnect.CKE/js/ckeditor/4.5.3/editor.css"));
+
+ ClientScriptManager cs = this.Page.ClientScript;
+
+ Type csType = this.GetType();
+
+ const string CsName = "CKEdScript";
+ const string CsAdaptName = "CKAdaptScript";
+ const string CsFindName = "CKFindScript";
+
+ JavaScript.RequestRegistration(CommonJs.jQuery);
+
+ // Inject jQuery if editor is loaded in a RadWindow
+ if (HttpContext.Current.Request.QueryString["rwndrnd"] != null)
+ {
+ ScriptManager.RegisterClientScriptInclude(
+ this, csType, "jquery_registered", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
+ }
+
+ if (File.Exists(this.Context.Server.MapPath("~/Providers/HtmlEditorProviders/DNNConnect.CKE/js/ckeditor/4.5.3/ckeditor.js"))
+ && !cs.IsClientScriptIncludeRegistered(csType, CsName))
+ {
+ cs.RegisterClientScriptInclude(
+ csType, CsName, Globals.ResolveUrl("~/Providers/HtmlEditorProviders/DNNConnect.CKE/js/ckeditor/4.5.3/ckeditor.js"));
+ }
+
+ if (
+ File.Exists(
+ this.Context.Server.MapPath(
+ "~/Providers/HtmlEditorProviders/DNNConnect.CKE/js/jquery.ckeditor.adapter.js"))
+ && !cs.IsClientScriptIncludeRegistered(csType, CsAdaptName))
+ {
+ cs.RegisterClientScriptInclude(
+ csType,
+ CsAdaptName,
+ Globals.ResolveUrl("~/Providers/HtmlEditorProviders/DNNConnect.CKE/js/jquery.ckeditor.adapter.js"));
+ }
+
+ if (
+ File.Exists(
+ this.Context.Server.MapPath("~/Providers/HtmlEditorProviders/DNNConnect.CKE/ckfinder/ckfinder.js")) &&
+ !cs.IsClientScriptIncludeRegistered(csType, CsFindName) && this.currentSettings.BrowserMode.Equals(BrowserType.CKFinder))
+ {
+ cs.RegisterClientScriptInclude(
+ csType,
+ CsFindName,
+ Globals.ResolveUrl("~/Providers/HtmlEditorProviders/DNNConnect.CKE/ckfinder/ckfinder.js"));
+ }
+
+ ClientResourceManager.RegisterScript(this.Page, Globals.ResolveUrl("~/Providers/HtmlEditorProviders/DNNConnect.CKE/js/editorOverride.js"));
+
+ // Load Custom JS File
+ if (!string.IsNullOrEmpty(this.currentSettings.CustomJsFile)
+ && !cs.IsClientScriptIncludeRegistered(csType, "CKCustomJSFile"))
+ {
+ cs.RegisterClientScriptInclude(
+ csType,
+ "CKCustomJSFile",
+ this.FormatUrl(this.currentSettings.CustomJsFile));
+ }
+ }
+
+ ///
+ /// Generates the editor load script.
+ ///
+ private void GenerateEditorLoadScript()
+ {
+ var editorVar = string.Format(
+ "editor{0}",
+ this.ClientID.Substring(this.ClientID.LastIndexOf("_", StringComparison.Ordinal) + 1).Replace(
+ "-", string.Empty));
+
+ var editorFixedId = this.ClientID.Replace("-", string.Empty).Replace(".", string.Empty);
+
+ var postBackScript = string.Format(
+ @" if (CKEDITOR && CKEDITOR.instances && CKEDITOR.instances.{0}) {{ CKEDITOR.instances.{0}.updateElement(); if (typeof Page_IsValid !== 'undefined' && Page_IsValid) CKEDITOR.instances.{0}.destroy(); }}",
+ editorFixedId);
+
+ this.RegisterOnSubmitStatement(
+ this.GetType(), string.Format("CKEditor_OnAjaxSubmit_{0}", editorFixedId), postBackScript);
+
+ var editorScript = new StringBuilder();
+
+ editorScript.AppendFormat(
+ "Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(LoadCKEditorInstance_{0});", editorFixedId);
+
+ editorScript.AppendFormat("function LoadCKEditorInstance_{0}(sender,args) {{", editorFixedId);
+
+ editorScript.AppendFormat(
+ @"if (jQuery(""[id*='UpdatePanel']"").length == 0 && CKEDITOR && CKEDITOR.instances && CKEDITOR.instances.{0}) {{ CKEDITOR.instances.{0}.updateElement();}}",
+ editorFixedId);
+
+ editorScript.AppendFormat(
+ "if (document.getElementById('{0}') == null){{return;}}",
+ editorFixedId);
+
+ // Render EditorConfig
+ var editorConfigScript = new StringBuilder();
+ editorConfigScript.AppendFormat("var editorConfig{0} = {{", editorVar);
+
+ var keysCount = this.Settings.Keys.Count;
+ var currentCount = 0;
+
+ // Write options
+ foreach (string key in this.Settings.Keys)
+ {
+ var value = this.Settings[key];
+
+ currentCount++;
+
+ // Is boolean state or string
+ if (value.Equals("true", StringComparison.InvariantCultureIgnoreCase)
+ || value.Equals("false", StringComparison.InvariantCultureIgnoreCase) || value.StartsWith("[")
+ || value.StartsWith("{") || Utility.IsNumeric(value))
+ {
+ if (value.Equals("True"))
+ {
+ value = "true";
+ }
+ else if (value.Equals("False"))
+ {
+ value = "false";
+ }
+
+ editorConfigScript.AppendFormat("{0}:{1}", key, value);
+
+ editorConfigScript.Append(currentCount == keysCount ? "};" : ",");
+ }
+ else
+ {
+ if (key == "browser")
+ {
+ continue;
+ }
+
+ editorConfigScript.AppendFormat("{0}:\'{1}\'", key, value);
+
+ editorConfigScript.Append(currentCount == keysCount ? "};" : ",");
+ }
+ }
+
+ editorScript.AppendFormat(
+ "if (CKEDITOR.instances.{0}){{return;}}",
+ editorFixedId);
+
+ // Check if we can use jQuery or $, and if both fail use ckeditor without the adapter
+ editorScript.Append("if (jQuery().ckeditor) {");
+
+ editorScript.AppendFormat("var {0} = jQuery('#{1}').ckeditor(editorConfig{0});", editorVar, editorFixedId);
+
+ editorScript.Append("} else if ($.ckeditor) {");
+
+ editorScript.AppendFormat("var {0} = $('#{1}').ckeditor(editorConfig{0});", editorVar, editorFixedId);
+
+ editorScript.Append("} else {");
+
+ editorScript.AppendFormat("var {0} = CKEDITOR.replace( '{1}', editorConfig{0});", editorVar, editorFixedId);
+
+ editorScript.Append("}");
+
+ // firefox maximize fix
+ editorScript.Append("CKEDITOR.on('instanceReady', function (ev) {");
+ editorScript.Append("ev.editor.on('maximize', function () {");
+ editorScript.Append("if (ev.editor.commands.maximize.state == 1) {");
+ editorScript.Append("var mainDocument = CKEDITOR.document;");
+ editorScript.Append("CKEDITOR.env.gecko && mainDocument.getDocumentElement().setStyle( 'position', 'fixed' );");
+ editorScript.Append("}");
+ editorScript.Append("});");
+ editorScript.Append("});");
+
+ editorScript.Append("if(CKEDITOR && CKEDITOR.config){");
+ editorScript.Append(" CKEDITOR.config.portalId = " + this.portalSettings.PortalId);
+ editorScript.Append("};");
+
+ // End of LoadScript
+ editorScript.Append("}");
+
+ this.RegisterScript(string.Format(@"{0}_CKE_Config", editorFixedId), editorConfigScript.ToString(), true);
+ this.RegisterStartupScript(string.Format(@"{0}_CKE_Startup", editorFixedId), editorScript.ToString(), true);
+ }
+ }
+}