void IElementEventHandler.Displaying(ElementDisplayContext context) { if (context.DisplayType == "Design") { return; } var element = context.Element as FormElement; if (element == null) { return; } var registrationContext = new RegisterClientValidationAttributesContext { FieldName = element.Name }; if (element.Form != null && element.Form.EnableClientValidation == true) { _formService.RegisterClientValidationAttributes(element, registrationContext); if (registrationContext.ClientAttributes.Any()) { registrationContext.ClientAttributes["data-val"] = "true"; } } context.ElementShape.ClientValidationAttributes = registrationContext.ClientAttributes; }
protected override void OnDisplaying(VectorImage element, ElementDisplayContext context) { var mediaId = element.MediaId; var vectorImage = mediaId != null?GetVectorImage(mediaId.Value) : default(VectorImagePart); context.ElementShape.VectorImagePart = vectorImage; }
protected override void OnDisplaying(PasswordField element, ElementDisplayContext context) { context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData()); context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode }); }
private void Displaying(ElementDisplayContext context, ShapeDescriptor shapeDescriptor) { var shapeType = shapeDescriptor.ShapeType; var shape = _shapeFactory.Value.Create(shapeType); context.ElementShape.Snippet = shape; }
protected override void OnDisplaying(Label element, ElementDisplayContext context) { context.ElementShape.ProcessedText = _tokenizer.Replace(element.Text, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode }); context.ElementShape.ProcessedFor = _tokenizer.Replace(element.For, context.GetTokenData()); }
protected override void OnDisplaying(Form element, ElementDisplayContext context) { var controller = _currentControllerAccessor.CurrentController; var modelState = controller != null?controller.FetchModelState(element) : default(ModelStateDictionary); if (modelState != null && !modelState.IsValid) { // Read any posted values from the previous request. var values = controller.FetchPostedValues(element); _formService.ReadElementValues(element, new NameValueCollectionValueProvider(values, _cultureAccessor.CurrentCulture)); // Add any model validation errors from the previous request. controller.ApplyAnyModelErrors(element, modelState); } // Assign the binding content type to each element within the form element. foreach (var child in element.Elements.Flatten().Where(x => x is FormElement).Cast <FormElement>()) { child.FormBindingContentType = element.CreateContent == true ? element.FormBindingContentType : default(string); } // Set tokenized properties. var tokenData = context.GetTokenData(); context.ElementShape.ProcessedAction = _tokenizer.Replace(element.Action, tokenData); }
protected override void OnDisplaying(ContentPart element, ElementDisplayContext context) { // Content is optional context, so if it's null, we can't render the part element. // This typically only happens when the layout editor is used outside the context of // a content item and still renders the various content part elements as part of the toolbox. if (context.Content == null) { return; } var contentItem = context.Content.ContentItem; var contentPartName = (string)element.Descriptor.StateBag["ElementTypeName"]; var contentPart = contentItem.Parts.FirstOrDefault(x => x.PartDefinition.Name == contentPartName); if ((contentItem.Id == 0 || context.DisplayType == "Design") && context.Updater != null) { // The content item hasn't been stored yet, so bind form values with the content part to represent actual state. var controller = (Controller)context.Updater; var oldValueProvider = controller.ValueProvider; controller.ValueProvider = context.Element.Data.ToValueProvider(_cultureAccessor.CurrentCulture); _contentPartDisplay.UpdateEditor(contentPart, context.Updater); _transactionManager.Cancel(); controller.ValueProvider = oldValueProvider; } var contentPartShape = _contentPartDisplay.BuildDisplay(contentPart, displayType: "Layout"); context.ElementShape.ContentPart = contentPart; context.ElementShape.Content = contentPartShape; }
protected override void OnDisplaying(Image element, ElementDisplayContext context) { var imageId = element.MediaId; var image = imageId != null?GetImage(imageId.Value) : default(ImagePart); context.ElementShape.ImagePart = image; }
protected override void OnDisplaying(Html element, ElementDisplayContext context) { var text = element.Content; var flavor = "html"; var processedText = ApplyHtmlFilters(text, flavor); context.ElementShape.ProcessedText = processedText; }
protected override void OnDisplaying(TextArea element, ElementDisplayContext context) { context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData()); context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode }); context.ElementShape.ProcessedValue = element.RuntimeValue; }
private void Displaying(ElementDisplayContext context, Element element) { var drivers = _elementManager.Value.GetDrivers(element); foreach (var driver in drivers) { driver.Displaying(context); } }
protected override void OnDisplaying(MediaItem element, ElementDisplayContext context) { var contentItemIds = RemoveCurrentContentItemId(element.MediaItemIds, context.Content.Id); var displayType = context.DisplayType != "Design" ? element.DisplayType : "Thumbnail"; var contentItems = GetContentItems(contentItemIds).ToArray(); var contentItemShapes = contentItems.Select(x => _contentManager.BuildDisplay(x, displayType)).ToArray(); context.ElementShape.ContentItems = contentItemShapes; }
protected override void OnDisplaying(Enumeration element, ElementDisplayContext context) { var tokenizedOptions = _tokenizer.Replace(element.Options).ToArray(); var typeName = element.GetType().Name; var displayType = context.DisplayType; context.ElementShape.TokenizedOptions = tokenizedOptions; context.ElementShape.Metadata.Alternates.Add(String.Format("Elements_{0}__{1}", typeName, element.InputType)); context.ElementShape.Metadata.Alternates.Add(String.Format("Elements_{0}_{1}__{2}", typeName, displayType, element.InputType)); }
protected override void OnDisplaying(Taxonomy element, ElementDisplayContext context) { var taxonomyId = element.TaxonomyId; var typeName = element.GetType().Name; var displayType = context.DisplayType; context.ElementShape.TermOptions = GetTermOptions(element, taxonomyId).ToArray(); context.ElementShape.Metadata.Alternates.Add(String.Format("Elements_{0}__{1}", typeName, element.InputType)); context.ElementShape.Metadata.Alternates.Add(String.Format("Elements_{0}_{1}__{2}", typeName, displayType, element.InputType)); }
protected override void OnDisplaying(ContentItem element, ElementDisplayContext context) { var contentItemIds = context.Content != null?RemoveCurrentContentItemId(element.ContentItemIds, context.Content.Id) : element.ContentItemIds; var displayType = element.DisplayType; var contentItems = GetContentItems(contentItemIds).ToArray(); var contentItemShapes = contentItems.Select(x => _contentManager.BuildDisplay(x, displayType)).ToArray(); context.ElementShape.ContentItems = contentItemShapes; }
protected override void OnDisplaying(Query element, ElementDisplayContext context) { var queryId = element.QueryId; var typeName = element.GetType().Name; var category = element.Category.ToSafeName(); var displayType = context.DisplayType; context.ElementShape.Options = GetOptions(element, queryId).ToArray(); context.ElementShape.Metadata.Alternates.Add(String.Format("Elements_{0}__{1}", typeName, element.InputType)); context.ElementShape.Metadata.Alternates.Add(String.Format("Elements_{0}_{1}__{2}", typeName, displayType, element.InputType)); }
public static IDictionary <string, object> GetTokenData(this ElementDisplayContext context) { var data = new Dictionary <string, object>(); if (context.Content != null) { data["Content"] = context.Content.ContentItem; } return(data); }
protected override void OnDisplaying(Shape element, ElementDisplayContext context) { if (String.IsNullOrWhiteSpace(element.ShapeType)) { return; } var shape = _shapeFactory.Create(element.ShapeType); context.ElementShape.Shape = shape; }
protected override void OnDisplaying(ReCaptcha element, ElementDisplayContext context) { var workContext = _services.WorkContext; var currentSite = workContext.CurrentSite; var settings = currentSite.As <ReCaptchaSettingsPart>(); if (settings.TrustAuthenticatedUsers && workContext.CurrentUser != null) { return; } context.ElementShape.PublicKey = settings.PublicKey; }
protected override void OnDisplaying(Taxonomy element, ElementDisplayContext context) { var taxonomyId = element.TaxonomyId; var typeName = element.GetType().Name; var displayType = context.DisplayType; var tokenData = context.GetTokenData(); context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData); context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData); context.ElementShape.TermOptions = GetTermOptions(element, context.DisplayType, taxonomyId, tokenData).ToArray(); context.ElementShape.Metadata.Alternates.Add(String.Format("Elements_{0}__{1}", typeName, element.InputType)); context.ElementShape.Metadata.Alternates.Add(String.Format("Elements_{0}_{1}__{2}", typeName, displayType, element.InputType)); }
protected override void OnDisplaying(ReCaptcha element, ElementDisplayContext context) { var workContext = _services.WorkContext; var currentSite = workContext.CurrentSite; var settings = currentSite.As <ReCaptchaSettingsPart>(); if (settings.TrustAuthenticatedUsers && workContext.CurrentUser != null) { return; } context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData()); context.ElementShape.PublicKey = settings.PublicKey; }
protected override void OnDisplaying(Enumeration element, ElementDisplayContext context) { var typeName = element.GetType().Name; var displayType = context.DisplayType; var tokenData = context.GetTokenData(); context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData); context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode }); context.ElementShape.ProcessedOptions = _tokenizer.Replace(element.Options, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode }).ToArray(); context.ElementShape.Metadata.Alternates.Add(String.Format("Elements_{0}__{1}", typeName, element.InputType)); context.ElementShape.Metadata.Alternates.Add(String.Format("Elements_{0}_{1}__{2}", typeName, displayType, element.InputType)); }
private void Displaying(ElementDisplayContext context) { var contentItem = context.Content.ContentItem; var typeName = context.Element.Descriptor.TypeName; var contentField = contentItem.GetContentField(typeName); if ((contentItem.Id == 0 || context.DisplayType == "Design") && context.Updater != null) { // The content item hasn't been stored yet, so bind form values with the content field to represent actual Data. var controller = (Controller)context.Updater; var oldValueProvider = controller.ValueProvider; controller.ValueProvider = context.Element.Data.ToValueProvider(_cultureAccessor.Value.CurrentCulture); _contentFieldDisplay.Value.UpdateEditor(contentItem, contentField, context.Updater); _transactionManager.Value.Cancel(); controller.ValueProvider = oldValueProvider; } var contentFieldShape = _contentFieldDisplay.Value.BuildDisplay(contentItem, contentField, displayType: "Layout"); context.ElementShape.ContentField = contentFieldShape; }
protected override void OnDisplaying(TextField element, ElementDisplayContext context) { context.ElementShape.TokenizedValue = _tokenizer.Replace(element.RuntimeValue, null); }
protected override void OnDisplaying(ImageFileField element, ElementDisplayContext context) { context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData()); context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData()); context.ElementShape.ProcessedValue = _tokenizer.Replace(element.RuntimeValue, context.GetTokenData()); }
protected override void OnDisplaying(HiddenField element, ElementDisplayContext context) { context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData()); context.ElementShape.ProcessedValue = _tokenizer.Replace(element.Value, context.GetTokenData()); }
public virtual void Displaying(ElementDisplayContext context) { }
protected override void OnDisplaying(Fieldset element, ElementDisplayContext context) { context.ElementShape.ProcessedLegend = _tokenizer.Replace(element.Legend, context.GetTokenData()); }
protected override void OnDisplaying(MarkdownElement element, ElementDisplayContext context) { context.ElementShape.ProcessedContent = ToHtml(element.Content); }
protected override void OnDisplaying(FormElement element, ElementDisplayContext context) { context.ElementShape.Metadata.Wrappers.Add("FormElement_Wrapper"); context.ElementShape.Child.Add(New.PlaceChildContent(Source: context.ElementShape)); }