/// <summary> /// Sets the custom parameters. /// </summary> /// <param name="renderingDefinition">The rendering definition.</param> /// <param name="options">The options.</param> private void SetCustomParameters( RenderingDefinition renderingDefinition, RenderingParametersFieldEditorOptions options) { Assert.ArgumentNotNull(renderingDefinition, "renderingDefinition"); Assert.ArgumentNotNull(options, "options"); Item item = (renderingDefinition.ItemID != null) ? Client.ContentDatabase.GetItem(renderingDefinition.ItemID) : null; if (item != null) { options.Parameters["rendering"] = item.Uri.ToString(); } if (Item != null) { options.Parameters["contentitem"] = Item.Uri.ToString(); } if (WebEditUtil.IsRenderingPersonalized(renderingDefinition)) { options.Parameters["warningtext"] = "There are personalization conditions defined for this control. Changing control properties may effect them."; } if (!string.IsNullOrEmpty(renderingDefinition.MultiVariateTest)) { options.Parameters["warningtext"] = "There is a multivariate test set up for this control. Changing control properties may effect the test."; } }
/// <summary> /// Sets the values. /// </summary> private void Save() { RenderingDefinition renderingDefinition = GetRenderingDefinition(); if (renderingDefinition != null) { Item standardValuesItem; using (new SecurityDisabler()) { standardValuesItem = GetStandardValuesItem(renderingDefinition); } if (standardValuesItem != null) { UrlString urlString = new UrlString(); foreach (FieldDescriptor field in RenderingParametersFieldEditorOptions.Parse(args.Result).Fields) { SetValue(renderingDefinition, urlString, standardValuesItem.Fields[field.FieldID].Name, field.Value); } renderingDefinition.Parameters = urlString.ToString(); LayoutDefinition layoutDefinition = GetLayoutDefinition(); SetLayoutDefinition(layoutDefinition); } } }
protected virtual bool ShowDialog(ClientPipelineArgs args, int selectedIndex, Item item) { var handleNameParam = args.Parameters["handleName"]; var deviceIdParam = args.Parameters["deviceId"]; if (args.IsPostBack) { if (args.HasResult) { Save(handleNameParam, deviceIdParam, args.Parameters, selectedIndex, args.Result); } return true; } if (selectedIndex < 0) { return true; } var args2 = new GetRenderingPropertiesArgs() { ClientParameters = args.Parameters, HandleName = handleNameParam, DeviceId = deviceIdParam, SelectedIndex = selectedIndex, }; CorePipeline.Run("getRenderingPropertiesFieldEditor", args2); var fields = args2.FieldDescriptors; var dialogTitle = GetDialogTitle(args); var options = new RenderingParametersFieldEditorOptions(fields) { DialogTitle = dialogTitle, HandleName = handleNameParam, PreserveSections = true }; this.SetCustomParameters(args2.RenderingDefinition, options, item); var url = options.ToUrlString(); SheerResponse.ShowModalDialog(url.ToString(), "720", "480", string.Empty, true); args.WaitForPostBack(); return false; }
protected virtual void SetCustomParameters(RenderingDefinition renderingDefinition, RenderingParametersFieldEditorOptions options, Item item) { Assert.ArgumentNotNull(renderingDefinition, "renderingDefinition"); Assert.ArgumentNotNull(options, "options"); var renderingItem = renderingDefinition.ItemID != null ? Sitecore.Client.ContentDatabase.GetItem(renderingDefinition.ItemID) : null; if (renderingItem != null) { options.Parameters["rendering"] = renderingItem.Uri.ToString(); } if (item != null) { options.Parameters["contentitem"] = item.Uri.ToString(); } if (Sitecore.Web.WebEditUtil.IsRenderingPersonalized(renderingDefinition)) { options.Parameters["warningtext"] = Sitecore.Texts.PersonalizationConditionsDefinedWarning; } if (!string.IsNullOrEmpty(renderingDefinition.MultiVariateTest)) { options.Parameters["warningtext"] = Sitecore.Texts.Thereisamultivariatetestsetupforthiscontro; } }
/// <summary> /// Shows this instance. /// /// </summary> /// /// <returns> /// The boolean. /// /// </returns> public bool Show() { if (!this.Args.IsPostBack) { //get the fields from the custom template RenderingParametersFieldEditorOptions fieldEditorOptions = new RenderingParametersFieldEditorOptions((IEnumerable<FieldDescriptor>)RenderCustomTemplate.GetFields(CustomTemplateID)); fieldEditorOptions.DialogTitle = Consts.Strings.DialogTitle; fieldEditorOptions.HandleName = this.HandleName; fieldEditorOptions.PreserveSections = true; RenderingParametersFieldEditorOptions options = fieldEditorOptions; //create url based on options UrlString urlString = options.ToUrlString(); //display UI SheerResponse.ShowModalDialog(urlString.ToString(), "720", "480", string.Empty, true); this.args.WaitForPostBack(); } return false; }
/// <summary> /// Shows this instance. /// </summary> /// <returns> /// The boolean. /// </returns> public bool Show() { if (Args.IsPostBack) { if (Args.HasResult) { Save(); } return(true); } if (SelectedIndex < 0) { return(true); } RenderingDefinition renderingDefinition = GetRenderingDefinition(); if (renderingDefinition == null) { return(true); } string text = null; if (!string.IsNullOrEmpty(renderingDefinition.ItemID)) { Item item = Client.ContentDatabase.GetItem(renderingDefinition.ItemID, Item.Language); if (item != null) { LinkField linkField = item.Fields["Customize Page"]; Assert.IsNotNull(linkField, "linkField"); if (!string.IsNullOrEmpty(linkField.Url)) { text = linkField.Url; } } } Dictionary <string, string> parameters = GetParameters(renderingDefinition); List <FieldDescriptor> fields = GetFields(renderingDefinition, parameters); RenderingParametersFieldEditorOptions renderingParametersFieldEditorOptions = new RenderingParametersFieldEditorOptions(fields) { DialogTitle = "Control Properties", HandleName = HandleName, PreserveSections = true }; SetCustomParameters(renderingDefinition, renderingParametersFieldEditorOptions); UrlString urlString; if (!string.IsNullOrEmpty(text)) { urlString = new UrlString(text); renderingParametersFieldEditorOptions.ToUrlHandle().Add(urlString, HandleName); } else { urlString = renderingParametersFieldEditorOptions.ToUrlString(); } SheerResponse.ShowModalDialog(new ModalDialogOptions(urlString.ToString()) { Width = "720", Height = "480", Response = true, Header = renderingParametersFieldEditorOptions.DialogTitle }); args.WaitForPostBack(); return(false); }