Exemple #1
0
        public static ListInfo GetListInfoByXmlNode(PageInfo pageInfo, ContextInfo contextInfo, EContextType contextType)
        {
            var listInfo = new ListInfo
            {
                _contextType = contextType
            };

            var innerHtml    = contextInfo.InnerHtml;
            var itemTemplate = string.Empty;

            if (!string.IsNullOrEmpty(innerHtml))
            {
                var stlElementList = StlParserUtility.GetStlElementList(innerHtml);
                if (stlElementList.Count > 0)
                {
                    foreach (var theStlElement in stlElementList)
                    {
                        if (StlParserUtility.IsSpecifiedStlElement(theStlElement, StlItemTemplate.ElementName))
                        {
                            var attributes     = TranslateUtils.NewIgnoreCaseNameValueCollection();
                            var templateString = StlParserUtility.GetInnerHtml(theStlElement, attributes);
                            if (!string.IsNullOrEmpty(templateString))
                            {
                                foreach (var key in attributes.AllKeys)
                                {
                                    if (!StringUtils.EqualsIgnoreCase(key, StlItemTemplate.Type.Name))
                                    {
                                        continue;
                                    }

                                    var type = attributes[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[StlItemTemplate.Selected.Name]))
                                        {
                                            var selected = attributes[StlItemTemplate.Selected.Name];
                                            var list     = new List <string>();
                                            if (selected.IndexOf(',') != -1)
                                            {
                                                list.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++)
                                                    {
                                                        list.Add(i.ToString());
                                                    }
                                                }
                                                else
                                                {
                                                    list.Add(selected);
                                                }
                                            }
                                            foreach (string val in list)
                                            {
                                                listInfo.SelectedItems.Set(val, templateString);
                                            }
                                            if (!string.IsNullOrEmpty(attributes[StlItemTemplate.SelectedValue.Name]))
                                            {
                                                var selectedValue = attributes[StlItemTemplate.SelectedValue.Name];
                                                listInfo.SelectedValues.Set(selectedValue, templateString);
                                            }
                                        }
                                    }
                                    else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeSeparator))
                                    {
                                        var selectedValue = TranslateUtils.ToInt(attributes[StlItemTemplate.SelectedValue.Name], 1);
                                        if (selectedValue <= 1)
                                        {
                                            listInfo.SeparatorTemplate = templateString;
                                        }
                                        else
                                        {
                                            listInfo.SeparatorRepeatTemplate = templateString;
                                            listInfo.SeparatorRepeat         = selectedValue;
                                        }
                                    }
                                }
                            }
                            innerHtml = innerHtml.Replace(theStlElement, string.Empty);
                        }
                        else if (StlParserUtility.IsSpecifiedStlElement(theStlElement, StlLoading.ElementName))
                        {
                            var innerBuilder = new StringBuilder(StlParserUtility.GetInnerHtml(theStlElement));
                            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                            listInfo.LoadingTemplate = innerBuilder.ToString();
                            innerHtml = innerHtml.Replace(theStlElement, string.Empty);
                        }
                        else if (contextType == EContextType.SqlContent && StlParserUtility.IsSpecifiedStlElement(theStlElement, StlQueryString.ElementName))
                        {
                            var innerBuilder = new StringBuilder(StlParserUtility.GetInnerHtml(theStlElement));
                            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                            listInfo.QueryString = innerBuilder.ToString();
                            innerHtml            = innerHtml.Replace(theStlElement, string.Empty);
                        }
                    }
                }
            }

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

            var isSetDirection = false;//是否设置了direction属性

            foreach (var name in contextInfo.Attributes.AllKeys)
            {
                var value = contextInfo.Attributes[name];

                if (StringUtils.EqualsIgnoreCase(name, StlListBase.ChannelIndex.Name))
                {
                    listInfo.ChannelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.ChannelName.Name))
                {
                    listInfo.ChannelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.UpLevel.Name))
                {
                    listInfo.UpLevel = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.TopLevel.Name))
                {
                    listInfo.TopLevel = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Scope.Name))
                {
                    listInfo.Scope = EScopeTypeUtils.GetEnumType(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsTop.Name))
                {
                    listInfo.IsTop = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsRecommend.Name))
                {
                    listInfo.IsRecommend = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsHot.Name))
                {
                    listInfo.IsHot = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsColor.Name))
                {
                    listInfo.IsColor = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Where.Name))
                {
                    listInfo.Where = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.TotalNum.Name))
                {
                    listInfo.TotalNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo));
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlPageContents.PageNum.Name))
                {
                    listInfo.PageNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo), StringUtils.Constants.PageSize);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlPageContents.MaxPage.Name))
                {
                    listInfo.MaxPage = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo));
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.StartNum.Name))
                {
                    listInfo.StartNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo));
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Order.Name))
                {
                    if (contextType == EContextType.Content)
                    {
                        listInfo.OrderByString = StlDataUtility.GetContentOrderByString(pageInfo.SiteId, value, ETaxisType.OrderByTaxisDesc);
                    }
                    else if (contextType == EContextType.Channel)
                    {
                        listInfo.OrderByString = StlDataUtility.GetChannelOrderByString(pageInfo.SiteId, value, ETaxisType.OrderByTaxis);
                    }
                    //else if (contextType == EContextType.InputContent)
                    //{
                    //    listInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.SiteId, value, ETableStyle.InputContent, ETaxisType.OrderByTaxisDesc);
                    //}
                    else
                    {
                        listInfo.OrderByString = value;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.GroupChannel.Name))
                {
                    listInfo.GroupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(listInfo.GroupChannel))
                    {
                        listInfo.GroupChannel = "__Empty__";
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.GroupChannelNot.Name))
                {
                    listInfo.GroupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(listInfo.GroupChannelNot))
                    {
                        listInfo.GroupChannelNot = "__Empty__";
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.GroupContent.Name) || StringUtils.EqualsIgnoreCase(name, StlListBase.Group.Name))
                {
                    listInfo.GroupContent = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(listInfo.GroupContent))
                    {
                        listInfo.GroupContent = "__Empty__";
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.GroupContentNot.Name) || StringUtils.EqualsIgnoreCase(name, StlListBase.GroupNot.Name))
                {
                    listInfo.GroupContentNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(listInfo.GroupContentNot))
                    {
                        listInfo.GroupContentNot = "__Empty__";
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Tags.Name))
                {
                    listInfo.Tags = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Columns.Name))
                {
                    listInfo.Columns = TranslateUtils.ToInt(value);
                    listInfo.Layout  = ELayout.Table;
                    if (listInfo.Columns > 1 && isSetDirection == false)
                    {
                        listInfo.Direction = RepeatDirection.Horizontal;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Direction.Name))
                {
                    listInfo.Layout    = ELayout.Table;
                    listInfo.Direction = TranslateUtils.ToRepeatDirection(value);
                    isSetDirection     = true;
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Height.Name))
                {
                    try
                    {
                        listInfo.Height = Unit.Parse(value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Width.Name))
                {
                    try
                    {
                        listInfo.Width = Unit.Parse(value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Align.Name))
                {
                    listInfo.Align = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.ItemHeight.Name))
                {
                    try
                    {
                        listInfo.ItemHeight = Unit.Parse(value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.ItemWidth.Name))
                {
                    try
                    {
                        listInfo.ItemWidth = Unit.Parse(value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.ItemAlign.Name))
                {
                    listInfo.ItemAlign = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.ItemVerticalAlign.Name))
                {
                    listInfo.ItemVerticalAlign = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.ItemClass.Name))
                {
                    listInfo.ItemClass = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsImage.Name))
                {
                    listInfo.IsImage = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsVideo.Name))
                {
                    listInfo.IsVideo = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsFile.Name))
                {
                    listInfo.IsFile = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsRelatedContents.Name))
                {
                    listInfo.IsRelatedContents = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Layout.Name))
                {
                    listInfo.Layout = ELayoutUtils.GetEnumType(value);
                }
                else if (contextType == EContextType.SqlContent && StringUtils.EqualsIgnoreCase(name, StlSqlContents.ConnectionString.Name))
                {
                    listInfo.ConnectionString = value;
                }
                else if (contextType == EContextType.SqlContent && StringUtils.EqualsIgnoreCase(name, StlSqlContents.ConnectionStringName.Name))
                {
                    listInfo.ConnectionString = WebConfigUtils.GetConnectionStringByName(value);
                    if (string.IsNullOrEmpty(listInfo.ConnectionString))
                    {
                        listInfo.ConnectionString = WebConfigUtils.ConnectionString;
                    }
                }
                else if (contextType == EContextType.SqlContent && StringUtils.EqualsIgnoreCase(name, StlSqlContents.QueryString.Name))
                {
                    listInfo.QueryString = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else
                {
                    listInfo.Others.Set(name, value);
                }
            }

            return(listInfo);
        }
Exemple #2
0
        public void ChangeSite(SiteInfo siteInfo, int pageChannelId, int pageContentId, ContextInfo contextInfo)
        {
            SiteId        = siteInfo.Id;
            SiteInfo      = siteInfo;
            PageChannelId = pageChannelId;
            PageContentId = pageContentId;

            contextInfo.SiteInfo  = siteInfo;
            contextInfo.ChannelId = pageChannelId;
            contextInfo.ContentId = pageContentId;
        }
Exemple #3
0
        public static ContentsDisplayInfo GetContentsDisplayInfoByXmlNode(XmlNode node, PageInfo pageInfo, ContextInfo contextInfo, EContextType contextType)
        {
            var displayInfo = new ContentsDisplayInfo
            {
                _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, StlItem.ElementName) ||
                            StlParserUtility.IsSpecifiedStlElement(theStlElement, StlItem.ElementName2)
                            )
                        {
                            var attributes     = new LowerNameValueCollection();
                            var templateString = StlParserUtility.GetInnerXml(theStlElement, true, attributes);
                            if (!string.IsNullOrEmpty(templateString))
                            {
                                foreach (string key in attributes.Keys)
                                {
                                    if (key == StlItem.Attribute_Type)
                                    {
                                        var type = attributes[key];
                                        if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_Item))
                                        {
                                            itemTemplate = templateString;
                                        }
                                        else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_Header))
                                        {
                                            displayInfo._headerTemplate = templateString;
                                        }
                                        else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_Footer))
                                        {
                                            displayInfo._footerTemplate = templateString;
                                        }
                                        else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_AlternatingItem))
                                        {
                                            displayInfo._alternatingItemTemplate = templateString;
                                        }
                                        else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_SelectedItem))
                                        {
                                            if (!string.IsNullOrEmpty(attributes[StlItem.Attribute_Selected]))
                                            {
                                                var selected  = attributes[StlItem.Attribute_Selected];
                                                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)
                                                {
                                                    displayInfo._selectedItems[val] = templateString;
                                                }
                                                if (!string.IsNullOrEmpty(attributes[StlItem.Attribute_SelectedValue]))
                                                {
                                                    var selectedValue = attributes[StlItem.Attribute_SelectedValue];
                                                    displayInfo._selectedValues[selectedValue] = templateString;
                                                }
                                            }
                                        }
                                        else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_Separator))
                                        {
                                            var selectedValue = TranslateUtils.ToInt(attributes[StlItem.Attribute_SelectedValue], 1);
                                            if (selectedValue <= 1)
                                            {
                                                displayInfo._separatorTemplate = templateString;
                                            }
                                            else
                                            {
                                                displayInfo._separatorRepeatTemplate = templateString;
                                                displayInfo._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);
                            displayInfo._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);
                            displayInfo.QueryString = innerBuilder.ToString();
                            innerXml = innerXml.Replace(theStlElement, string.Empty);
                        }
                    }
                }
            }

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

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

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

                if (attributeName.Equals(StlContents.Attribute_ChannelIndex))
                {
                    displayInfo.ChannelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                }
                else if (attributeName.Equals(StlContents.Attribute_ChannelName))
                {
                    displayInfo.ChannelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                }
                else if (attributeName.Equals(StlContents.Attribute_UpLevel))
                {
                    displayInfo.UpLevel = TranslateUtils.ToInt(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_TopLevel))
                {
                    displayInfo.TopLevel = TranslateUtils.ToInt(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_Scope))
                {
                    displayInfo.Scope = EScopeTypeUtils.GetEnumType(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsTop))
                {
                    displayInfo.IsTop = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsRecommend))
                {
                    displayInfo.IsRecommend = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsHot))
                {
                    displayInfo.IsHot = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsColor))
                {
                    displayInfo.IsColor = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_Where))
                {
                    displayInfo.Where = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsDynamic))
                {
                    displayInfo.IsDynamic = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_TotalNum))
                {
                    displayInfo.TotalNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (attributeName.Equals(StlPageContents.AttributePageNum))
                {
                    displayInfo.PageNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (attributeName.Equals(StlPageContents.AttributeMaxPage))
                {
                    displayInfo.MaxPage = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (attributeName.Equals(StlContents.Attribute_TitleWordNum))
                {
                    displayInfo.TitleWordNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (attributeName.Equals(StlContents.Attribute_StartNum))
                {
                    displayInfo.StartNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (attributeName.Equals(StlContents.Attribute_Order))
                {
                    if (contextType == EContextType.Content)
                    {
                        displayInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.PublishmentSystemId, attr.Value, ETableStyle.BackgroundContent, ETaxisType.OrderByTaxisDesc);
                    }
                    else if (contextType == EContextType.Channel)
                    {
                        displayInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.PublishmentSystemId, attr.Value, ETableStyle.Channel, ETaxisType.OrderByTaxis);
                    }
                    else if (contextType == EContextType.InputContent)
                    {
                        displayInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.PublishmentSystemId, attr.Value, ETableStyle.InputContent, ETaxisType.OrderByTaxisDesc);
                    }
                    else
                    {
                        displayInfo.OrderByString = attr.Value;
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_GroupChannel))
                {
                    displayInfo.GroupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(displayInfo.GroupChannel))
                    {
                        displayInfo.GroupChannel = "__Empty__";
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_GroupChannelNot))
                {
                    displayInfo.GroupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(displayInfo.GroupChannelNot))
                    {
                        displayInfo.GroupChannelNot = "__Empty__";
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_GroupContent) || attributeName.Equals(StlContents.Attribute_Group))
                {
                    displayInfo.GroupContent = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(displayInfo.GroupContent))
                    {
                        displayInfo.GroupContent = "__Empty__";
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_GroupContentNot) || attributeName.Equals(StlContents.Attribute_GroupNot))
                {
                    displayInfo.GroupContentNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(displayInfo.GroupContentNot))
                    {
                        displayInfo.GroupContentNot = "__Empty__";
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_Tags))
                {
                    displayInfo.Tags = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                }
                else if (attributeName.Equals(StlContents.Attribute_Columns))
                {
                    displayInfo.Columns = TranslateUtils.ToInt(attr.Value);
                    displayInfo.Layout  = ELayout.Table;
                    if (displayInfo.Columns > 1 && isSetDirection == false)
                    {
                        displayInfo.Direction = RepeatDirection.Horizontal;
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_Direction))
                {
                    displayInfo.Layout    = ELayout.Table;
                    displayInfo.Direction = Converter.ToRepeatDirection(attr.Value);
                    isSetDirection        = true;
                }
                else if (attributeName.Equals(StlContents.Attribute_Height))
                {
                    try
                    {
                        displayInfo.Height = Unit.Parse(attr.Value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_Width))
                {
                    try
                    {
                        displayInfo.Width = Unit.Parse(attr.Value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_Align))
                {
                    displayInfo.Align = attr.Value;
                }
                else if (attributeName.Equals(StlContents.Attribute_ItemHeight))
                {
                    try
                    {
                        displayInfo.ItemHeight = Unit.Parse(attr.Value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_ItemWidth))
                {
                    try
                    {
                        displayInfo.ItemWidth = Unit.Parse(attr.Value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_ItemAlign))
                {
                    displayInfo.ItemAlign = attr.Value;
                }
                else if (attributeName.Equals(StlContents.Attribute_ItemVerticalAlign))
                {
                    displayInfo.ItemVerticalAlign = attr.Value;
                }
                else if (attributeName.Equals(StlContents.Attribute_ItemClass))
                {
                    displayInfo.ItemClass = attr.Value;
                }
                else if (attributeName.Equals(StlContents.Attribute_IsImage))
                {
                    displayInfo.IsImage = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsVideo))
                {
                    displayInfo.IsVideo = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsFile))
                {
                    displayInfo.IsFile = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsNoDup))
                {
                    displayInfo.IsNoDup = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsRelatedContents))
                {
                    displayInfo.IsRelatedContents = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_Layout))
                {
                    displayInfo.Layout = ELayoutUtils.GetEnumType(attr.Value);
                }
                else if (contextType == EContextType.SqlContent && attributeName.Equals(StlSqlContents.Attribute_ConnectionString))
                {
                    displayInfo.ConnectionString = attr.Value;
                }
                else if (contextType == EContextType.SqlContent && attributeName.Equals(StlSqlContents.Attribute_ConnectionStringName))
                {
                    if (string.IsNullOrEmpty(displayInfo.ConnectionString))
                    {
                        displayInfo.ConnectionString = WebConfigUtils.ConnectionString;
                    }
                }
                else
                {
                    displayInfo.OtherAttributes.Add(attributeName, attr.Value);
                }
            }

            return(displayInfo);
        }
Exemple #4
0
        public ContextInfo Clone()
        {
            var contextInfo = new ContextInfo(this);

            return(contextInfo);
        }