protected void SwitchMenu_Click() { var parent = new Sitecore.Web.UI.HtmlControls.Menu(); Item item = Client.CoreDatabase.GetItem(Sitecore.ItemBucket.Kernel.Util.Constants.CoreApplicationsFolder); Assert.IsNotNull(item, "Item \"/sitecore/content/Applications/Content Editor/Applications\" not found"); ChildList children = item.Children; for (int i = 0; i < children.Count; i++) { Item item2 = children[i]; UrlString url = GetUrl(item2); url.Add("pa", i.ToString()); url.Add("pa0", WebUtil.GetQueryString("pa0")); url.Add("pa1", WebUtil.GetQueryString("pa1")); var control = new Sitecore.Web.UI.HtmlControls.MenuItem(); Context.ClientPage.AddControl(parent, control); control.Header = item2["Header"]; control.Icon = item2.Appearance.Icon; control.Click = "SwitchTo(\"" + url + "\")"; } SheerResponse.ShowPopup("SwitchMenu", "below-right", parent); }
/// <summary> /// This Method is used to display recent Publish from Sitecore Taskbar (Earch Icon besides Database Changing button) /// </summary> protected void ShowPublishDetails() { Sitecore.Web.UI.HtmlControls.Menu menu = new Sitecore.Web.UI.HtmlControls.Menu(); string name = Client.ContentDatabase.Name; SheerResponse.DisableOutput(); try { if (Client.ContentDatabase.ProxiesEnabled) { Sitecore.Web.UI.HtmlControls.MenuItem menuItem = new Sitecore.Web.UI.HtmlControls.MenuItem(); menu.Controls.Add(menuItem); if (Context.ProxiesActive) { menuItem.Header = Translate.Text("Deactivate Proxies"); menuItem.Icon = "Core/16x16/export_d.png"; menuItem.Click = "DeactivateProxies()"; } else { menuItem.Header = Translate.Text("Activate Proxies"); menuItem.Icon = "Core/16x16/export.png"; menuItem.Click = "ActivateProxies()"; } menu.Controls.Add(new MenuDivider()); } Sitecore.Web.UI.HtmlControls.MenuItem menuItem2 = new Sitecore.Web.UI.HtmlControls.MenuItem(); menu.Controls.Add(menuItem2); menuItem2.Header = Translate.Text("View Publish History Details"); menuItem2.Click = "ShowDesktopPublishDialog()"; menuItem2.Icon = "Network/16x16/environment.png"; menu.Controls.Add(new MenuDivider()); #region Kept for future Updates //Sitecore.Web.UI.HtmlControls.MenuItem menuItem4 = new Sitecore.Web.UI.HtmlControls.MenuItem(); //menu.Controls.Add(menuItem4); //menuItem4.Header = Translate.Text("Publish Dialog"); //menuItem4.Click = "ShowPublishDialog()"; //menuItem4.Icon = "Network/16x16/environment.png"; //menu.Controls.Add(new MenuDivider()); #endregion string logPath = Sitecore.Configuration.Settings.DataFolder + "/logs/PublishHistory.txt"; int skip = 0; int recentPublishEntries = int.Parse(Settings.GetSetting("RecentPublish")); for (int publishJobNumber = 0; publishJobNumber < recentPublishEntries; publishJobNumber++) { try { string[] lines = File.ReadLines(logPath).Reverse().Skip(skip).Take(4).ToArray(); if (!(lines == null || lines.Length == 0)) { Sitecore.Web.UI.HtmlControls.MenuItem PublishHandle = new Sitecore.Web.UI.HtmlControls.MenuItem(); menu.Controls.Add(PublishHandle); PublishHandle.Header = "Publish Handle : " + lines[3]; PublishHandle.Icon = "apps/16x16/earth.png"; Sitecore.Web.UI.HtmlControls.MenuItem PublishTarget = new Sitecore.Web.UI.HtmlControls.MenuItem(); menu.Controls.Add(PublishTarget); PublishTarget.Header = "Publish Target : " + lines[2]; Sitecore.Web.UI.HtmlControls.MenuItem PublishOwner = new Sitecore.Web.UI.HtmlControls.MenuItem(); menu.Controls.Add(PublishOwner); PublishOwner.Header = "Owner : " + lines[1]; Sitecore.Web.UI.HtmlControls.MenuItem PublishTime = new Sitecore.Web.UI.HtmlControls.MenuItem(); menu.Controls.Add(PublishTime); PublishTime.Header = "Date and Time : " + lines[0]; menu.Controls.Add(new MenuDivider()); } } catch (Exception ex) { Log.Error("Publish History : Sitecore Desktop Error : " + ex.Message, Context.Item); Log.Error("Publish History : Sitecore Desktop Error : " + ex.StackTrace, Context.Item); Sitecore.Web.UI.HtmlControls.MenuItem PublishDetails = new Sitecore.Web.UI.HtmlControls.MenuItem(); menu.Controls.Add(PublishDetails); PublishDetails.Header = "Publish log might be empty or has been deleted"; PublishDetails.Icon = "Network/16x16/environment_delete.png"; break; } finally { skip = skip + 4; } } } catch(Exception ex) { Log.Error("Publish History : Sitecore Desktop Error : " + ex.Message, Context.Item); Log.Error("Publish History : Sitecore Desktop Error : " + ex.StackTrace, Context.Item); } finally { SheerResponse.EnableOutput(); } SheerResponse.ShowContextMenu("DatabaseSelector", "above", menu); }