private void TemplateControl_DataBinding(object sender, EventArgs e) { var literal = (Literal)sender; var container = (RepeaterItem)literal.NamingContainer; var itemInfo = new DbItemInfo(container.DataItem, container.ItemIndex); if (_contextType == EContextType.Channel) { var channelItemInfo = new ChannelItemInfo(SqlUtils.EvalInt(container.DataItem, ChannelAttribute.Id), container.ItemIndex); _pageInfo.ChannelItems.Push(channelItemInfo); literal.Text = TemplateUtility.GetChannelsItemTemplateString(_templateString, _selectedItems, _selectedValues, container.ClientID, _pageInfo, _contextType, _contextInfo); } else if (_contextType == EContextType.Content) { var contentItemInfo = new ContentItemInfo(SqlUtils.EvalInt(container.DataItem, ContentAttribute.ChannelId), SqlUtils.EvalInt(container.DataItem, ContentAttribute.Id), container.ItemIndex); _pageInfo.ContentItems.Push(contentItemInfo); literal.Text = TemplateUtility.GetContentsItemTemplateString(_templateString, _selectedItems, _selectedValues, container.ClientID, _pageInfo, _contextType, _contextInfo); } else if (_contextType == EContextType.Comment) { _pageInfo.CommentItems.Push(itemInfo); literal.Text = TemplateUtility.GetCommentsTemplateString(_templateString, container.ClientID, _pageInfo, _contextType, _contextInfo); } //else if (_contextType == EContextType.InputContent) //{ // _pageInfo.InputItems.Push(itemInfo); // literal.Text = TemplateUtility.GetInputContentsTemplateString(_templateString, container.ClientID, _pageInfo, _contextType, _contextInfo); //} else if (_contextType == EContextType.SqlContent) { _pageInfo.SqlItems.Push(itemInfo); literal.Text = TemplateUtility.GetSqlContentsTemplateString(_templateString, _selectedItems, _selectedValues, container.ClientID, _pageInfo, _contextType, _contextInfo); } else if (_contextType == EContextType.Site) { _pageInfo.SiteItems.Push(itemInfo); literal.Text = TemplateUtility.GetSitesTemplateString(_templateString, container.ClientID, _pageInfo, _contextType, _contextInfo); } else if (_contextType == EContextType.Each) { _pageInfo.EachItems.Push(itemInfo); literal.Text = TemplateUtility.GetEachsTemplateString(_templateString, _selectedItems, _selectedValues, container.ClientID, _pageInfo, _contextType, _contextInfo); } if (_separatorRepeat > 1) { _i++; if (_i % _separatorRepeat == 0) { literal.Text += _separatorRepeatTemplate; } } }
public void AddContentItem( ContentItemInfo itemInfo ) { Console.WriteLine("AddContentItem at index:" + itemsCount ); contentItemsArray[itemsCount++] = itemInfo; ImageView imageView = new ImageView(); ImageVisual imageVisual = new ImageVisual(); // Categories to be the height of the ContentPane whilst having a fixed width imageVisual.URL = itemInfo.imageUrl; imageView.Image = imageVisual.OutputVisualMap; imageView.LayoutWidthSpecificationFixed = 1000; imageView.LayoutHeightSpecification = ChildLayoutData.MatchParent; imageView.Padding = new Extents(40, 40, 0, 0); imageView.Name = "ImageView_" + itemInfo.imageUrl; Add(imageView); }
public static string GetContentsItemTemplateString(string templateString, NameValueCollection selectedItems, NameValueCollection selectedValues, string containerClientId, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfoRef) { var itemContainer = DbItemContainer.GetItemContainer(pageInfo); //var contentInfo = new BackgroundContentInfo(itemContainer.ContentItem.DataItem); ContentItemInfo contentItemInfo = null; if (pageInfo.ContentItems.Count > 0) { contentItemInfo = pageInfo.ContentItems.Peek(); } if (contentItemInfo == null) { return(string.Empty); } var contentInfo = ContentManager.GetContentInfo(pageInfo.SiteInfo, contentItemInfo.ChannelId, contentItemInfo.ContentId); var contextInfo = contextInfoRef.Clone(); contextInfo.ContextType = contextType; contextInfo.ItemContainer = itemContainer; contextInfo.ContainerClientId = containerClientId; contextInfo.ChannelId = contentInfo.ChannelId; contextInfo.ContentId = contentInfo.Id; contextInfo.ContentInfo = contentInfo; var preSiteInfo = pageInfo.SiteInfo; var prePageChannelId = pageInfo.PageChannelId; var prePageContentId = pageInfo.PageContentId; if (contentInfo.SiteId != pageInfo.SiteId) { var siteInfo = SiteManager.GetSiteInfo(contentInfo.SiteId); if (siteInfo != null) { contextInfo.SiteInfo = siteInfo; pageInfo.ChangeSite(siteInfo, siteInfo.Id, 0, contextInfo); } } var theTemplateString = string.Empty; if (selectedItems != null && selectedItems.Count > 0) { foreach (var itemTypes in selectedItems.AllKeys) { var itemTypeArrayList = TranslateUtils.StringCollectionToStringList(itemTypes); var isTrue = true; foreach (var itemType in itemTypeArrayList) { if (!IsContentTemplateString(itemType, itemTypes, ref theTemplateString, selectedItems, selectedValues, pageInfo, contextInfo)) { isTrue = false; } } if (isTrue) { break; } theTemplateString = string.Empty; } } if (string.IsNullOrEmpty(theTemplateString)) { theTemplateString = templateString; } var innerBuilder = new StringBuilder(theTemplateString); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); DbItemContainer.PopContentItem(pageInfo); if (contentInfo.SiteId != pageInfo.SiteId) { pageInfo.ChangeSite(preSiteInfo, prePageChannelId, prePageContentId, contextInfoRef); } return(innerBuilder.ToString()); }