public override SC.Shell.Framework.Commands.CommandState QueryState(SC.Shell.Framework.Commands.CommandContext context) { Assert.ArgumentNotNull(context, "context"); if (context.Items.Length != 1) { return(base.QueryState(context)); } SC.Data.Items.Item item = context.Items[0]; Assert.ArgumentNotNull(item, "context.Items[0]"); if (SC.Context.IsAdministrator || !CheckIn.CanCheckIn(item)) { return(base.QueryState(context)); } if (!item.Locking.IsLocked()) { return(SC.Shell.Framework.Commands.CommandState.Hidden); } if (CanCheckIn(item)) { return(SC.Shell.Framework.Commands.CommandState.Enabled); } return(base.QueryState(context)); }
public override void Execute(Sitecore.Shell.Framework.Commands.CommandContext context) { var currentItem = context.Items[0]; var contentStub = currentItem.Axes.GetDescendant("content").Children[0]; contentStub.CloneTo(Sitecore.Context.ContentDatabase.GetItem(Sitecore.ItemIDs.ContentRoot)); var layoutStubs = currentItem.Children["layout"].Children; foreach (Item child in layoutStubs) { child.Children.First().CloneTo(Sitecore.Context.ContentDatabase.GetItem(Sitecore.ItemIDs.LayoutRoot).Children[child.Name]); } var mediaStubs = currentItem.Axes.GetDescendant("media library").Children; foreach (Item child in mediaStubs) { child.CloneTo(Sitecore.Context.ContentDatabase.GetItem(Sitecore.ItemIDs.MediaLibraryRoot)); } var templateStubs = currentItem.Axes.GetDescendant("templates").Children; foreach (Item child in mediaStubs) { child.CloneTo(Sitecore.Context.ContentDatabase.GetItem(Sitecore.ItemIDs.TemplateRoot)); } }
public override SC.Shell.Framework.Commands.CommandState QueryState( SC.Shell.Framework.Commands.CommandContext context) { SC.Diagnostics.Assert.IsNotNull(context, "context"); // if the context does not indicate exactly one item // then this must be the Debug command on the Sitecore menu // in which case permissions alone control access if (context.Items == null || context.Items.Length != 1 || context.Items[0] == null) { return(base.QueryState(context)); } SC.Data.Items.Item item = context.Items[0]; if (item.Paths.IsContentItem && (item.Database.Resources.Devices.GetAll().Where(compare => compare.ID != SC.Syndication.FeedUtil.FeedDeviceId || !SC.Syndication.FeedUtil.IsFeed(item)).Any(compare => item.Visualization.GetLayout(compare) != null))) { // the selected item has a URL return(SC.Shell.Framework.Commands.CommandState.Enabled); } // the selected item does not have a URL return(SC.Shell.Framework.Commands.CommandState.Disabled); }
public void CanExecuteBadContext() { Sitecore.Shell.Framework.Commands.CommandContext context = new Sitecore.Shell.Framework.Commands.CommandContext(); var fieldEditor = new FieldEditor(); var canExecute = fieldEditor.CanExecute(context); Assert.IsFalse(canExecute); }
public override void Execute( Sitecore.Shell.Framework.Commands.CommandContext context) { Sitecore.Diagnostics.Assert.ArgumentNotNull( context, "context"); // THe UI framework invokes the Process() method defined in this class Sitecore.Context.ClientPage.Start(this, "Process"); }
public override void Execute(Sitecore.Shell.Framework.Commands.CommandContext context) { var raiser = new CacheRebuildEventRaiser(); var ev = new CacheRebuildEvent { CacheKey = Constants.ClearAll }; raiser.RaiseEvent(ev); SheerResponse.Alert("Redis Cache flushed"); }
/// <summary> /// Execute the debug command. /// </summary> /// <param name="context">The command context.</param> public override void Execute( Sitecore.Shell.Framework.Commands.CommandContext context) { // Prompt to save if necessary. Context.ClientPage.ClientResponse.CheckModified(false); // Database selected by user. Sitecore.Data.Database contentDatabase = Context.ContentDatabase; // Database associated with item selected by user. if ((context.Items != null) && (context.Items.Length == 1)) { contentDatabase = context.Items[0].Database; } // Default URL for context (shell) site. Sitecore.Text.UrlString webSiteUrl = Sitecore.Sites.SiteContext.GetWebSiteUrl(); // Enable debugging. webSiteUrl.Add("sc_debug", "1"); if ((context.Items != null) && (context.Items.Length == 1)) { Sitecore.Data.Items.Item item = context.Items[0]; if (item.Visualization.Layout != null) { // Set the item to debug. webSiteUrl.Add("sc_itemid", item.ID.ToString()); } // Set the language to debug. webSiteUrl.Add("sc_lang", item.Language.ToString()); } // Set the database to debug. if (contentDatabase != null) { webSiteUrl.Add("sc_database", contentDatabase.Name); } // Enable profiling. webSiteUrl.Add("sc_prof", "1"); // Enable tracing. webSiteUrl.Add("sc_trace", "1"); // Enable rendering information. webSiteUrl.Add("sc_ri", "1"); // Show the debugging window. Context.ClientPage.ClientResponse.Eval("window.open('" + webSiteUrl + "', '_blank')"); }
public override SC.Shell.Framework.Commands.CommandState QueryState(SC.Shell.Framework.Commands.CommandContext context) { Assert.ArgumentNotNull(context, "context"); SC.Shell.Framework.Commands.CommandState state = base.QueryState(context); if (context.Items.Length == 1 && context.Items[0] != null && state == SC.Shell.Framework.Commands.CommandState.Disabled && CheckIn.CanCheckIn(context.Items[0])) { return(SC.Shell.Framework.Commands.CommandState.Enabled); } return(state); }
public override void Execute(Sitecore.Shell.Framework.Commands.CommandContext context) { if (context.Items != null && context.Items.Length > 0) { Item contextItem = context.Items[0]; NameValueCollection parameters = new NameValueCollection(); parameters["id"] = contextItem.ID.ToString(); parameters["name"] = contextItem.Name; parameters["database"] = contextItem.Database.Name; parameters["language"] = contextItem.Language.ToString(); Sitecore.Context.ClientPage.Start(this, "Run", parameters);//Run method executes on } }
public override void Execute( Sitecore.Shell.Framework.Commands.CommandContext context) { if (context.Items.Length != 1) { return; } Sitecore.Data.Items.Item item = context.Items[0]; NameValueCollection parameters = new NameValueCollection(); parameters["id"] = item.ID.ToString(); parameters["database"] = item.Database.ToString(); parameters["language"] = item.Language.ToString(); parameters["version"] = item.Version.ToString(); parameters["field"] = context.Parameters["field"]; Context.ClientPage.Start(this, "Run", parameters); }
/// <summary> /// Executes the command in the specified context. /// </summary> /// <param name="context">The context.</param> public override void Execute(Sitecore.Shell.Framework.Commands.CommandContext context) { if (context.Items.Length == 1) { Sitecore.Data.Items.Item item = context.Items[0]; ClientPipelineArgs args = new ClientPipelineArgs(); System.Collections.Specialized.NameValueCollection parameters = new System.Collections.Specialized.NameValueCollection(); parameters["id"] = item.ID.ToString(); parameters["language"] = item.Language.ToString(); parameters["database"] = item.Database.Name; args.Parameters = parameters; Sitecore.Context.ClientPage.Start(this, "Run", args); } }
public override void Execute(SC.Shell.Framework.Commands.CommandContext context) { SC.Diagnostics.Assert.IsNotNull(context, "context"); SC.Text.UrlString webSiteUrl = new SC.Text.UrlString("/"); webSiteUrl.Add("sc_debug", "1"); webSiteUrl.Add("sc_prof", "1"); webSiteUrl.Add("sc_trace", "1"); webSiteUrl.Add("sc_ri", "1"); SC.Data.Database db = SC.Context.ContentDatabase; SC.Globalization.Language lang = SC.Context.ContentLanguage; // if the context for invoking the command specifies exactly one item if (context.Items != null && context.Items.Length == 1 && context.Items[0] != null) { // ensure the user has saved the selected item SC.Context.ClientPage.ClientResponse.CheckModified(false); SC.Data.Items.Item item = context.Items[0]; db = item.Database; lang = item.Language; webSiteUrl.Add("sc_itemid", item.ID.ToString()); } if (db != null) { webSiteUrl.Add("sc_database", db.Name); } if (lang != null) { webSiteUrl.Add("sc_lang", lang.ToString()); } // without this, I didn't see the ribbon SC.Publishing.PreviewManager.RestoreUser(); SC.Context.ClientPage.ClientResponse.Eval( "window.open('" + webSiteUrl + "', '_blank')"); }
public override void Execute( Sitecore.Shell.Framework.Commands.CommandContext context) { Context.ClientPage.ClientResponse.CheckModified(false); Sitecore.Data.Database contentDatabase = Context.ContentDatabase; if ((context.Items != null) && (context.Items.Length == 1)) { Sitecore.Data.Database database = context.Items[0].Database; } Sitecore.Text.UrlString webSiteUrl = Sitecore.Sites.SiteContext.GetWebSiteUrl(); webSiteUrl.Add("sc_debug", "1"); if ((context.Items != null) && (context.Items.Length == 1)) { Sitecore.Data.Items.Item item = context.Items[0]; if (item.Visualization.Layout != null) { webSiteUrl.Add("sc_itemid", item.ID.ToString()); } webSiteUrl.Add("sc_lang", item.Language.ToString()); } if (contentDatabase != null) { webSiteUrl.Add("sc_database", contentDatabase.Name); } webSiteUrl.Add("sc_prof", "1"); webSiteUrl.Add("sc_trace", "1"); webSiteUrl.Add("sc_ri", "1"); Context.ClientPage.ClientResponse.Eval( "window.open('" + webSiteUrl + "', '_blank')"); }