protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");
            base.OnLoad(e);
            if (!Context.ClientPage.IsEvent)
            {
                CurrentLanguage = WebUtil.GetQueryString("currentLanguage");
                var addedLanguages = new Set <string>();

                foreach (var language in new LanguageHistory().GetLanguages())
                {
                    AddLanguage(language, addedLanguages);
                }
                foreach (var language in LanguageManager.GetLanguages(Factory.GetDatabase(ApplicationSettings.ScriptLibraryDb)))
                {
                    AddLanguage(language, addedLanguages);
                }
                var item =
                    Sitecore.Client.CoreDatabase.GetItem(
                        "/sitecore/content/Applications/PowerShell/PowerShellIse/Menus/Languages");
                if ((item != null) && item.HasChildren)
                {
                    var queryString    = WebUtil.GetQueryString("id");
                    var commandContext = new CommandContext(item);
                    commandContext.Parameters.Add("language", CurrentLanguage);
                    Options.AddFromDataSource(item, queryString, commandContext);
                }
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull(e, nameof(e));
            base.OnLoad(e);
            if (Context.ClientPage.IsEvent)
            {
                return;
            }

            Item currentItem = GetCurrentItem();

            if (currentItem != null)
            {
                if (currentItem.IsFallback)
                {
                    HtmlGenericControl htmlGenericControl = new HtmlGenericControl("div");
                    htmlGenericControl.InnerText           = Translate.Text("No version exists in the current language. You see a fallback version from '{0}' language.", (object)currentItem.OriginalLanguage);
                    htmlGenericControl.Attributes["class"] = "versionNumSelected";
                    Context.ClientPage.AddControl(Versions, htmlGenericControl);
                }
                else
                {
                    Item[] versions = currentItem.Versions.GetVersions();
                    for (int index = versions.Length - 1; index >= 0; --index)
                    {
                        Item       obj     = versions[index];
                        XmlControl control = ControlFactory.GetControl("Gallery.Versions.Option") as XmlControl;
                        Assert.IsNotNull(control, typeof(XmlControl), "Xml Control \"{0}\" not found", (object)"Gallery.Versions.Option");
                        Context.ClientPage.AddControl(Versions, control);
                        CultureInfo culture = Context.User.Profile.Culture;
                        string      str1    = obj.Statistics.Updated == DateTime.MinValue ? Translate.Text("[Not set]") : DateUtil.FormatShortDateTime(TimeZoneUtil.ToUserTime(obj.Statistics.Updated), culture);
                        string      str2    = obj.Statistics.UpdatedBy.Length == 0 ? "-" : obj.Statistics.UpdatedBy;
                        string      str3    = obj.Version + ".";
                        string      str4    = obj.Version.Number != currentItem.Version.Number ? "<div class=\"versionNum\">" + str3 + "</div>" : "<div class=\"versionNumSelected\">" + str3 + "</div>";
                        control["Number"] = str4;
                        control["Header"] = Translate.Text("Modified <b>{0}</b> by <b>{1}</b>.", str1, str2);
                        control["Click"]  =
                            $"item:load(id={currentItem.ID},language={currentItem.Language},version={obj.Version.Number})";
                    }
                }
            }

            Item obj1 = Client.CoreDatabase.GetItem("/sitecore/content/Applications/Content Editor/Menues/Versions");

            if (obj1 == null || !obj1.HasChildren)
            {
                return;
            }

            string queryString = WebUtil.GetQueryString("id");

            Options.AddFromDataSource(obj1, queryString, new CommandContext(currentItem));
        }
Пример #3
0
        protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");
            base.OnLoad(e);
            if (!Context.ClientPage.IsEvent)
            {
                CurrenSession = WebUtil.GetQueryString("currentSessionId");

                var sessions = ScriptSessionManager.GetAll();
                foreach (var session in sessions)
                {
                    var control = ControlFactory.GetControl("SessionIDGallery.Option") as XmlControl;
                    Assert.IsNotNull(control, typeof(XmlControl), "Xml Control \"{0}\" not found",
                                     "Gallery.Versions.Option");
                    Context.ClientPage.AddControl(Sessions, control);

                    var icon = session.ApplianceType == ApplicationNames.Console
                        ? "powershell/16x16/console.png"
                        : "powershell/16x16/PowerShell_Runner.png";
                    var builder = new ImageBuilder
                    {
                        Src   = Images.GetThemedImageSource(icon, ImageDimension.id16x16),
                        Class = "scRibbonToolbarSmallGalleryButtonIcon",
                        Alt   = session.ApplianceType
                    };
                    var type = builder.ToString();
                    if (session.ID == CurrenSession)
                    {
                        type = "<div class=\"versionNumSelected\">" + type + "</div>";
                    }
                    else
                    {
                        type = "<div class=\"versionNum\">" + type + "</div>";
                    }

                    control["Number"]    = type;
                    control["SessionId"] = Translate.Text(Texts.SessionIDGallery_ID, session.ID);
                    control["Location"]  = Translate.Text(Texts.SessionIDGallery_Location, session.CurrentLocation);
                    control["UserName"]  = Translate.Text(Texts.SessionIDGallery_User, session.UserName);
                    control["Click"]     = string.Format("ise:setsessionid(id={0})", session.ID);
                }
                var item =
                    Sitecore.Client.CoreDatabase.GetItem(
                        "/sitecore/content/Applications/PowerShell/PowerShellIse/Menus/Sessions");
                if ((item != null) && item.HasChildren)
                {
                    var queryString = WebUtil.GetQueryString("id");
                    Options.AddFromDataSource(item, queryString, new CommandContext(item));
                }
            }
        }
Пример #4
0
        protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");
            base.OnLoad(e);
            if (!Context.ClientPage.IsEvent)
            {
                Item   item;
                Item   item2;
                Item[] itemArray;
                RenderRecent();

                var db     = WebUtil.GetQueryString("contextDb");
                var itemId = WebUtil.GetQueryString("contextItem");
                InitialDatabase = string.IsNullOrEmpty(db) ? Sitecore.Client.ContentDatabase.Name : db;

                BuildDatabases();

                ContentDataContext.BeginUpdate();
                ContentDataContext.Parameters = "databasename=" + InitialDatabase;

                if (!string.IsNullOrEmpty(itemId) && !string.IsNullOrEmpty(db))
                {
                    ContentDataContext.SetFolder(Factory.GetDatabase(db).GetItem(itemId).Uri);
                }
                ContentDataContext.EndUpdate();
                ContentTreeview.RefreshRoot();

                ContentDataContext.GetFromQueryString();
                ContentDataContext.GetState(out item, out item2, out itemArray);
                if (itemArray.Length > 0)
                {
                    ContentDataContext.Folder = itemArray[0].ID.ToString();
                }
                var menuItem =
                    Sitecore.Client.CoreDatabase.GetItem(
                        "/sitecore/content/Applications/PowerShell/PowerShellIse/Menus/Context");
                if ((menuItem != null) && item.HasChildren)
                {
                    var queryString = WebUtil.GetQueryString("id");
                    Options.AddFromDataSource(menuItem, queryString, new CommandContext(menuItem));
                }
            }
        }
Пример #5
0
        protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");
            base.OnLoad(e);
            if (!Context.ClientPage.IsEvent)
            {
                CurrentUser = WebUtil.GetQueryString("currentUser");

                foreach (var user in new UserHistory().GetAccounts().Where(account => User.Exists(account)).Select(name => User.FromName(name, true)))
                {
                    AddUser(user);
                }
                var item =
                    Sitecore.Client.CoreDatabase.GetItem(
                        "/sitecore/content/Applications/PowerShell/PowerShellIse/Menus/Users");
                if ((item != null) && item.HasChildren)
                {
                    var queryString    = WebUtil.GetQueryString("id");
                    var commandContext = new CommandContext(item);
                    commandContext.Parameters.Add("user", CurrentUser);
                    Options.AddFromDataSource(item, queryString, commandContext);
                }
            }
        }