/// <summary> /// Add a new Content Editor Tab to Content Editor so that users can search for hidden content /// </summary> /// <param name="context">Context of Call</param> public override void Execute(CommandContext context) { Assert.ArgumentNotNull(context, "context"); if (context.Items.Length == 1) { string s = context.Parameters[0]; if (s.IsGuid()) { if (WebUtil.GetFormValue("scEditorTabs").Contains("contenteditor:launchtab") && WebUtil.GetFormValue("scEditorTabs").Contains(s)) { SheerResponse.Eval("scContent.onEditorTabClick(null, null, '" + s + "')"); } else { UrlString urlString = new UrlString(Util.Constants.ContentEditorRawUrlAddress); urlString.Add(Util.Constants.OpenItemEditorQueryStringKeyName, s); TrackOpenTab(context); context.Items[0].Uri.AddToUrlString(urlString); UIUtil.AddContentDatabaseParameter(urlString); urlString.Add(Util.Constants.ModeQueryStringKeyName, "preview"); urlString.Add("il", "0"); urlString.Add(Util.Constants.RibbonQueryStringKeyName, "{D3A2D76F-02E6-49DE-BE90-D23C9771DC8D}"); string str3 = context.Parameters["la"] ?? Context.Language.CultureInfo.TwoLetterISOLanguageName; urlString.Add("la", str3); AddLatestVersionToUrlString(urlString, s, str3); SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchtab", Header = Translate.Text(Context.ContentDatabase.GetItem(s).Name), Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = s, Closeable = true, Activate = Util.Constants.SettingsItem[Util.Constants.OpenSearchResult] != "New Tab Not Selected" }.ToString()); } } } }
/// <summary> /// Add a new Content Editor Tab to Content Editor so that users can search for hidden content /// </summary> /// <param name="context">Context of Call</param> public override void Execute(CommandContext context) { Assert.ArgumentNotNull(context, "context"); if (context.Items.Length == 1) { var itemId = context.Parameters[0]; if (WebUtil.GetFormValue("scEditorTabs").Contains("contenteditor:launchtab") && WebUtil.GetFormValue("scEditorTabs").Contains(itemId)) { SheerResponse.Eval("scContent.onEditorTabClick(null, null, '" + itemId + "')"); } else { var urlString = new UrlString("/sitecore/shell/sitecore/content/Applications/Content%20Editor.aspx"); urlString.Add(Util.Constants.OpenItemEditorQueryStringKeyName, itemId); TrackOpenTab(context); context.Items[0].Uri.AddToUrlString(urlString); UIUtil.AddContentDatabaseParameter(urlString); urlString.Add(Util.Constants.ModeQueryStringKeyName, "preview"); urlString.Add(Util.Constants.RibbonQueryStringKeyName, "{D3A2D76F-02E6-49DE-BE90-D23C9771DC8D}"); var language = context.Parameters["la"].IsNull() ? Sitecore.Context.Language.CultureInfo.TwoLetterISOLanguageName : context.Parameters["la"]; urlString.Add("la", language); AddLatestVersionToUrlString(urlString, itemId, language); SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchtab", Header = Translate.Text(Context.ContentDatabase.GetItem(itemId).Name), Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = itemId, Closeable = true, Activate = Util.Constants.SettingsItem.Fields[Util.Constants.OpenSearchResult].Value == "New Tab Not Selected" ? false : true }.ToString()); } } }
/// <summary> /// Add a new Content Editor Tab to Content Editor so that users can search for hidden content /// </summary> /// <param name="context">Context of Call</param> public override void Execute(CommandContext context) { Assert.ArgumentNotNull(context, "context"); if (context.Items.Length == 1) { var itemId = context.Parameters[0]; //if (WebUtil.GetFormValue("scEditorTabs").Contains("contenteditor:launchtab") && WebUtil.GetFormValue("scEditorTabs").Contains(itemId)) //{ // SheerResponse.Eval("scContent.onEditorTabClick(null, null, '" + itemId + "')"); //} //else //{ var urlString = new UrlString("/sitecore%20modules/Shell/Sitecore/ItemBuckets/ShowResult.aspx"); urlString.Add(Util.Constants.OpenItemEditorQueryStringKeyName, itemId); context.Items[0].Uri.AddToUrlString(urlString); UIUtil.AddContentDatabaseParameter(urlString); urlString.Add(Util.Constants.ModeQueryStringKeyName, "preview"); urlString.Add(Util.Constants.RibbonQueryStringKeyName, "{D3A2D76F-02E6-49DE-BE90-D23C9771DC8D}"); var language = context.Parameters["la"].IsNull() ? Sitecore.Context.Language.CultureInfo.TwoLetterISOLanguageName : context.Parameters["la"]; urlString.Add("la", language); //SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchtab", Header = "Another Search", Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = Id, Closeable = true, Activate = true }.ToString()); SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchblanktab", Header = "Search " + DateTime.Now.ToLongTimeString(), Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = new Random().Next(0, 99999999).ToString(), Closeable = true, Activate = true }.ToString()); // } } }
protected void LoadContentEditor(ClientPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); var parameters = new UrlString(); parameters.Add("id", args.Parameters["id"]); parameters.Add("fo", args.Parameters["id"]); Windows.RunApplication("Content Editor", parameters.ToString()); }
public override void Execute(CommandContext context) { var urlString = new UrlString(UIUtil.GetUri("control:PowerShellExternalView")); var keys = context.Parameters.AllKeys; using (var session = ScriptSessionManager.GetSession(string.Empty, ApplicationNames.Default, false)) { session.ExecuteScriptPart(""); foreach (var key in keys) { var param = context.Parameters[key] .Replace("{spe}", GetType().Assembly.GetName().Version.ToString()) .Replace("{ps}", ScriptSession.PsVersion.Major + "." + ScriptSession.PsVersion.Minor) .Replace("{sc}", SitecoreVersion.Current.Major + "." + SitecoreVersion.Current.Minor); urlString.Add(key, param); } } var width = keys.Contains("spe_w", StringComparer.OrdinalIgnoreCase) ? context.Parameters["spe_w"] : keys.Contains("width", StringComparer.OrdinalIgnoreCase) ? context.Parameters["width"] : "800"; var height = keys.Contains("spe_h", StringComparer.OrdinalIgnoreCase) ? context.Parameters["spe_h"] : keys.Contains("height", StringComparer.OrdinalIgnoreCase) ? context.Parameters["height"] : "800"; SheerResponse.ShowModalDialog(urlString.ToString(), width, height); }
protected override void ProcessRecord() { LogErrors(() => { string response = null; if (!string.IsNullOrEmpty(Url)) { response = JobContext.ShowModalDialog(Url, WidthString, HeightString); } else if (!string.IsNullOrEmpty(Control)) { UrlString url = new UrlString(UIUtil.GetUri("control:" + Control)); url["te"] = Title ?? "Sitecore"; if (Parameters != null) { foreach (string key in Parameters.Keys) { url.Add(key, WebUtil.SafeEncode(Parameters[key].ToString())); } } var message = new ShowModalDialogPsMessage(url.ToString(), WidthString, HeightString, HandleParameters); PutMessage(message); response = (string)GetSheerResult(message); } WriteObject(response); }); }
/// <summary> /// Shows a confirmation dialog. /// </summary> protected override void ShowUI() { var resultSig = Guid.NewGuid().ToString(); HttpContext.Current.Session[resultSig] = Html; var urlString = new UrlString(UIUtil.GetUri("control:PowerShellResultViewerText")); urlString.Add("sid", resultSig); SheerResponse.ShowModalDialog(urlString.ToString(), Width, Height); }
/// <summary> /// Runs the pipeline. /// </summary> /// <param name="args">The arguments.</param> protected void Run(ClientPipelineArgs args) { string id = args.Parameters["id"]; string language = args.Parameters["language"]; string version = args.Parameters["version"]; Item item = Context.ContentDatabase.Items[id, Language.Parse(language), Sitecore.Data.Version.Parse(version)]; Error.AssertItemFound(item); if (!SheerResponse.CheckModified()) { return; } if (args.IsPostBack) { if (args.Result != "undefined") { Sitecore.Web.UI.Sheer.SheerResponse.Download(args.Result); } } else { UrlString urlString = new UrlString(UIUtil.GetUri("control:QuickPackage")); urlString.Add("id", item.ID.ToString()); urlString.Add("la", item.Language.ToString()); urlString.Add("vs", item.Version.ToString()); ModalDialogOptions options = new ModalDialogOptions(urlString.ToString()) { MinWidth = "550px", Height = "250px", MinHeight = "250px", Response = true }; SheerResponse.ShowModalDialog(options); args.WaitForPostBack(); } }
/// <summary> /// Refresh the content tree with the new item opened /// </summary> /// <param name="item">Item that is being added</param> /// <remarks>You will need to override this if you are running without HttpContext e.g. Unit Tests</remarks> protected virtual void SetLocation(Item item) { if (HttpContext.Current.IsNotNull() && Context.ClientPage.IsNotNull()) //clientpage is never null? { var urlString = new UrlString(Constants.ContentEditorRawUrlAddress); urlString.Add(Constants.OpenItemEditorQueryStringKeyName, item.ID.ToString()); item.Uri.AddToUrlString(urlString); UIUtil.AddContentDatabaseParameter(urlString); SheerResponse.SetLocation(urlString.ToString()); } }
/// <summary> /// Refresh the content tree with the new item opened. /// </summary> /// <param name="item">Item that is being added.</param> /// <remarks>You will need to override this if you are running without HttpContext e.g. Unit Tests.</remarks> protected virtual void SetLocation(Item item) { if ((Context.GetSiteName() == "shell") && Context.ClientPage.IsNotNull() && !Client.Site.Notifications.Disabled) { var urlString = new UrlString(Constants.ContentEditorRawUrlAddress); urlString.Add(Constants.OpenItemEditorQueryStringKeyName, item.ID.ToString()); item.Uri.AddToUrlString(urlString); UIUtil.AddContentDatabaseParameter(urlString); SheerResponse.SetLocation(urlString.ToString()); } }
/// <summary> /// Add a new Content Editor Tab to Content Editor so that users can search for hidden content /// </summary> /// <param name="context">Context of Call</param> public override void Execute(CommandContext context) { Assert.ArgumentNotNull(context, "context"); if (context.Items.Length == 1) { var itemId = context.Parameters[0]; if (WebUtil.GetFormValue("scEditorTabs").Contains("contenteditor:launchtab") && WebUtil.GetFormValue("scEditorTabs").Contains(itemId)) { SheerResponse.Eval("scContent.onEditorTabClick(null, null, '" + itemId + "')"); } else { var urlString = new UrlString(Util.Constants.ContentEditorRawUrlAddress); urlString.Add(Util.Constants.OpenItemEditorQueryStringKeyName, itemId); context.Items[0].Uri.AddToUrlString(urlString); UIUtil.AddContentDatabaseParameter(urlString); urlString.Add(Util.Constants.ModeQueryStringKeyName, "preview"); AddLatestVersionToUrlString(urlString, itemId); SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchtab", Header = Translate.Text(Context.ContentDatabase.GetItem(itemId).Name), Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = itemId, Closeable = true, Activate = false }.ToString()); } } }
protected void Run(ClientPipelineArgs args) { string var = args.Parameters["rid"]; Util.AssertNotNull(var); if (!args.IsPostBack) { using (new SecurityDisabler()) { UrlString urlString = new UrlString("/sitecore/shell/~/xaml/RecipientListManagement.RecipientsLists.Lists.Creation.AddSitecoreRoles.SelectRoles.aspx"); new UrlHandle().Add(urlString); foreach (string str in args.Parameters.AllKeys) { urlString.Add(str, args.Parameters[str]); } SheerResponse.ShowModalDialog(urlString.ToString(), "600", "650", string.Empty, true); args.WaitForPostBack(); return; } } if (args.HasResult) { ListString roles = new ListString((args.Result == "-") ? string.Empty : args.Result); TargetAudience recipientList = Factory.GetTargetAudience(var); if ((recipientList != null) && (recipientList.InnerItem != null)) { IEnumerable <string> enumerable = null; if (recipientList.ExtraOptInList != null) { enumerable = (recipientList.OptInList == null) ? roles : (from role in roles where recipientList.OptInList.Roles.All <Role>(x => x.Name != role) && recipientList.ExtraOptInList.Roles.All <Role>(x => x.Name != role) select role).ToList <string>() as IEnumerable <string>; } else { enumerable = (recipientList.OptInList == null) ? roles : (from role in roles where recipientList.OptInList.Roles.All <Role>(x => x.Name != role) select role).ToList <string>() as IEnumerable <string>; } foreach (string str in enumerable) { recipientList.Source.AddRoleToExtraOptIn(str); } NotificationManager.Instance.Notify("MessageFromCommand", new MessageEventArgs("Recipients were imported to the selected list.")); NotificationManager.Instance.Notify("RecipientsChanged"); NotificationManager.Instance.Notify("RefreshRecipientLists"); } } }
/// <summary> /// Add a new Content Editor Tab to Content Editor so that users can search for hidden content /// </summary> /// <returns>Void</returns> public override void Execute(CommandContext context) { Assert.ArgumentNotNull(context, "context"); if (context.Items.Length == 1) { if (WebUtil.GetFormValue("scEditorTabs").Contains("contenteditor:launchtab") && WebUtil.GetFormValue("scEditorTabs").Contains(context.Parameters[0])) { SheerResponse.Eval("scContent.onEditorTabClick(null, null, '" + context.Parameters[0] + "')"); } else { var urlString = new UrlString("/sitecore/shell/sitecore/content/Applications/Content%20Editor.aspx"); urlString.Add("fo", context.Parameters[0]); context.Items[0].Uri.AddToUrlString(urlString); UIUtil.AddContentDatabaseParameter(urlString); //Open the new tab without the content tree showing urlString.Add("mo", "preview"); AddLatestVersionToUrlString(context, urlString); SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchtab", Header = Translate.Text(Context.ContentDatabase.GetItem(context.Parameters[0]).Name), Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = context.Parameters[0], Closeable = true, Activate = false}.ToString()); SheerResponse.Eval("scContent.onEditorTabClick('scEditorTabHeaderActive', 'scEditorTabHeaderActive', '" + "{59F53BBB-D1F5-4E38-8EBA-0D73109BB59B}" + "')"); } } }
/// <summary> /// Overriding the Execute method that Sitecore calls. /// </summary> /// <param name = "context"></param> public override void Execute(CommandContext context) { //check to see if there is an item selected) if (context.Items.Length != 1) return; //only use on authoring environment Item currentItem = context.Items[0]; if (currentItem == null || currentItem.Database.Name.ToLower() != "master") return; //get settings item ItemComparerSettingsItem settingsItem = ItemComparerSettingsItem.GetSettingsItem(); if (settingsItem == null || settingsItem.DatabasetoCompareAgainst.TargetItem == null) return; PublishingTargetItem publishingTargetItem = settingsItem.DatabasetoCompareAgainst.TargetItem; if (publishingTargetItem.TargetDatabaseItem == null) return; Database targetDatabase = publishingTargetItem.TargetDatabaseItem; //Build the url for the control string language = currentItem.Language.ToString(); string version = currentItem.Version.ToString(); // Add parameters to the UrlString UrlString parameters = new UrlString(); parameters.Add("id", currentItem.ID.ToString()); parameters.Add("fo", currentItem.ID.ToString()); parameters.Add("la", language); parameters.Add("vs", version); parameters.Add("sc_content", targetDatabase.Name); // Run function that initializes the Content Editor; pass in necessary parameters Item contentEditor = Database.GetDatabase("core").GetItem("{7EADA46B-11E2-4EC1-8C44-BE75784FF105}"); if (contentEditor == null) return; Sitecore.Shell.Framework.Windows.RunApplication(contentEditor, "/~/icon/People/16x16/cubes_blue.png", "Item Comparer (" + targetDatabase.Name + ")", parameters.ToString()); }
protected void Run(ClientPipelineArgs args) { string var = args.Parameters["rid"]; Util.AssertNotNull(var); if (!args.IsPostBack) { using (new SecurityDisabler()) { UrlString urlString = new UrlString("/sitecore/shell/~/xaml/RecipientListManagement.RecipientsLists.Lists.Creation.AddSitecoreRoles.SelectRoles.aspx"); new UrlHandle().Add(urlString); foreach (string str in args.Parameters.AllKeys) { urlString.Add(str, args.Parameters[str]); } SheerResponse.ShowModalDialog(urlString.ToString(), "600", "650", string.Empty, true); args.WaitForPostBack(); return; } } if (args.HasResult) { ListString roles = new ListString((args.Result == "-") ? string.Empty : args.Result); TargetAudience recipientList = Factory.GetTargetAudience(var); if ((recipientList != null) && (recipientList.InnerItem != null)) { IEnumerable<string> enumerable = null; if (recipientList.ExtraOptInList != null) { enumerable = (recipientList.OptInList == null) ? roles : (from role in roles where recipientList.OptInList.Roles.All<Role>(x => x.Name != role) && recipientList.ExtraOptInList.Roles.All<Role>(x => x.Name != role) select role).ToList<string>() as IEnumerable<string>; } else { enumerable = (recipientList.OptInList == null) ? roles : (from role in roles where recipientList.OptInList.Roles.All<Role>(x => x.Name != role) select role).ToList<string>() as IEnumerable<string>; } foreach (string str in enumerable) { recipientList.Source.AddRoleToExtraOptIn(str); } NotificationManager.Instance.Notify("MessageFromCommand", new MessageEventArgs("Recipients were imported to the selected list.")); NotificationManager.Instance.Notify("RecipientsChanged"); NotificationManager.Instance.Notify("RefreshRecipientLists"); } } }
public override void Execute(CommandContext context) { var itemId = context.Items[0].ID.ToString(); var itemDb = context.Items[0].Database.Name; var item = Factory.GetDatabase(itemDb).GetItem(new ID(itemId)); var urlString = new UrlString(); urlString.Append("id", item.ID.ToString()); urlString.Append("db", itemDb); if (!string.IsNullOrEmpty(context.Parameters["frameName"])) { urlString.Add("pfn", context.Parameters["frameName"]); } Windows.RunApplication("PowerShell/PowerShellIse", urlString.ToString()); }
/// <summary> /// Add a new Content Editor Tab to Content Editor so that users can search for hidden content /// </summary> /// <param name="context">Context of Call</param> public override void Execute(CommandContext context) { Assert.ArgumentNotNull(context, "context"); if (context.Items.Length == 1) { var itemId = context.Parameters[0]; if (WebUtil.GetFormValue("scEditorTabs").Contains("contenteditor:launchtab") && WebUtil.GetFormValue("scEditorTabs").Contains(itemId)) { SheerResponse.Eval("scContent.onEditorTabClick(null, null, '" + itemId + "')"); } else { var urlString = new UrlString(Util.Constants.ContentEditorRawUrlAddress); urlString.Add(Util.Constants.OpenItemEditorQueryStringKeyName, itemId); context.Items[0].Uri.AddToUrlString(urlString); UIUtil.AddContentDatabaseParameter(urlString); urlString.Add(Util.Constants.ModeQueryStringKeyName, "preview"); AddLatestVersionToUrlString(urlString, itemId); SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchtab", Header = Translate.Text(Context.ContentDatabase.GetItem(itemId).Name), Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = itemId, Closeable = true, Activate = false }.ToString()); } } }
protected virtual void Run(ClientPipelineArgs args) { if (!args.IsPostBack) { Context.SetActiveSite("shell"); UrlString urlString = new UrlString(UIUtil.GetUri(this.GetWizardUri())); foreach (string key in args.Parameters.AllKeys) { urlString.Add(key, args.Parameters[key]); } SheerResponse.ShowModalDialog(urlString.ToString(), "540px", "590px", string.Empty, true); args.WaitForPostBack(); } //else // this.HandlePostBack(args.Parameters["type"] ?? string.Empty); }
public override void Execute(CommandContext context) { var itemId = context.Items[0].ID.ToString(); var itemDb = context.Items[0].Database.Name; var item = Factory.GetDatabase(itemDb).GetItem(new ID(itemId)); var urlString = new UrlString(); urlString.Append("id", item.ID.ToString()); urlString.Append("db", itemDb); if (!string.IsNullOrEmpty(context.Parameters["frameName"])) { urlString.Add("pfn", context.Parameters["frameName"]); } Sitecore.Shell.Framework.Windows.RunApplication("PowerShell/PowerShellIse", urlString.ToString()); }
/// <summary> /// Overrides the ToString() method from the base class MediaUrlOptions /// </summary> /// <returns>The manipulated string</returns> public override string ToString() { if (UseCustomFunctions) { var urlString = new UrlString(); urlString.Add("useCustomFunctions", 1.ToString(CultureInfo.InvariantCulture)); if (KeepOrientation) { urlString.Add("keepOrientation", 1.ToString(CultureInfo.InvariantCulture)); } if (GreyScale) { urlString.Add("greyScale", 1.ToString(CultureInfo.InvariantCulture)); } if (!RotateFlip.ToString().Equals("RotateNoneFlipNone")) { urlString.Add("rotateFlip", RotateFlip.ToString()); } if (CenterCrop) { urlString.Add("centerCrop", 1.ToString(CultureInfo.InvariantCulture)); } if (ImageCrop != null) { urlString.Add("cropX", _mCropStartX.ToString(CultureInfo.InvariantCulture)); urlString.Add("cropY", _mCropStartY.ToString(CultureInfo.InvariantCulture)); } string finalString; if (!string.IsNullOrEmpty(base.ToString())) { finalString = "&" + urlString; } else { finalString = urlString.ToString(); } return(base.ToString() + finalString); } return(base.ToString()); }
/// <summary>Edits the text.</summary> /// <param name="args">The args.</param> protected void EditHtmlTinyMCE(ClientPipelineArgs args) { 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(); url.Add("so_mce", SourceMce); this.handle = richTextEditorUrl.Handle; SheerResponse.ShowModalDialog(new ModalDialogOptions(url.ToString()) { Width = "1200", Height = "730px", Response = true, Header = Translate.Text("Rich Text Editor") }); args.WaitForPostBack(); } }
public override void Execute(CommandContext context) { if (context.Items.Length == 1) { Item item = context.Items[0]; UrlString str = new UrlString(); str.Append("sc_content", item.Database.Name); str.Append("id", item.ID.ToString()); str.Append("la", item.Language.ToString()); str.Append("vs", item.Version.ToString()); if (!string.IsNullOrEmpty(context.Parameters["frameName"])) { str.Add("pfn", context.Parameters["frameName"]); } SheerResponse.Eval("window.open('/sitecore modules/pixlr/pixlr.aspx?" + str + "&mode=editor', 'MediaLibrary', 'location=0,resizable=1')"); } }
public override void Execute(CommandContext context) { var itemId = context.Items[0].ID.ToString(); var itemDb = context.Items[0].Database.Name; var item = Factory.GetDatabase(itemDb).GetItem(new ID(itemId)); var title = item.DisplayName; var urlString = new UrlString(); urlString.Append("id", item.ID.ToString()); urlString.Append("db", itemDb); if (!string.IsNullOrEmpty(context.Parameters["frameName"])) { urlString.Add("pfn", context.Parameters["frameName"]); } var appItem = Database.GetDatabase("core").GetItem("/sitecore/content/Applications/PowerShell/PowerShellIse"); var icon = appItem.Appearance.Icon; Sitecore.Shell.Framework.Windows.RunApplication(appItem, icon, title, urlString.Query); }
public void Execute() { var resultSig = Guid.NewGuid().ToString(); HttpContext.Current.Cache[resultSig] = this; if (!Modal) { var urlString = new UrlString(); urlString.Add("sid", resultSig); var appItem = Database.GetDatabase("core").GetItem("/sitecore/content/Applications/PowerShell/PowerShellListView"); Sitecore.Shell.Framework.Windows.RunApplication(appItem, "Business/32x32/table_sql_view.png", Title, urlString.Query); } else { var urlString = new UrlString(UIUtil.GetUri("control:PowerShellResultViewerList")); urlString.Add("sid", resultSig); SheerResponse.ShowModalDialog(urlString.ToString(), Width, Height); } }
protected virtual void Run(ClientPipelineArgs args) { if (!args.IsPostBack) { Context.SetActiveSite("shell"); string var = args.Parameters["itemID"]; Util.AssertNotNullOrEmpty(var); UrlString str2 = new UrlString(UIUtil.GetUri(this.GetWizardUri())); foreach (string str3 in args.Parameters.AllKeys) { str2.Add(str3, args.Parameters[str3]); } SheerResponse.ShowModalDialog(str2.ToString(), "540px", "590px", string.Empty, true); args.WaitForPostBack(); } else { string arg = args.Parameters["type"] ?? string.Empty; this.HandlePostBack(arg); } }
protected virtual void Run(ClientPipelineArgs args) { if (!args.IsPostBack) { Context.SetActiveSite("shell"); string var = args.Parameters["itemID"]; Util.AssertNotNullOrEmpty(var); UrlString str2 = new UrlString(UIUtil.GetUri(this.GetWizardUri())); foreach (string str3 in args.Parameters.AllKeys) { str2.Add(str3, args.Parameters[str3]); } SheerResponse.ShowModalDialog(str2.ToString(), "540px", "590px", string.Empty, true); args.WaitForPostBack(); } else { string arg = args.Parameters["type"] ?? string.Empty; this.HandlePostBack(arg); } }
protected override void ProcessRecord() { LogErrors(() => { if (!CheckSessionCanDoInteractiveAction()) { WriteObject("error"); return; } string response = null; if (!string.IsNullOrEmpty(Url)) { var jobUiManager = TypeResolver.Resolve <IJobMessageManager>(); response = jobUiManager.ShowModalDialog(Url, WidthString, HeightString); } else if (!string.IsNullOrEmpty(Control)) { var url = new UrlString(UIUtil.GetUri("control:" + Control)) { ["te"] = Title ?? "Sitecore" }; if (Parameters != null) { foreach (string key in Parameters.Keys) { url.Add(key, WebUtil.SafeEncode(Parameters[key].ToString())); } } var message = new ShowModalDialogPsMessage(url.ToString(), WidthString, HeightString, HandleParameters); PutMessage(message); response = (string)message.GetResult(); } WriteObject(response); }); }
protected void ConfigMethod(ClientPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); if (args.IsPostBack) { if (args.HasResult) { var results = new UrlString(args.Result); Assert.IsNotNull(_configT4Class.InnerItem, string.Format("'{0}' not found", T4ClassConsts.Configurations.ScT4ClassConfig)); using (new EditContext(_configT4Class.InnerItem)) { _configT4Class.UsingStatement = HttpUtility.UrlDecode(results["UsingStatement"]); _configT4Class.DefaultNamespace = HttpUtility.UrlDecode(results["DefaultNamespace"]); _configT4Class.DefaultFileName = HttpUtility.UrlDecode(results["DefaultFileName"]); _configT4Class.DefaultProjectPath = HttpUtility.UrlDecode(results["DefaultProjectPath"]); _configT4Class.ClassType = HttpUtility.UrlDecode(results["ClassType"]); } } } else { var dialogUrl = new UrlString( ControlManager.GetControlUrl( new ControlName("Sitecore.T4Class.Generate.Module.PresentationLayer.Application.Configuration"))); Assert.IsNotNull(_configT4Class.InnerItem, string.Format("'{0}' not found", T4ClassConsts.Configurations.ScT4ClassConfig)); dialogUrl.Add("DefaultProjectPath", _configT4Class.DefaultProjectPath); dialogUrl.Add("DefaultFileName", _configT4Class.DefaultFileName); dialogUrl.Add("DefaultNamespace", _configT4Class.DefaultNamespace); dialogUrl.Add("UsingStatement", _configT4Class.UsingStatement); dialogUrl.Add("ClassType", _configT4Class.ClassType); if (string.IsNullOrEmpty(_configT4Class.DefaultFileName)) { dialogUrl.Add("CurrentTreeviewItemName", CurrentTreeviewItem.Name); } SheerResponse.ShowModalDialog(dialogUrl.ToString(), true); args.WaitForPostBack(); } }
/// <summary> /// Rewrites media urls to point to CDN hostname and dehydrates querystring into filename /// </summary> /// <param name="inputUrl">/path/to/file.ext?a=1&b=2</param> /// <returns>http://cdnHostname/path/to/file!cf!a=1!b=2.ext</returns> public virtual string ReplaceMediaUrl(string inputUrl, string cdnHostname) { // string versionKey = inputUrl + "_v"; // string updatedKey = inputUrl + "_d"; string cachedKey = string.Concat(WebUtil.GetScheme(), inputUrl); try { string cachedUrl = this._cache.GetUrl(cachedKey); if (!string.IsNullOrEmpty(cachedUrl)) { return cachedUrl; } // ignore fully qualified urls or data: if (WebUtil.IsExternalUrl(inputUrl) || inputUrl.StartsWith("data:") || inputUrl.StartsWith("//")) { return inputUrl; } UrlString url = new UrlString(WebUtil.NormalizeUrl(inputUrl)); UrlString originalUrl = new UrlString(WebUtil.NormalizeUrl(inputUrl)); // if the stoptoken ex. ?nfc=1 is non-empty, don't replace this url if (!string.IsNullOrEmpty(url[this.StopToken])) { url.Remove(this.StopToken); } else { if (!string.IsNullOrEmpty(cdnHostname)) { url.HostName = cdnHostname; // insert CDN hostname } if (CDNSettings.MatchProtocol) { url.Protocol = WebUtil.GetScheme(); } url.Path = StringUtil.EnsurePrefix('/', url.Path); // ensure first "/" before ~/media if (CDNSettings.FilenameVersioningEnabled) { // NOTE: DOREL CHANGE: THIS CHANGE IS NEEDED TO ADDING PARAMS TO MEDIA THAT HAVE "/~/media/" string mediaLinkPrefixWithDash = Settings.Media.MediaLinkPrefix.Replace("~", "-"); string mediaLinkPrefixWithTilde = Settings.Media.MediaLinkPrefix.Replace("-", "~"); // NOTE: DOREL CHANGE: use url.Path instead of inputUrl, because url.Path already start with "/" anyway (because of previous EnsurePrefix) // if this is a media library request if (url.Path.Contains(mediaLinkPrefixWithDash) || url.Path.Contains(mediaLinkPrefixWithTilde)) { string version = url["vs"] ?? string.Empty; string updated = string.Empty; // get sitecore path of media item string mediaItemPath = this.GetMediaItemPath(url.Path); if (!string.IsNullOrEmpty(mediaItemPath) && Sitecore.Context.Database != null) { Item mediaItem = string.IsNullOrEmpty(version) ? Sitecore.Context.Database.SelectSingleItem(mediaItemPath) : Sitecore.Context.Database.GetItem(mediaItemPath, Sitecore.Context.Language, Sitecore.Data.Version.Parse(version)); if (mediaItem == null) { // no change to url url = originalUrl; } else { // do not replace url if media item isn't public or requires Analytics processing // keep local url for this case if (!this.IsMediaPubliclyAccessible(mediaItem) || this.IsMediaAnalyticsTracked(mediaItem)) { // no change to url url = originalUrl; } else { version = mediaItem.Version.Number.ToString(); // NOTE: DOREL CHANGE: if media item doesn't have corresponding language version, then get statistic from existing language version if (!mediaItem.Statistics.Updated.Equals(DateTime.MinValue)) { updated = DateUtil.ToIsoDate(mediaItem.Statistics.Updated); } else { Language languageInternational = LanguageManager.GetLanguage("en"); Item mediaItemInternational = string.IsNullOrEmpty(version) ? Sitecore.Context.Database.GetItem(mediaItemPath, languageInternational) : Sitecore.Context.Database.GetItem(mediaItemPath, languageInternational, Sitecore.Data.Version.Parse(version)); if (mediaItemInternational != null && !mediaItemInternational.Statistics.Updated.Equals(DateTime.MinValue)) { updated = DateUtil.ToIsoDate(mediaItemInternational.Statistics.Updated); } else { foreach (Language language in mediaItem.Languages) { Item mediaItemLanguage = string.IsNullOrEmpty(version) ? Sitecore.Context.Database.GetItem(mediaItemPath, language) : Sitecore.Context.Database.GetItem(mediaItemPath, language, Sitecore.Data.Version.Parse(version)); if (mediaItemLanguage != null && !mediaItemLanguage.Statistics.Updated.Equals(DateTime.MinValue)) { updated = DateUtil.ToIsoDate(mediaItemLanguage.Statistics.Updated); break; } } } } } } } if (!string.IsNullOrEmpty(version)) { // append version number qs url.Add("vs", version); } if (!string.IsNullOrEmpty(updated)) { // append timestamp qs url.Add("d", updated); } } else // else this is a static file url { string updated = string.Empty; if (FileUtil.FileExists(url.Path)) { DateTime lastWrite = FileUtil.GetFileWriteTime(url.Path); updated = DateUtil.ToIsoDate(lastWrite); } if (!string.IsNullOrEmpty(updated)) { // append timestamp qs url.Add("d", updated); } if (CDNSettings.MinifyEnabled && (url.Path.EndsWith(".css") || url.Path.EndsWith(".js"))) { url.Add("min", "1"); } } } } string outputUrl = url.ToString().TrimEnd('?'); // prevent trailing ? with blank querystring this._cache.SetUrl(cachedKey, outputUrl); return outputUrl; } catch (Exception ex) { Log.Error(string.Format("ReplaceMediaUrl {0} {1}", cdnHostname, inputUrl), ex, this); return inputUrl; } }
protected override void ProcessItem(Item item) { var rendering = new RenderingDefinition { ItemID = item.ID.ToString(), Placeholder = PlaceHolder, Datasource = DataSource != null ? DataSource.ID.ToString() : null, Cachable = Cacheable ? "1" : null, VaryByData = VaryByData ? "1" : null, VaryByDevice = VaryByDevice ? "1" : null, VaryByLogin = VaryByLogin ? "1" : null, VaryByParameters = VaryByParameters ? "1" : null, VaryByQueryString = VaryByQueryString ? "1" : null, VaryByUser = VaryByUser ? "1" : null }; if (Parameter != null) { var parameters = new UrlString(); foreach (string name in Parameter.Keys) parameters.Add(name, Parameter[name].ToString()); rendering.Parameters = parameters.ToString(); } //todo: add support for conditions //renderingDefinition.Conditions //todo: add support for multivariate tests //rendering.MultiVariateTest var psobj = ItemShellExtensions.WrapInItemOwner(SessionState, item, rendering); WriteObject(psobj); }
protected virtual void ViewResults() { var resultSig = Guid.NewGuid().ToString(); HttpContext.Current.Session[resultSig] = Result.Value; var urlString = new UrlString(UIUtil.GetUri("control:PowerShellResultViewerText")); urlString.Add("sid", resultSig); SheerResponse.ShowModalDialog(urlString.ToString(), "800", "600"); SheerResponse.CloseWindow(); }
public void OnDoubleClick() { if (ListViewer.GetSelectedItems().Length <= 0) return; var clickedId = Int32.Parse(ListViewer.GetSelectedItems()[0].Value); var originalData = ListViewer.Data.Data[clickedId].Original; if(originalData is Item) { var clickedItem = originalData as Item; var urlParams = new UrlString(); urlParams.Add("id", clickedItem.ID.ToString()); urlParams.Add("fo", clickedItem.ID.ToString()); urlParams.Add("la", clickedItem.Language.Name); urlParams.Add("vs", clickedItem.Version.Number.ToString(CultureInfo.InvariantCulture)); urlParams.Add("sc_content", clickedItem.Database.Name); Windows.RunApplication("Content editor", urlParams.ToString()); } ListViewer.Refresh(); }
protected override void ProcessItem(Item item) { if (ShouldProcess(item.GetProviderPath(), $"Set '{Instance.UniqueId}' rendering parameters. Rendering is of type: {Instance.ItemID}")) { LayoutField layoutField = item.Fields[LayoutFieldId]; if (layoutField == null || string.IsNullOrEmpty(layoutField.Value)) { return; } var layout = LayoutDefinition.Parse(layoutField.Value); DeviceDefinition device; RenderingDefinition rendering; foreach (DeviceDefinition aDevice in layout.Devices) { foreach ( RenderingDefinition aRendering in aDevice.Renderings.Cast <RenderingDefinition>() .Where(aRendering => aRendering.UniqueId == Instance.UniqueId)) { device = aDevice; rendering = aRendering; goto Renderingfound; } } return; Renderingfound: //goto label rendering.ItemID = Instance.ItemID; rendering.Placeholder = MyInvocation.BoundParameters.ContainsKey("PlaceHolder") ? PlaceHolder : Instance.Placeholder ?? rendering.Placeholder; rendering.Datasource = !string.IsNullOrEmpty(DataSource) ? DataSource : Instance.Datasource; rendering.Cachable = Instance.Cachable; rendering.VaryByData = Instance.VaryByData; rendering.VaryByDevice = Instance.VaryByDevice; rendering.VaryByLogin = Instance.VaryByLogin; rendering.VaryByParameters = Instance.VaryByParameters; rendering.VaryByQueryString = Instance.VaryByQueryString; rendering.VaryByUser = Instance.VaryByUser; rendering.Parameters = Instance.Parameters; rendering.MultiVariateTest = Instance.MultiVariateTest; rendering.Rules = Instance.Rules; rendering.Conditions = Instance.Conditions; if (Parameter != null) { var parameters = new UrlString(rendering.Parameters ?? string.Empty); foreach (string name in Parameter.Keys) { if (parameters.Parameters.AllKeys.Contains(name)) { parameters.Parameters[name] = Parameter[name].ToString(); } else { parameters.Add(name, Parameter[name].ToString()); } } rendering.Parameters = parameters.ToString(); } if (Index > -1) { device.Renderings.Remove(rendering); device.Insert(index, rendering); } item.Edit(p => { var outputXml = layout.ToXml(); LayoutField.SetFieldValue(item.Fields[LayoutFieldId], outputXml); }); } }
private void AddParameters(UrlString urlString) { if (Parameters != null) { foreach (string key in Parameters.Keys) { urlString.Add(key, HttpUtility.UrlPathEncode(Parameters[key].ToString())); } } }
protected override void ProcessLayout(Item item, LayoutDefinition layout, DeviceDefinition device) { if (!ShouldProcess(item.GetProviderPath(), "Add rendering " + Instance.ItemID)) { return; } var rendering = new RenderingDefinition { ItemID = Instance.ItemID, Placeholder = PlaceHolder ?? Instance.Placeholder, Datasource = DataSource ?? Instance.Datasource, Cachable = Instance.Cachable, ClearOnIndexUpdate = Instance.ClearOnIndexUpdate, VaryByData = Instance.VaryByData, VaryByDevice = Instance.VaryByDevice, VaryByLogin = Instance.VaryByLogin, VaryByParameters = Instance.VaryByParameters, VaryByQueryString = Instance.VaryByQueryString, VaryByUser = Instance.VaryByUser }; if (Parameter != null && Parameter.Keys.Count > 0) { var parameters = new UrlString(rendering.Parameters ?? string.Empty); var renderingItem = Sitecore.Client.ContentDatabase.GetItem(Instance.ItemID); if (renderingItem == null) { WriteError(new ItemNotFoundException($"The rendering with Id {Instance.ItemID} could not be found in the ContentDatabase."), ErrorIds.ItemNotFound, ErrorCategory.ObjectNotFound, this); return; } var standardValuesItem = RenderingItem.GetStandardValuesItemFromParametersTemplate(renderingItem); var excludedFields = new List <string> { "additional parameters", "placeholder", "data source", "caching", "personalization", "test" }; foreach (Field standardValueField in standardValuesItem.Fields) { var fieldName = standardValueField.Name; var lowerInvariant = fieldName.ToLowerInvariant(); if (excludedFields.Contains(lowerInvariant)) { continue; } if (!RenderingItem.IsRenderingParameterField(standardValueField)) { continue; } var fieldValue = standardValueField.Value ?? string.Empty; if (parameters.Parameters.AllKeys.Contains(fieldName)) { parameters.Parameters[fieldName] = fieldValue; } else { parameters.Add(fieldName, fieldValue); } } foreach (string name in Parameter.Keys) { if (parameters.Parameters.AllKeys.Contains(name)) { parameters.Parameters[name] = Parameter[name].ToString(); } else { parameters.Add(name, Parameter[name].ToString()); } } rendering.Parameters = parameters.ToString(); } //todo: add support for conditions //renderingDefinition.Conditions //todo: add support for multivariate tests //rendering.MultiVariateTest if (Index > -1) { device.Insert(Index, rendering); } else { device.AddRendering(rendering); } item.Edit(p => { var outputXml = layout.ToXml(); LayoutField.SetFieldValue(item.Fields[LayoutFieldId], outputXml); }); if (PassThru) { WriteObject(rendering); } }
protected void Run(ClientPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); string str = args.Parameters["id"]; string name = args.Parameters["language"]; string str3 = args.Parameters["version"]; string str4 = args.Parameters["tofolder"]; Item item = Client.ContentDatabase.Items[str, Language.Parse(name), Sitecore.Data.Version.Parse(str3)]; if (item == null) { SheerResponse.Alert("Item not found.", new string[0]); } else { if (str4 == "1") { Item parent = item; while (((parent != null) && (parent.TemplateID != TemplateIDs.Folder)) && (((parent.TemplateID != TemplateIDs.Node) && (parent.TemplateID != TemplateIDs.MediaFolder)) && (parent.ID != ItemIDs.MediaLibraryRoot))) { parent = parent.Parent; } if (parent != null) { item = parent; } } if (args.IsPostBack) { if (args.HasResult) { if (args.Parameters["load"] == "1") { Context.ClientPage.SendMessage(this, "item:load(id=" + args.Result + ")"); } else { Context.ClientPage.SendMessage(this, "media:refresh"); } } Sitecore.Shell.Applications.Dialogs.ProgressBoxes.ProgressBox.Execute( "Importing Site", "Step 1 : Setting Rollback Snapshot\n Step2: Importing Items\n Step 3: Updating Databases\n Step 4: Merging Files", new Sitecore.Shell.Applications.Dialogs.ProgressBoxes .ProgressBoxMethod(StartProcess), new object[] { item.ID.ToString() }); } else { if (UIUtil.UseFlashUpload()) { UrlString str5 = new UrlString(ControlManager.GetControlUrl(new ControlName("Sitecore.Shell.Applications.FlashUpload.Simple"))); str5.Add("uri", item.Uri.ToString()); str5.Add("edit", args.Parameters["edit"]); SheerResponse.ShowModalDialog(str5.ToString(), "450", "140", string.Empty, true); } else { UrlString urlString = new UrlString("/sitecore/shell/Applications/Media/Upload Media/UploadMedia.aspx"); item.Uri.AddToUrlString(urlString); urlString.Append("edit", args.Parameters["edit"]); SheerResponse.ShowModalDialog(urlString.ToString(), "450", "140", string.Empty, true); } args.WaitForPostBack(); } } }
/// <summary> /// Sends the mail. /// </summary> /// <param name="templateName">Name of the template.</param> /// <param name="parameters">The parameters.</param> /// <param name="queryString">The query string.</param> /// <exception cref="ConfigurationErrorsException"><c>The Configuration errors exception</c>.</exception> public virtual void SendMail([NotNull] string templateName, [NotNull] object parameters, [NotNull] string queryString) { Assert.ArgumentNotNull(templateName, "templateName"); Assert.ArgumentNotNull(parameters, "parameters"); Assert.ArgumentNotNull(queryString, "queryString"); GeneralSettings generalSettings = Context.Entity.GetConfiguration<GeneralSettings>(); Item templateItem = Sitecore.Context.Database.GetItem(generalSettings.MailTemplatesLink); if (templateItem == null) { return; } string templatePath = string.Format("{0}/{1}", templateItem.Paths.FullPath, templateName); Item mailTemplate = Sitecore.Context.Database.GetItem(templatePath); if (mailTemplate == null) { Log.Warn(string.Format(CouldNotLoadTemplateMessage, templatePath), this); return; } string body = mailTemplate["Body"].FormatWith(parameters); string subject = mailTemplate["Subject"].FormatWith(parameters); // Get body from external source string bodySourceId = mailTemplate["BodySource"]; Item bodySourceItem = Sitecore.Context.Database.GetItem(bodySourceId); if (bodySourceItem != null) { UrlString qs = new UrlString(queryString); string orderId = qs["orderid"]; Assert.IsNotNullOrEmpty(orderId, "Unable to send mail. Order number is null or empty."); string encryptKey = Crypto.EncryptTripleDES(orderId, EncryptKey); encryptKey = Uri.EscapeDataString(encryptKey); UrlString url = new UrlString(LinkManager.GetItemUrl(bodySourceItem)); url.Add("key", encryptKey); url.Append(new UrlString(queryString)); using (new SecurityDisabler()) { body += WebUtil.ExecuteWebPage(url.ToString()); } } // Replace relative url with absolute url string urlPrefix = "http://" + HttpContext.Current.Request.Url.Host + "/"; body = body.Replace("href=\"/", "href=\"" + urlPrefix); body = body.Replace("href='/", "href='" + urlPrefix); body = body.Replace("HREF=\"/", "href=\"" + urlPrefix); body = body.Replace("HREF='/", "href='" + urlPrefix); body = body.Replace("src=\"/", "src=\"" + urlPrefix); body = body.Replace("src='/", "src='" + urlPrefix); body = body.Replace("SRC=\"/", "src=\"" + urlPrefix); body = body.Replace("SRC='/", "src='" + urlPrefix); // Configuration.OrderGrid string from = mailTemplate["From"].FormatWith(parameters); if (!MainUtil.IsValidEmailAddress(from)) { string info = string.Format(InvalidEmailAddressMessage, from, templateName, "From"); ConfigurationErrorsException configurationErrorsException = new ConfigurationErrorsException(info); Log.Warn(configurationErrorsException.Message, configurationErrorsException, this); return; } string to = mailTemplate["To"].FormatWith(parameters); if (!MainUtil.IsValidEmailAddress(to)) { string info = string.Format(InvalidEmailAddressMessage, to, templateName, "To"); ConfigurationErrorsException configurationErrorsException = new ConfigurationErrorsException(info); Log.Warn(configurationErrorsException.Message, configurationErrorsException, this); return; } this.SendMail(to, from, subject, body, string.Empty); }
protected void viewTargetItemButton_OnClick(object sender, EventArgs e) { string queryString = WebUtil.GetQueryString("id"); string language = WebUtil.GetQueryString("la", Language.Current.Name); string version = WebUtil.GetQueryString("vs", "0"); Item item = Database.GetDatabase("master").GetItem(queryString, Language.Parse(language), Version.Parse(version)); if (item == null) { SheerResponse.Alert("Item is null"); return; } //get settings item ItemComparerSettingsItem settingsItem = ItemComparerSettingsItem.GetSettingsItem(); if (settingsItem == null || settingsItem.DatabasetoCompareAgainst.TargetItem == null) return; PublishingTargetItem publishingTargetItem = settingsItem.DatabasetoCompareAgainst.TargetItem; if (publishingTargetItem.TargetDatabaseItem == null) return; Database targetDatabase = publishingTargetItem.TargetDatabaseItem; // Add parameters to the UrlString UrlString parameters = new UrlString(); parameters.Add("id", item.ID.ToString()); parameters.Add("fo", item.ID.ToString()); parameters.Add("la", language); parameters.Add("vs", version); parameters.Add("sc_content", targetDatabase.Name); // Run function that initializes the Content Editor; pass in necessary parameters Item contentEditor = Database.GetDatabase("core").GetItem("{7EADA46B-11E2-4EC1-8C44-BE75784FF105}"); if (contentEditor == null) return; Sitecore.Shell.Framework.Windows.RunApplication(contentEditor, "/~/icon/People/16x16/cubes_blue.png", "Item Comparer (" + targetDatabase.Name + ")", parameters.ToString()); }
// GET: Snippet public ActionResult CompositeComponent() { var renderingContext = RenderingContext.CurrentOrNull; if (renderingContext == null) { throw new ApplicationException("Could not find current rendering context, aborting"); } var hasDataSource = !string.IsNullOrWhiteSpace(renderingContext.Rendering.DataSource); var pageContext = new PageContext() { RequestContext = this.ControllerContext.RequestContext, Item = !hasDataSource ? null : renderingContext.Rendering.Item }; var oldDisplayMode = global::Sitecore.Context.Site != null ? global::Sitecore.Context.Site.DisplayMode : DisplayMode.Normal; try { if (oldDisplayMode == DisplayMode.Edit && global::Sitecore.Context.Site != null) { //disable the editing of the nested component global::Sitecore.Context.Site.SetDisplayMode(DisplayMode.Preview, DisplayModeDuration.Temporary); } using (PlaceholderContext.Enter(new PlaceholderContext("/"))) using (ContextService.Get().Push <PageContext>(pageContext)) { var htmlHelper = new HtmlHelper(new ViewContext(), new ViewPage()); var stringWriter = new StringWriter(); if (oldDisplayMode == DisplayMode.Edit) { if (hasDataSource) { UrlString webSiteUrl = SiteContext.GetWebSiteUrl(Sitecore.Context.Database); webSiteUrl.Add("sc_mode", "edit"); webSiteUrl.Add("sc_itemid", pageContext.Item.ID.ToString()); webSiteUrl.Add("sc_lang", pageContext.Item.Language.ToString()); //copied style from bootstrap alert stringWriter.Write("<div role=\"alert\" class=\"alert alert-warning\" style=\"box-sizing: border-box; margin-bottom: 20px; border-top: rgb(250,235,204) 1px solid; border-right: rgb(250,235,204) 1px solid; white-space: normal; word-spacing: 0px; border-bottom: rgb(250,235,204) 1px solid; text-transform: none; color: rgb(138,109,59); padding-bottom: 15px; padding-top: 15px; font: 14px/20px 'Helvetica Neue', helvetica, arial, sans-serif; padding-left: 15px; border-left: rgb(250,235,204) 1px solid; widows: 1; letter-spacing: normal; padding-right: 15px; background-color: rgb(252,248,227); text-indent: 0px; border-radius: 4px; -webkit-text-stroke-width: 0px\">"); stringWriter.Write("<a class=\"alert-link\" style=\"box-sizing: border-box; text-decoration: none; font-weight: 700; color: rgb(102,81,44); background-color: transparent\" href=\""); stringWriter.Write(webSiteUrl); stringWriter.Write("\" target=\"_blank\" onmousedown=\"window.open(this.href)\">""); stringWriter.Write(pageContext.Item.DisplayName); stringWriter.Write("" is a 'composite component'. Click here to open it's editor</a><br /></div>"); } else { //copied style from bootstrap alert stringWriter.Write("<div role=\"alert\" class=\"alert alert-warning\" style=\"box-sizing: border-box; margin-bottom: 20px; border-top: rgb(250,235,204) 1px solid; border-right: rgb(250,235,204) 1px solid; white-space: normal; word-spacing: 0px; border-bottom: rgb(250,235,204) 1px solid; text-transform: none; color: rgb(138,109,59); padding-bottom: 15px; padding-top: 15px; font: 14px/20px 'Helvetica Neue', helvetica, arial, sans-serif; padding-left: 15px; border-left: rgb(250,235,204) 1px solid; widows: 1; letter-spacing: normal; padding-right: 15px; background-color: rgb(252,248,227); text-indent: 0px; border-radius: 4px; -webkit-text-stroke-width: 0px\">"); stringWriter.Write("<a class=\"alert-link\" style=\"box-sizing: border-box; text-decoration: none; font-weight: 700; color: rgb(102,81,44); background-color: transparent\" href=\"\" onmousedown=\""); stringWriter.Write("Sitecore.PageModes.PageEditor.postRequest('webedit:setdatasource(referenceId="); stringWriter.Write(renderingContext.Rendering.UniqueId.ToString("B").ToUpper()); stringWriter.Write(",renderingId="); stringWriter.Write(renderingContext.Rendering.RenderingItem.ID); stringWriter.Write(",id="); stringWriter.Write(renderingContext.Rendering.Item.ID); stringWriter.Write(")',null,false)"); stringWriter.Write("\" target=\"_blank\">This is a 'composite component' without a datasource. Click here to associate a composite component instance</a><br /></div>"); } } else { var enableAync = htmlHelper.GetCheckboxRenderingParameterValue("Enable Async"); var baseUrl = htmlHelper.GetRenderingParameter("Async Fetch Base Url"); var componentClass = enableAync ? "composite async" : "composite"; var tagAttributes = htmlHelper.GetContainerTagAttributes(componentClass); var asyncUrl = renderingContext.Rendering.Item.GetItemUrl(); if (!string.IsNullOrEmpty(baseUrl)) { asyncUrl = baseUrl + "/" + asyncUrl; } var asyncAttr = enableAync ? string.Format(@"data-src=""{0}""", asyncUrl) : string.Empty; stringWriter.Write(string.Format(@"<div {0} {1}>", tagAttributes, asyncAttr)); } if (hasDataSource) { var loadAsyncOnly = htmlHelper.GetCheckboxRenderingParameterValue("Load Content Async Only"); if (!loadAsyncOnly || oldDisplayMode == DisplayMode.Edit) { PipelineService.Get().RunPipeline <RenderPlaceholderArgs>("mvc.renderPlaceholder", new RenderPlaceholderArgs(pageContext.Item["PlaceholderName"] ?? "compositecontent", (TextWriter)stringWriter, new ContentRendering())); } } if (oldDisplayMode != DisplayMode.Edit) { stringWriter.Write("</div>"); } return(Content(stringWriter.ToString())); } } finally { global::Sitecore.Context.Site.SetDisplayMode(oldDisplayMode, DisplayModeDuration.Temporary); } }
private void AddParameters(UrlString urlString) { if (Parameters != null) { foreach (string key in Parameters.Keys) { urlString.Add(key, Parameters[key].ToString()); } } }
/// <summary> /// Rewrites media urls to point to CDN hostname and dehydrates querystring into filename /// </summary> /// <param name="inputUrl">/path/to/file.ext?a=1&b=2</param> /// <returns>http://cdnHostname/path/to/file!cf!a=1!b=2.ext</returns> public virtual string ReplaceMediaUrl(string inputUrl, string cdnHostname) { //string versionKey = inputUrl + "_v"; //string updatedKey = inputUrl + "_d"; string cachedKey = string.Concat(WebUtil.GetScheme(), inputUrl); try { string cachedUrl = _cache.GetUrl(cachedKey); if (!string.IsNullOrEmpty(cachedUrl)) { return(cachedUrl); } // ignore fully qualified urls or data: if (WebUtil.IsExternalUrl(inputUrl) || inputUrl.StartsWith("data:") || inputUrl.StartsWith("//")) { return(inputUrl); } UrlString url = new UrlString(WebUtil.NormalizeUrl(inputUrl)); UrlString originalUrl = new UrlString(WebUtil.NormalizeUrl(inputUrl)); // if the stoptoken ex. ?nfc=1 is non-empty, don't replace this url if (!string.IsNullOrEmpty(url[this.StopToken])) { url.Remove(this.StopToken); } else { if (!string.IsNullOrEmpty(cdnHostname)) { url.HostName = cdnHostname; // insert CDN hostname } if (CDNSettings.MatchProtocol) { url.Protocol = WebUtil.GetScheme(); } url.Path = StringUtil.EnsurePrefix('/', url.Path); //ensure first "/" before ~/media if (CDNSettings.FilenameVersioningEnabled) { // if this is a media library request if (inputUrl.Contains(Settings.Media.MediaLinkPrefix)) { string version = url["vs"] ?? string.Empty; string updated = string.Empty; // get sitecore path of media item string mediaItemPath = GetMediaItemPath(url.Path); if (!string.IsNullOrEmpty(mediaItemPath) && Sitecore.Context.Database != null) { Item mediaItem = null; if (!string.IsNullOrEmpty(version)) { mediaItem = Sitecore.Context.Database.GetItem(mediaItemPath, Sitecore.Context.Language, Sitecore.Data.Version.Parse(version)); } else { mediaItem = Sitecore.Context.Database.SelectSingleItem(mediaItemPath); } if (mediaItem == null) { // no change to url url = originalUrl; } else { // do not replace url if media item isn't public or requires Analytics processing // keep local url for this case if (!this.IsMediaPubliclyAccessible(mediaItem) || IsMediaAnalyticsTracked(mediaItem)) { // no change to url url = originalUrl; } else { version = mediaItem.Version.Number.ToString(); updated = DateUtil.ToIsoDate(mediaItem.Statistics.Updated); } } } if (!string.IsNullOrEmpty(version)) { // append version number qs url.Add("vs", version); } if (!string.IsNullOrEmpty(updated)) { // append timestamp qs url.Add("d", updated); } } else // else this is a static file url { string updated = string.Empty; if (string.IsNullOrEmpty(updated)) { if (FileUtil.FileExists(url.Path)) { DateTime lastWrite = FileUtil.GetFileWriteTime(url.Path); updated = DateUtil.ToIsoDate(lastWrite); } } if (!string.IsNullOrEmpty(updated)) { // append timestamp qs url.Add("d", updated); } if (CDNSettings.MinifyEnabled && (url.Path.EndsWith(".css") || url.Path.EndsWith(".js"))) { url.Add("min", "1"); } } } } string outputUrl = url.ToString().TrimEnd('?');//prevent trailing ? with blank querystring _cache.SetUrl(cachedKey, outputUrl); return(outputUrl); } catch (Exception ex) { Log.Error(string.Format("ReplaceMediaUrl {0} {1}", cdnHostname, inputUrl), ex, this); return(inputUrl); } }
/// <summary> /// Sends the mail. /// </summary> /// <param name="templateName">Name of the template.</param> /// <param name="parameters">The parameters.</param> /// <param name="queryString">The query string.</param> /// <exception cref="ConfigurationErrorsException"><c>The Configuration errors exception</c>.</exception> public virtual void SendMail([NotNull] string templateName, [NotNull] object parameters, [NotNull] string queryString) { Assert.ArgumentNotNull(templateName, "templateName"); Assert.ArgumentNotNull(parameters, "parameters"); Assert.ArgumentNotNull(queryString, "queryString"); GeneralSettings generalSettings = Context.Entity.GetConfiguration <GeneralSettings>(); Item templateItem = Sitecore.Context.Database.GetItem(generalSettings.MailTemplatesLink); if (templateItem == null) { return; } string templatePath = string.Format("{0}/{1}", templateItem.Paths.FullPath, templateName); Item mailTemplate = Sitecore.Context.Database.GetItem(templatePath); if (mailTemplate == null) { Log.Warn(string.Format(CouldNotLoadTemplateMessage, templatePath), this); return; } string body = mailTemplate["Body"].FormatWith(parameters); string subject = mailTemplate["Subject"].FormatWith(parameters); // Get body from external source string bodySourceId = mailTemplate["BodySource"]; Item bodySourceItem = Sitecore.Context.Database.GetItem(bodySourceId); if (bodySourceItem != null) { UrlString qs = new UrlString(queryString); string orderId = qs["orderid"]; Assert.IsNotNullOrEmpty(orderId, "Unable to send mail. Order number is null or empty."); string encryptKey = Crypto.EncryptTripleDES(orderId, EncryptKey); encryptKey = Uri.EscapeDataString(encryptKey); UrlString url = new UrlString(LinkManager.GetItemUrl(bodySourceItem)); url.Add("key", encryptKey); url.Append(new UrlString(queryString)); using (new SecurityDisabler()) { body += WebUtil.ExecuteWebPage(url.ToString()); } } // Replace relative url with absolute url string urlPrefix = "http://" + HttpContext.Current.Request.Url.Host + "/"; body = body.Replace("href=\"/", "href=\"" + urlPrefix); body = body.Replace("href='/", "href='" + urlPrefix); body = body.Replace("HREF=\"/", "href=\"" + urlPrefix); body = body.Replace("HREF='/", "href='" + urlPrefix); body = body.Replace("src=\"/", "src=\"" + urlPrefix); body = body.Replace("src='/", "src='" + urlPrefix); body = body.Replace("SRC=\"/", "src=\"" + urlPrefix); body = body.Replace("SRC='/", "src='" + urlPrefix); // Configuration.OrderGrid string from = mailTemplate["From"].FormatWith(parameters); if (!MainUtil.IsValidEmailAddress(from)) { string info = string.Format(InvalidEmailAddressMessage, from, templateName, "From"); ConfigurationErrorsException configurationErrorsException = new ConfigurationErrorsException(info); Log.Warn(configurationErrorsException.Message, configurationErrorsException, this); return; } string to = mailTemplate["To"].FormatWith(parameters); if (!MainUtil.IsValidEmailAddress(to)) { string info = string.Format(InvalidEmailAddressMessage, to, templateName, "To"); ConfigurationErrorsException configurationErrorsException = new ConfigurationErrorsException(info); Log.Warn(configurationErrorsException.Message, configurationErrorsException, this); return; } this.SendMail(to, from, subject, body, string.Empty); }
/// <summary> /// Overide Sitecore choosing which version to open and get the latest instead /// </summary> /// <param name="urlString">Raw Url String</param> /// <param name="itemId">Id of the Item that will have the its version checked</param> private static void AddLatestVersionToUrlString(UrlString urlString, string itemId) { urlString.Remove(Util.Constants.VersionQueryStringKeyName); urlString.Add(Util.Constants.VersionQueryStringKeyName, Context.ContentDatabase.GetItem(itemId).Versions.GetLatestVersion().Version.ToString()); }
protected virtual void StartWizard(ClientPipelineArgs args) { if (!SheerResponse.CheckModified()) { return; } if (!args.IsPostBack) { UrlString url = new UrlString(UIUtil.GetUri("control:DMSPollWizard")); url.Add("id", args.Parameters["parentID"]); url.Add("language", args.Parameters["language"]); url.Add("showpageeditorfunctionality", args.Parameters["showpageeditorfunctionality"]); SheerResponse.ShowModalDialog(url.ToString(), true); args.WaitForPostBack(); } else { _wizardPipeline = null; if (args.HasResult) { var pollItem = Context.ContentDatabase.GetItem(args.Result); if (pollItem != null) { var itemToRefresh = pollItem.Parent; Context.ClientPage.SendMessage(this, "item:updated(id=" + itemToRefresh.ID + ")"); Context.ClientPage.SendMessage(this, "item:refreshchildren(id=" + itemToRefresh.ID + ")"); } } } }
/// <summary> /// Overide Sitecore choosing which version to open and get the latest instead /// </summary> /// <param name="urlString">Raw Url String</param> /// <param name="itemId">Id of the Item that will have the its version checked</param> private static void AddLatestVersionToUrlString(UrlString urlString, string itemId) { urlString.Remove(Util.Constants.VersionQueryStringKeyName); urlString.Add(Util.Constants.VersionQueryStringKeyName, Context.ContentDatabase.GetItem(itemId).Versions.GetLatestVersion().Version.ToString()); }
/// <summary> /// Rewrites media urls to point to CDN hostname and dehydrates querystring into filename /// </summary> /// <param name="inputUrl">/path/to/file.ext?a=1&b=2</param> /// <returns>http://cdnHostname/path/to/file!cf!a=1!b=2.ext</returns> public virtual string ReplaceMediaUrl(string inputUrl, string cdnHostname) { //string versionKey = inputUrl + "_v"; //string updatedKey = inputUrl + "_d"; string cachedKey = string.Concat(WebUtil.GetScheme(), inputUrl); try { string cachedUrl = _cache.GetUrl(cachedKey); if (!string.IsNullOrEmpty(cachedUrl)) { return cachedUrl; } // ignore fully qualified urls or data: if (WebUtil.IsExternalUrl(inputUrl) || inputUrl.StartsWith("data:") || inputUrl.StartsWith("//")) return inputUrl; UrlString url = new UrlString(WebUtil.NormalizeUrl(inputUrl)); UrlString originalUrl = new UrlString(WebUtil.NormalizeUrl(inputUrl)); // if the stoptoken ex. ?nfc=1 is non-empty, don't replace this url if (!string.IsNullOrEmpty(url[this.StopToken])) { url.Remove(this.StopToken); } else { if (!string.IsNullOrEmpty(cdnHostname)) url.HostName = cdnHostname; // insert CDN hostname if (CDNSettings.MatchProtocol) url.Protocol = WebUtil.GetScheme(); url.Path = StringUtil.EnsurePrefix('/', url.Path); //ensure first "/" before ~/media if (CDNSettings.FilenameVersioningEnabled) { // if this is a media library request if (inputUrl.Contains(Settings.Media.MediaLinkPrefix)) { string version = url["vs"] ?? string.Empty; string updated = string.Empty; // get sitecore path of media item string mediaItemPath = GetMediaItemPath(url.Path); if (!string.IsNullOrEmpty(mediaItemPath) && Sitecore.Context.Database != null) { Item mediaItem = null; if (!string.IsNullOrEmpty(version)) { mediaItem = Sitecore.Context.Database.GetItem(mediaItemPath, Sitecore.Context.Language, Sitecore.Data.Version.Parse(version)); } else { mediaItem = Sitecore.Context.Database.SelectSingleItem(mediaItemPath); } if (mediaItem == null) { // no change to url url = originalUrl; } else { // do not replace url if media item isn't public or requires Analytics processing // keep local url for this case if (!this.IsMediaPubliclyAccessible(mediaItem) || IsMediaAnalyticsTracked(mediaItem)) { // no change to url url = originalUrl; } else { version = mediaItem.Version.Number.ToString(); updated = DateUtil.ToIsoDate(mediaItem.Statistics.Updated); } } } if (!string.IsNullOrEmpty(version)) { // append version number qs url.Add("vs", version); } if (!string.IsNullOrEmpty(updated)) { // append timestamp qs url.Add("d", updated); } } else // else this is a static file url { string updated = string.Empty; if (string.IsNullOrEmpty(updated)) { if (FileUtil.FileExists(url.Path)) { DateTime lastWrite = FileUtil.GetFileWriteTime(url.Path); updated = DateUtil.ToIsoDate(lastWrite); } } if (!string.IsNullOrEmpty(updated)) { // append timestamp qs url.Add("d", updated); } if (CDNSettings.MinifyEnabled && (url.Path.EndsWith(".css") || url.Path.EndsWith(".js"))) url.Add("min", "1"); } } } string outputUrl = url.ToString().TrimEnd('?');//prevent trailing ? with blank querystring _cache.SetUrl(cachedKey, outputUrl); return outputUrl; } catch (Exception ex) { Log.Error(string.Format("ReplaceMediaUrl {0} {1}", cdnHostname, inputUrl), ex, this); return inputUrl; } }
// GET: Snippet public ActionResult CompositeComponent() { var renderingContext = RenderingContext.CurrentOrNull; if (renderingContext == null) { throw new ApplicationException("Could not find current rendering context, aborting"); } var hasDataSource = !string.IsNullOrWhiteSpace(renderingContext.Rendering.DataSource); var dataSourceItem = hasDataSource ? renderingContext.Rendering.Item : null; var pageContext = new PageContext() { RequestContext = this.ControllerContext.RequestContext, Item = dataSourceItem }; var oldDisplayMode = global::Sitecore.Context.Site != null ? global::Sitecore.Context.Site.DisplayMode : DisplayMode.Normal; try { if (oldDisplayMode == DisplayMode.Edit && global::Sitecore.Context.Site != null) { //disable the editing of the nested component global::Sitecore.Context.Site.SetDisplayMode(DisplayMode.Preview, DisplayModeDuration.Temporary); } using (PlaceholderContext.Enter(new PlaceholderContext("/"))) using (ContextService.Get().Push <PageContext>(pageContext)) { var stringWriter = new StringWriter(); if (oldDisplayMode == DisplayMode.Edit) { if (hasDataSource) { UrlString webSiteUrl = SiteContext.GetWebSiteUrl(global::Sitecore.Context.ContentDatabase ?? global::Sitecore.Context.Database); webSiteUrl.Add("sc_mode", "edit"); webSiteUrl.Add("sc_itemid", pageContext.Item.ID.ToString()); webSiteUrl.Add("sc_lang", pageContext.Item.Language.ToString()); //copied style from bootstrap alert stringWriter.Write("<div role=\"alert\" class=\"alert alert-warning\" style=\"box-sizing: border-box; margin-bottom: 20px; border-top: rgb(250,235,204) 1px solid; border-right: rgb(250,235,204) 1px solid; white-space: normal; word-spacing: 0px; border-bottom: rgb(250,235,204) 1px solid; text-transform: none; color: rgb(138,109,59); padding-bottom: 15px; padding-top: 15px; font: 14px/20px 'Helvetica Neue', helvetica, arial, sans-serif; padding-left: 15px; border-left: rgb(250,235,204) 1px solid; widows: 1; letter-spacing: normal; padding-right: 15px; background-color: rgb(252,248,227); text-indent: 0px; border-radius: 4px; -webkit-text-stroke-width: 0px\">"); stringWriter.Write("<a class=\"alert-link\" style=\"box-sizing: border-box; text-decoration: none; font-weight: 700; color: rgb(102,81,44); background-color: transparent\" href=\""); stringWriter.Write(webSiteUrl); stringWriter.Write("\" target=\"_blank\" onmousedown=\"window.open(this.href)\">""); stringWriter.Write(pageContext.Item.DisplayName); stringWriter.Write("" is a 'composite component'. Click here to open it's editor</a><br /></div>"); } else { //copied style from bootstrap alert stringWriter.Write("<div role=\"alert\" class=\"alert alert-warning\" style=\"box-sizing: border-box; margin-bottom: 20px; border-top: rgb(250,235,204) 1px solid; border-right: rgb(250,235,204) 1px solid; white-space: normal; word-spacing: 0px; border-bottom: rgb(250,235,204) 1px solid; text-transform: none; color: rgb(138,109,59); padding-bottom: 15px; padding-top: 15px; font: 14px/20px 'Helvetica Neue', helvetica, arial, sans-serif; padding-left: 15px; border-left: rgb(250,235,204) 1px solid; widows: 1; letter-spacing: normal; padding-right: 15px; background-color: rgb(252,248,227); text-indent: 0px; border-radius: 4px; -webkit-text-stroke-width: 0px\">"); stringWriter.Write("<a class=\"alert-link\" style=\"box-sizing: border-box; text-decoration: none; font-weight: 700; color: rgb(102,81,44); background-color: transparent\" href=\"\" onmousedown=\""); stringWriter.Write("Sitecore.PageModes.PageEditor.postRequest('webedit:setdatasource(referenceId="); stringWriter.Write(renderingContext.Rendering.UniqueId.ToString("B").ToUpper()); stringWriter.Write(",renderingId="); stringWriter.Write(renderingContext.Rendering.RenderingItem.ID); stringWriter.Write(",id="); stringWriter.Write(renderingContext.Rendering.Item.ID); stringWriter.Write(")',null,false)"); stringWriter.Write("\" target=\"_blank\">This is a 'composite component' without a datasource. Click here to associate a composite component instance</a><br /></div>"); } } if (hasDataSource && dataSourceItem != null && dataSourceItem?.TemplateID == new global::Sitecore.Data.ID(CompositeComponentInstanceTemplateId) && !string.IsNullOrEmpty(pageContext.Item?["PlaceholderName"])) { PipelineService.Get().RunPipeline <RenderPlaceholderArgs>("mvc.renderPlaceholder", new RenderPlaceholderArgs(pageContext.Item["PlaceholderName"], (TextWriter)stringWriter, new ContentRendering())); } return(Content(stringWriter.ToString())); } } finally { global::Sitecore.Context.Site.SetDisplayMode(oldDisplayMode, DisplayModeDuration.Temporary); } }
/// <summary> /// Overide Sitecore choosing which version to open and get the latest instead /// </summary> /// <returns>Void</returns> private static void AddLatestVersionToUrlString(CommandContext context, UrlString urlString) { urlString.Remove("vs"); urlString.Add("vs", Context.ContentDatabase.GetItem(context.Parameters[0]).Versions.GetLatestVersion(). Version.ToString()); }
public void OnDoubleClick() { if (ListViewer.GetSelectedItems().Length <= 0) return; var clickedId = int.Parse(ListViewer.GetSelectedItems()[0].Value); var firstDataItem = ListViewer.Data.Data.FirstOrDefault(p => p.Id == clickedId); if (firstDataItem != null) { var originalData = firstDataItem.Original; var item = originalData as Item; if (item != null) { var urlParams = new UrlString(); urlParams.Add("id", item.ID.ToString()); urlParams.Add("fo", item.ID.ToString()); urlParams.Add("la", item.Language.Name); urlParams.Add("vs", item.Version.Number.ToString(CultureInfo.InvariantCulture)); urlParams.Add("sc_content", item.Database.Name); Windows.RunApplication("Content editor", urlParams.ToString()); } } ListViewer.Refresh(); }
protected override void ProcessItem(Item item) { if (ShouldProcess(item.GetProviderPath(), string.Format("Set '{0}' rendering parameters. Rendering is of type: {1}", Instance.UniqueId, Instance.ItemID))) { LayoutField layoutField = item.Fields[FieldIDs.LayoutField]; if (layoutField == null || string.IsNullOrEmpty(layoutField.Value)) { return; } var layout = LayoutDefinition.Parse(layoutField.Value); DeviceDefinition device; RenderingDefinition rendering; foreach (DeviceDefinition aDevice in layout.Devices) { foreach ( RenderingDefinition aRendering in aDevice.Renderings.Cast<RenderingDefinition>() .Where(aRendering => aRendering.UniqueId == Instance.UniqueId)) { device = aDevice; rendering = aRendering; goto Renderingfound; } } return; Renderingfound: //goto label rendering.ItemID = Instance.ItemID; rendering.Placeholder = MyInvocation.BoundParameters.ContainsKey("PlaceHolder") ? PlaceHolder : Instance.Placeholder ?? rendering.Placeholder; rendering.Datasource = !string.IsNullOrEmpty(DataSource) ? DataSource : Instance.Datasource; rendering.Cachable = Instance.Cachable; rendering.VaryByData = Instance.VaryByData; rendering.VaryByDevice = Instance.VaryByDevice; rendering.VaryByLogin = Instance.VaryByLogin; rendering.VaryByParameters = Instance.VaryByParameters; rendering.VaryByQueryString = Instance.VaryByQueryString; rendering.VaryByUser = Instance.VaryByUser; rendering.Parameters = Instance.Parameters; rendering.MultiVariateTest = Instance.MultiVariateTest; rendering.Rules = Instance.Rules; rendering.Conditions = Instance.Conditions; if (Parameter != null) { var parameters = new UrlString(rendering.Parameters ?? string.Empty); foreach (string name in Parameter.Keys) if (parameters.Parameters.AllKeys.Contains(name)) { parameters.Parameters[name] = Parameter[name].ToString(); } else { parameters.Add(name, Parameter[name].ToString()); } rendering.Parameters = parameters.ToString(); } if (Index > -1) { device.Renderings.Remove(rendering); device.Insert(index, rendering); } item.Edit(p => { var outputXml = layout.ToXml(); Item["__Renderings"] = outputXml; }); } }