Пример #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);
        }
Пример #2
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);
        }
Пример #3
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();
        }