public ItemInspector(IContent item, ContentItemMetadata metadata) { _item = item; _metadata = metadata; _common = item.Get<ICommonAspect>(); _routable = item.Get<RoutableAspect>(); _body = item.Get<BodyAspect>(); }
public ItemInspector(IContent item, ContentItemMetadata metadata, IEnumerable<IHtmlFilter> htmlFilters) { _item = item; _metadata = metadata; _htmlFilters = htmlFilters; _common = item.Get<ICommonPart>(); _titleAspect = item.Get<ITitleAspect>(); _body = item.Get<BodyPart>(); }
public void PropertyWrapper( dynamic Display, TextWriter Output, HtmlHelper Html, UrlHelper Url, dynamic Item, ContentItem ContentItem, ContentItemMetadata ContentItemMetadata, PropertyRecord Property ) { // Display will encode any string which is not IHtmlString string resultOutput = Convert.ToString(Display(Item)); var resultIsEmpty = String.IsNullOrEmpty(resultOutput) || (resultOutput == "0" && Property.ZeroIsEmpty); if(Property.HideEmpty && resultIsEmpty) { return; } if(Property.RewriteOutput) { resultOutput = _tokenizerWork.Value.Replace(Property.RewriteText, new Dictionary<string, object> { { "Text", resultOutput }, { "Content", ContentItem } }); } if(Property.StripHtmlTags) { resultOutput = resultOutput.RemoveTags(); } if(Property.TrimLength) { var ellipsis = Property.AddEllipsis ? " …" : ""; resultOutput = resultOutput.Ellipsize(Property.MaxLength, ellipsis, Property.TrimOnWordBoundary); } if(Property.TrimWhiteSpace) { resultOutput = resultOutput.Trim(); } if(Property.PreserveLines) { using(var sw = new StringWriter()) { using(var sr = new StringReader(resultOutput)) { string line; while(null != (line = sr.ReadLine())) { sw.WriteLine(line); sw.WriteLine("<br />"); } } resultOutput = sw.ToString(); } } var wrapperTag = new TagBuilder(Property.CustomizeWrapperHtml && !String.IsNullOrEmpty(Property.CustomWrapperTag) ? Property.CustomWrapperTag : "div"); if (Property.CustomizeWrapperHtml && !String.IsNullOrEmpty(Property.CustomWrapperCss)) { wrapperTag.AddCssClass(_tokenizerWork.Value.Replace(Property.CustomWrapperCss, new Dictionary<string, object>())); } if (!(Property.CustomizeWrapperHtml && Property.CustomWrapperTag == "-")) { Output.Write(wrapperTag.ToString(TagRenderMode.StartTag)); } if (Property.CreateLabel) { var labelTag = new TagBuilder(Property.CustomizeLabelHtml && !String.IsNullOrEmpty(Property.CustomLabelTag) ? Property.CustomLabelTag : "span"); if (Property.CustomizeLabelHtml && !String.IsNullOrEmpty(Property.CustomLabelCss)) { labelTag.AddCssClass(_tokenizerWork.Value.Replace(Property.CustomLabelCss, new Dictionary<string, object>())); } if (!(Property.CustomizeLabelHtml && Property.CustomLabelTag == "-")) { Output.Write(labelTag.ToString(TagRenderMode.StartTag)); } Output.Write(_tokenizerWork.Value.Replace(Property.Label, new Dictionary<string, object>())); if (!(Property.CustomizeLabelHtml && Property.CustomLabelTag == "-")) { Output.Write(labelTag.ToString(TagRenderMode.EndTag)); } } var propertyTag = new TagBuilder(Property.CustomizePropertyHtml && !String.IsNullOrEmpty(Property.CustomPropertyTag) ? Property.CustomPropertyTag : "span"); if (Property.CustomizePropertyHtml && !String.IsNullOrEmpty(Property.CustomPropertyCss)) { propertyTag.AddCssClass(_tokenizerWork.Value.Replace(Property.CustomPropertyCss, new Dictionary<string, object>())); } if (!(Property.CustomizePropertyHtml && Property.CustomPropertyTag == "-")) { Output.Write(propertyTag.ToString(TagRenderMode.StartTag)); } if (!resultIsEmpty) { if (Property.LinkToContent) { var linkTag = new TagBuilder("a"); linkTag.Attributes.Add("href", Url.RouteUrl(ContentItemMetadata.DisplayRouteValues)); linkTag.InnerHtml = resultOutput; Output.Write(linkTag.ToString()); } else { Output.Write(resultOutput); } } else { Output.Write(_tokenizerWork.Value.Replace(Property.NoResultText, new Dictionary<string, object>())); } if (!(Property.CustomizePropertyHtml && Property.CustomPropertyTag == "-")) { Output.Write(propertyTag.ToString(TagRenderMode.EndTag)); } if (!(Property.CustomizeWrapperHtml && Property.CustomWrapperTag == "-")) { Output.Write(wrapperTag.ToString(TagRenderMode.EndTag)); } }
public ItemInspector(IContent item, ContentItemMetadata metadata) : this(item, metadata, Enumerable.Empty<IHtmlFilter>()) {}
protected virtual void GetContentItemMetadata(SocketsPart part, ContentItemMetadata metadata) { return; }