Example #1
0
        public static TinyEditorConfigurationResult LoadTinyEditorConfiguration()
        {
            var configurationResult = new TinyEditorConfigurationResult();

            using (new SecurityEnabler()) {
                //Compatibility with Sitecore builtin Telerik RTE:
                //"so" - default parameter left for RTE
                //"so_mce" - new parameter to setup profile for so_mce
                //if you need to setup profile, you need to type &so_mce=/sitecore/system/Settings/TinyMCE Editor Profiles/TinyMCE Full Classic Profile
                var queryString = WebUtil.GetQueryString("so_mce", Sitecore.Configuration.Settings.GetSetting("TinyEditor.DefaultProfile"));

                Assert.IsNotNull((object)queryString, "source");

                var coreDb = Sitecore.Data.Database.GetDatabase("core");
                Assert.IsNotNull((object)coreDb, "database");
                var profile1 = coreDb.GetItem(queryString);

                if (profile1 != null)
                {
                    var editorConfiguration = TinyEditorConfiguration.Create(profile1);
                    configurationResult = editorConfiguration.Apply();
                }
            }

            return(configurationResult);
        }
Example #2
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">
        /// The <see cref="T:System.EventArgs" /> object that contains the event data.
        /// </param>
        protected override void OnLoad(EventArgs e)
        {
            User user = Sitecore.Context.User;

            if (!user.IsInRole(Constants.SitecoreClientUsersRole) && !user.IsAdministrator)
            {
                WebUtil.RedirectToLoginPage();
            }
            base.OnLoad(e);
            if (this.IsPostBack || string.IsNullOrEmpty(WebUtil.GetQueryString("hdl")))
            {
                return;
            }

            TinyEditorConfigurationResult configurationResult = Utils.LoadTinyEditorConfiguration();

            this.RegisterMediaPrefixes();

            this.EditorToolbar.Value      = configurationResult.EditorToolbar;
            this.EditorPlugins.Value      = configurationResult.EditorPlugins;
            this.EditorInitCallback.Value = configurationResult.EditorInitCallback;
            this.EditorMenubar.Value      = configurationResult.EditorMenubar;
            this.EditorBranding.Value     = configurationResult.EditorBranding;
            this.CSSPath.Value            = Sitecore.Configuration.Settings.GetSetting("WebStylesheet");

            this.RenderScriptConstants();
            this.LoadHtml();
        }
Example #3
0
        public static TinyEditorConfigurationResult LoadTinyEditorConfiguration()
        {
            TinyEditorConfigurationResult configurationResult = new TinyEditorConfigurationResult();

            using (new SecurityEnabler()) {
                string queryString = WebUtil.GetQueryString("so", Sitecore.Configuration.Settings.GetSetting("TinyEditor.DefaultProfile"));
                Assert.IsNotNull((object)queryString, "source");

                Database coreDB = Sitecore.Data.Database.GetDatabase("core");
                Assert.IsNotNull((object)coreDB, "database");
                Sitecore.Data.Items.Item profile1 = coreDB.GetItem(queryString);

                if (profile1 != null)
                {
                    TinyEditorConfiguration editorConfiguration = TinyEditorConfiguration.Create(profile1);
                    configurationResult = editorConfiguration.Apply();
                }
                else
                {
                    Sitecore.Data.Items.Item profile2 = coreDB.GetItem(Settings.HtmlEditor.DefaultProfile);
                    if (profile2 != null)
                    {
                        TinyEditorConfiguration editorConfiguration = TinyEditorConfiguration.Create(profile2);
                        configurationResult = editorConfiguration.Apply();
                    }
                }
            }

            return(configurationResult);
        }
Example #4
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">
        /// The <see cref="T:System.EventArgs" /> object that contains the event data.
        /// </param>
        protected override void OnLoad(EventArgs e)
        {
            User user = Sitecore.Context.User;

            if (!user.IsInRole(Constants.SitecoreClientUsersRole) && !user.IsAdministrator)
            {
                WebUtil.RedirectToLoginPage();
            }
            base.OnLoad(e);
            if (this.IsPostBack || string.IsNullOrEmpty(WebUtil.GetQueryString("hdl")))
            {
                return;
            }
            TinyEditorConfigurationResult configurationResult = new TinyEditorConfigurationResult();

            using (new UserSwitcher(user)) {
                using (new SecurityEnabler()) {
                    string queryString = WebUtil.GetQueryString("so", Sitecore.Configuration.Settings.GetSetting("TinyEditor.DefaultProfile"));
                    Assert.IsNotNull((object)queryString, "source");

                    Database database = Sitecore.Context.Database;
                    Assert.IsNotNull((object)database, "database");
                    Sitecore.Data.Items.Item profile1 = database.GetItem(queryString);

                    if (profile1 != null)
                    {
                        TinyEditorConfiguration editorConfiguration = TinyEditorConfiguration.Create(profile1);
                        configurationResult = editorConfiguration.Apply();
                    }
                    else
                    {
                        Sitecore.Data.Items.Item profile2 = database.GetItem(Settings.HtmlEditor.DefaultProfile);
                        if (profile2 != null)
                        {
                            TinyEditorConfiguration editorConfiguration = TinyEditorConfiguration.Create(profile2);
                            configurationResult = editorConfiguration.Apply();
                        }
                    }
                }
            }
            this.RegisterMediaPrefixes();

            this.EditorToolbar.Value      = configurationResult.EditorToolbar;
            this.EditorPlugins.Value      = configurationResult.EditorPlugins;
            this.EditorInitCallback.Value = configurationResult.EditorInitCallback;
            this.EditorMenubar.Value      = configurationResult.EditorMenubar;
            this.EditorBranding.Value     = configurationResult.EditorBranding;
            this.CSSPath.Value            = Sitecore.Configuration.Settings.GetSetting("WebStylesheet");

            this.RenderScriptConstants();
            this.LoadHtml();
        }
        /// <summary>Edits the text.</summary>
        /// <param name="args">The args.</param>
        protected void EditHtmlTinyMCE(ClientPipelineArgs args) {
            TinyEditorConfigurationResult configurationResult = Utils.LoadTinyEditorConfiguration();

            int windowWidth, windowHeight;
            if (!int.TryParse(configurationResult.EditorWindowWidth, out windowWidth)) {
                windowWidth = 1220;
            }
            if (!int.TryParse(configurationResult.EditorWindowHeight, out windowHeight)) {
                windowHeight = 730;
            }

            Assert.ArgumentNotNull((object)args, ExtensionMethods.nameof(() => args));
            if (this.Disabled)
                return;
            if (args.IsPostBack) {
                if (args.Result == null || !(args.Result != "undefined"))
                    return;
                this.UpdateHtml(args);
            } else {
                TinyMCEEditorUrl richTextEditorUrl = new TinyMCEEditorUrl() {
                    Conversion = TinyMCEEditorUrl.HtmlConversion.DoNotConvert,
                    Disabled = this.Disabled,
                    FieldID = this.FieldID,
                    ID = this.ID,
                    ItemID = this.ItemID,
                    Language = this.ItemLanguage,
                    Mode = string.Empty,
                    ShowInFrameBasedDialog = true,
                    Source = this.Source,
                    Url = "/sitecore/shell/Controls/TinyMCE Editor/EditorPage.aspx",
                    Value = this.Value,
                    Version = this.ItemVersion
                };
                UrlString url = richTextEditorUrl.GetUrl();
                this.handle = richTextEditorUrl.Handle;
                SheerResponse.ShowModalDialog(new ModalDialogOptions(url.ToString()) {
                    Width = string.Format("{0}px", windowWidth),
                    Height = string.Format("{0}px", windowHeight),
                    Response = true,
                    Header = Translate.Text("Rich Text Editor")
                });
                args.WaitForPostBack();
            }
        }