Esempio n. 1
0
        public List <TableStyleInfo> GetTableStyleInfoWithItemsList(string tableName, string attributeName)
        {
            var arraylist = new List <TableStyleInfo>();

            var parms = new IDataParameter[]
            {
                GetParameter(ParmTableName, EDataType.VarChar, 50, tableName),
                GetParameter(ParmAttributeName, EDataType.VarChar, 50, attributeName)
            };

            using (var rdr = ExecuteReader(SqlSelectTableStyles, parms))
            {
                while (rdr.Read())
                {
                    var styleInfo = GetTableStyleInfoByReader(rdr);
                    if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.CheckBox) || EInputTypeUtils.Equals(styleInfo.InputType, EInputType.Radio) || EInputTypeUtils.Equals(styleInfo.InputType, EInputType.SelectMultiple) || EInputTypeUtils.Equals(styleInfo.InputType, EInputType.SelectOne))
                    {
                        var styleItems = GetStyleItemInfoList(styleInfo.TableStyleId);
                        if (styleItems != null && styleItems.Count > 0)
                        {
                            styleInfo.StyleItems = styleItems;
                        }
                    }
                    arraylist.Add(styleInfo);
                }
                rdr.Close();
            }

            return(arraylist);
        }
Esempio n. 2
0
        public static Dictionary <string, object> ContentToDictionary(ContentInfo contentInfo, ETableStyle tableStyle, string tableName, List <int> relatedIdentities)
        {
            var dict = TranslateUtils.ObjectToDictionary(contentInfo);

            dict.Remove("Attributes");

            var styleInfoList = TableStyleManager.GetTableStyleInfoList(tableStyle, tableName, relatedIdentities);

            foreach (var styleInfo in styleInfoList)
            {
                if (!styleInfo.IsVisible)
                {
                    continue;
                }
                if (!dict.ContainsKey(styleInfo.AttributeName))
                {
                    dict[styleInfo.AttributeName] = contentInfo.GetExtendedAttribute(styleInfo.AttributeName);
                }
                if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.Image))
                {
                    var extendName  = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName);
                    var extendValue = contentInfo.GetExtendedAttribute(extendName);
                    if (!string.IsNullOrEmpty(extendValue))
                    {
                        dict[extendName] = extendValue;
                    }
                }
            }

            return(dict);
        }
Esempio n. 3
0
            public static IDictionary GetDictionary(PublishmentSystemInfo publishmentSystemInfo, int nodeId)
            {
                var dictionary = new ListDictionary
                {
                    { ChannelId, "栏目ID" },
                    { ChannelIndex, "栏目索引" },
                    { Year, "年份" },
                    { Month, "月份" },
                    { Day, "日期" },
                    { Hour, "小时" },
                    { Minute, "分钟" },
                    { Second, "秒钟" },
                    { Sequence, "顺序数" },
                    { ParentRule, "父级命名规则" },
                    { ChannelName, "栏目名称" }
                };

                //继承父级设置 20151113 sessionliang

                var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(publishmentSystemInfo.PublishmentSystemId, nodeId);

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

                foreach (var styleInfo in styleInfoList)
                {
                    if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.Text))
                    {
                        dictionary.Add($@"{{@{styleInfo.AttributeName}}}", styleInfo.DisplayName);
                    }
                }

                return(dictionary);
            }
Esempio n. 4
0
        public static string Parse(PublishmentSystemInfo publishmentSystemInfo, TableStyleInfo styleInfo, string attributeName, NameValueCollection pageScripts)
        {
            var retval = string.Empty;

            if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.Text))
            {
                retval = ParseText(attributeName, styleInfo);
            }
            else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.TextArea))
            {
                retval = ParseTextArea(attributeName, styleInfo);
            }
            else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.TextEditor))
            {
                retval = ParseTextEditor(publishmentSystemInfo, attributeName, pageScripts, styleInfo);
            }
            else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.SelectOne))
            {
                retval = ParseSelectOne(attributeName, styleInfo);
            }
            else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.SelectMultiple))
            {
                retval = ParseSelectMultiple(attributeName, styleInfo);
            }
            else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.CheckBox))
            {
                retval = ParseCheckBox(attributeName, styleInfo);
            }
            else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.Radio))
            {
                retval = ParseRadio(attributeName, styleInfo);
            }
            else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.Date))
            {
                retval = ParseDate(publishmentSystemInfo, attributeName, pageScripts, styleInfo);
            }
            else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.DateTime))
            {
                retval = ParseDateTime(publishmentSystemInfo, attributeName, pageScripts, styleInfo);
            }
            else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.Image))
            {
                retval = ParseImageUpload(attributeName, styleInfo);
            }
            else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.Video))
            {
                retval = ParseVideoUpload(attributeName, styleInfo);
            }
            else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.File))
            {
                retval = ParseFileUpload(attributeName, styleInfo);
            }
            else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.RelatedField))
            {
                retval = ParseRelatedField(publishmentSystemInfo, attributeName, styleInfo);
            }

            return(retval);
        }
Esempio n. 5
0
        public static string GetValidateHtmlString(TableStyleInfo styleInfo, out string validateAttributes)
        {
            var builder = new StringBuilder();

            validateAttributes = string.Empty;

            if (styleInfo.Additional.IsValidate && !EInputTypeUtils.Equals(styleInfo.InputType, EInputType.TextEditor))
            {
                validateAttributes = InputParserUtils.GetValidateAttributes(styleInfo.Additional.IsValidate, styleInfo.DisplayName, styleInfo.Additional.IsRequired, styleInfo.Additional.MinNum, styleInfo.Additional.MaxNum, styleInfo.Additional.ValidateType, styleInfo.Additional.RegExp, styleInfo.Additional.ErrorMessage);

                builder.Append(
                    $@"&nbsp;<span id=""{styleInfo.AttributeName}_msg"" style=""color:red;display:none;"">*</span>");
                builder.Append($@"
<script>event_observe('{styleInfo.AttributeName}', 'blur', checkAttributeValue);</script>
");
            }
            return(builder.ToString());
        }
Esempio n. 6
0
        private static string GetValidateHtmlString(TableStyleInfo styleInfo, out string validateAttributes)
        {
            validateAttributes = string.Empty;
            if (!styleInfo.Additional.IsValidate || EInputTypeUtils.Equals(styleInfo.InputType, EInputType.TextEditor))
            {
                return(string.Empty);
            }

            var builder = new StringBuilder();

            validateAttributes = InputParserUtils.GetValidateAttributes(styleInfo.Additional.IsValidate, styleInfo.DisplayName, styleInfo.Additional.IsRequired, styleInfo.Additional.MinNum, styleInfo.Additional.MaxNum, styleInfo.Additional.ValidateType, styleInfo.Additional.RegExp, styleInfo.Additional.ErrorMessage);

            builder.Append(
                $@"<span id=""{styleInfo.AttributeName}_msg"" style=""color:red;margin-left: 5px;display:none;"">*</span>");
            builder.Append($@"
<script>inputBlur('{styleInfo.AttributeName}');</script>
");
            return(builder.ToString());
        }
Esempio n. 7
0
        public void GetContent_Click(object sender, EventArgs e)
        {
            var getContent = (Button)sender;
            var contentUrl = getContent.CommandArgument;

            var gatherRuleInfo = DataProvider.GatherRuleDao.GetGatherRuleInfo(_gatherRuleName, PublishmentSystemId);

            var regexContentExclude = GatherUtility.GetRegexString(gatherRuleInfo.ContentExclude);
            var regexChannel        = GatherUtility.GetRegexChannel(gatherRuleInfo.ContentChannelStart, gatherRuleInfo.ContentChannelEnd);
            var regexContent        = GatherUtility.GetRegexContent(gatherRuleInfo.ContentContentStart, gatherRuleInfo.ContentContentEnd);
            var regexContent2       = string.Empty;

            if (!string.IsNullOrEmpty(gatherRuleInfo.Additional.ContentContentStart2) && !string.IsNullOrEmpty(gatherRuleInfo.Additional.ContentContentEnd2))
            {
                regexContent2 = GatherUtility.GetRegexContent(gatherRuleInfo.Additional.ContentContentStart2, gatherRuleInfo.Additional.ContentContentEnd2);
            }
            var regexContent3 = string.Empty;

            if (!string.IsNullOrEmpty(gatherRuleInfo.Additional.ContentContentStart3) && !string.IsNullOrEmpty(gatherRuleInfo.Additional.ContentContentEnd3))
            {
                regexContent3 = GatherUtility.GetRegexContent(gatherRuleInfo.Additional.ContentContentStart3, gatherRuleInfo.Additional.ContentContentEnd3);
            }
            var regexNextPage        = GatherUtility.GetRegexUrl(gatherRuleInfo.ContentNextPageStart, gatherRuleInfo.ContentNextPageEnd);
            var regexTitle           = GatherUtility.GetRegexTitle(gatherRuleInfo.ContentTitleStart, gatherRuleInfo.ContentTitleEnd);
            var contentAttributes    = TranslateUtils.StringCollectionToStringList(gatherRuleInfo.ContentAttributes);
            var contentAttributesXML = TranslateUtils.ToNameValueCollection(gatherRuleInfo.ContentAttributesXml);

            var attributes = GatherUtility.GetContentNameValueCollection(gatherRuleInfo.Charset, contentUrl, gatherRuleInfo.CookieString, regexContentExclude, gatherRuleInfo.ContentHtmlClearCollection, gatherRuleInfo.ContentHtmlClearTagCollection, regexTitle, regexContent, regexContent2, regexContent3, regexNextPage, regexChannel, contentAttributes, contentAttributesXML);

            var builder = new StringBuilder();

            var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, PublishmentSystemId);

            var styleInfoList = TableStyleManager.GetTableStyleInfoList(ETableStyle.BackgroundContent, PublishmentSystemInfo.AuxiliaryTableForContent, relatedIdentities);

            foreach (var styleInfo in styleInfoList)
            {
                if (string.IsNullOrEmpty(attributes[styleInfo.AttributeName.ToLower()]))
                {
                    continue;
                }
                if (StringUtils.EqualsIgnoreCase(ContentAttribute.Title, styleInfo.AttributeName))
                {
                    builder.Append(
                        $@"<a href=""{contentUrl}"" target=""_blank"">{styleInfo.DisplayName}: {attributes[
                            styleInfo.AttributeName.ToLower()]}</a><br><br>");
                }
                else if (StringUtils.EqualsIgnoreCase(BackgroundContentAttribute.ImageUrl, styleInfo.AttributeName) || EInputTypeUtils.Equals(styleInfo.InputType, EInputType.Image))
                {
                    var imageUrl = PageUtils.GetUrlByBaseUrl(attributes[styleInfo.AttributeName.ToLower()], contentUrl);
                    builder.Append($"{styleInfo.DisplayName}: <img src='{imageUrl}' /><br><br>");
                }
                else
                {
                    builder.Append($"{styleInfo.DisplayName}: {attributes[styleInfo.AttributeName.ToLower()]}<br><br>");
                }
            }

            Content.Text = builder.ToString();
        }
Esempio n. 8
0
        protected override void Render(HtmlTextWriter output)
        {
            if (string.IsNullOrEmpty(_tableName))
            {
                return;
            }

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

            var builder       = new StringBuilder();
            var styleInfoList = TableStyleManager.GetTableStyleInfoList(_tableStyle, _tableName, _relatedIdentities);
            var pageScripts   = new NameValueCollection();

            if (styleInfoList != null)
            {
                var isPreviousSingleLine = true;
                var isPreviousLeftColumn = false;
                foreach (var styleInfo in styleInfoList)
                {
                    if (styleInfo.IsVisible && !_excludeAttributeNames.Contains(styleInfo.AttributeName.ToLower()))
                    {
                        var text  = $"{styleInfo.DisplayName}:";
                        var value = BackgroundInputTypeParser.Parse(_publishmentSystemInfo, _nodeId, styleInfo, _tableStyle, styleInfo.AttributeName, _formCollection, _isEdit, _isPostBack, null, pageScripts, true);

                        if (builder.Length > 0)
                        {
                            if (isPreviousSingleLine)
                            {
                                builder.Append("</tr>");
                            }
                            else
                            {
                                if (!isPreviousLeftColumn)
                                {
                                    builder.Append("</tr>");
                                }
                                else if (styleInfo.IsSingleLine)
                                {
                                    builder.Append(@"<td></td><td></td></tr>");
                                }
                            }
                        }

                        //this line

                        if (styleInfo.IsSingleLine || isPreviousSingleLine || !isPreviousLeftColumn)
                        {
                            builder.Append("<tr>");
                        }

                        if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.TextEditor))
                        {
                            var commands = WebUtils.GetTextEditorCommands(_publishmentSystemInfo, styleInfo.AttributeName);
                            builder.Append(
                                $@"<td>{text}</td><td colspan=""3"">{commands}</td></tr><tr><td colspan=""4"">{value}</td>");
                        }
                        else
                        {
                            if (styleInfo.AttributeName == "Title" || styleInfo.AttributeName == "SubTitle")
                            {
                                builder.Append(
                                    $@"<td>{text}</td><td {(styleInfo.IsSingleLine ? @"colspan=""3""" : string.Empty)}>{value}</td>");
                            }
                            else
                            {
                                builder.Append(
                                    $@"<td>{text}</td><td {(styleInfo.IsSingleLine ? @"colspan=""3""" : string.Empty)}>{value}</td>");
                            }
                        }

                        if (styleInfo.IsSingleLine)
                        {
                            isPreviousSingleLine = true;
                            isPreviousLeftColumn = false;
                        }
                        else
                        {
                            isPreviousSingleLine = false;
                            isPreviousLeftColumn = !isPreviousLeftColumn;
                        }
                    }
                }

                if (builder.Length > 0)
                {
                    if (isPreviousSingleLine || !isPreviousLeftColumn)
                    {
                        builder.Append("</tr>");
                    }
                    else
                    {
                        builder.Append(@"<td></td><td></td></tr>");
                    }
                }

                output.Write(builder.ToString());

                foreach (string key in pageScripts.Keys)
                {
                    output.Write(pageScripts[key]);
                }
            }
        }
Esempio n. 9
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]);
            }
        }