Example #1
0
        public static string GetEachsTemplateString(string templateString, LowerNameValueCollection selectedItems, LowerNameValueCollection selectedValues, string containerClientID, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfoRef)
        {
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);

            var contextInfo = contextInfoRef.Clone();

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

            if (selectedItems != null && selectedItems.Count > 0)
            {
                foreach (string itemType in selectedItems.Keys)
                {
                    if (IsNumberInRange(itemContainer.SqlItem.ItemIndex + 1, itemType))
                    {
                        templateString = selectedItems[itemType];
                        break;
                    }
                }
            }

            var innerBuilder = new StringBuilder(templateString);

            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);

            DbItemContainer.PopEachItem(pageInfo);

            return(innerBuilder.ToString());
        }
Example #2
0
        public static LowerNameValueCollection GetAttributes(string stlElement, bool isInnerElement)
        {
            var attributes = new LowerNameValueCollection();

            try
            {
                var     xmlDocument = GetXmlDocument(stlElement, isInnerElement);
                XmlNode node        = xmlDocument.DocumentElement;
                if (node != null)
                {
                    node = node.FirstChild;

                    if (node.Attributes != null)
                    {
                        foreach (XmlAttribute attribute in node.Attributes)
                        {
                            attributes.Set(attribute.Name, attribute.Value);
                        }
                    }
                }
            }
            catch
            {
                // ignored
            }
            return(attributes);
        }
Example #3
0
        //TODO:测试
        public static string GetInnerXml(string stlElement, bool isInnerElement, LowerNameValueCollection attributes)
        {
            var retval = string.Empty;

            try
            {
                var     xmlDocument = GetXmlDocument(stlElement, isInnerElement);
                XmlNode node        = xmlDocument.DocumentElement;
                if (node != null)
                {
                    node   = node.FirstChild;
                    retval = node.InnerXml;

                    if (attributes != null && node.Attributes != null)
                    {
                        foreach (XmlAttribute attribute in node.Attributes)
                        {
                            attributes.Set(attribute.Name, attribute.Value);
                        }
                    }
                }
            }
            catch
            {
                // ignored
            }
            return(retval);
        }
Example #4
0
 public RepeaterTemplate(string templateString, LowerNameValueCollection selectedItems, LowerNameValueCollection selectedValues, string separatorRepeatTemplate, int separatorRepeat, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfo)
 {
     this.templateString          = templateString;
     this.selectedItems           = selectedItems;
     this.selectedValues          = selectedValues;
     this.separatorRepeatTemplate = separatorRepeatTemplate;
     this.separatorRepeat         = separatorRepeat;
     this.pageInfo    = pageInfo;
     this.contextType = contextType;
     this.contextInfo = contextInfo;
 }
 public DataListTemplate(string templateString, LowerNameValueCollection selectedItems, LowerNameValueCollection selectedValues, string separatorRepeatTemplate, int separatorRepeat, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfo)
 {
     _templateString          = templateString;
     _selectedItems           = selectedItems;
     _selectedValues          = selectedValues;
     _separatorRepeatTemplate = separatorRepeatTemplate;
     _separatorRepeat         = separatorRepeat;
     _contextType             = contextType;
     _contextInfo             = contextInfo;
     _pageInfo = pageInfo;
 }
Example #6
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());
        }
Example #7
0
        public static string ToAttributesString(LowerNameValueCollection attributes)
        {
            var builder = new StringBuilder();

            if (attributes != null && attributes.Count > 0)
            {
                foreach (var key in attributes.Keys)
                {
                    var value = attributes.Get(key);
                    if (!string.IsNullOrEmpty(value))
                    {
                        value = value.Replace("\"", "'");
                    }
                    builder.Append($@"{key}=""{value}"" ");
                }
                builder.Length--;
            }
            return(builder.ToString());
        }
Example #8
0
 private static bool IsContentTemplateString(string itemType, string itemTypes, ref string templateString, LowerNameValueCollection selectedItems, LowerNameValueCollection selectedValues, PageInfo pageInfo, ContextInfo contextInfo)
 {
     if (itemType == StlItem.ContentsItem.Selected_Current)//当前内容
     {
         if (contextInfo.ContentInfo.Id == pageInfo.PageContentId)
         {
             templateString = selectedItems[itemTypes];
             return(true);
         }
     }
     else if (itemType == StlItem.ContentsItem.Selected_IsTop)//置顶内容
     {
         if (contextInfo.ContentInfo.IsTop)
         {
             templateString = selectedItems[itemTypes];
             return(true);
         }
     }
     else if (itemType == StlItem.ContentsItem.Selected_Image)//带图片的内容
     {
         if (!string.IsNullOrEmpty(contextInfo.ContentInfo.GetExtendedAttribute(BackgroundContentAttribute.ImageUrl)))
         {
             templateString = selectedItems[itemTypes];
             return(true);
         }
     }
     else if (itemType == StlItem.ContentsItem.Selected_Video)//带视频的内容
     {
         if (!string.IsNullOrEmpty(contextInfo.ContentInfo.GetExtendedAttribute(BackgroundContentAttribute.VideoUrl)))
         {
             templateString = selectedItems[itemTypes];
             return(true);
         }
     }
     else if (itemType == StlItem.ContentsItem.Selected_File)//带附件的内容
     {
         if (!string.IsNullOrEmpty(contextInfo.ContentInfo.GetExtendedAttribute(BackgroundContentAttribute.FileUrl)))
         {
             templateString = selectedItems[itemTypes];
             return(true);
         }
     }
     else if (itemType == StlItem.ContentsItem.Selected_IsRecommend)//推荐的内容
     {
         if (TranslateUtils.ToBool(contextInfo.ContentInfo.GetExtendedAttribute(BackgroundContentAttribute.IsRecommend)))
         {
             templateString = selectedItems[itemTypes];
             return(true);
         }
     }
     else if (itemType == StlItem.ContentsItem.Selected_IsHot)//热点内容
     {
         if (TranslateUtils.ToBool(contextInfo.ContentInfo.GetExtendedAttribute(BackgroundContentAttribute.IsHot)))
         {
             templateString = selectedItems[itemTypes];
             return(true);
         }
     }
     else if (itemType == StlItem.ContentsItem.Selected_IsColor)//醒目内容
     {
         if (TranslateUtils.ToBool(contextInfo.ContentInfo.GetExtendedAttribute(BackgroundContentAttribute.IsColor)))
         {
             templateString = selectedItems[itemTypes];
             return(true);
         }
     }
     else if (itemType == StlItem.ContentsItem.Selected_ChannelName)//带有附件的内容
     {
         if (selectedValues.Count > 0)
         {
             var nodeInfo = NodeManager.GetNodeInfo(contextInfo.ContentInfo.PublishmentSystemId, contextInfo.ContentInfo.NodeId);
             if (nodeInfo != null)
             {
                 if (selectedValues[nodeInfo.NodeName] != null)
                 {
                     templateString = selectedValues[nodeInfo.NodeName];
                     return(true);
                 }
             }
         }
     }
     else if (IsNumberInRange(contextInfo.ItemContainer.ContentItem.ItemIndex + 1, itemType))
     {
         templateString = selectedItems[itemTypes];
         return(true);
     }
     return(false);
 }
Example #9
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());
        }
Example #10
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);

            ContentItemInfo contentItemInfo = null;

            if (pageInfo.ContentItems.Count > 0)
            {
                contentItemInfo = pageInfo.ContentItems.Peek();
            }
            if (contentItemInfo == null)
            {
                return(string.Empty);
            }
            var contentInfo = Cache.Content.GetContentInfo(pageInfo.SiteId, 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);
                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.Keys)
                {
                    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());
        }
Example #11
0
        public static ListInfo GetListInfoByXmlNode(XmlNode node, PageInfo pageInfo, ContextInfo contextInfo, EContextType contextType)
        {
            var listInfo = new ListInfo
            {
                _contextType = contextType
            };

            var innerXml     = node.InnerXml;
            var itemTemplate = string.Empty;

            if (!string.IsNullOrEmpty(innerXml))
            {
                var stlElementList = StlParserUtility.GetStlElementList(innerXml);
                if (stlElementList.Count > 0)
                {
                    foreach (var theStlElement in stlElementList)
                    {
                        if (StlParserUtility.IsSpecifiedStlElement(theStlElement, StlItemTemplate.ElementName))
                        {
                            var attributes     = new LowerNameValueCollection();
                            var templateString = StlParserUtility.GetInnerXml(theStlElement, true, attributes);
                            if (!string.IsNullOrEmpty(templateString))
                            {
                                foreach (var key in attributes.Keys)
                                {
                                    if (!StringUtils.EqualsIgnoreCase(key, StlItemTemplate.AttributeType))
                                    {
                                        continue;
                                    }

                                    var type = attributes.Get(key);
                                    if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeItem))
                                    {
                                        itemTemplate = templateString;
                                    }
                                    else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeHeader))
                                    {
                                        listInfo.HeaderTemplate = templateString;
                                    }
                                    else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeFooter))
                                    {
                                        listInfo.FooterTemplate = templateString;
                                    }
                                    else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeAlternatingItem))
                                    {
                                        listInfo.AlternatingItemTemplate = templateString;
                                    }
                                    else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeSelectedItem))
                                    {
                                        if (!string.IsNullOrEmpty(attributes.Get(StlItemTemplate.AttributeSelected)))
                                        {
                                            var selected  = attributes.Get(StlItemTemplate.AttributeSelected);
                                            var arraylist = new ArrayList();
                                            if (selected.IndexOf(',') != -1)
                                            {
                                                arraylist.AddRange(selected.Split(','));
                                            }
                                            else
                                            {
                                                if (selected.IndexOf('-') != -1)
                                                {
                                                    var first  = TranslateUtils.ToInt(selected.Split('-')[0]);
                                                    var second = TranslateUtils.ToInt(selected.Split('-')[1]);
                                                    for (var i = first; i <= second; i++)
                                                    {
                                                        arraylist.Add(i.ToString());
                                                    }
                                                }
                                                else
                                                {
                                                    arraylist.Add(selected);
                                                }
                                            }
                                            foreach (string val in arraylist)
                                            {
                                                listInfo.SelectedItems.Set(val, templateString);
                                            }
                                            if (!string.IsNullOrEmpty(attributes.Get(StlItemTemplate.AttributeSelectedValue)))
                                            {
                                                var selectedValue = attributes.Get(StlItemTemplate.AttributeSelectedValue);
                                                listInfo.SelectedValues.Set(selectedValue, templateString);
                                            }
                                        }
                                    }
                                    else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeSeparator))
                                    {
                                        var selectedValue = TranslateUtils.ToInt(attributes.Get(StlItemTemplate.AttributeSelectedValue), 1);
                                        if (selectedValue <= 1)
                                        {
                                            listInfo.SeparatorTemplate = templateString;
                                        }
                                        else
                                        {
                                            listInfo.SeparatorRepeatTemplate = templateString;
                                            listInfo.SeparatorRepeat         = selectedValue;
                                        }
                                    }
                                }
                            }
                            innerXml = innerXml.Replace(theStlElement, string.Empty);
                        }
                        else if (StlParserUtility.IsSpecifiedStlElement(theStlElement, StlLoading.ElementName))
                        {
                            var innerBuilder = new StringBuilder(StlParserUtility.GetInnerXml(theStlElement, true));
                            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                            StlParserUtility.XmlToHtml(innerBuilder);
                            listInfo.LoadingTemplate = innerBuilder.ToString();
                            innerXml = innerXml.Replace(theStlElement, string.Empty);
                        }
                        else if (contextType == EContextType.SqlContent && StlParserUtility.IsSpecifiedStlElement(theStlElement, StlQueryString.ElementName))
                        {
                            var innerBuilder = new StringBuilder(StlParserUtility.GetInnerXml(theStlElement, true));
                            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                            StlParserUtility.XmlToHtml(innerBuilder);
                            listInfo.QueryString = innerBuilder.ToString();
                            innerXml             = innerXml.Replace(theStlElement, string.Empty);
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(itemTemplate))
            {
                listInfo.ItemTemplate = !string.IsNullOrEmpty(innerXml) ? innerXml : "<stl:a target=\"_blank\"></stl:a>";
            }
            else
            {
                listInfo.ItemTemplate = itemTemplate;
            }

            var ie             = node.Attributes.GetEnumerator();
            var isSetDirection = false;//是否设置了direction属性

            while (ie.MoveNext())
            {
                var attr = (XmlAttribute)ie.Current;

                if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeChannelIndex))
                {
                    listInfo.ChannelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeChannelName))
                {
                    listInfo.ChannelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeUpLevel))
                {
                    listInfo.UpLevel = TranslateUtils.ToInt(attr.Value);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeTopLevel))
                {
                    listInfo.TopLevel = TranslateUtils.ToInt(attr.Value);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeScope))
                {
                    listInfo.Scope = EScopeTypeUtils.GetEnumType(attr.Value);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeIsTop))
                {
                    listInfo.IsTop = TranslateUtils.ToBool(attr.Value);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeIsRecommend))
                {
                    listInfo.IsRecommend = TranslateUtils.ToBool(attr.Value);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeIsHot))
                {
                    listInfo.IsHot = TranslateUtils.ToBool(attr.Value);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeIsColor))
                {
                    listInfo.IsColor = TranslateUtils.ToBool(attr.Value);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeWhere))
                {
                    listInfo.Where = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeIsDynamic))
                {
                    listInfo.IsDynamic = TranslateUtils.ToBool(attr.Value);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeTotalNum))
                {
                    listInfo.TotalNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlPageContents.AttributePageNum))
                {
                    listInfo.PageNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlPageContents.AttributeMaxPage))
                {
                    listInfo.MaxPage = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeTitleWordNum))
                {
                    listInfo.TitleWordNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeStartNum))
                {
                    listInfo.StartNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeOrder))
                {
                    if (contextType == EContextType.Content)
                    {
                        listInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.PublishmentSystemId, attr.Value, ETableStyle.BackgroundContent, ETaxisType.OrderByTaxisDesc);
                    }
                    else if (contextType == EContextType.Channel)
                    {
                        listInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.PublishmentSystemId, attr.Value, ETableStyle.Channel, ETaxisType.OrderByTaxis);
                    }
                    else if (contextType == EContextType.InputContent)
                    {
                        listInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.PublishmentSystemId, attr.Value, ETableStyle.InputContent, ETaxisType.OrderByTaxisDesc);
                    }
                    else
                    {
                        listInfo.OrderByString = attr.Value;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeGroupChannel))
                {
                    listInfo.GroupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(listInfo.GroupChannel))
                    {
                        listInfo.GroupChannel = "__Empty__";
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeGroupChannelNot))
                {
                    listInfo.GroupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(listInfo.GroupChannelNot))
                    {
                        listInfo.GroupChannelNot = "__Empty__";
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeGroupContent) || StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeGroup))
                {
                    listInfo.GroupContent = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(listInfo.GroupContent))
                    {
                        listInfo.GroupContent = "__Empty__";
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeGroupContentNot) || StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeGroupNot))
                {
                    listInfo.GroupContentNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(listInfo.GroupContentNot))
                    {
                        listInfo.GroupContentNot = "__Empty__";
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeTags))
                {
                    listInfo.Tags = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeColumns))
                {
                    listInfo.Columns = TranslateUtils.ToInt(attr.Value);
                    listInfo.Layout  = ELayout.Table;
                    if (listInfo.Columns > 1 && isSetDirection == false)
                    {
                        listInfo.Direction = RepeatDirection.Horizontal;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeDirection))
                {
                    listInfo.Layout    = ELayout.Table;
                    listInfo.Direction = Converter.ToRepeatDirection(attr.Value);
                    isSetDirection     = true;
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeHeight))
                {
                    try
                    {
                        listInfo.Height = Unit.Parse(attr.Value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeWidth))
                {
                    try
                    {
                        listInfo.Width = Unit.Parse(attr.Value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeAlign))
                {
                    listInfo.Align = attr.Value;
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeItemHeight))
                {
                    try
                    {
                        listInfo.ItemHeight = Unit.Parse(attr.Value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeItemWidth))
                {
                    try
                    {
                        listInfo.ItemWidth = Unit.Parse(attr.Value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeItemAlign))
                {
                    listInfo.ItemAlign = attr.Value;
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeItemVerticalAlign))
                {
                    listInfo.ItemVerticalAlign = attr.Value;
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeItemClass))
                {
                    listInfo.ItemClass = attr.Value;
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeIsImage))
                {
                    listInfo.IsImage = TranslateUtils.ToBool(attr.Value);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeIsVideo))
                {
                    listInfo.IsVideo = TranslateUtils.ToBool(attr.Value);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeIsFile))
                {
                    listInfo.IsFile = TranslateUtils.ToBool(attr.Value);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeIsNoDup))
                {
                    listInfo.IsNoDup = TranslateUtils.ToBool(attr.Value);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeIsRelatedContents))
                {
                    listInfo.IsRelatedContents = TranslateUtils.ToBool(attr.Value);
                }
                else if (StringUtils.EqualsIgnoreCase(attr.Name, StlContents.AttributeLayout))
                {
                    listInfo.Layout = ELayoutUtils.GetEnumType(attr.Value);
                }
                else if (contextType == EContextType.SqlContent && StringUtils.EqualsIgnoreCase(attr.Name, StlSqlContents.AttributeConnectionString))
                {
                    listInfo.ConnectionString = attr.Value;
                }
                else if (contextType == EContextType.SqlContent && StringUtils.EqualsIgnoreCase(attr.Name, StlSqlContents.AttributeConnectionStringName))
                {
                    if (string.IsNullOrEmpty(listInfo.ConnectionString))
                    {
                        listInfo.ConnectionString = WebConfigUtils.ConnectionString;
                    }
                }
                else
                {
                    listInfo.Others.Set(attr.Name, attr.Value);
                }
            }

            return(listInfo);
        }
Example #12
0
        public static IEnumerable GetContentsDataSource(PublishmentSystemInfo publishmentSystemInfo, int channelId, int contentId, string groupContent, string groupContentNot, string tags, bool isImageExists, bool isImage, bool isVideoExists, bool isVideo, bool isFileExists, bool isFile, bool isNoDup, bool isRelatedContents, int startNum, int totalNum, string orderByString, bool isTopExists, bool isTop, bool isRecommendExists, bool isRecommend, bool isHotExists, bool isHot, bool isColorExists, bool isColor, string where, EScopeType scopeType, string groupChannel, string groupChannelNot, LowerNameValueCollection others)
        {
            IEnumerable ie = null;

            if (DataProvider.NodeDao.IsExists(channelId))
            {
                var nodeInfo   = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, channelId);
                var tableStyle = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);
                var tableName  = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo);

                if (isRelatedContents && contentId > 0)
                {
                    var isTags        = false;
                    var tagCollection = BaiRongDataProvider.ContentDao.GetValue(tableName, contentId, ContentAttribute.Tags);
                    if (!string.IsNullOrEmpty(tagCollection))
                    {
                        var contentIdArrayList = BaiRongDataProvider.TagDao.GetContentIdListByTagCollection(TranslateUtils.StringCollectionToStringCollection(tagCollection), publishmentSystemInfo.PublishmentSystemId);
                        contentIdArrayList.Remove(contentId);
                        if (contentIdArrayList.Count > 0)
                        {
                            isTags = true;
                            if (string.IsNullOrEmpty(where))
                            {
                                where =
                                    $"ID IN ({TranslateUtils.ToSqlInStringWithoutQuote(contentIdArrayList)})";
                            }
                            else
                            {
                                where +=
                                    $" AND (ID IN ({TranslateUtils.ToSqlInStringWithoutQuote(contentIdArrayList)}))";
                            }
                        }
                    }

                    if (!isTags)
                    {
                        if (string.IsNullOrEmpty(where))
                        {
                            where = $"ID <> {contentId}";
                        }
                        else
                        {
                            where += $" AND (ID <> {contentId})";
                        }
                    }
                }

                string sqlWhereString;
                if (tableStyle == ETableStyle.BackgroundContent || tableStyle == ETableStyle.GovPublicContent)
                {
                    sqlWhereString = DataProvider.BackgroundContentDao.GetStlWhereString(publishmentSystemInfo, tableName, groupContent, groupContentNot, tags, isImageExists, isImage, isVideoExists, isVideo, isFileExists, isFile, isTopExists, isTop, isRecommendExists, isRecommend, isHotExists, isHot, isColorExists, isColor, where);
                }
                else
                {
                    sqlWhereString = BaiRongDataProvider.ContentDao.GetStlWhereString(publishmentSystemInfo.PublishmentSystemId, groupContent, groupContentNot, tags, isTopExists, isTop, where);
                }
                ie = DataProvider.ContentDao.GetStlDataSourceChecked(tableName, channelId, startNum, totalNum, orderByString, sqlWhereString, scopeType, groupChannel, groupChannelNot, isNoDup, others);
            }

            return(ie);
        }
Example #13
0
        public IEnumerable GetStlDataSourceChecked(string tableName, int nodeId, int startNum, int totalNum, string orderByString, string whereString, EScopeType scopeType, string groupChannel, string groupChannelNot, bool isNoDup, LowerNameValueCollection others)
        {
            var nodeIdList = DataProvider.NodeDao.GetNodeIdListByScopeType(nodeId, scopeType, groupChannel, groupChannelNot);

            return(BaiRongDataProvider.ContentDao.GetStlDataSourceChecked(tableName, nodeIdList, startNum, totalNum, orderByString, whereString, isNoDup, others));
        }
Example #14
0
        public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfoRef)
        {
            string parsedContent;
            var    contextInfo = contextInfoRef.Clone();

            try
            {
                var tagLevel       = 1;
                var totalNum       = 0;
                var isOrderByCount = false;
                var theme          = "default";
                var isDynamic      = false;
                var isInnerXml     = !string.IsNullOrEmpty(node.InnerXml);
                var attributes     = new LowerNameValueCollection();

                var ie = node.Attributes?.GetEnumerator();
                if (ie != null)
                {
                    while (ie.MoveNext())
                    {
                        var attr = (XmlAttribute)ie.Current;

                        if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTagLevel))
                        {
                            tagLevel = TranslateUtils.ToInt(attr.Value);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTotalNum))
                        {
                            totalNum = TranslateUtils.ToInt(attr.Value);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsOrderByCount))
                        {
                            isOrderByCount = TranslateUtils.ToBool(attr.Value);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTheme))
                        {
                            theme = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeContext))
                        {
                            contextInfo.ContextType = EContextTypeUtils.GetEnumType(attr.Value);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic))
                        {
                            isDynamic = TranslateUtils.ToBool(attr.Value);
                        }
                        else
                        {
                            attributes.Set(attr.Name, attr.Value);
                        }
                    }
                }

                parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(stlElement, isInnerXml, pageInfo, contextInfo, tagLevel, totalNum, isOrderByCount, theme);
            }
            catch (Exception ex)
            {
                parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex);
            }

            return(parsedContent);
        }
Example #15
0
 private static bool IsContentTemplateString(string itemType, string itemTypes, ref string templateString, LowerNameValueCollection selectedItems, LowerNameValueCollection selectedValues, PageInfo pageInfo, ContextInfo contextInfo)
 {
     if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedCurrent))//当前内容
     {
         if (contextInfo.ContentInfo.Id == pageInfo.PageContentId)
         {
             templateString = selectedItems.Get(itemTypes);
             return(true);
         }
     }
     else if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedIsTop))//置顶内容
     {
         if (contextInfo.ContentInfo.IsTop)
         {
             templateString = selectedItems.Get(itemTypes);
             return(true);
         }
     }
     else if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedImage))//带图片的内容
     {
         if (!string.IsNullOrEmpty(contextInfo.ContentInfo.GetString(BackgroundContentAttribute.ImageUrl)))
         {
             templateString = selectedItems.Get(itemTypes);
             return(true);
         }
     }
     else if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedVideo))//带视频的内容
     {
         if (!string.IsNullOrEmpty(contextInfo.ContentInfo.GetString(BackgroundContentAttribute.VideoUrl)))
         {
             templateString = selectedItems.Get(itemTypes);
             return(true);
         }
     }
     else if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedFile))//带附件的内容
     {
         if (!string.IsNullOrEmpty(contextInfo.ContentInfo.GetString(BackgroundContentAttribute.FileUrl)))
         {
             templateString = selectedItems.Get(itemTypes);
             return(true);
         }
     }
     else if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedIsRecommend))//推荐的内容
     {
         if (TranslateUtils.ToBool(contextInfo.ContentInfo.GetString(ContentAttribute.IsRecommend)))
         {
             templateString = selectedItems.Get(itemTypes);
             return(true);
         }
     }
     else if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedIsHot))//热点内容
     {
         if (TranslateUtils.ToBool(contextInfo.ContentInfo.GetString(ContentAttribute.IsHot)))
         {
             templateString = selectedItems.Get(itemTypes);
             return(true);
         }
     }
     else if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedIsColor))//醒目内容
     {
         if (TranslateUtils.ToBool(contextInfo.ContentInfo.GetString(ContentAttribute.IsColor)))
         {
             templateString = selectedItems.Get(itemTypes);
             return(true);
         }
     }
     else if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedChannelName))//带有附件的内容
     {
         if (selectedValues.Count > 0)
         {
             var nodeInfo = ChannelManager.GetChannelInfo(contextInfo.ContentInfo.SiteId, contextInfo.ContentInfo.ChannelId);
             if (nodeInfo != null)
             {
                 if (selectedValues.Get(nodeInfo.ChannelName) != null)
                 {
                     templateString = selectedValues.Get(nodeInfo.ChannelName);
                     return(true);
                 }
             }
         }
     }
     else if (IsNumberInRange(contextInfo.ItemContainer.ContentItem.ItemIndex + 1, itemType))
     {
         templateString = selectedItems.Get(itemTypes);
         return(true);
     }
     return(false);
 }
Example #16
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 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.Keys)
                {
                    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());
        }
Example #17
0
        public static DataSet GetContentsDataSource(SiteInfo siteInfo, int channelId, int contentId, string groupContent, string groupContentNot, string tags, bool isImageExists, bool isImage, bool isVideoExists, bool isVideo, bool isFileExists, bool isFile, bool isRelatedContents, int startNum, int totalNum, string orderByString, bool isTopExists, bool isTop, bool isRecommendExists, bool isRecommend, bool isHotExists, bool isHot, bool isColorExists, bool isColor, string where, EScopeType scopeType, string groupChannel, string groupChannelNot, LowerNameValueCollection others)
        {
            if (!ChannelManager.IsExists(siteInfo.Id, channelId))
            {
                return(null);
            }

            var nodeInfo  = ChannelManager.GetChannelInfo(siteInfo.Id, channelId);
            var tableName = ChannelManager.GetTableName(siteInfo, nodeInfo);

            if (isRelatedContents && contentId > 0)
            {
                var isTags        = false;
                var tagCollection = Content.GetValue(tableName, contentId, ContentAttribute.Tags);
                if (!string.IsNullOrEmpty(tagCollection))
                {
                    var contentIdList = Tag.GetContentIdListByTagCollection(TranslateUtils.StringCollectionToStringCollection(tagCollection), siteInfo.Id);
                    if (contentIdList.Count > 0)
                    {
                        contentIdList.Remove(contentId);
                        isTags = true;
                        if (string.IsNullOrEmpty(where))
                        {
                            where =
                                $"ID IN ({TranslateUtils.ToSqlInStringWithoutQuote(contentIdList)})";
                        }
                        else
                        {
                            where +=
                                $" AND (ID IN ({TranslateUtils.ToSqlInStringWithoutQuote(contentIdList)}))";
                        }
                    }
                }

                if (!isTags)
                {
                    if (string.IsNullOrEmpty(where))
                    {
                        where = $"ID <> {contentId}";
                    }
                    else
                    {
                        where += $" AND (ID <> {contentId})";
                    }
                }
            }

            var sqlWhereString = PluginManager.IsExists(nodeInfo.ContentModelPluginId)
                ? Content.GetStlWhereString(siteInfo.Id, groupContent, groupContentNot,
                                            tags, isTopExists, isTop, where)
                : Content.GetStlWhereString(siteInfo.Id, groupContent,
                                            groupContentNot, tags, isImageExists, isImage, isVideoExists, isVideo, isFileExists, isFile,
                                            isTopExists, isTop, isRecommendExists, isRecommend, isHotExists, isHot, isColorExists, isColor,
                                            where);

            var channelIdList = ChannelManager.GetChannelIdList(nodeInfo, scopeType, groupChannel, groupChannelNot, string.Empty);

            return(Content.GetStlDataSourceChecked(channelIdList, tableName, startNum, totalNum, orderByString, sqlWhereString, others));
        }
Example #18
0
        public static DataSet GetStlDataSourceChecked(List <int> channelIdList, string tableName, int startNum, int totalNum, string orderByString, string whereString, LowerNameValueCollection others)
        {
            var cacheKey = StlCacheUtils.GetCacheKey(nameof(Content), nameof(GetStlDataSourceChecked),
                                                     TranslateUtils.ObjectCollectionToString(channelIdList), tableName, startNum.ToString(), totalNum.ToString(), orderByString, whereString, TranslateUtils.NameValueCollectionToString(others));
            var retval = StlCacheUtils.GetCache <DataSet>(cacheKey);

            if (retval != null)
            {
                return(retval);
            }

            lock (LockObject)
            {
                retval = StlCacheUtils.GetCache <DataSet>(cacheKey);
                if (retval == null)
                {
                    retval = DataProvider.ContentDao.GetStlDataSourceChecked(channelIdList, tableName, startNum, totalNum, orderByString, whereString, others);
                    StlCacheUtils.SetCache(cacheKey, retval);
                }
            }

            return(retval);
        }
Example #19
0
        public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo)
        {
            var parsedContent = string.Empty;

            try
            {
                var attributes = new LowerNameValueCollection();
                var ie         = node.Attributes.GetEnumerator();

                var channelIndex    = string.Empty;
                var channelName     = string.Empty;
                var upLevel         = 0;
                var topLevel        = -1;
                var groupChannel    = string.Empty;
                var groupChannelNot = string.Empty;

                var title               = string.Empty;
                var isLoading           = false;
                var isShowContentNum    = false;
                var isShowTreeLine      = true;
                var currentFormatString = "<strong>{0}</strong>";
                var isDynamic           = false;

                while (ie.MoveNext())
                {
                    var attr          = (XmlAttribute)ie.Current;
                    var attributeName = attr.Name.ToLower();

                    if (attributeName.Equals(Attribute_ChannelIndex))
                    {
                        channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    }
                    else if (attributeName.Equals(Attribute_ChannelName))
                    {
                        channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    }
                    else if (attributeName.Equals(Attribute_UpLevel))
                    {
                        upLevel = TranslateUtils.ToInt(attr.Value);
                    }
                    else if (attributeName.Equals(Attribute_TopLevel))
                    {
                        topLevel = TranslateUtils.ToInt(attr.Value);
                    }
                    else if (attributeName.Equals(Attribute_GroupChannel))
                    {
                        groupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    }
                    else if (attributeName.Equals(Attribute_GroupChannelNot))
                    {
                        groupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    }
                    else if (attributeName.Equals(Attribute_Title))
                    {
                        title = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    }
                    else if (attributeName.Equals(Attribute_IsLoading))
                    {
                        isLoading = TranslateUtils.ToBool(attr.Value, false);
                    }
                    else if (attributeName.Equals(Attribute_IsShowContentNum))
                    {
                        isShowContentNum = TranslateUtils.ToBool(attr.Value, false);
                    }
                    else if (attributeName.Equals(Attribute_IsShowTreeLine))
                    {
                        isShowTreeLine = TranslateUtils.ToBool(attr.Value, true);
                    }
                    else if (attributeName.Equals(Attribute_CurrentFormatString))
                    {
                        currentFormatString = attr.Value;
                        if (!StringUtils.Contains(currentFormatString, "{0}"))
                        {
                            currentFormatString += "{0}";
                        }
                    }
                    else if (attributeName.Equals(Attribute_IsDynamic))
                    {
                        isDynamic = TranslateUtils.ToBool(attr.Value);
                    }
                    else
                    {
                        attributes[attributeName] = attr.Value;
                    }
                }

                if (isDynamic)
                {
                    parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo);
                }
                else
                {
                    if (isLoading)
                    {
                        parsedContent = ParseImplAjax(pageInfo, contextInfo, channelIndex, channelName, upLevel, topLevel, groupChannel, groupChannelNot, title, isShowContentNum, isShowTreeLine, currentFormatString);
                    }
                    else
                    {
                        parsedContent = ParseImplNotAjax(pageInfo, contextInfo, channelIndex, channelName, upLevel, topLevel, groupChannel, groupChannelNot, title, isShowContentNum, isShowTreeLine, currentFormatString);
                    }
                }
            }
            catch (Exception ex)
            {
                parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex);
            }

            return(parsedContent);
        }
Example #20
0
        public string GetSelectSqlStringWithChecked(int publishmentSystemId, int inputId, bool isReplyExists, bool isReply, int startNum, int totalNum, string whereString, string orderByString, LowerNameValueCollection others)
        {
            if (!string.IsNullOrEmpty(whereString) && !StringUtils.StartsWithIgnoreCase(whereString.Trim(), "AND "))
            {
                whereString = "AND " + whereString.Trim();
            }
            string sqlWhereString = $"WHERE InputID = {inputId} AND IsChecked = '{true}' {whereString}";

            if (isReplyExists)
            {
                if (isReply)
                {
                    sqlWhereString += " AND " + SqlUtils.GetNotNullAndEmpty("Reply");
                }
                else
                {
                    sqlWhereString += " AND " + SqlUtils.GetNullOrEmpty("Reply");
                }
            }
            if (others != null && others.Count > 0)
            {
                var relatedIdentities = RelatedIdentities.GetRelatedIdentities(ETableStyle.InputContent, publishmentSystemId, inputId);
                var styleInfoList     = TableStyleManager.GetTableStyleInfoList(ETableStyle.InputContent, TableName, relatedIdentities);
                foreach (var tableStyleInfo in styleInfoList)
                {
                    if (!string.IsNullOrEmpty(others.Get(tableStyleInfo.AttributeName)))
                    {
                        sqlWhereString +=
                            $" AND ({InputContentAttribute.SettingsXml} LIKE '%{tableStyleInfo.AttributeName}={others.Get(tableStyleInfo.AttributeName)}%')";
                    }
                }
            }

            return(BaiRongDataProvider.TableStructureDao.GetSelectSqlString(TableName, startNum, totalNum, SqlUtils.Asterisk, sqlWhereString, orderByString));
        }