예제 #1
0
        public static string GetChannelsItemTemplateString(string templateString, NameValueCollection selectedItems, NameValueCollection selectedValues, string containerClientId, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfoRef)
        {
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);

            var channelId = itemContainer.ChannelItem.ChannelId;

            var contextInfo = contextInfoRef.Clone();

            contextInfo.ContextType       = contextType;
            contextInfo.ItemContainer     = itemContainer;
            contextInfo.ContainerClientId = containerClientId;
            contextInfo.ChannelId         = channelId;

            var nodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, channelId);

            if (selectedItems != null && selectedItems.Count > 0)
            {
                foreach (var itemType in selectedItems.AllKeys)
                {
                    if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedCurrent))//当前栏目
                    {
                        if (channelId == pageInfo.PageChannelId)
                        {
                            templateString = selectedItems.Get(itemType);
                            break;
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedImage))//带有图片的栏目
                    {
                        if (!string.IsNullOrEmpty(nodeInfo.ImageUrl))
                        {
                            templateString = selectedItems.Get(itemType);
                            break;
                        }
                    }
                    else if (StringUtils.StartsWithIgnoreCase(itemType, StlItemTemplate.SelectedUp))//当前栏目的上级栏目
                    {
                        var upLevel = StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedUp) ? 1 : TranslateUtils.ToInt(itemType.Substring(2));
                        if (upLevel > 0)
                        {
                            var theChannelId = StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, pageInfo.PageChannelId, upLevel, -1);
                            if (channelId == theChannelId)
                            {
                                templateString = selectedItems.Get(itemType);
                                break;
                            }
                        }
                    }
                    else if (StringUtils.StartsWithIgnoreCase(itemType, StlItemTemplate.SelectedTop))//当前栏目从首页向下的上级栏目栏目
                    {
                        var topLevel = StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedTop) ? 1 : TranslateUtils.ToInt(itemType.Substring(3));
                        if (topLevel >= 0)
                        {
                            var theChannelId = StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, pageInfo.PageChannelId, 0, topLevel);
                            if (channelId == theChannelId)
                            {
                                templateString = selectedItems.Get(itemType);
                                break;
                            }
                        }
                    }
                    else if (IsNumberInRange(itemContainer.ChannelItem.ItemIndex + 1, itemType))
                    {
                        templateString = selectedItems.Get(itemType);
                        break;
                    }
                }
            }

            var innerBuilder = new StringBuilder(templateString);

            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);

            DbItemContainer.PopChannelItem(pageInfo);

            return(innerBuilder.ToString());
        }
예제 #2
0
        public static string GetChannelsItemTemplateString(string templateString, LowerNameValueCollection selectedItems, LowerNameValueCollection selectedValues, string containerClientID, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfoRef)
        {
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);

            var nodeID = SqlUtils.EvalInt(itemContainer.ChannelItem.DataItem, NodeAttribute.NodeId);

            var contextInfo = contextInfoRef.Clone();

            contextInfo.ContextType       = contextType;
            contextInfo.ItemContainer     = itemContainer;
            contextInfo.ContainerClientID = containerClientID;
            contextInfo.ChannelID         = nodeID;

            var nodeInfo = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, nodeID);

            if (selectedItems != null && selectedItems.Count > 0)
            {
                foreach (string itemType in selectedItems.Keys)
                {
                    if (itemType == StlItem.ChannelsItem.Selected_Current)//当前栏目
                    {
                        if (nodeID == pageInfo.PageNodeId)
                        {
                            templateString = selectedItems[itemType];
                            break;
                        }
                    }
                    else if (itemType == StlItem.ChannelsItem.Selected_Image)//带有图片的栏目
                    {
                        if (!string.IsNullOrEmpty(nodeInfo.ImageUrl))
                        {
                            templateString = selectedItems[itemType];
                            break;
                        }
                    }
                    else if (itemType.StartsWith(StlItem.ChannelsItem.Selected_Up))//当前栏目的上级栏目
                    {
                        var upLevel = 1;
                        if (itemType == StlItem.ChannelsItem.Selected_Up)
                        {
                            upLevel = 1;
                        }
                        else
                        {
                            upLevel = TranslateUtils.ToInt(itemType.Substring(2));
                        }
                        if (upLevel > 0)
                        {
                            var theNodeID = StlDataUtility.GetNodeIdByLevel(pageInfo.PublishmentSystemId, pageInfo.PageNodeId, upLevel, -1);
                            if (nodeID == theNodeID)
                            {
                                templateString = selectedItems[itemType];
                                break;
                            }
                        }
                    }
                    else if (itemType.StartsWith(StlItem.ChannelsItem.Selected_Top))//当前栏目从首页向下的上级栏目栏目
                    {
                        var topLevel = 1;
                        if (itemType == StlItem.ChannelsItem.Selected_Top)
                        {
                            topLevel = 1;
                        }
                        else
                        {
                            topLevel = TranslateUtils.ToInt(itemType.Substring(3));
                        }
                        if (topLevel >= 0)
                        {
                            var theNodeID = StlDataUtility.GetNodeIdByLevel(pageInfo.PublishmentSystemId, pageInfo.PageNodeId, 0, topLevel);
                            if (nodeID == theNodeID)
                            {
                                templateString = selectedItems[itemType];
                                break;
                            }
                        }
                    }
                    else if (IsNumberInRange(itemContainer.ChannelItem.ItemIndex + 1, itemType))
                    {
                        templateString = selectedItems[itemType];
                        break;
                    }
                }
            }

            var innerBuilder = new StringBuilder(templateString);

            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);

            DbItemContainer.PopChannelItem(pageInfo);

            return(innerBuilder.ToString());
        }