예제 #1
0
        public static string GetContentsItemTemplateString(string templateString, LowerNameValueCollection selectedItems, LowerNameValueCollection selectedValues, string containerClientID, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfoRef)
        {
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);
            var contentInfo   = new BackgroundContentInfo(itemContainer.ContentItem.DataItem);

            var contextInfo = contextInfoRef.Clone();

            contextInfo.ContextType       = contextType;
            contextInfo.ItemContainer     = itemContainer;
            contextInfo.ContainerClientID = containerClientID;
            contextInfo.ChannelID         = contentInfo.NodeId;
            contextInfo.ContentID         = contentInfo.Id;
            contextInfo.ContentInfo       = contentInfo;

            var theTemplateString = string.Empty;

            if (selectedItems != null && selectedItems.Count > 0)
            {
                foreach (string itemTypes in selectedItems.Keys)
                {
                    var itemTypeArrayList = TranslateUtils.StringCollectionToStringList(itemTypes);
                    var isTrue            = true;
                    foreach (string itemType in itemTypeArrayList)
                    {
                        if (!IsContentTemplateString(itemType, itemTypes, ref theTemplateString, selectedItems, selectedValues, pageInfo, contextInfo))
                        {
                            isTrue = false;
                        }
                    }
                    if (isTrue)
                    {
                        break;
                    }
                    else
                    {
                        theTemplateString = string.Empty;
                    }
                }
            }

            if (string.IsNullOrEmpty(theTemplateString))
            {
                theTemplateString = templateString;
            }

            var innerBuilder = new StringBuilder(theTemplateString);

            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);

            DbItemContainer.PopContentItem(pageInfo);

            return(innerBuilder.ToString());
        }
예제 #2
0
        public static async Task <string> GetContentsItemTemplateStringAsync(string templateString, NameValueCollection selectedItems, NameValueCollection selectedValues, string containerClientId, IParseManager parseManager, ParseType contextType)
        {
            var context = parseManager.ContextInfo;

            var pageInfo      = parseManager.PageInfo;
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);
            var content       = itemContainer.ContentItem.Value;

            parseManager.ContextInfo                   = parseManager.ContextInfo.Clone();
            parseManager.ContextInfo.ContextType       = contextType;
            parseManager.ContextInfo.ItemContainer     = itemContainer;
            parseManager.ContextInfo.ContainerClientId = containerClientId;
            parseManager.ContextInfo.ChannelId         = content.ChannelId;
            parseManager.ContextInfo.ContentId         = content.Id;
            parseManager.ContextInfo.SetContent(content);

            var preSite          = pageInfo.Site;
            var prePageChannelId = pageInfo.PageChannelId;
            var prePageContentId = pageInfo.PageContentId;

            if (content.SiteId != pageInfo.SiteId)
            {
                var siteInfo = await parseManager.DatabaseManager.SiteRepository.GetAsync(content.SiteId);

                parseManager.ContextInfo.Site = siteInfo;
                pageInfo.ChangeSite(siteInfo, siteInfo.Id, 0, parseManager.ContextInfo);
            }

            var theTemplateString = string.Empty;

            if (selectedItems != null && selectedItems.Count > 0)
            {
                foreach (var itemTypes in selectedItems.AllKeys)
                {
                    var itemTypeArrayList = ListUtils.GetStringList(itemTypes);
                    var isTrue            = true;
                    foreach (var itemType in itemTypeArrayList)
                    {
                        var(success, contentTemplateString) = await IsContentTemplateStringAsync(itemType, itemTypes,
                                                                                                 selectedItems, selectedValues, parseManager);

                        if (!success)
                        {
                            isTrue = false;
                        }
                        else
                        {
                            theTemplateString = contentTemplateString;
                        }
                    }
                    if (isTrue)
                    {
                        break;
                    }
                    theTemplateString = string.Empty;
                }
            }

            if (string.IsNullOrEmpty(theTemplateString))
            {
                theTemplateString = templateString;
            }

            var innerBuilder = new StringBuilder(theTemplateString);
            await parseManager.ParseInnerContentAsync(innerBuilder);

            DbItemContainer.PopContentItem(pageInfo);

            if (content.SiteId != pageInfo.SiteId)
            {
                pageInfo.ChangeSite(preSite, prePageChannelId, prePageContentId, parseManager.ContextInfo);
            }

            parseManager.ContextInfo = context;

            return(innerBuilder.ToString());
        }
예제 #3
0
        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());
        }