/// <summary> /// /// </summary> /// <param name="helper"></param> /// <param name="content"></param> /// <typeparam name="TModel"></typeparam> /// <returns></returns> public static IHtmlString EditorHelpSummary <TModel>(this HtmlHelper <TModel> helper, IContentData content) { if (PageIsInEditMode(helper) == false) { return(null); } var contentType = content.GetOriginalType(); if (IsBlockAndNotInPreview(helper, contentType)) { return(null); } IEnumerable <ModelMetadata> propertiesMeta = ModelMetadataProviders.Current.GetMetadataForType(() => content, contentType).Properties; IList <string> hints = new List <string>(); foreach (var propertyMetadata in propertiesMeta) { object showInSummaryObj; if (propertyMetadata.AdditionalValues.TryGetValue(MetadataConstants.EditorHelp.ShowInSummaryPropertyName, out showInSummaryObj) == false) { continue; } var showInSummary = (bool?)showInSummaryObj; if (showInSummary.GetValueOrDefault(true) == false) { continue; } object hintObj; if (propertyMetadata.AdditionalValues.TryGetValue(MetadataConstants.EditorHelp.HelpTextPropertyName, out hintObj) == false) { continue; } var hint = hintObj as string; if (string.IsNullOrWhiteSpace(hint)) { continue; } hints.Add(hint); } if (hints.Count > 0) { var tag = GetHintsTag(hints); return(new MvcHtmlString(tag.ToString())); } return(null); }
public ContentRenderingErrorModel(IContentData contentData, Exception exception) { var content = contentData as IContent; ContentName = content != null ? content.Name : string.Empty; ContentTypeName = contentData.GetOriginalType().Name; Exception = exception; }
public static bool HasTemplate(this IContentData contentData) { if (contentData == null) { return(false); } var templateRepository = ServiceLocator.Current.GetInstance <ITemplateRepository>(); return(templateRepository.List(contentData.GetOriginalType()).Any(x => x.TemplateTypeCategory.IsCategory(TemplateTypeCategories.Page))); }
/// <summary> /// /// </summary> /// <param name="helper"></param> /// <param name="content"></param> /// <param name="helpText"></param> /// <typeparam name="TModel"></typeparam> /// <returns></returns> public static IHtmlString EditorHelp <TModel>(this HtmlHelper <TModel> helper, IContentData content, string helpText) { if (!PageIsInEditMode(helper)) { return(null); } if (IsBlockAndNotInPreview(helper, content.GetOriginalType())) { return(null); } return(MvcHtmlString.Create(GetHintsTag(helpText).ToString())); }
public IEnumerable <PropertyInfo> GetProperties(IContentData contentData) { var type = contentData.GetOriginalType(); if (_cachedContentTypes.ContainsKey(type)) { return(_cachedContentTypes[type]); } var properties = type.GetProperties().Where(ShouldBeIncluded).ToList(); _cachedContentTypes[type] = properties; return(properties); }
public ContentRenderingErrorModel(IContentData contentData, Exception exception) { if (contentData is IContent content) { ContentName = content.Name; } else { ContentName = string.Empty; } ContentTypeName = contentData.GetOriginalType().Name; Exception = exception; }
public ContentRenderingErrorModel(IContentData contentData, Exception exception) { var content = contentData as IContent; if(content != null) { ContentName = content.Name; } else { ContentName = string.Empty; } ContentTypeName = contentData.GetOriginalType().Name; Exception = exception; }
public object Execute(PropertyInfo property, IContentData contentData, ISelectionFactory selectionFactory) { var result = (IEnumerable <SelectOption>) this._defaultSelectManyStrategy.Execute(property, contentData, selectionFactory); var type = contentData.GetOriginalType(); if (IsCustomContentType(type, property.Name)) { var onlyValue = CustomProperties[type][property.Name]; if (onlyValue) { return(result.Where(x => x.Selected).Select(x => x.Value)); } return(result.Where(x => x.Selected)); } return(result); }
public static void RenderContentData(HtmlHelper html, IContentData content, string tag) { var templateResolver = ServiceLocator.Current.GetInstance <TemplateResolver>(); var templateModel = templateResolver.Resolve( html.ViewContext.HttpContext, content.GetOriginalType(), content, TemplateTypeCategories.MvcPartial, tag); var contentRenderer = ServiceLocator.Current.GetInstance <IContentRenderer>(); html.RenderContentData( content, true, templateModel, contentRenderer); }
/// <summary> /// Render edit buttons for <see cref="IContentData"/> instance. /// </summary> /// <param name="helper"></param> /// <param name="content"></param> /// <param name="includeBuiltInProperties">If true, also renders edit button for built-in Category property.</param> /// <typeparam name="TModel"></typeparam> /// <returns></returns> public static IHtmlString EditButtonsGroup <TModel>(this HtmlHelper <TModel> helper, IContentData content, bool includeBuiltInProperties = false) { if (PageIsInEditMode(helper) == false) { return(null); } var contentType = content.GetOriginalType(); if (IsBlockAndNotInPreview(helper, contentType)) { return(null); } IEnumerable <ModelMetadata> propertiesMeta = ModelMetadataProviders.Current.GetMetadataForType(() => content, contentType).Properties; IList <string> iconCssDivs = new List <string>(); IList <string> fullRefreshPropertyNames = new List <string>(); foreach (var propertyMetadata in propertiesMeta) { object showInGroupObj; if (propertyMetadata.ShowForEdit == false || propertyMetadata.AdditionalValues.TryGetValue(MetadataConstants.EditButton.ShowInGroupPropertyName, out showInGroupObj) == false) { continue; } var showInGroup = (bool?)showInGroupObj; if (showInGroup.GetValueOrDefault(true) == false) { continue; } object iconCssClassObj; propertyMetadata.AdditionalValues.TryGetValue(MetadataConstants.EditButton.IconCssClassPropertyName, out iconCssClassObj); var iconCssClass = iconCssClassObj as string; bool triggerFullRefresh; if (propertyMetadata.TryGetAdditionalValue(MetadataConstants.EditButton.TriggerFullRefreshPropertyName, out triggerFullRefresh) == false) { triggerFullRefresh = true; } if (triggerFullRefresh) { fullRefreshPropertyNames.Add(propertyMetadata.PropertyName); } var editButtonHtml = GetEditButtonTag(helper, propertyMetadata.PropertyName, propertyMetadata.AdditionalValues[MetadataConstants.EditButton.ButtonLabel] as string ?? propertyMetadata.DisplayName ?? propertyMetadata.PropertyName, iconCssClass); iconCssDivs.Add(editButtonHtml); } if (includeBuiltInProperties) { var categorizableContent = content as ICategorizable; if (categorizableContent != null) { iconCssDivs.Add(GetSpecialEditButtonTag("Category", LocalizationService.Current.GetString("/contenttypes/icontentdata/properties/icategorizable_category/caption"), null)); fullRefreshPropertyNames.Add("icategorizable_category"); } var pageContent = content as PageData; if (pageContent != null) { iconCssDivs.Add(GetSpecialEditButtonTag("PageExternalURL", LocalizationService.Current.GetString("/contenttypes/icontentdata/properties/pageexternalurl/caption"), null)); } var routable = content as IRoutable; if (routable != null) { iconCssDivs.Add(GetSpecialEditButtonTag("iroutable_routesegment", LocalizationService.Current.GetString("/contenttypes/icontentdata/properties/pageurlsegment/caption"), null)); } if (pageContent != null) { iconCssDivs.Add(GetSpecialEditButtonTag("PageVisibleInMenu", LocalizationService.Current.GetString("/contenttypes/icontentdata/properties/pagevisibleinmenu/caption"), null)); } var versionableContent = content as IVersionable; if (versionableContent != null) { iconCssDivs.Add(GetSpecialEditButtonTag("iversionable_startpublish", LocalizationService.Current.GetString("/contenttypes/icontentdata/properties/iversionable_startpublish/caption"), null)); } var changeTrackableContent = content as IChangeTrackable; if (changeTrackableContent != null) { iconCssDivs.Add(GetSpecialEditButtonTag("ichangetrackable_setchangedonpublish", LocalizationService.Current.GetString("/contenttypes/icontentdata/properties/ichangetrackable_setchangedonpublish/caption"), null)); } } if (iconCssDivs.Count > 0) { var container = new TagBuilder("div"); container.AddCssClass("editor-buttons"); foreach (var iconCssDiv in iconCssDivs) { container.InnerHtml += iconCssDiv; } return(MvcHtmlString.Create(container.ToString() + helper.FullRefreshPropertiesMetaData(fullRefreshPropertyNames.ToArray()))); } return(null); }