Example #1
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            bool isChanged;

            var inputType = EInputTypeUtils.GetEnumType(ddlInputType.SelectedValue);

            if (inputType == EInputType.Radio || inputType == EInputType.SelectMultiple || inputType == EInputType.SelectOne)
            {
                var isRapid = TranslateUtils.ToBool(ddlItemType.SelectedValue);
                if (!isRapid)
                {
                    var itemCount = TranslateUtils.ToInt(tbItemCount.Text);
                    if (itemCount == 0)
                    {
                        FailMessage("操作失败,选项数目不能为0!");
                        return;
                    }
                }
            }

            if (_styleInfo.TableStyleId == 0 && _styleInfo.RelatedIdentity == 0)//数据库中没有此项及父项的表样式
            {
                isChanged = InsertTableStyleInfo(inputType);
            }
            else//数据库中有此项的表样式
            {
                isChanged = UpdateTableStyleInfo(inputType);
            }

            if (isChanged)
            {
                PageUtils.CloseModalPageAndRedirect(Page, _redirectUrl);
            }
        }
Example #2
0
        public static Dictionary <string, List <TableStyleInfo> > GetTableStyleInfoWithItemsDictinary(string tableName, List <int> allRelatedIdentities)
        {
            var dict = new Dictionary <string, List <TableStyleInfo> >();

            var entries = GetAllTableStyleInfoPairs();

            foreach (var key in entries.Keys)
            {
                var identityFromKey  = TranslateUtils.ToInt(key.Split('$')[0]);
                var tableNameFromKey = key.Split('$')[1];
                if (!StringUtils.EqualsIgnoreCase(tableNameFromKey, tableName) ||
                    !allRelatedIdentities.Contains(identityFromKey))
                {
                    continue;
                }

                var styleInfo = (TableStyleInfo)entries.GetValue(key);
                if (EInputTypeUtils.IsWithStyleItems(EInputTypeUtils.GetEnumType(styleInfo.InputType)))
                {
                    styleInfo.StyleItems = BaiRongDataProvider.TableStyleDao.GetStyleItemInfoList(styleInfo.TableStyleId);
                }
                var tableStyleInfoWithItemList = dict.ContainsKey(styleInfo.AttributeName) ? dict[styleInfo.AttributeName] : new List <TableStyleInfo>();
                tableStyleInfoWithItemList.Add(styleInfo);
                dict[styleInfo.AttributeName] = tableStyleInfoWithItemList;
            }

            return(dict);
        }
Example #3
0
        public void ReFresh(object sender, EventArgs e)
        {
            TrRelatedField.Visible = TrHeightAndWidth.Visible = SpanDateTip.Visible = TrItemsType.Visible = TrItemsRapid.Visible = TrItems.Visible = TrRepeat.Visible = PhItemCount.Visible = PhIsFormatString.Visible = false;

            if (!string.IsNullOrEmpty(_attributeName))
            {
                TbAttributeName.Enabled = false;
            }

            var inputType = EInputTypeUtils.GetEnumType(DdlInputType.SelectedValue);

            if (inputType == EInputType.CheckBox || inputType == EInputType.Radio || inputType == EInputType.SelectMultiple || inputType == EInputType.SelectOne)
            {
                TrItemsType.Visible = true;
                var isRapid = TranslateUtils.ToBool(DdlItemType.SelectedValue);
                if (isRapid)
                {
                    TrItemsRapid.Visible = true;
                    PhItemCount.Visible  = false;
                    TrItems.Visible      = false;
                }
                else
                {
                    TrItemsRapid.Visible = false;
                    PhItemCount.Visible  = true;
                    TrItems.Visible      = true;
                }
                if (inputType == EInputType.CheckBox || inputType == EInputType.Radio)
                {
                    TrRepeat.Visible = true;
                }
            }
            else if (inputType == EInputType.TextEditor)
            {
                TrHeightAndWidth.Visible = true;
            }
            else if (inputType == EInputType.TextArea)
            {
                TrHeightAndWidth.Visible = true;
            }
            else if (inputType == EInputType.Text)
            {
                PhIsFormatString.Visible = true;
                TrHeightAndWidth.Visible = true;
            }
            else if (inputType == EInputType.Date || inputType == EInputType.DateTime)
            {
                SpanDateTip.Visible = true;
            }
            else if (inputType == EInputType.RelatedField)
            {
                TrRelatedField.Visible = true;
            }
        }
Example #4
0
        private static string ParseImpl(XmlNode node, PageInfo pageInfo, ContextInfo contextInfo, StringDictionary attributes, string leftText, string rightText, string formatString, string separator, int startIndex, int length, int wordNum, string ellipsis, string replace, string to, bool isClearTags, bool isReturnToBr, bool isLower, bool isUpper, string type)
        {
            var parsedContent = string.Empty;

            if (InputContentAttribute.Id.ToLower().Equals(type))
            {
                parsedContent = SqlUtils.EvalString(contextInfo.ItemContainer.InputItem.DataItem, InputContentAttribute.Id);
            }
            else if (InputContentAttribute.AddDate.ToLower().Equals(type))
            {
                var addDate = SqlUtils.EvalDateTime(contextInfo.ItemContainer.InputItem.DataItem, InputContentAttribute.AddDate);
                parsedContent = DateUtils.Format(addDate, formatString);
            }
            else if (InputContentAttribute.UserName.ToLower().Equals(type))
            {
                parsedContent = SqlUtils.EvalString(contextInfo.ItemContainer.InputItem.DataItem, InputContentAttribute.UserName);
            }
            else if (InputContentAttribute.Reply.ToLower().Equals(type))
            {
                var content = SqlUtils.EvalString(contextInfo.ItemContainer.InputItem.DataItem, InputContentAttribute.Reply);
                parsedContent = content;
                parsedContent = StringUtils.ParseString(EInputType.TextEditor, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);
            }
            else if (StringUtils.StartsWithIgnoreCase(type, StlParserUtility.ItemIndex))
            {
                parsedContent = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.InputItem.ItemIndex, type, contextInfo).ToString();
            }
            else
            {
                var id = SqlUtils.EvalInt(contextInfo.ItemContainer.InputItem.DataItem, InputContentAttribute.Id);
                var inputContentInfo = DataProvider.InputContentDao.GetContentInfo(id);
                if (inputContentInfo != null)
                {
                    parsedContent = inputContentInfo.GetExtendedAttribute(type);
                    if (!string.IsNullOrEmpty(parsedContent))
                    {
                        if (!InputContentAttribute.HiddenAttributes.Contains(type.ToLower()))
                        {
                            var styleInfo = TableStyleManager.GetTableStyleInfo(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, type, RelatedIdentities.GetRelatedIdentities(ETableStyle.InputContent, pageInfo.PublishmentSystemId, inputContentInfo.InputId));
                            parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, separator, pageInfo.PublishmentSystemInfo, ETableStyle.InputContent, styleInfo, formatString, attributes, node.InnerXml, false);
                            parsedContent = StringUtils.ParseString(EInputTypeUtils.GetEnumType(styleInfo.InputType), parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(parsedContent))
            {
                parsedContent = leftText + parsedContent + rightText;
            }

            return(parsedContent);
        }
Example #5
0
        private static string GetValueByControl(TableStyleInfo styleInfo, PublishmentSystemInfo publishmentSystemInfo, Control containerControl)
        {
            var theValue = ControlUtils.GetInputValue(containerControl, styleInfo.AttributeName) ?? string.Empty;

            var inputType = EInputTypeUtils.GetEnumType(styleInfo.InputType);

            if (inputType == EInputType.TextEditor)
            {
                theValue = StringUtility.TextEditorContentEncode(theValue, publishmentSystemInfo);
            }

            return(theValue);
        }
Example #6
0
        private static string GetValueByForm(TableStyleInfo styleInfo, PublishmentSystemInfo publishmentSystemInfo, NameValueCollection formCollection, bool isSaveImage)
        {
            var theValue = formCollection[styleInfo.AttributeName] ?? string.Empty;

            var inputType = EInputTypeUtils.GetEnumType(styleInfo.InputType);

            if (inputType == EInputType.TextEditor)
            {
                theValue = StringUtility.TextEditorContentEncode(theValue, publishmentSystemInfo, isSaveImage && publishmentSystemInfo.Additional.IsSaveImageInTextEditor);
                theValue = ETextEditorTypeUtils.TranslateToStlElement(theValue);
            }

            return(theValue);
        }
Example #7
0
        public static void SingleImportTableStyle(ETableStyle tableStyle, string tableName, string styleDirectoryPath, int relatedIdentity)
        {
            if (!DirectoryUtils.IsDirectoryExists(styleDirectoryPath))
            {
                return;
            }

            var filePaths = DirectoryUtils.GetFilePaths(styleDirectoryPath);

            foreach (var filePath in filePaths)
            {
                var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(filePath));

                var attributeName   = AtomUtility.GetDcElementContent(feed.AdditionalElements, "AttributeName");
                var taxis           = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(feed.AdditionalElements, "Taxis"), 0);
                var displayName     = AtomUtility.GetDcElementContent(feed.AdditionalElements, "DisplayName");
                var helpText        = AtomUtility.GetDcElementContent(feed.AdditionalElements, "HelpText");
                var isVisible       = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsVisible"));
                var isVisibleInList = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsVisibleInList"));
                var isSingleLine    = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsSingleLine"));
                var inputType       = EInputTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(feed.AdditionalElements, "InputType"));
                var defaultValue    = AtomUtility.GetDcElementContent(feed.AdditionalElements, "DefaultValue");
                var isHorizontal    = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsHorizontal"));
                //SettingsXML
                var extendValues = AtomUtility.GetDcElementContent(feed.AdditionalElements, "ExtendValues");

                var styleInfo = new TableStyleInfo(0, relatedIdentity, tableName, attributeName, taxis, displayName, helpText, isVisible, isVisibleInList, isSingleLine, EInputTypeUtils.GetValue(inputType), defaultValue, isHorizontal, extendValues);

                var styleItems = new List <TableStyleItemInfo>();
                foreach (AtomEntry entry in feed.Entries)
                {
                    var itemTitle  = AtomUtility.GetDcElementContent(entry.AdditionalElements, "ItemTitle");
                    var itemValue  = AtomUtility.GetDcElementContent(entry.AdditionalElements, "ItemValue");
                    var isSelected = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, "IsSelected"));

                    styleItems.Add(new TableStyleItemInfo(0, 0, itemTitle, itemValue, isSelected));
                }

                if (styleItems.Count > 0)
                {
                    styleInfo.StyleItems = styleItems;
                }

                if (TableStyleManager.IsExists(relatedIdentity, tableName, attributeName))
                {
                    TableStyleManager.Delete(relatedIdentity, tableName, attributeName);
                }
                TableStyleManager.InsertWithTaxis(styleInfo, tableStyle);
            }
        }
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _relatedIdentities = TranslateUtils.StringCollectionToIntList(Body.GetQueryString("RelatedIdentities"));
            if (_relatedIdentities.Count == 0)
            {
                _relatedIdentities.Add(0);
            }
            _tableName   = Body.GetQueryString("TableName");
            _tableStyle  = ETableStyleUtils.GetEnumType(Body.GetQueryString("TableStyle"));
            _redirectUrl = StringUtils.ValueFromUrl(Body.GetQueryString("RedirectUrl"));

            if (!IsPostBack)
            {
                IsVisible.Items[0].Value = true.ToString();
                IsVisible.Items[1].Value = false.ToString();

                IsSingleLine.Items[0].Value = true.ToString();
                IsSingleLine.Items[1].Value = false.ToString();

                IsHorizontal.Items[0].Value = true.ToString();
                IsHorizontal.Items[1].Value = false.ToString();

                EInputTypeUtils.AddListItems(InputType);

                var styleInfo = TableStyleManager.GetTableStyleInfo(_tableStyle, _tableName, string.Empty, _relatedIdentities);

                ControlUtils.SelectListItems(InputType, EInputTypeUtils.GetValue(EInputTypeUtils.GetEnumType(styleInfo.InputType)));
                ControlUtils.SelectListItems(IsVisible, styleInfo.IsVisible.ToString());
                ControlUtils.SelectListItems(IsSingleLine, styleInfo.IsSingleLine.ToString());
                DefaultValue.Text          = styleInfo.DefaultValue;
                IsHorizontal.SelectedValue = styleInfo.IsHorizontal.ToString();
                Columns.Text = styleInfo.Additional.Columns.ToString();

                Height.Text = styleInfo.Additional.Height.ToString();
                Width.Text  = styleInfo.Additional.Width.ToString();

                ItemCount.Text = "0";
            }

            ReFresh(null, EventArgs.Empty);
        }
        protected override void Render(HtmlTextWriter output)
        {
            var nodeId = int.Parse(HttpContext.Current.Request.QueryString["NodeID"]);
            var publishmentSystemId   = int.Parse(HttpContext.Current.Request.QueryString["PublishmentSystemID"]);
            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);

            if (_formCollection == null)
            {
                if (HttpContext.Current.Request.Form.Count > 0)
                {
                    _formCollection = HttpContext.Current.Request.Form;
                }
                else
                {
                    _formCollection = new NameValueCollection();
                }
            }

            var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(publishmentSystemId, nodeId);
            var styleInfoList     = TableStyleManager.GetTableStyleInfoList(ETableStyle.Channel, DataProvider.NodeDao.TableName, relatedIdentities);

            if (styleInfoList != null)
            {
                var builder     = new StringBuilder();
                var pageScripts = new NameValueCollection();
                foreach (var styleInfo in styleInfoList)
                {
                    if (styleInfo.IsVisible)
                    {
                        var attributes = InputParserUtils.GetAdditionalAttributes(string.Empty, EInputTypeUtils.GetEnumType(styleInfo.InputType));
                        //string inputHtml = TableInputParser.Parse(styleInfo, styleInfo.AttributeName, this.formCollection, this.isEdit, isPostBack, attributes, pageScripts);
                        var inputHtml = BackgroundInputTypeParser.Parse(publishmentSystemInfo, nodeId, styleInfo, ETableStyle.Channel, styleInfo.AttributeName, _formCollection, _isEdit, _isPostBack, attributes, pageScripts, true);

                        builder.AppendFormat(GetFormatString(EInputTypeUtils.GetEnumType(styleInfo.InputType)), styleInfo.DisplayName, inputHtml, styleInfo.HelpText);
                    }
                }

                output.Write(builder.ToString());

                foreach (string key in pageScripts.Keys)
                {
                    output.Write(pageScripts[key]);
                }
            }
        }
Example #10
0
        public string GetInnerAdditionalAttributes(TableStyleInfo styleInfo)
        {
            var additionalAttributes = string.Empty;

            var inputType = EInputTypeUtils.GetEnumType(styleInfo.InputType);

            if (inputType == EInputType.Text || inputType == EInputType.Date || inputType == EInputType.DateTime)
            {
                additionalAttributes = @"class=""is_text""";
            }
            else if (inputType == EInputType.Image || inputType == EInputType.Video || inputType == EInputType.File)
            {
                additionalAttributes = @"class=""is_upload""";
            }
            else if (inputType == EInputType.TextArea)
            {
                additionalAttributes = @"class=""is_textarea""";
            }

            return(additionalAttributes);
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            var inputType = EInputTypeUtils.GetEnumType(InputType.SelectedValue);

            if (inputType == EInputType.CheckBox || inputType == EInputType.Radio || inputType == EInputType.SelectMultiple || inputType == EInputType.SelectOne)
            {
                var itemCount = TranslateUtils.ToInt(ItemCount.Text);
                if (itemCount == 0)
                {
                    FailMessage("操作失败,选项数目不能为0!");
                    return;
                }
            }

            isChanged = InsertTableStyleInfo(inputType);

            if (isChanged)
            {
                PageUtils.CloseModalPageAndRedirect(Page, _redirectUrl);
            }
        }
        public void ReFresh(object sender, EventArgs e)
        {
            RowDefaultValue.Visible = RowHeightAndWidth.Visible = DateTip.Visible = RowItemCount.Visible = RowSetItems.Visible = RowRepeat.Visible = false;
            Height.Enabled          = true;

            DefaultValue.TextMode = TextBoxMode.MultiLine;
            var inputType = EInputTypeUtils.GetEnumType(InputType.SelectedValue);

            if (inputType == EInputType.CheckBox || inputType == EInputType.Radio || inputType == EInputType.SelectMultiple || inputType == EInputType.SelectOne)
            {
                RowItemCount.Visible = RowSetItems.Visible = true;
                if (inputType == EInputType.CheckBox || inputType == EInputType.Radio)
                {
                    RowRepeat.Visible = true;
                }
            }
            else if (inputType == EInputType.TextEditor)
            {
                RowDefaultValue.Visible = RowHeightAndWidth.Visible = true;
            }
            else if (inputType == EInputType.TextArea)
            {
                RowDefaultValue.Visible = RowHeightAndWidth.Visible = true;
            }
            else if (inputType == EInputType.Text)
            {
                RowDefaultValue.Visible = RowHeightAndWidth.Visible = true;
                Height.Enabled          = false;
                DefaultValue.TextMode   = TextBoxMode.SingleLine;
            }
            else if (inputType == EInputType.Date || inputType == EInputType.DateTime)
            {
                DateTip.Visible       = RowDefaultValue.Visible = true;
                DefaultValue.TextMode = TextBoxMode.SingleLine;
            }
        }
Example #13
0
        private static string ParseImpl(XmlNode node, PageInfo pageInfo, ContextInfo contextInfo, string leftText, string rightText, string formatString, string no, string separator, int startIndex, int length, int wordNum, string ellipsis, string replace, string to, bool isClearTags, string isReturnToBrStr, bool isLower, bool isUpper, bool isOriginal, string type, StringDictionary attributes, string imageType)
        {
            var parsedContent = string.Empty;

            var isReturnToBr = false;

            if (string.IsNullOrEmpty(isReturnToBrStr))
            {
                if (BackgroundContentAttribute.Summary.ToLower().Equals(type))
                {
                    isReturnToBr = true;
                }
            }
            else
            {
                isReturnToBr = TranslateUtils.ToBool(isReturnToBrStr, true);
            }

            var contentId   = contextInfo.ContentID;
            var contentInfo = contextInfo.ContentInfo;

            if (contentInfo == null)
            {
                return(string.Empty);
            }

            if (isOriginal)
            {
                if (contentInfo.ReferenceId > 0 && contentInfo.SourceId > 0 && contentInfo.GetExtendedAttribute(ContentAttribute.TranslateContentType) == ETranslateContentType.Reference.ToString())
                {
                    var targetNodeId = contentInfo.SourceId;
                    var targetPublishmentSystemId   = DataProvider.NodeDao.GetPublishmentSystemId(targetNodeId);
                    var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetPublishmentSystemId);
                    var targetNodeInfo = NodeManager.GetNodeInfo(targetPublishmentSystemId, targetNodeId);

                    var tableStyle        = NodeManager.GetTableStyle(targetPublishmentSystemInfo, targetNodeInfo);
                    var tableName         = NodeManager.GetTableName(targetPublishmentSystemInfo, targetNodeInfo);
                    var targetContentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentInfo.ReferenceId);
                    if (targetContentInfo != null && targetContentInfo.NodeId > 0)
                    {
                        //标题可以使用自己的
                        targetContentInfo.Title = contentInfo.Title;
                        contentInfo             = targetContentInfo;
                    }
                }
            }

            if (!string.IsNullOrEmpty(formatString))
            {
                formatString = formatString.Trim();
                if (!formatString.StartsWith("{0"))
                {
                    formatString = "{0:" + formatString;
                }
                if (!formatString.EndsWith("}"))
                {
                    formatString = formatString + "}";
                }
            }

            if (contentId != 0)
            {
                if (ContentAttribute.Title.ToLower().Equals(type))
                {
                    var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(pageInfo.PublishmentSystemId, contentInfo.NodeId);
                    var nodeInfo          = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contentInfo.NodeId);
                    var tableStyle        = NodeManager.GetTableStyle(pageInfo.PublishmentSystemInfo, nodeInfo);
                    var tableName         = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, nodeInfo);

                    var styleInfo = TableStyleManager.GetTableStyleInfo(tableStyle, tableName, type, relatedIdentities);
                    if (wordNum == 0)
                    {
                        wordNum = contextInfo.TitleWordNum;
                    }
                    parsedContent = InputParserUtility.GetContentByTableStyle(contentInfo.Title, separator, pageInfo.PublishmentSystemInfo, tableStyle, styleInfo, formatString, attributes, node.InnerXml, false);
                    parsedContent = StringUtils.ParseString(EInputTypeUtils.GetEnumType(styleInfo.InputType), parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);

                    if (!isClearTags && !string.IsNullOrEmpty(contentInfo.Attributes[BackgroundContentAttribute.TitleFormatString]))
                    {
                        parsedContent = ContentUtility.FormatTitle(contentInfo.Attributes[BackgroundContentAttribute.TitleFormatString], parsedContent);
                    }

                    if (!contextInfo.IsInnerElement)
                    {
                        parsedContent = parsedContent.Replace("&", "&amp;");
                    }

                    if (pageInfo.PublishmentSystemInfo.Additional.IsContentTitleBreakLine)
                    {
                        parsedContent = parsedContent.Replace("  ", !contextInfo.IsInnerElement ? "<br />" : string.Empty);
                    }
                }
                else if (BackgroundContentAttribute.Summary.ToLower().Equals(type))
                {
                    parsedContent = StringUtils.ParseString(contentInfo.GetExtendedAttribute(BackgroundContentAttribute.Summary), replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);
                    if (!contextInfo.IsInnerElement)
                    {
                        parsedContent = parsedContent.Replace("&", "&amp;");
                    }
                }
                else if (BackgroundContentAttribute.Content.ToLower().Equals(type))
                {
                    parsedContent = StringUtility.TextEditorContentDecode(contentInfo.GetExtendedAttribute(BackgroundContentAttribute.Content), pageInfo.PublishmentSystemInfo);

                    if (pageInfo.PublishmentSystemInfo.Additional.IsInnerLink)
                    {
                        var innerLinkInfoList = pageInfo.CacheOfInnerLinkInfoList;
                        if (innerLinkInfoList != null && innerLinkInfoList.Count > 0)
                        {
                            InnerLinkInfo newInnerLinkInfo;
                            for (var i = 0; i < innerLinkInfoList.Count - 1; i++)
                            {
                                for (var j = i + 1; j < innerLinkInfoList.Count; j++)
                                {
                                    if (innerLinkInfoList[i].InnerLinkName.Length < innerLinkInfoList[j].InnerLinkName.Length)
                                    {
                                        newInnerLinkInfo     = innerLinkInfoList[i];
                                        innerLinkInfoList[i] = innerLinkInfoList[j];
                                        innerLinkInfoList[j] = newInnerLinkInfo;
                                    }
                                }
                            }

                            var arrayLinkName  = new List <string>();
                            var arrayInnerLink = new List <string>();
                            for (var i = 0; i < innerLinkInfoList.Count; i++)
                            {
                                newInnerLinkInfo = innerLinkInfoList[i];
                                arrayLinkName.Add(newInnerLinkInfo.InnerLinkName);
                                arrayInnerLink.Add(newInnerLinkInfo.InnerString);
                            }
                            for (var m = 0; m < arrayLinkName.Count; m++)
                            {
                                var innerLinkName = arrayLinkName[m];
                                arrayLinkName[m] = Guid.NewGuid().ToString();
                                parsedContent    = RegexUtils.Replace(
                                    $"({innerLinkName.Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", parsedContent, arrayLinkName[m], pageInfo.PublishmentSystemInfo.Additional.InnerLinkMaxNum);
                            }
                            for (var n = 0; n < arrayLinkName.Count; n++)
                            {
                                parsedContent = RegexUtils.Replace(
                                    $"({arrayLinkName[n].Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", parsedContent, arrayInnerLink[n], pageInfo.PublishmentSystemInfo.Additional.InnerLinkMaxNum);
                            }
                        }
                    }

                    if (isClearTags)
                    {
                        parsedContent = StringUtils.StripTags(parsedContent);
                    }

                    if (!string.IsNullOrEmpty(replace))
                    {
                        parsedContent = StringUtils.Replace(replace, parsedContent, to);
                    }

                    if (wordNum > 0 && !string.IsNullOrEmpty(parsedContent))
                    {
                        parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis);
                    }

                    if (!string.IsNullOrEmpty(formatString))
                    {
                        parsedContent = string.Format(formatString, parsedContent);
                    }

                    if (!contextInfo.IsInnerElement)
                    {
                        parsedContent = parsedContent.Replace("&", "&amp;");
                    }
                }
                else if (BackgroundContentAttribute.PageContent.ToLower().Equals(type))
                {
                    //if (contextInfo.IsInnerElement)
                    // {
                    parsedContent = StringUtility.TextEditorContentDecode(contentInfo.GetExtendedAttribute(BackgroundContentAttribute.Content), pageInfo.PublishmentSystemInfo);


                    if (pageInfo.PublishmentSystemInfo.Additional.IsInnerLink)
                    {
                        var innerLinkInfoList = pageInfo.CacheOfInnerLinkInfoList;
                        if (innerLinkInfoList != null && innerLinkInfoList.Count > 0)
                        {
                            InnerLinkInfo newInnerLinkInfo;
                            for (var i = 0; i < innerLinkInfoList.Count - 1; i++)
                            {
                                for (var j = i + 1; j < innerLinkInfoList.Count; j++)
                                {
                                    if (innerLinkInfoList[i].InnerLinkName.Length < innerLinkInfoList[j].InnerLinkName.Length)
                                    {
                                        newInnerLinkInfo     = innerLinkInfoList[i];
                                        innerLinkInfoList[i] = innerLinkInfoList[j];
                                        innerLinkInfoList[j] = newInnerLinkInfo;
                                    }
                                }
                            }
                            for (var i = 0; i < innerLinkInfoList.Count; i++)
                            {
                                newInnerLinkInfo = innerLinkInfoList[i];
                                for (var j = i + 1; j < innerLinkInfoList.Count; j++)
                                {
                                    var lastInnerLinkInfo = innerLinkInfoList[j];
                                    if (newInnerLinkInfo.InnerLinkName.Contains(lastInnerLinkInfo.InnerLinkName))
                                    {
                                        innerLinkInfoList.Remove(lastInnerLinkInfo);
                                    }
                                }
                                parsedContent = RegexUtils.Replace(
                                    $"({newInnerLinkInfo.InnerLinkName.Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", parsedContent, newInnerLinkInfo.InnerString, pageInfo.PublishmentSystemInfo.Additional.InnerLinkMaxNum);
                            }
                        }
                    }

                    if (isClearTags)
                    {
                        parsedContent = StringUtils.StripTags(parsedContent);
                    }

                    if (!string.IsNullOrEmpty(replace))
                    {
                        parsedContent = StringUtils.Replace(replace, parsedContent, to);
                    }

                    if (wordNum > 0 && !string.IsNullOrEmpty(parsedContent))
                    {
                        parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis);
                    }

                    if (!string.IsNullOrEmpty(formatString))
                    {
                        parsedContent = string.Format(formatString, parsedContent);
                    }
                }
                else if (ContentAttribute.AddDate.ToLower().Equals(type))
                {
                    parsedContent = DateUtils.Format(contentInfo.AddDate, formatString);
                }
                else if (ContentAttribute.LastEditDate.ToLower().Equals(type))
                {
                    parsedContent = DateUtils.Format(contentInfo.LastEditDate, formatString);
                }
                else if (BackgroundContentAttribute.ImageUrl.ToLower().Equals(type))
                {
                    if (no == "all")
                    {
                        var sbParsedContent = new StringBuilder();
                        //第一条
                        if (contextInfo.IsCurlyBrace)
                        {
                            sbParsedContent.Append(PageUtility.ParseNavigationUrl(pageInfo.PublishmentSystemInfo, GetImageUrlByType(contentInfo.GetExtendedAttribute(BackgroundContentAttribute.ImageUrl), imageType)));
                        }
                        else
                        {
                            sbParsedContent.Append(InputParserUtility.GetImageOrFlashHtml(pageInfo.PublishmentSystemInfo, GetImageUrlByType(contentInfo.GetExtendedAttribute(BackgroundContentAttribute.ImageUrl), imageType), attributes, false));
                        }
                        //第n条
                        var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl);
                        var extendValues        = contentInfo.GetExtendedAttribute(extendAttributeName);
                        if (!string.IsNullOrEmpty(extendValues))
                        {
                            foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                            {
                                var newExtendValue = GetImageUrlByType(extendValue, imageType);
                                if (contextInfo.IsCurlyBrace)
                                {
                                    sbParsedContent.Append(PageUtility.ParseNavigationUrl(pageInfo.PublishmentSystemInfo, newExtendValue));
                                }
                                else
                                {
                                    sbParsedContent.Append(InputParserUtility.GetImageOrFlashHtml(pageInfo.PublishmentSystemInfo, newExtendValue, attributes, false));
                                }
                            }
                        }

                        parsedContent = sbParsedContent.ToString();
                    }
                    else
                    {
                        var num = TranslateUtils.ToInt(no, 0);
                        if (num <= 1)
                        {
                            if (contextInfo.IsCurlyBrace)
                            {
                                parsedContent = PageUtility.ParseNavigationUrl(pageInfo.PublishmentSystemInfo, GetImageUrlByType(contentInfo.GetExtendedAttribute(BackgroundContentAttribute.ImageUrl), imageType));
                            }
                            else
                            {
                                parsedContent = InputParserUtility.GetImageOrFlashHtml(pageInfo.PublishmentSystemInfo, GetImageUrlByType(contentInfo.GetExtendedAttribute(BackgroundContentAttribute.ImageUrl), imageType), attributes, false);
                            }
                        }
                        else
                        {
                            var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl);
                            var extendValues        = contentInfo.GetExtendedAttribute(extendAttributeName);
                            if (!string.IsNullOrEmpty(extendValues))
                            {
                                var index = 2;
                                foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                {
                                    var newExtendValue = GetImageUrlByType(extendValue, imageType);
                                    if (index == num)
                                    {
                                        if (contextInfo.IsCurlyBrace)
                                        {
                                            parsedContent = PageUtility.ParseNavigationUrl(pageInfo.PublishmentSystemInfo, newExtendValue);
                                        }
                                        else
                                        {
                                            parsedContent = InputParserUtility.GetImageOrFlashHtml(pageInfo.PublishmentSystemInfo, newExtendValue, attributes, false);
                                        }
                                        break;
                                    }
                                    index++;
                                }
                            }
                        }
                    }
                }
                else if (BackgroundContentAttribute.VideoUrl.ToLower().Equals(type))
                {
                    if (no == "all")
                    {
                        var sbParsedContent = new StringBuilder();
                        //第一条
                        sbParsedContent.Append(InputParserUtility.GetVideoHtml(pageInfo.PublishmentSystemInfo, contentInfo.GetExtendedAttribute(BackgroundContentAttribute.VideoUrl), attributes, false));

                        //第n条
                        var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.VideoUrl);
                        var extendValues        = contentInfo.GetExtendedAttribute(extendAttributeName);
                        if (!string.IsNullOrEmpty(extendValues))
                        {
                            foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                            {
                                sbParsedContent.Append(InputParserUtility.GetVideoHtml(pageInfo.PublishmentSystemInfo, extendValue, attributes, false));
                            }
                        }

                        parsedContent = sbParsedContent.ToString();
                    }
                    else
                    {
                        var num = TranslateUtils.ToInt(no, 0);
                        if (num <= 1)
                        {
                            parsedContent = InputParserUtility.GetVideoHtml(pageInfo.PublishmentSystemInfo, contentInfo.GetExtendedAttribute(BackgroundContentAttribute.VideoUrl), attributes, false);
                        }
                        else
                        {
                            var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.VideoUrl);
                            var extendValues        = contentInfo.GetExtendedAttribute(extendAttributeName);
                            if (!string.IsNullOrEmpty(extendValues))
                            {
                                var index = 2;
                                foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                {
                                    if (index == num)
                                    {
                                        parsedContent = InputParserUtility.GetVideoHtml(pageInfo.PublishmentSystemInfo, extendValue, attributes, false);
                                        break;
                                    }
                                    index++;
                                }
                            }
                        }
                    }
                }
                else if (BackgroundContentAttribute.FileUrl.ToLower().Equals(type))
                {
                    if (no == "all")
                    {
                        var sbParsedContent = new StringBuilder();
                        if (contextInfo.IsCurlyBrace)
                        {
                            //第一条
                            sbParsedContent.Append(contentInfo.GetExtendedAttribute(BackgroundContentAttribute.FileUrl));
                            //第n条
                            var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl);
                            var extendValues        = contentInfo.GetExtendedAttribute(extendAttributeName);
                            if (!string.IsNullOrEmpty(extendValues))
                            {
                                foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                {
                                    sbParsedContent.Append(extendValue);
                                }
                            }
                        }
                        else
                        {
                            //第一条
                            sbParsedContent.Append(InputParserUtility.GetFileHtmlWithCount(pageInfo.PublishmentSystemInfo, contentInfo.NodeId, contentInfo.Id, contentInfo.GetExtendedAttribute(BackgroundContentAttribute.FileUrl), attributes, node.InnerXml, false));
                            //第n条
                            var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl);
                            var extendValues        = contentInfo.GetExtendedAttribute(extendAttributeName);
                            if (!string.IsNullOrEmpty(extendValues))
                            {
                                foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                {
                                    sbParsedContent.Append(InputParserUtility.GetFileHtmlWithCount(pageInfo.PublishmentSystemInfo, contentInfo.NodeId, contentInfo.Id, extendValue, attributes, node.InnerXml, false));
                                }
                            }
                        }

                        parsedContent = sbParsedContent.ToString();
                    }
                    else
                    {
                        var num = TranslateUtils.ToInt(no, 0);
                        if (contextInfo.IsCurlyBrace)
                        {
                            if (num <= 1)
                            {
                                parsedContent = contentInfo.GetExtendedAttribute(BackgroundContentAttribute.FileUrl);
                            }
                            else
                            {
                                var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl);
                                var extendValues        = contentInfo.GetExtendedAttribute(extendAttributeName);
                                if (!string.IsNullOrEmpty(extendValues))
                                {
                                    var index = 2;
                                    foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                    {
                                        if (index == num)
                                        {
                                            parsedContent = extendValue;
                                            break;
                                        }
                                        index++;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (num <= 1)
                            {
                                parsedContent = InputParserUtility.GetFileHtmlWithCount(pageInfo.PublishmentSystemInfo, contentInfo.NodeId, contentInfo.Id, contentInfo.GetExtendedAttribute(BackgroundContentAttribute.FileUrl), attributes, node.InnerXml, false);
                            }
                            else
                            {
                                var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl);
                                var extendValues        = contentInfo.GetExtendedAttribute(extendAttributeName);
                                if (!string.IsNullOrEmpty(extendValues))
                                {
                                    var index = 2;
                                    foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                    {
                                        if (index == num)
                                        {
                                            parsedContent = InputParserUtility.GetFileHtmlWithCount(pageInfo.PublishmentSystemInfo, contentInfo.NodeId, contentInfo.Id, extendValue, attributes, node.InnerXml, false);
                                            break;
                                        }
                                        index++;
                                    }
                                }
                            }
                        }
                    }
                }
                else if (BackgroundContentAttribute.NavigationUrl.ToLower().Equals(type))
                {
                    parsedContent = PageUtility.GetContentUrl(pageInfo.PublishmentSystemInfo, contentInfo);
                }
                else if (ContentAttribute.Tags.ToLower().Equals(type))
                {
                    parsedContent = contentInfo.Tags;
                }
                else if (StringUtils.StartsWithIgnoreCase(type, StlParserUtility.ItemIndex) && contextInfo.ItemContainer?.ContentItem != null)
                {
                    var itemIndex = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.ContentItem.ItemIndex, type, contextInfo);
                    parsedContent = !string.IsNullOrEmpty(formatString) ? string.Format(formatString, itemIndex) : itemIndex.ToString();
                }
                else if (ContentAttribute.AddUserName.ToLower().Equals(type))
                {
                    if (!string.IsNullOrEmpty(contentInfo.AddUserName))
                    {
                        var displayName = BaiRongDataProvider.AdministratorDao.GetDisplayName(contentInfo.AddUserName);
                        parsedContent = string.IsNullOrEmpty(displayName) ? contentInfo.AddUserName : displayName;
                    }
                }
                else
                {
                    var isSelected = false;
                    var nodeInfo   = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contentInfo.NodeId);
                    var tableStyle = NodeManager.GetTableStyle(pageInfo.PublishmentSystemInfo, nodeInfo);

                    //WCM SPECIFIC

                    if (tableStyle == ETableStyle.GovInteractContent)
                    {
                        isSelected = true;
                        if (GovInteractContentAttribute.State.ToLower().Equals(type))
                        {
                            parsedContent = EGovInteractStateUtils.GetText(EGovInteractStateUtils.GetEnumType(contentInfo.GetExtendedAttribute(GovInteractContentAttribute.State)));
                        }
                        else if (StringUtils.EqualsIgnoreCase(type, GovInteractContentAttribute.Reply))
                        {
                            var replyInfo = DataProvider.GovInteractReplyDao.GetReplyInfoByContentId(pageInfo.PublishmentSystemId, contentInfo.Id);
                            if (replyInfo != null)
                            {
                                parsedContent = replyInfo.Reply;
                                if (!string.IsNullOrEmpty(parsedContent))
                                {
                                    parsedContent = StringUtils.ParseString(EInputType.TextEditor, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);
                                }
                            }
                        }
                        else if (StringUtils.EqualsIgnoreCase(type, GovInteractContentAttribute.ReplyDepartment))
                        {
                            var replyInfo = DataProvider.GovInteractReplyDao.GetReplyInfoByContentId(pageInfo.PublishmentSystemId, contentInfo.Id);
                            if (replyInfo != null)
                            {
                                parsedContent = DepartmentManager.GetDepartmentName(replyInfo.DepartmentID);
                            }
                        }
                        else if (StringUtils.EqualsIgnoreCase(type, GovInteractContentAttribute.ReplyUserName))
                        {
                            var replyInfo = DataProvider.GovInteractReplyDao.GetReplyInfoByContentId(pageInfo.PublishmentSystemId, contentInfo.Id);
                            if (replyInfo != null)
                            {
                                parsedContent = replyInfo.UserName;
                            }
                        }
                        else if (StringUtils.EqualsIgnoreCase(type, GovInteractContentAttribute.ReplyDate))
                        {
                            var replyInfo = DataProvider.GovInteractReplyDao.GetReplyInfoByContentId(pageInfo.PublishmentSystemId, contentInfo.Id);
                            if (replyInfo != null)
                            {
                                var addDate = replyInfo.AddDate;
                                parsedContent = DateUtils.Format(addDate, formatString);
                            }
                        }
                        else if (StringUtils.EqualsIgnoreCase(type, GovInteractContentAttribute.ReplyFileUrl))
                        {
                            var replyInfo = DataProvider.GovInteractReplyDao.GetReplyInfoByContentId(pageInfo.PublishmentSystemId, contentInfo.Id);
                            if (replyInfo != null)
                            {
                                parsedContent = PageUtility.ParseNavigationUrl(pageInfo.PublishmentSystemInfo, replyInfo.FileUrl);
                            }
                        }
                        else
                        {
                            isSelected = false;
                        }
                    }

                    //WCM SPECIFIC

                    if (!isSelected && contentInfo.ContainsKey(type))
                    {
                        if (!ContentAttribute.HiddenAttributes.Contains(type.ToLower()))
                        {
                            var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(pageInfo.PublishmentSystemId, contentInfo.NodeId);
                            var tableName         = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, nodeInfo);
                            var styleInfo         = TableStyleManager.GetTableStyleInfo(tableStyle, tableName, type, relatedIdentities);
                            var num = TranslateUtils.ToInt(no);
                            parsedContent = InputParserUtility.GetContentByTableStyle(contentInfo, separator, pageInfo.PublishmentSystemInfo, tableStyle, styleInfo, formatString, num, attributes, node.InnerXml, false);
                            parsedContent = StringUtils.ParseString(EInputTypeUtils.GetEnumType(styleInfo.InputType), parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);
                        }
                        else
                        {
                            parsedContent = contentInfo.GetExtendedAttribute(type);
                            parsedContent = StringUtils.ParseString(parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);
                        }
                    }

                    if (!contextInfo.IsInnerElement)
                    {
                        parsedContent = parsedContent.Replace("&", "&amp;");
                    }
                }

                if (!string.IsNullOrEmpty(parsedContent))
                {
                    parsedContent = leftText + parsedContent + rightText;
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(type) && contextInfo.ItemContainer != null && contextInfo.ItemContainer.ContentItem != null)
                {
                    parsedContent = DataBinder.Eval(contextInfo.ItemContainer.ContentItem.DataItem, type, "{0}");

                    parsedContent = StringUtils.ParseString(parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);

                    if (!string.IsNullOrEmpty(parsedContent))
                    {
                        parsedContent = leftText + parsedContent + rightText;
                    }
                }
            }

            return(parsedContent);
        }
Example #14
0
        void dgContents_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var styleInfo = e.Item.DataItem as TableStyleInfo;

                var ltlAttributeName = e.Item.FindControl("ltlAttributeName") as Literal;
                var ltlDataType      = e.Item.FindControl("ltlDataType") as Literal;
                var ltlDisplayName   = e.Item.FindControl("ltlDisplayName") as Literal;
                var ltlInputType     = e.Item.FindControl("ltlInputType") as Literal;
                var ltlFieldType     = e.Item.FindControl("ltlFieldType") as Literal;;
                var ltlIsVisible     = e.Item.FindControl("ltlIsVisible") as Literal;
                var ltlValidate      = e.Item.FindControl("ltlValidate") as Literal;
                var ltlEditStyle     = e.Item.FindControl("ltlEditStyle") as Literal;
                var ltlEditValidate  = e.Item.FindControl("ltlEditValidate") as Literal;
                var upLinkButton     = e.Item.FindControl("UpLinkButton") as HyperLink;
                var downLinkButton   = e.Item.FindControl("DownLinkButton") as HyperLink;

                var showPopWinString = ModalTableMetadataView.GetOpenWindowString(_modelInfo.TableType,
                                                                                  _modelInfo.TableName, styleInfo.AttributeName);
                ltlAttributeName.Text =
                    $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">{styleInfo.AttributeName}</a>";

                ltlDisplayName.Text = styleInfo.DisplayName;
                ltlInputType.Text   = EInputTypeUtils.GetText(EInputTypeUtils.GetEnumType(styleInfo.InputType));
                if (TableManager.IsAttributeNameExists(_tableStyle, _modelInfo.TableName, styleInfo.AttributeName))
                {
                    ltlFieldType.Text =
                        $"真实 {TableManager.GetTableMetadataDataType(_modelInfo.TableName, styleInfo.AttributeName)}";
                }
                else
                {
                    ltlFieldType.Text = "虚拟字段";
                }

                ltlIsVisible.Text = StringUtils.GetTrueOrFalseImageHtml(styleInfo.IsVisible.ToString());
                ltlValidate.Text  = EInputValidateTypeUtils.GetValidateInfo(styleInfo);

                showPopWinString = ModalTableStyleAdd.GetOpenWindowString(PublishmentSystemId, styleInfo.TableStyleId, _relatedIdentities, _modelInfo.TableName, styleInfo.AttributeName, _tableStyle, _redirectUrl);
                var editText = "添加";
                if (styleInfo.RelatedIdentity == _nodeInfo.NodeId)//数据库中有样式
                {
                    editText = "修改";
                }
                ltlEditStyle.Text = $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">{editText}</a>";

                showPopWinString     = ModalTableStyleValidateAdd.GetOpenWindowString(styleInfo.TableStyleId, _relatedIdentities, _modelInfo.TableName, styleInfo.AttributeName, _tableStyle, _redirectUrl);
                ltlEditValidate.Text = $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">设置</a>";

                if (styleInfo.RelatedIdentity == _nodeInfo.NodeId)//数据库中有样式
                {
                    var urlStyle = PageUtils.GetCmsUrl(nameof(PageTableStyleContent), new NameValueCollection
                    {
                        { "PublishmentSystemID", PublishmentSystemId.ToString() },
                        { "NodeID", _nodeInfo.NodeId.ToString() },
                        { "DeleteStyle", true.ToString() },
                        { "TableName", _modelInfo.TableName },
                        { "AttributeName", styleInfo.AttributeName }
                    });
                    ltlEditStyle.Text +=
                        $@"&nbsp;&nbsp;<a href=""{urlStyle}"" onClick=""javascript:return confirm('此操作将删除对应显示样式,确认吗?');"">删除</a>";
                }

                var isTaxisVisible = true;
                //if (TableStyleManager.IsMetadata(this.tableStyle, styleInfo.AttributeName) || styleInfo.RelatedIdentity != this.nodeInfo.NodeID)
                //{
                //    isTaxisVisible = false;
                //}
                //else
                //{
                isTaxisVisible = !TableStyleManager.IsExistsInParents(_relatedIdentities, _modelInfo.TableName, styleInfo.AttributeName);
                //}

                if (!isTaxisVisible)
                {
                    upLinkButton.Visible = downLinkButton.Visible = false;
                }
                else
                {
                    var tableMetadataId = BaiRongDataProvider.TableMetadataDao.GetTableMetadataId(styleInfo.TableName, styleInfo.AttributeName);
                    upLinkButton.NavigateUrl = PageUtils.GetCmsUrl(nameof(PageTableStyleContent), new NameValueCollection
                    {
                        { "PublishmentSystemID", PublishmentSystemId.ToString() },
                        { "NodeID", _nodeInfo.NodeId.ToString() },
                        { "SetTaxis", true.ToString() },
                        { "TableStyleID", styleInfo.TableStyleId.ToString() },
                        { "Direction", "UP" },
                        { "TableMetadataId", tableMetadataId.ToString() }
                    });
                    downLinkButton.NavigateUrl = PageUtils.GetCmsUrl(nameof(PageTableStyleContent), new NameValueCollection
                    {
                        { "PublishmentSystemID", PublishmentSystemId.ToString() },
                        { "NodeID", _nodeInfo.NodeId.ToString() },
                        { "SetTaxis", true.ToString() },
                        { "TableStyleID", styleInfo.TableStyleId.ToString() },
                        { "Direction", "DOWN" },
                        { "TableMetadataId", tableMetadataId.ToString() }
                    });
                }
            }
        }
Example #15
0
        public void ImportTableStyles(int publishmentSystemId)
        {
            if (!DirectoryUtils.IsDirectoryExists(_directoryPath))
            {
                return;
            }

            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);

            var importObject        = new ImportObject(publishmentSystemId);
            var tableNameCollection = importObject.GetTableNameCache();

            var styleDirectoryPaths = DirectoryUtils.GetDirectoryPaths(_directoryPath);

            foreach (var styleDirectoryPath in styleDirectoryPaths)
            {
                var tableName = PathUtils.GetDirectoryName(styleDirectoryPath);
                if (!string.IsNullOrEmpty(tableNameCollection?[tableName]))
                {
                    tableName = tableNameCollection[tableName];
                }

                ETableStyle tableStyle;

                if (BaiRongDataProvider.TableCollectionDao.IsTableExists(tableName))
                {
                    var tableType = BaiRongDataProvider.TableCollectionDao.GetTableType(tableName);
                    tableStyle = EAuxiliaryTableTypeUtils.GetTableStyle(tableType);
                }
                else
                {
                    tableStyle = PublishmentSystemManager.GetTableStyle(publishmentSystemInfo, tableName);
                }

                var attributeNamePaths = DirectoryUtils.GetDirectoryPaths(styleDirectoryPath);
                foreach (var attributeNamePath in attributeNamePaths)
                {
                    var attributeName = PathUtils.GetDirectoryName(attributeNamePath);
                    var filePaths     = DirectoryUtils.GetFilePaths(attributeNamePath);
                    foreach (var filePath in filePaths)
                    {
                        var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(filePath));

                        var taxis           = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(feed.AdditionalElements, "Taxis"), 0);
                        var displayName     = AtomUtility.GetDcElementContent(feed.AdditionalElements, "DisplayName");
                        var helpText        = AtomUtility.GetDcElementContent(feed.AdditionalElements, "HelpText");
                        var isVisible       = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsVisible"));
                        var isVisibleInList = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsVisibleInList"));
                        var isSingleLine    = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsSingleLine"));
                        var inputType       = EInputTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(feed.AdditionalElements, "InputType"));
                        var defaultValue    = AtomUtility.GetDcElementContent(feed.AdditionalElements, "DefaultValue");
                        var isHorizontal    = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsHorizontal"));
                        var extendValues    = AtomUtility.GetDcElementContent(feed.AdditionalElements, "ExtendValues");

                        int relatedIdentity;
                        if (tableStyle == ETableStyle.Site)
                        {
                            relatedIdentity = publishmentSystemId;
                        }
                        else
                        {
                            var orderString = AtomUtility.GetDcElementContent(feed.AdditionalElements, "OrderString");

                            if (!string.IsNullOrEmpty(orderString))
                            {
                                relatedIdentity = DataProvider.NodeDao.GetNodeId(publishmentSystemId, orderString);
                            }
                            else
                            {
                                relatedIdentity = publishmentSystemId;
                            }
                        }

                        if (relatedIdentity <= 0 ||
                            TableStyleManager.IsExists(relatedIdentity, tableName, attributeName))
                        {
                            continue;
                        }

                        var styleInfo = new TableStyleInfo(0, relatedIdentity, tableName, attributeName, taxis, displayName, helpText, isVisible, isVisibleInList, isSingleLine, EInputTypeUtils.GetValue(inputType), defaultValue, isHorizontal, extendValues);

                        var styleItems = new List <TableStyleItemInfo>();
                        foreach (AtomEntry entry in feed.Entries)
                        {
                            var itemTitle  = AtomUtility.GetDcElementContent(entry.AdditionalElements, "ItemTitle");
                            var itemValue  = AtomUtility.GetDcElementContent(entry.AdditionalElements, "ItemValue");
                            var isSelected = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, "IsSelected"));

                            styleItems.Add(new TableStyleItemInfo(0, 0, itemTitle, itemValue, isSelected));
                        }

                        if (styleItems.Count > 0)
                        {
                            styleInfo.StyleItems = styleItems;
                        }

                        TableStyleManager.InsertWithTaxis(styleInfo, tableStyle);
                    }
                }
            }
        }
Example #16
0
        void dgContents_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var tableMetadataId = SqlUtils.EvalInt(e.Item.DataItem, "TableMetadataID");
                var attributeName   = SqlUtils.EvalString(e.Item.DataItem, "AttributeName");
                var dataType        = SqlUtils.EvalString(e.Item.DataItem, "DataType");
                var dataLength      = SqlUtils.EvalInt(e.Item.DataItem, "DataLength");
                var isSystem        = SqlUtils.EvalString(e.Item.DataItem, "IsSystem");

                var ltlAttributeName = e.Item.FindControl("ltlAttributeName") as Literal;
                var ltlDisplayName   = e.Item.FindControl("ltlDisplayName") as Literal;
                var ltlIsVisible     = e.Item.FindControl("ltlIsVisible") as Literal;
                var ltlValidate      = e.Item.FindControl("ltlValidate") as Literal;
                var ltlDataType      = e.Item.FindControl("ltlDataType") as Literal;
                var ltlInputType     = e.Item.FindControl("ltlInputType") as Literal;
                var upLinkButton     = e.Item.FindControl("UpLinkButton") as HyperLink;
                var downLinkButton   = e.Item.FindControl("DownLinkButton") as HyperLink;
                var ltlStyle         = e.Item.FindControl("ltlStyle") as Literal;
                var ltlEditValidate  = e.Item.FindControl("ltlEditValidate") as Literal;
                var ltlEditUrl       = e.Item.FindControl("ltlEditUrl") as Literal;
                var ltlDeleteUrl     = e.Item.FindControl("ltlDeleteUrl") as Literal;

                var showPopWinString = ModalTableMetadataView.GetOpenWindowString(_tableType, _tableName, attributeName);
                ltlAttributeName.Text =
                    $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">{attributeName}</a>";

                var styleInfo = TableStyleManager.GetTableStyleInfo(EAuxiliaryTableTypeUtils.GetTableStyle(_tableType), _tableName, attributeName, null);
                ltlDisplayName.Text = styleInfo.DisplayName;

                ltlIsVisible.Text = StringUtils.GetTrueOrFalseImageHtml(styleInfo.IsVisible.ToString());
                ltlValidate.Text  = EInputValidateTypeUtils.GetValidateInfo(styleInfo);

                ltlDataType.Text  = EDataTypeUtils.GetTextByAuxiliaryTable(EDataTypeUtils.GetEnumType(dataType), dataLength);
                ltlInputType.Text = EInputTypeUtils.GetText(EInputTypeUtils.GetEnumType(styleInfo.InputType));

                if (IsSystem(isSystem))
                {
                    if (upLinkButton != null)
                    {
                        upLinkButton.NavigateUrl = PageUtils.GetSysUrl(nameof(PageTableMetadata),
                                                                       new NameValueCollection
                        {
                            { "PublishmentSystemID", PublishmentSystemId.ToString() },
                            { "SetTaxis", "True" },
                            { "TableStyleID", styleInfo.TableStyleId.ToString() },
                            { "Direction", "UP" },
                            { "TableMetadataId", tableMetadataId.ToString() },
                            { "ENName", _tableName },
                            { "TableType", EAuxiliaryTableTypeUtils.GetValue(_tableType) }
                        });
                    }
                    if (downLinkButton != null)
                    {
                        downLinkButton.NavigateUrl = PageUtils.GetSysUrl(nameof(PageTableMetadata),
                                                                         new NameValueCollection
                        {
                            { "PublishmentSystemID", PublishmentSystemId.ToString() },
                            { "SetTaxis", "True" },
                            { "TableStyleID", styleInfo.TableStyleId.ToString() },
                            { "Direction", "DOWN" },
                            { "TableMetadataId", tableMetadataId.ToString() },
                            { "ENName", _tableName },
                            { "TableType", EAuxiliaryTableTypeUtils.GetValue(_tableType) }
                        });
                    }
                }

                ltlStyle.Text = GetEditStyleHtml(tableMetadataId, attributeName);

                showPopWinString     = ModalTableStyleValidateAdd.GetOpenWindowString(styleInfo.TableStyleId, _tableName, styleInfo.AttributeName, EAuxiliaryTableTypeUtils.GetTableStyle(_tableType), _redirectUrl);
                ltlEditValidate.Text = $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">设置</a>";

                ltlEditUrl.Text = GetEditHtml(isSystem, tableMetadataId);

                if (!IsSystem(isSystem))
                {
                    var attributes = new NameValueCollection
                    {
                        { "Delete", true.ToString() },
                        { "TableMetadataID", tableMetadataId.ToString() }
                    };
                    var deleteUrl = PageUtils.AddQueryString(_redirectUrl, attributes);
                    ltlDeleteUrl.Text =
                        $@"<a href=""{deleteUrl}"" onClick=""javascript:return confirm('此操作将删除辅助字段“{attributeName}”,确认吗?');"">删除字段</a>";
                }
            }
        }
Example #17
0
        protected override void Render(HtmlTextWriter output)
        {
            if (formCollection == null)
            {
                if (HttpContext.Current.Request.Form != null && HttpContext.Current.Request.Form.Count > 0)
                {
                    formCollection = HttpContext.Current.Request.Form;
                }
                else
                {
                    formCollection = new NameValueCollection();
                }
            }

            var styleInfo = TableStyleManager.GetTableStyleInfo(tableStyle, tableName, attributeName, relatedIdentities);

            if (!string.IsNullOrEmpty(DefaultValue))
            {
                styleInfo.DefaultValue = DefaultValue;
            }

            if (styleInfo.IsVisible == false)
            {
                return;
            }

            var helpHtml    = $"{styleInfo.DisplayName}:";
            var pageScripts = new NameValueCollection();

            if (string.IsNullOrEmpty(AdditionalAttributes))
            {
                AdditionalAttributes = InputParserUtils.GetAdditionalAttributes(string.Empty, EInputTypeUtils.GetEnumType(styleInfo.InputType));
            }

            styleInfo.Additional.IsValidate = TranslateUtils.ToBool(IsValidate);
            styleInfo.Additional.IsRequired = TranslateUtils.ToBool(IsRequire);

            var inputHtml = BackgroundInputTypeParser.Parse(publishmentSystemInfo, nodeID, styleInfo, tableStyle, attributeName, formCollection, isEdit, isPostBack, AdditionalAttributes, pageScripts, true);

            if (string.IsNullOrEmpty(FormatString))
            {
                if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.TextEditor))
                {
                    output.Write(@"
<tr><td colspan=""4"" align=""left"">{0}</td></tr>
<tr><td colspan=""4"" align=""left"">{1}</td></tr>
", helpHtml, inputHtml);
                }
                else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.Image))
                {
                    output.Write(@"
<tr height=""80"" valign=""middle""><td>{0}</td><td colspan=""3"">{1}</td></tr>
", helpHtml, inputHtml);
                }
                else
                {
                    output.Write(@"
<tr><td>{0}</td><td colspan=""3"">{1}</td></tr>
", helpHtml, inputHtml);
                }
            }
            else
            {
                output.Write(FormatString, helpHtml, inputHtml);
            }

            foreach (string key in pageScripts.Keys)
            {
                output.Write(pageScripts[key]);
            }
        }
Example #18
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _tableType     = EAuxiliaryTableTypeUtils.GetEnumType(Body.GetQueryString("TableType"));
            _tableName     = Body.GetQueryString("TableName");
            _attributeName = Body.GetQueryString("AttributeName");

            if (!IsPostBack)
            {
                var metadataInfo = TableManager.GetTableMetadataInfo(_tableName, _attributeName);

                if (metadataInfo != null)
                {
                    lblAttributeName.Text     = metadataInfo.AttributeName;
                    AuxiliaryTableENName.Text = metadataInfo.AuxiliaryTableEnName;
                    DataType.Text             = metadataInfo.DataType.ToString();
                    DataLength.Text           = metadataInfo.DataLength.ToString();

                    var styleInfo = TableStyleManager.GetTableStyleInfo(EAuxiliaryTableTypeUtils.GetTableStyle(_tableType), metadataInfo.AuxiliaryTableEnName, metadataInfo.AttributeName, new List <int> {
                        0
                    });

                    if (EInputTypeUtils.EqualsAny(styleInfo.InputType, EInputType.CheckBox, EInputType.Radio, EInputType.SelectMultiple, EInputType.SelectOne))
                    {
                        RowDefaultValue.Visible = RowIsHorizontal.Visible = false;
                        RowSetItems.Visible     = true;
                        if (EInputTypeUtils.EqualsAny(styleInfo.InputType, EInputType.CheckBox, EInputType.Radio))
                        {
                            RowIsHorizontal.Visible = true;
                        }
                    }
                    else if (EInputTypeUtils.EqualsAny(styleInfo.InputType, EInputType.Text, EInputType.TextArea, EInputType.TextEditor))
                    {
                        RowDefaultValue.Visible = true;
                        RowSetItems.Visible     = RowIsHorizontal.Visible = false;
                    }
                    else
                    {
                        RowDefaultValue.Visible = RowIsHorizontal.Visible = RowSetItems.Visible = false;
                    }

                    if (metadataInfo.IsSystem)
                    {
                        RowDefaultValue.Visible = RowIsHorizontal.Visible = RowSetItems.Visible = false;
                    }

                    DisplayName.Text = styleInfo.DisplayName;
                    HelpText.Text    = styleInfo.HelpText;
                    IsVisible.Text   = StringUtils.GetTrueOrFalseImageHtml(styleInfo.IsVisible.ToString());
                    IsValidate.Text  = StringUtils.GetTrueImageHtml(styleInfo.Additional.IsValidate);
                    InputType.Text   = EInputTypeUtils.GetText(EInputTypeUtils.GetEnumType(styleInfo.InputType));

                    DefaultValue.Text = styleInfo.DefaultValue;
                    IsHorizontal.Text = StringUtils.GetBoolText(styleInfo.IsHorizontal);

                    var styleItems = BaiRongDataProvider.TableStyleDao.GetStyleItemInfoList(styleInfo.TableStyleId);
                    MyRepeater.DataSource     = TableStyleManager.GetStyleItemDataSet(styleItems.Count, styleItems);
                    MyRepeater.ItemDataBound += MyRepeater_ItemDataBound;
                    MyRepeater.DataBind();
                }
                else
                {
                    FailMessage("此字段为虚拟字段,在数据库中不存在!");
                    phAttribute.Visible = false;
                }
            }
        }
Example #19
0
        public HttpResponseMessage Main()
        {
            var body = new RequestBody();

            var siteId     = TranslateUtils.ToInt(body.GetQueryString("siteId"));
            var uploadType = EInputTypeUtils.GetEnumType(body.GetQueryString("uploadType"));

            var errorMessage          = string.Empty;
            var fileUrls              = new List <string>();
            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(siteId);

            if (body.IsUserLoggin && publishmentSystemInfo != null)
            {
                try
                {
                    if (HttpContext.Current.Request.Files.Count > 0)
                    {
                        for (var i = 0; i < HttpContext.Current.Request.Files.Count; i++)
                        {
                            var postedFile         = HttpContext.Current.Request.Files[i];
                            var filePath           = postedFile.FileName;
                            var fileExtName        = PathUtils.GetExtension(filePath).ToLower();
                            var localDirectoryPath = PathUtility.GetUploadDirectoryPath(publishmentSystemInfo, fileExtName);
                            var localFileName      = PathUtility.GetUploadFileName(publishmentSystemInfo, filePath);
                            var localFilePath      = PathUtils.Combine(localDirectoryPath, localFileName);

                            if (uploadType == EInputType.Image)
                            {
                                if (!PathUtility.IsImageExtenstionAllowed(publishmentSystemInfo, fileExtName))
                                {
                                    errorMessage = "上传图片格式不正确!";
                                    break;
                                }
                                else if (!PathUtility.IsImageSizeAllowed(publishmentSystemInfo, postedFile.ContentLength))
                                {
                                    errorMessage = "上传失败,上传图片超出规定文件大小!";
                                    break;
                                }

                                postedFile.SaveAs(localFilePath);
                                FileUtility.AddWaterMark(publishmentSystemInfo, localFilePath);
                                var imageUrl = PageUtility.GetPublishmentSystemUrlByPhysicalPath(publishmentSystemInfo, localFilePath);
                                fileUrls.Add(imageUrl);
                            }
                            else if (uploadType == EInputType.Video)
                            {
                                if (!PathUtility.IsVideoExtenstionAllowed(publishmentSystemInfo, fileExtName))
                                {
                                    errorMessage = "上传视频格式不正确!";
                                    break;
                                }
                                if (!PathUtility.IsVideoSizeAllowed(publishmentSystemInfo, postedFile.ContentLength))
                                {
                                    errorMessage = "上传失败,上传视频超出规定文件大小!";
                                    break;
                                }
                                postedFile.SaveAs(localFilePath);
                                var videoUrl = PageUtility.GetPublishmentSystemUrlByPhysicalPath(publishmentSystemInfo, localFilePath);
                                fileUrls.Add(videoUrl);
                            }
                            else if (uploadType == EInputType.File)
                            {
                                if (!PathUtility.IsFileExtenstionAllowed(publishmentSystemInfo, fileExtName))
                                {
                                    errorMessage = "此格式不允许上传,请选择有效的文件!";
                                    break;
                                }
                                if (!PathUtility.IsFileSizeAllowed(publishmentSystemInfo, postedFile.ContentLength))
                                {
                                    errorMessage = "上传失败,上传文件超出规定文件大小!";
                                    break;
                                }
                                postedFile.SaveAs(localFilePath);
                                FileUtility.AddWaterMark(publishmentSystemInfo, localFilePath);
                                var fileUrl = PageUtility.GetPublishmentSystemUrlByPhysicalPath(publishmentSystemInfo, localFilePath);
                                fileUrls.Add(fileUrl);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    //errorMessage = ex.Message;
                    errorMessage = "程序错误";
                }
            }

            var builder = new StringBuilder();

            if (fileUrls.Count == 0)
            {
                builder.Append("{\"errorMessage\":\"");
                builder.Append(!string.IsNullOrEmpty(errorMessage) ? errorMessage : "未知错误");
                builder.Append("\"}");
            }
            else
            {
                builder.Append("{\"fileUrls\":[");
                foreach (var fileUrl in fileUrls)
                {
                    builder.Append("\"");
                    builder.Append(fileUrl);
                    builder.Append("\",");
                }
                builder.Length--;
                builder.Append("]}");
            }

            var resp = new HttpResponseMessage();

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.Headers.Get("X-Access-Token")))
            {
                resp.Content = new StringContent(builder.ToString(), Encoding.UTF8, "application/json");
            }
            else
            {
                resp.Content = new StringContent(builder.ToString(), Encoding.UTF8, "text/plain");
            }

            return(resp);
        }
Example #20
0
        public static string GetContentByTableStyle(ContentInfo contentInfo, string separator, PublishmentSystemInfo publishmentSystemInfo, ETableStyle tableStyle, TableStyleInfo styleInfo, string formatString, int no, StringDictionary attributes, string innerXml, bool isStlEntity)
        {
            var value         = contentInfo.GetExtendedAttribute(styleInfo.AttributeName);
            var parsedContent = string.Empty;

            var inputType = EInputTypeUtils.GetEnumType(styleInfo.InputType);

            if (inputType == EInputType.Date)
            {
                var dateTime = TranslateUtils.ToDateTime(value);
                if (dateTime != DateUtils.SqlMinValue)
                {
                    if (string.IsNullOrEmpty(formatString))
                    {
                        formatString = DateUtils.FormatStringDateOnly;
                    }
                    parsedContent = DateUtils.Format(dateTime, formatString);
                }
            }
            else if (inputType == EInputType.DateTime)
            {
                var dateTime = TranslateUtils.ToDateTime(value);
                if (dateTime != DateUtils.SqlMinValue)
                {
                    if (string.IsNullOrEmpty(formatString))
                    {
                        formatString = DateUtils.FormatStringDateTime;
                    }
                    parsedContent = DateUtils.Format(dateTime, formatString);
                }
            }
            else if (inputType == EInputType.CheckBox || inputType == EInputType.Radio || inputType == EInputType.SelectMultiple || inputType == EInputType.SelectOne)//选择类型
            {
                var selectedTexts  = new ArrayList();
                var selectedValues = TranslateUtils.StringCollectionToStringList(value);
                var styleItems     = styleInfo.StyleItems ??
                                     BaiRongDataProvider.TableStyleDao.GetStyleItemInfoList(styleInfo.TableStyleId);
                foreach (var itemInfo in styleItems)
                {
                    if (selectedValues.Contains(itemInfo.ItemValue))
                    {
                        selectedTexts.Add(isStlEntity ? itemInfo.ItemValue : itemInfo.ItemTitle);
                    }
                }
                parsedContent = separator == null?TranslateUtils.ObjectCollectionToString(selectedTexts) : TranslateUtils.ObjectCollectionToString(selectedTexts, separator);
            }
            else if (inputType == EInputType.TextEditor)
            {
                /****获取编辑器中内容,解析@符号,添加了远程路径处理 20151103****/
                parsedContent = StringUtility.TextEditorContentDecode(value, publishmentSystemInfo, true);
            }
            else if (inputType == EInputType.Image)
            {
                if (no <= 1)
                {
                    parsedContent = GetImageOrFlashHtml(publishmentSystemInfo, value, attributes, isStlEntity);
                }
                else
                {
                    var extendAttributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName);
                    var extendValues        = contentInfo.GetExtendedAttribute(extendAttributeName);
                    if (!string.IsNullOrEmpty(extendValues))
                    {
                        var index = 2;
                        foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                        {
                            if (index == no)
                            {
                                parsedContent = GetImageOrFlashHtml(publishmentSystemInfo, extendValue, attributes, isStlEntity);
                                break;
                            }
                            index++;
                        }
                    }
                }
            }
            else if (inputType == EInputType.Video)
            {
                if (no <= 1)
                {
                    parsedContent = GetVideoHtml(publishmentSystemInfo, value, attributes, isStlEntity);
                }
                else
                {
                    var extendAttributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName);
                    var extendValues        = contentInfo.GetExtendedAttribute(extendAttributeName);
                    if (!string.IsNullOrEmpty(extendValues))
                    {
                        var index = 2;
                        foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                        {
                            if (index == no)
                            {
                                parsedContent = GetVideoHtml(publishmentSystemInfo, extendValue, attributes, isStlEntity);
                                break;
                            }
                            index++;
                        }
                    }
                }
            }
            else if (inputType == EInputType.File)
            {
                if (no <= 1)
                {
                    parsedContent = GetFileHtmlWithoutCount(publishmentSystemInfo, value, attributes, innerXml, isStlEntity);
                }
                else
                {
                    var extendAttributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName);
                    var extendValues        = contentInfo.GetExtendedAttribute(extendAttributeName);
                    if (!string.IsNullOrEmpty(extendValues))
                    {
                        var index = 2;
                        foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                        {
                            if (index == no)
                            {
                                parsedContent = GetFileHtmlWithoutCount(publishmentSystemInfo, extendValue, attributes, innerXml, isStlEntity);
                                break;
                            }
                            index++;
                        }
                    }
                }
            }
            else
            {
                parsedContent = value;
            }

            return(parsedContent);
        }
Example #21
0
        private static string ParseImpl(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo, StringDictionary attributes, string leftText, string rightText, string channelIndex, string channelName, int upLevel, int topLevel, string type, string formatString, string separator, int startIndex, int length, int wordNum, string ellipsis, string replace, string to, bool isClearTags, bool isReturnToBr, bool isLower, bool isUpper)
        {
            var parsedContent = string.Empty;

            var channelId = StlDataUtility.GetNodeIdByLevel(pageInfo.PublishmentSystemId, contextInfo.ChannelID, upLevel, topLevel);

            channelId = StlCacheManager.NodeId.GetNodeIdByChannelIdOrChannelIndexOrChannelName(pageInfo.PublishmentSystemId, channelId, channelIndex, channelName);
            var channel = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, channelId);

            if (!string.IsNullOrEmpty(formatString))
            {
                formatString = formatString.Trim();
                if (!formatString.StartsWith("{0"))
                {
                    formatString = "{0:" + formatString;
                }
                if (!formatString.EndsWith("}"))
                {
                    formatString = formatString + "}";
                }
            }

            if (!string.IsNullOrEmpty(type))
            {
                if (type.ToLower().Equals(NodeAttribute.Title.ToLower()))
                {
                    parsedContent = channel.NodeName;

                    if (isClearTags)
                    {
                        parsedContent = StringUtils.StripTags(parsedContent);
                    }

                    if (!string.IsNullOrEmpty(replace))
                    {
                        parsedContent = StringUtils.Replace(replace, parsedContent, to);
                    }

                    if (wordNum == 0 && contextInfo.TitleWordNum > 0)
                    {
                        wordNum = contextInfo.TitleWordNum;
                    }

                    if (!string.IsNullOrEmpty(parsedContent) && wordNum > 0)
                    {
                        parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis);
                    }
                }
                else if (type.ToLower().Equals(NodeAttribute.ChannelIndex.ToLower()))
                {
                    parsedContent = channel.NodeIndexName;

                    if (!string.IsNullOrEmpty(replace))
                    {
                        parsedContent = StringUtils.Replace(replace, parsedContent, to);
                    }

                    if (!string.IsNullOrEmpty(parsedContent) && wordNum > 0)
                    {
                        parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis);
                    }
                }
                else if (type.ToLower().Equals(NodeAttribute.Content.ToLower()))
                {
                    parsedContent = StringUtility.TextEditorContentDecode(channel.Content, pageInfo.PublishmentSystemInfo);

                    if (isClearTags)
                    {
                        parsedContent = StringUtils.StripTags(parsedContent);
                    }

                    if (!string.IsNullOrEmpty(replace))
                    {
                        parsedContent = StringUtils.Replace(replace, parsedContent, to);
                    }

                    if (!string.IsNullOrEmpty(parsedContent) && wordNum > 0)
                    {
                        parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis);
                    }
                }
                else if (type.ToLower().Equals(NodeAttribute.PageContent.ToLower()))
                {
                    if (contextInfo.IsInnerElement || pageInfo.TemplateInfo.TemplateType != ETemplateType.ChannelTemplate)
                    {
                        parsedContent = StringUtility.TextEditorContentDecode(channel.Content, pageInfo.PublishmentSystemInfo);

                        if (isClearTags)
                        {
                            parsedContent = StringUtils.StripTags(parsedContent);
                        }

                        if (!string.IsNullOrEmpty(replace))
                        {
                            parsedContent = StringUtils.Replace(replace, parsedContent, to);
                        }

                        if (!string.IsNullOrEmpty(parsedContent) && wordNum > 0)
                        {
                            parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis);
                        }
                    }
                    else
                    {
                        return(stlElement);
                    }
                }
                else if (type.ToLower().Equals(NodeAttribute.AddDate.ToLower()))
                {
                    parsedContent = DateUtils.Format(channel.AddDate, formatString);
                }
                else if (type.ToLower().Equals(NodeAttribute.ImageUrl.ToLower()))
                {
                    parsedContent = InputParserUtility.GetImageOrFlashHtml(pageInfo.PublishmentSystemInfo, channel.ImageUrl, attributes, false);
                }
                else if (type.ToLower().Equals(NodeAttribute.Id.ToLower()))
                {
                    parsedContent = channelId.ToString();
                }
                else if (StringUtils.StartsWithIgnoreCase(type, StlParserUtility.ItemIndex) && contextInfo.ItemContainer?.ChannelItem != null)
                {
                    var itemIndex = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.ChannelItem.ItemIndex, type, contextInfo);
                    parsedContent = !string.IsNullOrEmpty(formatString) ? string.Format(formatString, itemIndex) : itemIndex.ToString();
                }
                else if (type.ToLower().Equals(NodeAttribute.CountOfChannels.ToLower()))
                {
                    parsedContent = channel.ChildrenCount.ToString();
                }
                else if (type.ToLower().Equals(NodeAttribute.CountOfContents.ToLower()))
                {
                    parsedContent = channel.ContentNum.ToString();
                }
                else if (type.ToLower().Equals(NodeAttribute.CountOfImageContents.ToLower()))
                {
                    var count = DataProvider.BackgroundContentDao.GetCountCheckedImage(pageInfo.PublishmentSystemId, channel.NodeId);
                    parsedContent = count.ToString();
                }
                else if (type.ToLower().Equals(NodeAttribute.Keywords.ToLower()))
                {
                    parsedContent = channel.Keywords;
                }
                else if (type.ToLower().Equals(NodeAttribute.Description.ToLower()))
                {
                    parsedContent = channel.Description;
                }
                else
                {
                    var attributeName = type;

                    var formCollection = channel.Additional.Attributes;
                    if (formCollection != null && formCollection.Count > 0)
                    {
                        var styleInfo = TableStyleManager.GetTableStyleInfo(ETableStyle.Channel, DataProvider.NodeDao.TableName, attributeName, RelatedIdentities.GetChannelRelatedIdentities(pageInfo.PublishmentSystemId, channel.NodeId));
                        parsedContent = GetValue(attributeName, formCollection, false, styleInfo.DefaultValue);
                        if (!string.IsNullOrEmpty(parsedContent))
                        {
                            parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, separator, pageInfo.PublishmentSystemInfo, ETableStyle.Channel, styleInfo, formatString, attributes, node.InnerXml, false);
                            parsedContent = StringUtils.ParseString(EInputTypeUtils.GetEnumType(styleInfo.InputType), parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(parsedContent))
                {
                    parsedContent = leftText + parsedContent + rightText;
                }
            }

            return(parsedContent);
        }
Example #22
0
        private static string ParseImpl(XmlNode node, PageInfo pageInfo, ContextInfo contextInfo, string type, StringDictionary attributes, string formatString, string separator, int startIndex, int length, int wordNum, string ellipsis, string replace, string to, bool isClearTags, bool isReturnToBR, bool isLower, bool isUpper)
        {
            var parsedContent = string.Empty;

            if (type.Length > 0)
            {
                if (type.ToLower().Equals(Type_SiteName.ToLower()))
                {
                    parsedContent = pageInfo.PublishmentSystemInfo.PublishmentSystemName;
                }
                else if (type.ToLower().Equals(Type_SiteUrl.ToLower()))
                {
                    parsedContent = pageInfo.PublishmentSystemInfo.PublishmentSystemUrl;
                }
                else if (type.ToLower().Equals(Type_Date.ToLower()))
                {
                    pageInfo.AddPageScriptsIfNotExists("datestring.js",
                                                       $@"<script charset=""{SiteFilesAssets.DateString.Charset}"" src=""{SiteFilesAssets.GetUrl(
                            pageInfo.ApiUrl, SiteFilesAssets.DateString.Js)}"" type=""text/javascript""></script>");

                    parsedContent = @"<script language=""javascript"" type=""text/javascript"">RunGLNL(false);</script>";
                }
                else if (type.ToLower().Equals(Type_DateOfTraditional.ToLower()))
                {
                    pageInfo.AddPageScriptsIfNotExists("datestring",
                                                       $@"<script charset=""{SiteFilesAssets.DateString.Charset}"" src=""{SiteFilesAssets.GetUrl(
                            pageInfo.ApiUrl, SiteFilesAssets.DateString.Js)}"" type=""text/javascript""></script>");

                    parsedContent = @"<script language=""javascript"" type=""text/javascript"">RunGLNL(true);</script>";
                }
                else
                {
                    if (pageInfo.PublishmentSystemInfo.Additional.Attributes.Get(type) == null)
                    {
                        var stlTagInfo = DataProvider.StlTagDao.GetStlTagInfo(pageInfo.PublishmentSystemId, type);
                        if (stlTagInfo == null)
                        {
                            stlTagInfo = DataProvider.StlTagDao.GetStlTagInfo(0, type);
                        }
                        if (stlTagInfo != null && !string.IsNullOrEmpty(stlTagInfo.TagContent))
                        {
                            var innerBuilder = new StringBuilder(stlTagInfo.TagContent);
                            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                            parsedContent = innerBuilder.ToString();
                        }
                    }
                    else
                    {
                        parsedContent = pageInfo.PublishmentSystemInfo.Additional.Attributes[type];
                        if (!string.IsNullOrEmpty(parsedContent))
                        {
                            var styleInfo = TableStyleManager.GetTableStyleInfo(ETableStyle.Site, DataProvider.PublishmentSystemDao.TableName, type, RelatedIdentities.GetRelatedIdentities(ETableStyle.Site, pageInfo.PublishmentSystemId, pageInfo.PublishmentSystemId));

                            if (isClearTags && EInputTypeUtils.EqualsAny(styleInfo.InputType, EInputType.Image, EInputType.File))
                            {
                                parsedContent = PageUtility.ParseNavigationUrl(pageInfo.PublishmentSystemInfo, parsedContent);
                            }
                            else
                            {
                                parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, separator, pageInfo.PublishmentSystemInfo, ETableStyle.Site, styleInfo, formatString, attributes, node.InnerXml, false);
                                parsedContent = StringUtils.ParseString(EInputTypeUtils.GetEnumType(styleInfo.InputType), parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBR, isLower, isUpper, formatString);
                            }
                        }
                    }
                }
            }

            return(parsedContent);
        }
Example #23
0
        public static string GetContentByTableStyle(string content, string separator, PublishmentSystemInfo publishmentSystemInfo, ETableStyle tableStyle, TableStyleInfo styleInfo, string formatString, StringDictionary attributes, string innerXml, bool isStlEntity)
        {
            var parsedContent = content;

            var inputType = EInputTypeUtils.GetEnumType(styleInfo.InputType);

            if (inputType == EInputType.Date)
            {
                var dateTime = TranslateUtils.ToDateTime(content);
                if (dateTime != DateUtils.SqlMinValue)
                {
                    if (string.IsNullOrEmpty(formatString))
                    {
                        formatString = DateUtils.FormatStringDateOnly;
                    }
                    parsedContent = DateUtils.Format(dateTime, formatString);
                }
                else
                {
                    parsedContent = string.Empty;
                }
            }
            else if (inputType == EInputType.DateTime)
            {
                var dateTime = TranslateUtils.ToDateTime(content);
                if (dateTime != DateUtils.SqlMinValue)
                {
                    if (string.IsNullOrEmpty(formatString))
                    {
                        formatString = DateUtils.FormatStringDateTime;
                    }
                    parsedContent = DateUtils.Format(dateTime, formatString);
                }
                else
                {
                    parsedContent = string.Empty;
                }
            }
            else if (inputType == EInputType.CheckBox || inputType == EInputType.Radio || inputType == EInputType.SelectMultiple || inputType == EInputType.SelectOne)//选择类型
            {
                var selectedTexts  = new ArrayList();
                var selectedValues = TranslateUtils.StringCollectionToStringList(content);
                var styleItems     = styleInfo.StyleItems;
                if (styleItems == null)
                {
                    styleItems = BaiRongDataProvider.TableStyleDao.GetStyleItemInfoList(styleInfo.TableStyleId);
                }
                foreach (var itemInfo in styleItems)
                {
                    if (selectedValues.Contains(itemInfo.ItemValue))
                    {
                        if (isStlEntity)
                        {
                            selectedTexts.Add(itemInfo.ItemValue);
                        }
                        else
                        {
                            selectedTexts.Add(itemInfo.ItemTitle);
                        }
                    }
                }
                if (separator == null)
                {
                    parsedContent = TranslateUtils.ObjectCollectionToString(selectedTexts);
                }
                else
                {
                    parsedContent = TranslateUtils.ObjectCollectionToString(selectedTexts, separator);
                }
            }
            //else if (styleInfo.InputType == EInputType.TextArea)
            //{
            //    parsedContent = StringUtils.ReplaceNewlineToBR(parsedContent);
            //}
            else if (inputType == EInputType.TextEditor)
            {
                /****获取编辑器中内容,解析@符号,添加了远程路径处理 20151103****/
                parsedContent = StringUtility.TextEditorContentDecode(parsedContent, publishmentSystemInfo, true);
            }
            else if (inputType == EInputType.Image)
            {
                parsedContent = InputParserUtility.GetImageOrFlashHtml(publishmentSystemInfo, parsedContent, attributes, isStlEntity);
            }
            else if (inputType == EInputType.Video)
            {
                parsedContent = InputParserUtility.GetVideoHtml(publishmentSystemInfo, parsedContent, attributes, isStlEntity);
            }
            else if (inputType == EInputType.File)
            {
                parsedContent = InputParserUtility.GetFileHtmlWithoutCount(publishmentSystemInfo, parsedContent, attributes, innerXml, isStlEntity);
            }

            return(parsedContent);
        }
Example #24
0
        private void DgContents_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var styleInfo = (TableStyleInfo)e.Item.DataItem;

            var ltlAttributeName = (Literal)e.Item.FindControl("ltlAttributeName");
            var ltlDisplayName   = (Literal)e.Item.FindControl("ltlDisplayName");
            var ltlInputType     = (Literal)e.Item.FindControl("ltlInputType");
            var ltlFieldType     = (Literal)e.Item.FindControl("ltlFieldType");
            var ltlIsVisible     = (Literal)e.Item.FindControl("ltlIsVisible");
            var ltlValidate      = (Literal)e.Item.FindControl("ltlValidate");
            var ltlEditStyle     = (Literal)e.Item.FindControl("ltlEditStyle");
            var ltlEditValidate  = (Literal)e.Item.FindControl("ltlEditValidate");
            var upLinkButton     = (HyperLink)e.Item.FindControl("UpLinkButton");
            var downLinkButton   = (HyperLink)e.Item.FindControl("DownLinkButton");

            ltlAttributeName.Text = styleInfo.AttributeName;

            ltlDisplayName.Text = styleInfo.DisplayName;
            ltlInputType.Text   = EInputTypeUtils.GetText(EInputTypeUtils.GetEnumType(styleInfo.InputType));
            ltlFieldType.Text   = "虚拟字段";

            ltlIsVisible.Text = StringUtils.GetTrueOrFalseImageHtml(styleInfo.IsVisible.ToString());
            ltlValidate.Text  = EInputValidateTypeUtils.GetValidateInfo(styleInfo);

            string showPopWinString = ModalTableStyleAdd.GetOpenWindowString(PublishmentSystemId, styleInfo.TableStyleId, _relatedIdentities, _tableName, styleInfo.AttributeName, ETableStyle.Channel, _redirectUrl);
            var    editText         = "添加";

            if (styleInfo.RelatedIdentity == _nodeInfo.NodeId)//数据库中有样式
            {
                editText = "修改";
            }
            ltlEditStyle.Text = $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">{editText}</a>";

            showPopWinString     = ModalTableStyleValidateAdd.GetOpenWindowString(styleInfo.TableStyleId, _relatedIdentities, _tableName, styleInfo.AttributeName, ETableStyle.Channel, _redirectUrl);
            ltlEditValidate.Text = $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">设置</a>";

            if (styleInfo.RelatedIdentity == _nodeInfo.NodeId)//数据库中有样式
            {
                var urlStyle = PageUtils.GetCmsUrl(nameof(PageTableStyleChannel), new NameValueCollection
                {
                    { "PublishmentSystemID", PublishmentSystemId.ToString() },
                    { "NodeID", _nodeInfo.NodeId.ToString() },
                    { "DeleteStyle", true.ToString() },
                    { "TableName", _tableName },
                    { "AttributeName", styleInfo.AttributeName }
                });
                ltlEditStyle.Text +=
                    $@"&nbsp;&nbsp;<a href=""{urlStyle}"" onClick=""javascript:return confirm('此操作将删除对应显示样式,确认吗?');"">删除</a>";
            }

            bool isTaxisVisible;

            if (styleInfo.RelatedIdentity != _nodeInfo.NodeId)
            {
                isTaxisVisible = false;
            }
            else
            {
                isTaxisVisible = !TableStyleManager.IsExistsInParents(_relatedIdentities, _tableName, styleInfo.AttributeName);
            }

            if (!isTaxisVisible)
            {
                upLinkButton.Visible = downLinkButton.Visible = false;
            }
            else
            {
                upLinkButton.NavigateUrl = PageUtils.GetCmsUrl(nameof(PageTableStyleChannel), new NameValueCollection
                {
                    { "PublishmentSystemID", PublishmentSystemId.ToString() },
                    { "NodeID", _nodeInfo.NodeId.ToString() },
                    { "SetTaxis", true.ToString() },
                    { "TableStyleID", styleInfo.TableStyleId.ToString() },
                    { "Direction", "UP" }
                });
                downLinkButton.NavigateUrl = PageUtils.GetCmsUrl(nameof(PageTableStyleChannel), new NameValueCollection
                {
                    { "PublishmentSystemID", PublishmentSystemId.ToString() },
                    { "NodeID", _nodeInfo.NodeId.ToString() },
                    { "SetTaxis", true.ToString() },
                    { "TableStyleID", styleInfo.TableStyleId.ToString() },
                    { "Direction", "DOWN" }
                });
            }
        }