protected void Run(ClientPipelineArgs args) { string str = args.Parameters["id"]; string name = args.Parameters["language"]; string str3 = args.Parameters["version"]; var version = Sitecore.Data.Version.Parse(str3); Item item = Context.ContentDatabase.GetItem(str, Sitecore.Globalization.Language.Parse(name), version); Error.AssertItemFound(item); if (!SheerResponse.CheckModified()) return; if (!args.IsPostBack) { string forItemPageURL = Sitecore.Configuration.Settings.GetSetting("SCBasics.AuditTrail.ForItemPageURL"); if (!string.IsNullOrWhiteSpace(forItemPageURL)) { Sitecore.Text.UrlString url = new Sitecore.Text.UrlString( forItemPageURL); url.Append("id", HttpUtility.UrlEncode(args.Parameters["id"])); url.Append("la", HttpUtility.UrlEncode(args.Parameters["language"])); url.Append("ve", HttpUtility.UrlEncode(args.Parameters["version"])); Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog(url.ToString(), "990px", "570px", "ForItemPageURL", true); args.WaitForPostBack(); } else { SheerResponse.Alert("SCBasics.AuditTrail.ForItemPageURL is empty. Please verify your configurations", true); } } }
protected new void Edit(SC.Web.UI.Sheer.ClientPipelineArgs args) { SC.Diagnostics.Assert.ArgumentNotNull(args, "args"); if (this.Enabled) { if (args.IsPostBack) { if ((args.Result != null) && (args.Result != "undefined")) { string result = args.Result; if (result == "-") { result = string.Empty; } else if (this.Value != result) { SC.Context.ClientPage.Modified = true; } this.Value = result; HtmlTextWriter output = new HtmlTextWriter(new StringWriter()); this.RenderItems(output); SC.Web.UI.Sheer.SheerResponse.SetInnerHtml( this.ID, output.InnerWriter.ToString()); } } else { SC.Text.UrlString urlString = new SC.Text.UrlString( UIUtil.GetUri("control:TreeListExEditor")); SC.Web.UrlHandle handle = new SC.Web.UrlHandle(); string str3 = this.Value; if (str3 == "__#!$No value$!#__") { str3 = string.Empty; } handle["value"] = str3; handle["source"] = this.Source; handle["language"] = this.ItemLanguage; handle["itemid"] = this.ItemID; handle["itemlanguage"] = this.ItemLanguage; handle["itemversion"] = this.ItemVersion; handle.Add(urlString); SC.Web.UI.Sheer.SheerResponse.ShowModalDialog( urlString.ToString(), "800px", "500px", string.Empty, true); args.WaitForPostBack(); } } }
/// <summary> /// Handles the Postback of the Sheer Dialogs /// </summary> protected void Run(ClientPipelineArgs args) { try { if (!args.IsPostBack) { if (!args.HasResult && !string.IsNullOrEmpty(args.Parameters["name"]) && args.Parameters["first"] == "True") { args.Parameters["first"] = "False"; SheerResponse.Input("Enter a name for the new item:", "Copy of " + args.Parameters["name"], Settings.ItemNameValidation, Translate.Text("'$Input' is not a valid name."), Settings.MaxItemNameLength); args.WaitForPostBack(); } } else if (args.HasResult && !(string.IsNullOrEmpty(args.Result)) && ID.IsID(args.Result)) { //This will make sure the Content Editor loads the latest version after dialog closes. string load = String.Concat(new object[] { "item:load(id=", args.Result, ")" }); Context.ClientPage.SendMessage(this, load); String refresh = String.Format("item:refreshchildren(id={0})", args.Result); Context.ClientPage.ClientResponse.Timer(refresh, 2); } else if (args.HasResult && !(string.IsNullOrEmpty(args.Result))) { //Check if valid item name string itemName = ItemUtil.ProposeValidItemName(args.Result); if (itemName == args.Result) { //Show the dialog to select the languages Sitecore.Text.UrlString url = new Sitecore.Text.UrlString("/sitecore/admin/SharedSource/DuplicateItemSelectLanguages.aspx"); url.Append("id", args.Parameters["id"]); url.Append("duplicateItemName", args.Result); url.Append("currentItemName", args.Parameters["name"]); url.Append("database", args.Parameters["database"]); Context.ClientPage.ClientResponse.ShowModalDialog(url.ToString(), "420", "400", string.Empty, true, "", "", false); args.WaitForPostBack(true); } else { //Item name is invalid. //If Item Name empty //Control will never come here. SheerResponse.Input("Enter a name for the new item:", "Copy of " + args.Parameters["name"]); args.WaitForPostBack(); } } else { // Do Nothing } } catch (Exception ex) { Log.Error("Some Error Occurred in Duplicate Item In Selected Languages", ex, this); } }
/// <summary> /// Get the Source /// </summary> /// <returns> /// The Source String <see cref="string"/>. /// </returns> protected override string GetSource() { var baseUrl = new Sitecore.Text.UrlString(base.GetSource().Replace("&", "&")); if (Parameters.ContainsKey("useCustomFunctions")) { baseUrl.Add("useCustomFunctions", Parameters["useCustomFunctions"]); // remove useNamicsFuctions from the parameters dictionary so it's not added as an attribute on the img tag Parameters.Remove("useCustomFunctions"); } if (Parameters.ContainsKey("centerCrop")) { baseUrl.Add("centerCrop", Parameters["centerCrop"]); // remove centerCrop from the parameters dictionary so it's not added as an attribute on the img tag Parameters.Remove("centerCrop"); } if (Parameters.ContainsKey("cropX") && Parameters.ContainsKey("cropY")) { baseUrl.Add("cropX", Parameters["cropX"]); baseUrl.Add("cropY", Parameters["cropY"]); // remove cropStartX, cropStartY, cropWidth and cropHeight from the parameters dictionary so they not added as attributes on the img tag Parameters.Remove("cropX"); Parameters.Remove("cropY"); } if (Parameters.ContainsKey("keepOrientation")) { baseUrl.Add("keepOrientation", Parameters["keepOrientation"]); // remove keepOrientation from the parameters dictionary so it's not added as an attribute on the img tag Parameters.Remove("keepOrientation"); } if (Parameters.ContainsKey("greyScale")) { baseUrl.Add("greyScale", Parameters["greyScale"]); // remove greyScale from the parameters dictionary so it's not added as an attribute on the img tag Parameters.Remove("greyScale"); } if (Parameters.ContainsKey("rotateFlip")) { baseUrl.Add("rotateFlip", Parameters["rotateFlip"]); // remove rotateFlip from the parameters dictionary so it's not added as an attribute on the img tag Parameters.Remove("rotateFlip"); } return(baseUrl.GetUrl(Xhtml && Settings.Rendering.ImagesAsXhtml)); }
/// <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')"); }
private static void OpenContentEditor(Sitecore.Data.Items.Item item) { Assert.IsNotNull(item, "item is null"); Sitecore.Text.UrlString parameters = new Sitecore.Text.UrlString(); parameters.Add("id", item.ID.ToString()); parameters.Add("fo", item.ID.ToString()); parameters.Add("la", item.Language.Name); parameters.Add("vs", item.Version.Number.ToString()); Sitecore.Shell.Framework.Windows.RunApplication("Content editor", parameters.ToString()); }
public void Process(LogoutArgs args) { Tracer.Info("Intercepting call to Sitecore logout. Redirecting to Single Logout instead"); Sitecore.Text.UrlString urlString = new Sitecore.Text.UrlString("https://www.google.com"); args.RedirectUrl = urlString; //var uri = "https://www.google.com"; //var psi = new System.Diagnostics.ProcessStartInfo(); //psi.UseShellExecute = true; //psi.FileName = uri; //System.Diagnostics.Process.Start(psi); }
private void LoginRedirect() { Sitecore.Text.UrlString url = new Sitecore.Text.UrlString("/Login.aspx"); url["returnUrl"] = GetRawUrl(Sitecore.Context.RawUrl); if (!Sitecore.Configuration.Settings.RequestErrors.UseServerSideRedirect) { WebUtil.Redirect(url.ToString(), false); return; } HttpContext.Current.Server.Transfer(url.ToString()); }
protected void Process(Sitecore.Web.UI.Sheer.ClientPipelineArgs args) { Sitecore.Diagnostics.Assert.ArgumentNotNull(args, "args"); if (!args.IsPostBack) { string url = new Sitecore.Text.UrlString( Sitecore.UIUtil.GetUri("control:RunAgent")).ToString(); Sitecore.Web.UI.Sheer.SheerResponse.ShowModalDialog(url, true); args.WaitForPostBack(); } }
/// <summary> /// Method is used for populating a request model from Query String parameters. If you need to add populating any extra parameters - just override this method. /// IMPORTANT! This method is executed during building a query for search and shouldn't be called in another places. /// </summary> protected virtual void PopulateFromQueryString(ISearchRequestModel model) { if (!SearchConfiguration.LoadQueryString || !string.IsNullOrWhiteSpace(model.SearchBoxQuery) || (model.Filters != null && model.Filters.Any())) { Logging.Log.Debug("Loading search parameters from query string is disabled"); return; } if (String.IsNullOrWhiteSpace(model.CurrentUrl)) { Logging.Log.Debug("Loading search parameters from query string is impossible due the HttpContext is null."); return; } var url = new Sitecore.Text.UrlString(model.CurrentUrl); if (url.Parameters.Count < 1) { Logging.Log.Debug("There is no any query string parameters in the current request."); return; } var query = url.Parameters.Get("q"); if (!string.IsNullOrWhiteSpace(query)) { var decoded = HttpUtility.UrlDecode(query); model.SearchBoxQuery = decoded; } var parameterBlacklist = new [] { "sc_itemid", "sc_mode", "sc_lang", "sc_site" }; var querystrings = url.Parameters.ToKeyValues().Where(q => q.Key != "q" && !parameterBlacklist.Contains(q.Key) && !string.IsNullOrWhiteSpace(q.Value)).ToList(); if (!querystrings.Any()) { return; } model.Filters = querystrings.Select(q => new FilterModel { FieldName = q.Key, FieldValue = q.Value }).ToList(); var filter = model.Filters.LastOrDefault(); if (filter != null) { model.LastChangedFilterName = filter.FieldName; } }
protected void Run(Sitecore.Web.UI.Sheer.ClientPipelineArgs args) { if (args.IsPostBack) { } else { Sitecore.Text.UrlString url = new Sitecore.Text.UrlString("/sitecore/client/Your Apps/View Jobs/Job Listing?sc_lang=en"); url.Append("id", args.Parameters["id"]); url.Append("database", args.Parameters["database"]); Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog(url.ToString(), true); args.WaitForPostBack(true); } }
private string GetRenderingContent() { StringWriter sw = new StringWriter(); //Sitecore.Data.Fields.ReferenceField device = this.dataSourceItem.Fields["Use Device"]; var pdfurl = new Sitecore.Text.UrlString(HttpContext.Current.Request.Url.ToString()); pdfurl.Add("sc_device", this.dataSourceItem["Use Device"]); string html = GenerateResponseXMl(pdfurl.ToString()); return(html); }
protected void Run(Sitecore.Web.UI.Sheer.ClientPipelineArgs args) { if (args.IsPostBack) { } else { Sitecore.Text.UrlString url = new Sitecore.Text.UrlString("/sitecore modules/Shell/Demo/TestPage.aspx"); url.Append("id", args.Parameters["id"]); url.Append("database", args.Parameters["database"]); Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog(url.ToString(), true); args.WaitForPostBack(true); } }
private void IdentityLoginRedirect() { //Sitecore.Text.UrlString url = new Sitecore.Text.UrlString(string.Format("/identitylogin?redirectUrl={0}", // HttpUtility.UrlEncode(GetRawUrl(Sitecore.Context.RawUrl)))); Sitecore.Text.UrlString url = new Sitecore.Text.UrlString(string.Format("/identitylogin?redirectUrl={0}", "/identitylogin/securedpage")); if (!Sitecore.Configuration.Settings.RequestErrors.UseServerSideRedirect) { WebUtil.Redirect(url.ToString(), false); return; } HttpContext.Current.Server.Transfer(url.ToString()); //HttpContext.Current.Response.Redirect(HttpUtility.UrlEncode(string.Format("/identity/externallogin?authenticationType=IS4&ReturnUrl=/identity/externallogincallback?ReturnUrl={0}&sc_site=website&authenticationSource=Default&sc_site=website", // HttpUtility.UrlEncode(GetRawUrl(Sitecore.Context.RawUrl))))); }
/// <summary> /// Handles the AddChildElement dialog /// </summary> /// <param name="args"></param> protected void ExecNewChildPipeline(ClientPipelineArgs args) { if (args.IsPostBack) { if ((!String.IsNullOrEmpty(args.Result)) && args.Result != "undefined") { args.Parameters["id"] = args.Result; Sitecore.Context.ClientPage.Start(this, "ExecEditContentPipeline", args.Parameters); } } else { Sitecore.Text.UrlString url = new Sitecore.Text.UrlString(Sitecore.UIUtil.GetUri("control:AddChildElement")); url.Append("id", args.Parameters["id"]); url.Append("database", args.Parameters["database"]); url.Append("lang", args.Parameters["la"]); Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog(url.ToString(), "400px", "300px", string.Empty, true); args.WaitForPostBack(true); } }
protected void Run(ClientPipelineArgs args) { string str = args.Parameters["id"]; string name = args.Parameters["language"]; string str3 = args.Parameters["version"]; var version = Sitecore.Data.Version.Parse(str3); Item item = Context.ContentDatabase.GetItem(str, Sitecore.Globalization.Language.Parse(name), version); Error.AssertItemFound(item); if (!SheerResponse.CheckModified()) { return; } if (!args.IsPostBack) { string forSitePageURL = Sitecore.Configuration.Settings.GetSetting("SCBasics.AuditTrail.ForSitePageURL"); if (!string.IsNullOrWhiteSpace(forSitePageURL)) { Sitecore.Text.UrlString url = new Sitecore.Text.UrlString( forSitePageURL); url.Append("id", HttpUtility.UrlEncode(args.Parameters["id"])); url.Append("la", HttpUtility.UrlEncode(args.Parameters["language"])); url.Append("ve", HttpUtility.UrlEncode(args.Parameters["version"])); Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog(url.ToString(), "990px", "570px", "ForSitePageURL", true); args.WaitForPostBack(); } else { SheerResponse.Alert("SCBasics.AuditTrail.ForItemPageURL is empty. Please verify your configurations", true); } } }
protected void Run(ClientPipelineArgs args) { string str = args.Parameters[IdParameterKey]; string name = args.Parameters[LanguageParameterKey]; string str3 = args.Parameters[VersionParameterKey]; var version = Sitecore.Data.Version.Parse(str3); Item item = Context.ContentDatabase.GetItem(str, Sitecore.Globalization.Language.Parse(name), version); Error.AssertItemFound(item); if (!SheerResponse.CheckModified()) { return; } if (!args.IsPostBack) { string forSitePageURL = "/Sitecore Modules/Shell/SitecoreEventLog/SiteEventLog.aspx"; if (!string.IsNullOrWhiteSpace(forSitePageURL)) { Sitecore.Text.UrlString url = new Sitecore.Text.UrlString( forSitePageURL); url.Append(IdParameterKey, HttpUtility.UrlEncode(args.Parameters[IdParameterKey])); url.Append("la", HttpUtility.UrlEncode(args.Parameters[LanguageParameterKey])); url.Append("ve", HttpUtility.UrlEncode(args.Parameters[VersionParameterKey])); Context.ClientPage.ClientResponse.ShowModalDialog(url.ToString(), "990px", "650px", "ForSitePageURL", true); args.WaitForPostBack(); } else { SheerResponse.Alert("SiteEventLog.aspx url is wrong, please check the source code.", true); } } }
public void Execute( XElement element, string name, SC.Text.UrlString parameters, string value) { SC.Diagnostics.Assert.ArgumentNotNull(element, "element"); SC.Diagnostics.Assert.ArgumentNotNull(name, "name"); SC.Diagnostics.Assert.ArgumentNotNull(parameters, "parameters"); SC.Diagnostics.Assert.ArgumentNotNull(value, "value"); SC.Diagnostics.Assert.IsNotNull( SC.Context.ContentDatabase, "Sitecore.Context.ContentDatabase"); SC.Shell.Applications.Dialogs.ItemLister.SelectItemOptions options = new SC.Shell.Applications.Dialogs.ItemLister.SelectItemOptions(); if (!String.IsNullOrEmpty(value)) { SC.Data.Items.Item item = Client.ContentDatabase.GetItem(value); if (item != null) { options.SelectedItem = item; } } options.Root = Client.ContentDatabase.GetItem(SC.ItemIDs.WorkflowRoot); SC.Data.Items.TemplateItem workflowCommandTemplate = SC.Context.ContentDatabase.GetTemplate( SC.TemplateIDs.WorkflowCommand); SC.Diagnostics.Assert.IsNotNull(workflowCommandTemplate, "workflowCommandTemplate"); options.IncludeTemplatesForSelection = SC.Shell.Applications.Dialogs.ItemLister.SelectItemOptions.GetTemplateList( workflowCommandTemplate.GetSelfAndDerivedTemplates()); options.Title = "Select Workflow Command"; options.Text = "Select the workflow command to use in this rule."; options.Icon = "Applications/16x16/nav_right_green.png"; SC.Web.UI.Sheer.SheerResponse.ShowModalDialog( options.ToUrlString().ToString(), true); }
protected void Run(ClientPipelineArgs args) { SecurityController security = new SecurityController(); Logger.Info("ReviewAndUnlock running"); if (security.IsAuthorized()) { if (args.IsPostBack) { Sitecore.Context.ClientPage.SendMessage(this, "item:refresh"); return; } else { Sitecore.Text.UrlString popUpUrl = new Sitecore.Text.UrlString("/api/locksmith/modal"); popUpUrl.Append("id", args.Parameters["id"]); SheerResponse.ShowModalDialog(popUpUrl.ToString(), "700", "550"); args.WaitForPostBack(); } } }
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')"); }
/// <summary> /// Handles the edit-item dialog afte the new child has been created /// </summary> /// <param name="args"></param> protected void ExecEditContentPipeline(ClientPipelineArgs args) { if (args.IsPostBack) { Database masterDb = Sitecore.Configuration.Factory.GetDatabase("master"); Item item = masterDb.GetItem(args.Parameters["id"]); string parentId = item.Parent.ID.ToString(); Sitecore.Context.ClientPage.SendMessage(this, "item:load(id=" + parentId + ")"); Sitecore.Context.ClientPage.SendMessage(this, "item:refreshchildren(id=" + parentId + ")"); } else { Sitecore.Text.UrlString url = new Sitecore.Text.UrlString("/sitecore/shell/Applications/Content%20Manager/default.aspx"); url.Append("fo", args.Parameters["id"]); url.Append("vs", "1"); url.Append("mo", "preview"); url.Append("la", args.Parameters["la"]); Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog(url.ToString(), "960px", "800px", string.Empty, true); args.WaitForPostBack(true); } }
protected string GetCampaignQueryString() { var options = _linkManager.GetDefaultUrlOptions(); options.AlwaysIncludeServerUrl = true; string itemUrl = _linkManager.GetItemUrl(_pageContext.Item, options); var urlString = new Sitecore.Text.UrlString(itemUrl); var campaignId = GetCamapignId(); if (!campaignId.IsNull) { urlString.Add("sc_camp", campaignId.ToShortID().ToString()); } return urlString.GetUrl(); }
protected virtual void BuildRendering([Diagnostics.NotNull] RenderingBuilder renderingBuilder, [Diagnostics.NotNull] Item renderingItem, [Diagnostics.NotNull] XElement renderingElement, [Diagnostics.NotNull] [ItemNotNull] List<Item> renderingItems) { var parameters = new UrlString(renderingElement.GetAttributeValue("par")); renderingBuilder.Id = parameters.Parameters["Id"]; renderingBuilder.Placeholder = renderingElement.GetAttributeValue("ph"); foreach (var placeholder in renderingItem["Place Holders"].Split(Constants.Comma, StringSplitOptions.RemoveEmptyEntries)) { renderingBuilder.Placeholders.Add(placeholder.Replace("$Id", renderingBuilder.Id).Trim()); } var fields = new Dictionary<string, TemplateField>(); var parametersTemplateItem = renderingItem.Database.GetItem(renderingItem["Parameters Template"]); if (parametersTemplateItem != null) { var template = TemplateManager.GetTemplate(parametersTemplateItem.ID, renderingItem.Database); if (template != null) { foreach (var field in template.GetFields(true)) { if (field.Template.BaseIDs.Length != 0) { fields[field.Name.ToLowerInvariant()] = field; } } } } // rendering name var name = renderingItem.Name; var duplicates = renderingItems.Where(i => i.Name == renderingItem.Name).ToList(); if (duplicates.Count > 1) { name = GetUniqueRenderingName(duplicates, renderingItem); } renderingBuilder.UnsafeName = !SafeName.IsMatch(name); renderingBuilder.Name = name; // parameters foreach (var key in parameters.Parameters.Keys.OfType<string>().Where(k => !string.IsNullOrEmpty(k)).OrderBy(k => k)) { var value = parameters.Parameters[key]; if (string.IsNullOrEmpty(value)) { continue; } value = HttpUtility.UrlDecode(value) ?? string.Empty; TemplateField field; if (fields.TryGetValue(key.ToLowerInvariant(), out field)) { switch (field.Type.ToLowerInvariant()) { case "checkbox": if (!value.StartsWith("{Binding")) { value = MainUtil.GetBool(value, false) ? "True" : "False"; } break; case "droptree": if (ID.IsID(value)) { var i = renderingItem.Database.GetItem(value); if (i != null) { value = i.Paths.Path; } } break; } var source = new Sitecore.Text.UrlString(field.Source); var defaultValue = source.Parameters["defaultvalue"] ?? string.Empty; if (string.Equals(value, defaultValue, StringComparison.OrdinalIgnoreCase)) { continue; } } // todo: Hacky, hacky, hacky if ((key == "IsEnabled" || key == "IsVisible") && value == "True") { continue; } renderingBuilder.Attributes[key] = value; } // data source var dataSource = renderingElement.GetAttributeValue("ds"); if (ID.IsID(dataSource)) { var dataSourceItem = renderingItem.Database.GetItem(dataSource); if (dataSourceItem != null) { dataSource = dataSourceItem.Paths.Path; } } renderingBuilder.DataSource = dataSource; // caching renderingBuilder.Cacheable = renderingElement.GetAttributeValue("cac") == @"1"; renderingBuilder.VaryByData = renderingElement.GetAttributeValue("vbd") == @"1"; renderingBuilder.VaryByDevice = renderingElement.GetAttributeValue("vbdev") == @"1"; renderingBuilder.VaryByLogin = renderingElement.GetAttributeValue("vbl") == @"1"; renderingBuilder.VaryByParameters = renderingElement.GetAttributeValue("vbp") == @"1"; renderingBuilder.VaryByQueryString = renderingElement.GetAttributeValue("vbqs") == @"1"; renderingBuilder.VaryByUser = renderingElement.GetAttributeValue("vbu") == @"1"; }
private static void OpenContentEditor(Sitecore.Data.Items.Item item) { Assert.IsNotNull(item,"item is null"); Sitecore.Text.UrlString parameters = new Sitecore.Text.UrlString(); parameters.Add("id", item.ID.ToString()); parameters.Add("fo", item.ID.ToString()); parameters.Add("la", item.Language.Name); parameters.Add("vs", item.Version.Number.ToString()); Sitecore.Shell.Framework.Windows.RunApplication("Content editor", parameters.ToString()); }
protected virtual void WriteRenderingParameters([Diagnostics.NotNull] JsonTextWriter output, [Diagnostics.NotNull] Item rendering) { var parametersTemplateItemId = rendering["Parameters Template"]; if (string.IsNullOrEmpty(parametersTemplateItemId)) { return; } var parametersTemplateItem = rendering.Database.GetItem(parametersTemplateItemId); if (parametersTemplateItem == null) { return; } var fieldNames = new List<string>(); fieldNames.Add("Placeholder"); fieldNames.Add("DataSource"); var template = TemplateManager.GetTemplate(parametersTemplateItem.ID, rendering.Database); foreach (var field in template.GetFields(true).OrderBy(f => f.Name)) { if (field.Template.BaseIDs.Length == 0) { continue; } var fieldName = field.Name; if (fieldNames.Contains(fieldName)) { continue; } fieldNames.Add(fieldName); var urlString = new Sitecore.Text.UrlString(field.Source); var bindmode = (urlString["bindmode"] ?? string.Empty).ToLowerInvariant(); if (string.Compare(field.Type, "droplist", StringComparison.InvariantCultureIgnoreCase) == 0) { if (!WriteDropListAttribute(output, rendering.Database, field, urlString, bindmode)) { WriteAttributeString(output, fieldName, "string", field.GetToolTip(LanguageManager.DefaultLanguage)); } } else { // todo: support SPEAK bindings var description = field.GetToolTip(LanguageManager.DefaultLanguage); var type = "string"; switch (field.Type.ToLowerInvariant()) { case "checkbox": type = "boolean"; break; case "integer": type = bindmode == "server" || bindmode == "read" ? "integer" : "string"; break; } WriteAttributeString(output, fieldName, type, description); } } }
/// <summary> /// Opens a new window with the selected element where it can be edited /// </summary> /// <param name="id"></param> private void EditChild(string id) { if(string.IsNullOrEmpty(id)) { return; } Language lang = GetEditingContextLanguage(); Item itemToEdit = Sitecore.Context.ContentDatabase.GetItem(id, lang); if (itemToEdit == null) { SheerResponse.Alert("Item with id: " + id + " could not be found"); } Sitecore.Text.UrlString url = new Sitecore.Text.UrlString("/sitecore/shell/Applications/Content%20Manager/default.aspx"); url.Append("fo", id); url.Append("vs", "1"); url.Append("mo", "preview"); url.Append("la", lang.Name); Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog(url.ToString(), "960px", "800px", string.Empty, false); }