public PairList GetAllTableStyleInfoPairs() { var pairs = new PairList(); using (var rdr = ExecuteReader(SqlSelectAllTableStyle)) { while (rdr.Read()) { var styleInfo = GetTableStyleInfoByReader(rdr); var inputType = styleInfo.InputType; if (InputTypeUtils.IsWithStyleItems(inputType)) { styleInfo.StyleItems = DataProvider.TableStyleItemDao.GetStyleItemInfoList(styleInfo.Id); } var key = TableStyleManager.GetCacheKey(styleInfo.RelatedIdentity, styleInfo.TableName, styleInfo.AttributeName); if (!pairs.ContainsKey(key)) { var pair = new Pair(key, styleInfo); pairs.Add(pair); } } rdr.Close(); } return(pairs); }
public void ReFresh(object sender, EventArgs e) { PhDefaultValue.Visible = PhWidth.Visible = PhHeight.Visible = SpDateTip.Visible = PhIsSelectField.Visible = PhRepeat.Visible = false; TbDefaultValue.TextMode = TextBoxMode.MultiLine; var inputType = InputTypeUtils.GetEnumType(DdlInputType.SelectedValue); if (inputType == InputType.CheckBox || inputType == InputType.Radio || inputType == InputType.SelectMultiple || inputType == InputType.SelectOne) { PhIsSelectField.Visible = true; if (inputType == InputType.CheckBox || inputType == InputType.Radio) { PhRepeat.Visible = true; } } else if (inputType == InputType.TextEditor) { PhDefaultValue.Visible = PhWidth.Visible = PhHeight.Visible = true; } else if (inputType == InputType.TextArea) { PhDefaultValue.Visible = PhWidth.Visible = PhHeight.Visible = true; } else if (inputType == InputType.Text) { PhDefaultValue.Visible = PhWidth.Visible = true; TbDefaultValue.TextMode = TextBoxMode.SingleLine; } else if (inputType == InputType.Date || inputType == InputType.DateTime) { SpDateTip.Visible = PhDefaultValue.Visible = true; TbDefaultValue.TextMode = TextBoxMode.SingleLine; } }
public void ReFresh(object sender, EventArgs e) { PhRelatedField.Visible = PhWidth.Visible = PhHeight.Visible = SpanDateTip.Visible = PhIsSelectField.Visible = PhRapid.Visible = PhNotRapid.Visible = PhRepeat.Visible = PhIsFormatString.Visible = PhDefaultValue.Visible = PhCustomize.Visible = false; if (!string.IsNullOrEmpty(_attributeName)) { TbAttributeName.Enabled = false; } var inputType = InputTypeUtils.GetEnumType(DdlInputType.SelectedValue); if (inputType == InputType.CheckBox || inputType == InputType.Radio || inputType == InputType.SelectMultiple || inputType == InputType.SelectOne) { PhDefaultValue.Visible = PhIsSelectField.Visible = true; var isRapid = TranslateUtils.ToBool(DdlIsRapid.SelectedValue); if (isRapid) { PhRapid.Visible = true; PhNotRapid.Visible = false; } else { PhRapid.Visible = false; PhNotRapid.Visible = true; } if (inputType == InputType.CheckBox || inputType == InputType.Radio) { PhRepeat.Visible = true; } } else if (inputType == InputType.TextEditor) { PhDefaultValue.Visible = PhWidth.Visible = PhHeight.Visible = true; } else if (inputType == InputType.TextArea) { PhDefaultValue.Visible = PhWidth.Visible = PhHeight.Visible = true; } else if (inputType == InputType.Text) { PhDefaultValue.Visible = PhIsFormatString.Visible = PhWidth.Visible = true; } else if (inputType == InputType.Date || inputType == InputType.DateTime) { PhDefaultValue.Visible = SpanDateTip.Visible = true; } else if (inputType == InputType.SelectCascading) { PhDefaultValue.Visible = PhRelatedField.Visible = true; } else if (inputType == InputType.Image || inputType == InputType.Video || inputType == InputType.File) { PhDefaultValue.Visible = true; } else if (inputType == InputType.Customize) { PhCustomize.Visible = true; } }
private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs 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 ltlValidate = (Literal)e.Item.FindControl("ltlValidate"); var ltlTaxis = (Literal)e.Item.FindControl("ltlTaxis"); var ltlEditStyle = (Literal)e.Item.FindControl("ltlEditStyle"); var ltlEditValidate = (Literal)e.Item.FindControl("ltlEditValidate"); ltlAttributeName.Text = styleInfo.AttributeName; ltlDisplayName.Text = styleInfo.DisplayName; ltlInputType.Text = InputTypeUtils.GetText(styleInfo.InputType); var columnInfo = TableColumnManager.GetTableColumnInfo(_tableName, styleInfo.AttributeName); ltlFieldType.Text = columnInfo != null ? $"真实 {DataTypeUtils.GetText(columnInfo.DataType)}" : "虚拟字段"; ltlValidate.Text = TableStyleManager.GetValidateInfo(styleInfo); if (!StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.Title)) { var showPopWinString = ModalTableStyleAdd.GetOpenWindowString(SiteId, styleInfo.Id, _relatedIdentities, _tableName, styleInfo.AttributeName, _redirectUrl); ltlEditStyle.Text = $@"<a href=""javascript:;"" onclick=""{showPopWinString}"">设置</a>"; showPopWinString = ModalTableStyleValidateAdd.GetOpenWindowString(SiteId, styleInfo.Id, _relatedIdentities, _tableName, styleInfo.AttributeName, _redirectUrl); ltlEditValidate.Text = $@"<a href=""javascript:;"" onclick=""{showPopWinString}"">设置</a>"; } ltlTaxis.Text = styleInfo.Taxis.ToString(); if (styleInfo.RelatedIdentity != _channelInfo.Id) { return; } var urlStyle = PageUtils.GetCmsUrl(SiteId, nameof(PageTableStyleContent), new NameValueCollection { { "channelId", _channelInfo.Id.ToString() }, { "DeleteStyle", true.ToString() }, { "TableName", _tableName }, { "AttributeName", styleInfo.AttributeName } }); ltlEditStyle.Text += $@" <a href=""{urlStyle}"" onClick=""javascript:return confirm('此操作将删除对应显示样式,确认吗?');"">删除</a>"; }
private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } var styleInfo = (TableStyleInfo)e.Item.DataItem; if (_attributeNames.Contains(styleInfo.AttributeName)) { e.Item.Visible = false; return; } var ltlAttributeName = (Literal)e.Item.FindControl("ltlAttributeName"); var ltlDisplayName = (Literal)e.Item.FindControl("ltlDisplayName"); var ltlInputType = (Literal)e.Item.FindControl("ltlInputType"); var ltlValidate = (Literal)e.Item.FindControl("ltlValidate"); var ltlTaxis = (Literal)e.Item.FindControl("ltlTaxis"); var ltlEditStyle = (Literal)e.Item.FindControl("ltlEditStyle"); var ltlEditValidate = (Literal)e.Item.FindControl("ltlEditValidate"); ltlAttributeName.Text = styleInfo.AttributeName; ltlDisplayName.Text = styleInfo.DisplayName; ltlInputType.Text = InputTypeUtils.GetText(styleInfo.InputType); ltlValidate.Text = TableStyleManager.GetValidateInfo(styleInfo); var redirectUrl = GetRedirectUrl(SiteId, _relatedIdentity, _itemId, _returnUrl); var showPopWinString = ModalTableStyleAdd.GetOpenWindowString(SiteId, styleInfo.Id, _relatedIdentities, _tableName, styleInfo.AttributeName, redirectUrl); var editText = styleInfo.RelatedIdentity == _relatedIdentity ? "修改" : "设置"; ltlEditStyle.Text = $@"<a href=""javascript:;"" onclick=""{showPopWinString}"">{editText}</a>"; showPopWinString = ModalTableStyleValidateAdd.GetOpenWindowString(SiteId, styleInfo.Id, _relatedIdentities, _tableName, styleInfo.AttributeName, redirectUrl); ltlEditValidate.Text = $@"<a href=""javascript:;"" onclick=""{showPopWinString}"">设置</a>"; ltlTaxis.Text = styleInfo.Taxis.ToString(); if (styleInfo.RelatedIdentity != _relatedIdentity) { return; } var urlStyle = PageUtils.GetCmsUrl(SiteId, nameof(PageTableStyleSite), new NameValueCollection { { "TableName", _tableName }, { "RelatedIdentity", _relatedIdentity.ToString() }, { "DeleteStyle", true.ToString() }, { "AttributeName", styleInfo.AttributeName } }); ltlEditStyle.Text += $@" <a href=""{urlStyle}"" onClick=""javascript:return confirm('此操作将删除对应显示样式,确认吗?');"">删除</a>"; }
private string GetAttributesHtml(NameValueCollection formCollection) { if (formCollection == null) { formCollection = Request.Form.Count > 0 ? Request.Form : new NameValueCollection(); } var pageScripts = new NameValueCollection(); if (_styleInfoList == null) { return(string.Empty); } var attributes = new AttributesImpl(formCollection); var builder = new StringBuilder(); foreach (var styleInfo in _styleInfoList) { string extra; var value = BackgroundInputTypeParser.Parse(SiteInfo, 0, styleInfo, attributes, pageScripts, out extra); if (string.IsNullOrEmpty(value) && string.IsNullOrEmpty(extra)) { continue; } if (InputTypeUtils.Equals(styleInfo.InputType, InputType.TextEditor)) { var commands = WebUtils.GetTextEditorCommands(SiteInfo, styleInfo.AttributeName); builder.Append($@" <div class=""form-group""> <label class=""control-label"">{styleInfo.DisplayName}</label> {commands} <hr /> {value} {extra} </div>"); } else { builder.Append($@" <div class=""form-group""> <label class=""control-label"">{styleInfo.DisplayName}</label> {value} {extra} </div>"); } } foreach (string key in pageScripts.Keys) { builder.Append(pageScripts[key]); } return(builder.ToString()); }
private static string ParseImpl(ContextInfo contextInfo, string connectionString, string queryString, string leftText, string rightText, string formatString, 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 (!string.IsNullOrEmpty(type) && contextInfo.ItemContainer?.SqlItem != null) { if (!string.IsNullOrEmpty(formatString)) { formatString = formatString.Trim(); if (!formatString.StartsWith("{0")) { formatString = "{0:" + formatString; } if (!formatString.EndsWith("}")) { formatString = formatString + "}"; } } else { formatString = "{0}"; } if (StringUtils.StartsWithIgnoreCase(type, StlParserUtility.ItemIndex)) { var itemIndex = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.SqlItem.ItemIndex, type, contextInfo); parsedContent = !string.IsNullOrEmpty(formatString) ? string.Format(formatString, itemIndex) : itemIndex.ToString(); } else { parsedContent = DataBinder.Eval(contextInfo.ItemContainer.SqlItem.DataItem, type, formatString); } } else if (!string.IsNullOrEmpty(queryString)) { if (string.IsNullOrEmpty(connectionString)) { connectionString = WebConfigUtils.ConnectionString; } //parsedContent = DataProvider.DatabaseDao.GetString(connectionString, queryString); parsedContent = StlDatabaseCache.GetString(connectionString, queryString); } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = InputTypeUtils.ParseString(InputType.Text, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = leftText + parsedContent + rightText; } } return(parsedContent); }
private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs 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 ltlValidate = (Literal)e.Item.FindControl("ltlValidate"); var ltlTaxis = (Literal)e.Item.FindControl("ltlTaxis"); var ltlEditStyle = (Literal)e.Item.FindControl("ltlEditStyle"); var ltlEditValidate = (Literal)e.Item.FindControl("ltlEditValidate"); ltlAttributeName.Text = styleInfo.AttributeName; ltlDisplayName.Text = styleInfo.DisplayName; ltlInputType.Text = InputTypeUtils.GetText(styleInfo.InputType); var columnInfo = TableColumnManager.GetTableColumnInfo(_tableName, styleInfo.AttributeName); ltlFieldType.Text = columnInfo != null ? $"真实 {DataTypeUtils.GetText(columnInfo.DataType)}" : "虚拟字段"; ltlValidate.Text = TableStyleManager.GetValidateInfo(styleInfo); var showPopWinString = ModalTableStyleAdd.GetOpenWindowString(0, styleInfo.Id, new List <int> { 0 }, _tableName, styleInfo.AttributeName, _redirectUrl); var editText = styleInfo.Id != 0 ? "修改" : "添加"; ltlEditStyle.Text = $@"<a href=""javascript:;"" onclick=""{showPopWinString}"">{editText}</a>"; showPopWinString = ModalTableStyleValidateAdd.GetOpenWindowString(0, styleInfo.Id, new List <int> { 0 }, _tableName, styleInfo.AttributeName, _redirectUrl); ltlEditValidate.Text = $@"<a href=""javascript:;"" onclick=""{showPopWinString}"">设置</a>"; ltlTaxis.Text = styleInfo.Taxis.ToString(); if (styleInfo.Id == 0) { return; } ltlEditStyle.Text += $@" <a href=""{PageUtils.GetSettingsUrl(nameof(PageSiteTableStyle), new NameValueCollection { {"tableName", _tableName}, {"DeleteStyle", true.ToString()}, {"AttributeName", styleInfo.AttributeName} })}"" onClick=""javascript:return confirm('此操作将删除对应显示样式,确认吗?');"">删除</a>"; }
public override void Submit_OnClick(object sender, EventArgs e) { var inputType = InputTypeUtils.GetEnumType(DdlInputType.SelectedValue); var isChanged = InsertTableStyleInfo(inputType); if (isChanged) { LayerUtils.CloseAndRedirect(Page, _redirectUrl); } }
private static async Task <object> ParseImplAsync(IParseManager parseManager, string type, string formatString, int startIndex, int length, int wordNum, string ellipsis, string replace, string to, bool isClearTags, bool isReturnToBr, bool isLower, bool isUpper) { var pageInfo = parseManager.PageInfo; var contextInfo = parseManager.ContextInfo; if (string.IsNullOrEmpty(type)) { return(string.Empty); } string parsedContent; if (contextInfo.ContextType == ParseType.Each) { parsedContent = contextInfo.ItemContainer.EachItem.Value as string; return(parsedContent); } if (StringUtils.EqualsIgnoreCase(type, TypeDate)) { if (!pageInfo.BodyCodes.ContainsKey("datestring.js")) { var jsUrl = parseManager.PathManager.GetSiteFilesUrl(Resources.DateString.Js); pageInfo.BodyCodes.Add("datestring.js", $@"<script charset=""{Resources.DateString.Charset}"" src=""{jsUrl}"" type=""text/javascript""></script>"); } parsedContent = @"<script language=""javascript"" type=""text/javascript"">RunGLNL(false);</script>"; } else if (StringUtils.EqualsIgnoreCase(type, TypeDateOfTraditional)) { if (!pageInfo.BodyCodes.ContainsKey("datestring")) { var jsUrl = parseManager.PathManager.GetSiteFilesUrl(Resources.DateString.Js); pageInfo.BodyCodes.Add("datestring", $@"<script charset=""{Resources.DateString.Charset}"" src=""{jsUrl}"" type=""text/javascript""></script>"); } parsedContent = @"<script language=""javascript"" type=""text/javascript"">RunGLNL(true);</script>"; } else if (pageInfo.Parameters != null && pageInfo.Parameters.ContainsKey(type)) { pageInfo.Parameters.TryGetValue(type, out parsedContent); parsedContent = InputTypeUtils.ParseString(InputType.Text, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); } else { return(await StlSite.ParseAsync(parseManager)); } return(parsedContent); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } _tableStyleId = AuthRequest.GetQueryInt("TableStyleID"); _relatedIdentities = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("RelatedIdentities")); if (_relatedIdentities.Count == 0) { _relatedIdentities.Add(0); } _tableName = AuthRequest.GetQueryString("TableName"); _attributeName = AuthRequest.GetQueryString("AttributeName"); _redirectUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("RedirectUrl")); _styleInfo = _tableStyleId != 0 ? TableStyleManager.GetTableStyleInfo(_tableStyleId) : TableStyleManager.GetTableStyleInfo(_tableName, _attributeName, _relatedIdentities); if (IsPostBack) { return; } DdlIsValidate.Items[0].Value = true.ToString(); DdlIsValidate.Items[1].Value = false.ToString(); ControlUtils.SelectSingleItem(DdlIsValidate, _styleInfo.Additional.IsValidate.ToString()); DdlIsRequired.Items[0].Value = true.ToString(); DdlIsRequired.Items[1].Value = false.ToString(); ControlUtils.SelectSingleItem(DdlIsRequired, _styleInfo.Additional.IsRequired.ToString()); PhNum.Visible = InputTypeUtils.EqualsAny(_styleInfo.InputType, InputType.Text, InputType.TextArea); TbMinNum.Text = _styleInfo.Additional.MinNum.ToString(); TbMaxNum.Text = _styleInfo.Additional.MaxNum.ToString(); ValidateTypeUtils.AddListItems(DdlValidateType); ControlUtils.SelectSingleItem(DdlValidateType, _styleInfo.Additional.ValidateType.Value); TbRegExp.Text = _styleInfo.Additional.RegExp; TbErrorMessage.Text = _styleInfo.Additional.ErrorMessage; DdlValidate_SelectedIndexChanged(null, EventArgs.Empty); }
public ActionResult <GetResult> Get() { var styles = new List <Style> { new Style { InputType = InputType.Text } }; return(new GetResult { InputTypes = InputTypeUtils.GetInputTypes(), Styles = styles }); }
public static void SingleImportTableStyle(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, nameof(TableStyleInfo.AttributeName)); var taxis = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.Taxis)), 0); var displayName = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.DisplayName)); var helpText = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.HelpText)); var isVisibleInList = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.IsVisibleInList))); var inputType = InputTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.InputType))); var defaultValue = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.DefaultValue)); var isHorizontal = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.IsHorizontal))); //SettingsXML var extendValues = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.ExtendValues)); var styleInfo = new TableStyleInfo(0, relatedIdentity, tableName, attributeName, taxis, displayName, helpText, isVisibleInList, inputType, defaultValue, isHorizontal, extendValues); var styleItems = new List <TableStyleItemInfo>(); foreach (AtomEntry entry in feed.Entries) { var itemTitle = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableStyleItemInfo.ItemTitle)); var itemValue = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableStyleItemInfo.ItemValue)); var isSelected = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableStyleItemInfo.IsSelected))); styleItems.Add(new TableStyleItemInfo(0, 0, itemTitle, itemValue, isSelected)); } if (styleItems.Count > 0) { styleInfo.StyleItems = styleItems; } if (TableStyleManager.IsExists(relatedIdentity, tableName, attributeName)) { DataProvider.TableStyleDao.Delete(relatedIdentity, tableName, attributeName); } DataProvider.TableStyleDao.Insert(styleInfo); } }
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"); _redirectUrl = StringUtils.ValueFromUrl(Body.GetQueryString("RedirectUrl")); if (!IsPostBack) { DdlIsHorizontal.Items[0].Value = true.ToString(); DdlIsHorizontal.Items[1].Value = false.ToString(); DdlInputType.Items.Add(InputTypeUtils.GetListItem(InputType.Text, false)); DdlInputType.Items.Add(InputTypeUtils.GetListItem(InputType.TextArea, false)); DdlInputType.Items.Add(InputTypeUtils.GetListItem(InputType.TextEditor, false)); DdlInputType.Items.Add(InputTypeUtils.GetListItem(InputType.CheckBox, false)); DdlInputType.Items.Add(InputTypeUtils.GetListItem(InputType.Radio, false)); DdlInputType.Items.Add(InputTypeUtils.GetListItem(InputType.SelectOne, false)); DdlInputType.Items.Add(InputTypeUtils.GetListItem(InputType.SelectMultiple, false)); DdlInputType.Items.Add(InputTypeUtils.GetListItem(InputType.Date, false)); DdlInputType.Items.Add(InputTypeUtils.GetListItem(InputType.DateTime, false)); DdlInputType.Items.Add(InputTypeUtils.GetListItem(InputType.Image, false)); DdlInputType.Items.Add(InputTypeUtils.GetListItem(InputType.Video, false)); DdlInputType.Items.Add(InputTypeUtils.GetListItem(InputType.File, false)); var styleInfo = TableStyleManager.GetTableStyleInfo(_tableName, string.Empty, _relatedIdentities); ControlUtils.SelectSingleItem(DdlInputType, styleInfo.InputType.Value); TbDefaultValue.Text = styleInfo.DefaultValue; DdlIsHorizontal.SelectedValue = styleInfo.IsHorizontal.ToString(); TbColumns.Text = styleInfo.Additional.Columns.ToString(); TbHeight.Text = styleInfo.Additional.Height == 0 ? string.Empty : styleInfo.Additional.Height.ToString(); TbWidth.Text = styleInfo.Additional.Width; } ReFresh(null, EventArgs.Empty); }
public IHttpActionResult Delete() { try { var request = new RequestImpl(); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.SettingsPermissions.Admin)) { return(Unauthorized()); } var attributeName = request.GetPostString("attributeName"); DataProvider.TableStyleDao.Delete(0, DataProvider.UserDao.TableName, attributeName); var list = new List <object>(); foreach (var styleInfo in TableStyleManager.GetUserStyleInfoList()) { list.Add(new { styleInfo.Id, styleInfo.AttributeName, styleInfo.DisplayName, InputType = InputTypeUtils.GetText(styleInfo.InputType), Validate = TableStyleManager.GetValidateInfo(styleInfo), styleInfo.Taxis, IsSystem = StringUtils.ContainsIgnoreCase(UserAttribute.AllAttributes.Value, styleInfo.AttributeName) }); } return(Ok(new { Value = list })); } catch (Exception ex) { return(InternalServerError(ex)); } }
public override void Submit_OnClick(object sender, EventArgs e) { bool isChanged; var inputType = InputTypeUtils.GetEnumType(DdlInputType.SelectedValue); if (inputType == InputType.Radio || inputType == InputType.SelectMultiple || inputType == InputType.SelectOne) { var isRapid = TranslateUtils.ToBool(DdlIsRapid.SelectedValue); if (!isRapid) { var itemCount = TranslateUtils.ToInt(TbItemCount.Text); if (itemCount == 0) { FailMessage("操作失败,选项数目不能为0!"); return; } } } if (_styleInfo.Id == 0 && _styleInfo.RelatedIdentity == 0)//数据库中没有此项及父项的表样式 { isChanged = InsertTableStyleInfo(inputType); } else if (_styleInfo.RelatedIdentity != _relatedIdentities[0])//数据库中没有此项的表样式,但是有父项的表样式 { isChanged = InsertTableStyleInfo(inputType); } else//数据库中有此项的表样式 { isChanged = UpdateTableStyleInfo(inputType); } if (isChanged) { LayerUtils.CloseAndRedirect(Page, _redirectUrl); } }
public IHttpActionResult Get() { try { var request = new AuthenticatedRequest(); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.SettingsPermissions.User)) { return(Unauthorized()); } var list = new List <object>(); foreach (var styleInfo in TableStyleManager.GetUserStyleInfoList()) { list.Add(new { styleInfo.Id, styleInfo.AttributeName, styleInfo.DisplayName, InputType = InputTypeUtils.GetText(styleInfo.InputType), Validate = styleInfo.Additional.VeeValidate, styleInfo.Taxis, IsSystem = StringUtils.ContainsIgnoreCase(UserAttribute.AllAttributes.Value, styleInfo.AttributeName) }); } return(Ok(new { Value = list, DataProvider.UserDao.TableName, RelatedIdentities = TableStyleManager.EmptyRelatedIdentities })); } catch (Exception ex) { return(InternalServerError(ex)); } }
private static async Task <string> ParseImplAsync(IParseManager parseManager, string type, string title, int id, int startIndex, int length, int wordNum, string ellipsis, string replace, string to, bool isClearTags, bool isReturnToBr, bool isLower, bool isUpper) { if (string.IsNullOrEmpty(type)) { return(string.Empty); } var parsedContent = string.Empty; if (StringUtils.EqualsIgnoreCase(type, MaterialType.Article.GetValue())) { if (id > 0) { parsedContent = await parseManager.DatabaseManager.MaterialArticleRepository.GetBodyByIdAsync(id); } else if (!string.IsNullOrEmpty(title)) { parsedContent = await parseManager.DatabaseManager.MaterialArticleRepository.GetBodyByTitleAsync(title); } } else if (StringUtils.EqualsIgnoreCase(type, MaterialType.Image.GetValue())) { if (id > 0) { parsedContent = await parseManager.DatabaseManager.MaterialImageRepository.GetUrlByIdAsync(id); } else if (!string.IsNullOrEmpty(title)) { parsedContent = await parseManager.DatabaseManager.MaterialImageRepository.GetUrlByTitleAsync(title); } } parsedContent = InputTypeUtils.ParseString(InputType.Text, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, string.Empty); return(parsedContent); }
private static string ParseImpl(string type, string name, int id, int startIndex, int length, int wordNum, string ellipsis, string replace, string to, bool isClearTags, bool isReturnToBr, bool isLower, bool isUpper) { if (string.IsNullOrEmpty(type)) { return(string.Empty); } var parsedContent = string.Empty; if (StringUtils.EqualsIgnoreCase(type, TypeText)) { if (id > 0) { parsedContent = DataProvider.LibraryTextDao.GetContentById(id); } else if (!string.IsNullOrEmpty(name)) { parsedContent = DataProvider.LibraryTextDao.GetContentByTitle(name); } } else if (StringUtils.EqualsIgnoreCase(type, TypeImage)) { if (id > 0) { parsedContent = DataProvider.LibraryImageDao.GetUrlById(id); } else if (!string.IsNullOrEmpty(name)) { parsedContent = DataProvider.LibraryImageDao.GetUrlByTitle(name); } } parsedContent = InputTypeUtils.ParseString(InputType.Text, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, string.Empty); return(parsedContent); }
internal static string Parse(string stlEntity, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; try { var entityName = StlParserUtility.GetNameFromEntity(stlEntity); var channelIndex = StlParserUtility.GetValueFromEntity(stlEntity); var attributeName = entityName.Substring(9, entityName.Length - 10); var upLevel = 0; var topLevel = -1; var channelId = contextInfo.ChannelId; if (!string.IsNullOrEmpty(channelIndex)) { //channelId = DataProvider.ChannelDao.GetIdByIndexName(pageInfo.SiteId, channelIndex); channelId = Node.GetIdByIndexName(pageInfo.SiteId, channelIndex); if (channelId == 0) { channelId = contextInfo.ChannelId; } } if (attributeName.ToLower().StartsWith("up") && attributeName.IndexOf(".", StringComparison.Ordinal) != -1) { if (attributeName.ToLower().StartsWith("up.")) { upLevel = 1; } else { var upLevelStr = attributeName.Substring(2, attributeName.IndexOf(".", StringComparison.Ordinal) - 2); upLevel = TranslateUtils.ToInt(upLevelStr); } topLevel = -1; attributeName = attributeName.Substring(attributeName.IndexOf(".", StringComparison.Ordinal) + 1); } else if (attributeName.ToLower().StartsWith("top") && attributeName.IndexOf(".", StringComparison.Ordinal) != -1) { if (attributeName.ToLower().StartsWith("top.")) { topLevel = 1; } else { var topLevelStr = attributeName.Substring(3, attributeName.IndexOf(".", StringComparison.Ordinal) - 3); topLevel = TranslateUtils.ToInt(topLevelStr); } upLevel = 0; attributeName = attributeName.Substring(attributeName.IndexOf(".", StringComparison.Ordinal) + 1); } var nodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, channelId, upLevel, topLevel)); if (StringUtils.EqualsIgnoreCase(ChannelId, attributeName))//栏目ID { parsedContent = nodeInfo.Id.ToString(); } else if (StringUtils.EqualsIgnoreCase(Title, attributeName) || StringUtils.EqualsIgnoreCase(ChannelName, attributeName))//栏目名称 { parsedContent = nodeInfo.ChannelName; } else if (StringUtils.EqualsIgnoreCase(ChannelIndex, attributeName))//栏目索引 { parsedContent = nodeInfo.IndexName; } else if (StringUtils.EqualsIgnoreCase(Content, attributeName))//栏目正文 { parsedContent = ContentUtility.TextEditorContentDecode(pageInfo.SiteInfo, nodeInfo.Content, pageInfo.IsLocal); } else if (StringUtils.EqualsIgnoreCase(NavigationUrl, attributeName))//栏目链接地址 { parsedContent = PageUtility.GetChannelUrl(pageInfo.SiteInfo, nodeInfo, pageInfo.IsLocal); } else if (StringUtils.EqualsIgnoreCase(ImageUrl, attributeName))//栏目图片地址 { parsedContent = nodeInfo.ImageUrl; if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } } else if (StringUtils.EqualsIgnoreCase(AddDate, attributeName))//栏目添加日期 { parsedContent = DateUtils.Format(nodeInfo.AddDate, string.Empty); } else if (StringUtils.EqualsIgnoreCase(DirectoryName, attributeName))//生成文件夹名称 { parsedContent = PathUtils.GetDirectoryName(nodeInfo.FilePath, true); } else if (StringUtils.EqualsIgnoreCase(Group, attributeName))//栏目组别 { parsedContent = nodeInfo.GroupNameCollection; } else if (StringUtils.StartsWithIgnoreCase(attributeName, StlParserUtility.ItemIndex) && contextInfo.ItemContainer?.ChannelItem != null) { parsedContent = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.ChannelItem.ItemIndex, attributeName, contextInfo).ToString(); } else if (StringUtils.EqualsIgnoreCase(ChannelAttribute.Keywords, attributeName))//栏目组别 { parsedContent = nodeInfo.Keywords; } else if (StringUtils.EqualsIgnoreCase(ChannelAttribute.Description, attributeName))//栏目组别 { parsedContent = nodeInfo.Description; } else { //var styleInfo = TableStyleManager.GetTableStyleInfo(ETableStyle.Channel, DataProvider.ChannelDao.TableName, attributeName, RelatedIdentities.GetChannelRelatedIdentities(pageInfo.SiteId, nodeInfo.ChannelId)); //parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, ",", pageInfo.SiteInfo, ETableStyle.Channel, styleInfo, string.Empty, null, string.Empty, true); var formCollection = nodeInfo.Additional.ToNameValueCollection(); if (formCollection != null && formCollection.Count > 0) { var styleInfo = TableStyleManager.GetTableStyleInfo(DataProvider.ChannelDao.TableName, attributeName, RelatedIdentities.GetChannelRelatedIdentities(pageInfo.SiteId, nodeInfo.Id)); // 如果 styleInfo.TableStyleId <= 0,表示此字段已经被删除了,不需要再显示值了 ekun008 if (styleInfo.Id > 0) { parsedContent = GetValue(attributeName, formCollection, false, styleInfo.DefaultValue); if (!string.IsNullOrEmpty(parsedContent)) { if (InputTypeUtils.EqualsAny(styleInfo.InputType, InputType.Image, InputType.File)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } else { parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, null, pageInfo.SiteInfo, styleInfo, string.Empty, null, string.Empty, true); } } } } } } catch { // ignored } return(parsedContent); }
private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, SiteInfo siteInfo, 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) { if (siteInfo == null) { return(string.Empty); } var parsedContent = string.Empty; if (!string.IsNullOrEmpty(contextInfo.InnerHtml)) { var preSiteInfo = pageInfo.SiteInfo; var prePageChannelId = pageInfo.PageChannelId; var prePageContentId = pageInfo.PageContentId; pageInfo.ChangeSite(siteInfo, siteInfo.Id, 0, contextInfo); var innerBuilder = new StringBuilder(contextInfo.InnerHtml); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); parsedContent = innerBuilder.ToString(); pageInfo.ChangeSite(preSiteInfo, prePageChannelId, prePageContentId, contextInfo); return(parsedContent); } var inputType = InputType.Text; if (type.ToLower().Equals(TypeSiteName.ToLower())) { parsedContent = pageInfo.SiteInfo.SiteName; } else if (type.ToLower().Equals(TypeSiteUrl.ToLower())) { parsedContent = pageInfo.SiteInfo.Additional.WebUrl; } else if (pageInfo.SiteInfo.Additional.GetString(type) != null) { parsedContent = pageInfo.SiteInfo.Additional.GetString(type); if (!string.IsNullOrEmpty(parsedContent)) { var styleInfo = TableStyleManager.GetTableStyleInfo(DataProvider.SiteDao.TableName, type, TableStyleManager.GetRelatedIdentities(pageInfo.SiteId)); // 如果 styleInfo.TableStyleId <= 0,表示此字段已经被删除了,不需要再显示值了 ekun008 if (styleInfo.Id > 0) { if (isClearTags && InputTypeUtils.EqualsAny(styleInfo.InputType, InputType.Image, InputType.File)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } else { parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, separator, pageInfo.SiteInfo, styleInfo, formatString, contextInfo.Attributes, contextInfo.InnerHtml, false); inputType = styleInfo.InputType; //parsedContent = StringUtils.ParseString(styleInfo.InputType, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); } } else { // 如果字段已经被删除或不再显示了,则此字段的值为空。有时虚拟字段值不会清空 parsedContent = string.Empty; } } } if (string.IsNullOrEmpty(parsedContent)) { return(string.Empty); } return(InputTypeUtils.ParseString(inputType, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString)); }
private static async Task <string> ParseImplAsync(IParseManager parseManager, string leftText, string rightText, string type, string formatString, string no, string separator, int startIndex, int length, int wordNum, string ellipsis, string replace, string to, bool isClearTags, bool isReturnToBr, bool isLower, bool isUpper, Channel channel, int channelId, NameValueCollection attributes) { var databaseManager = parseManager.DatabaseManager; var pageInfo = parseManager.PageInfo; var contextInfo = parseManager.ContextInfo; if (string.IsNullOrEmpty(type)) { type = nameof(StlParserUtility.Title); } //type = StringUtils.ToLower(type); var parsedContent = string.Empty; if (!string.IsNullOrEmpty(formatString)) { formatString = formatString.Trim(); if (!formatString.StartsWith("{0")) { formatString = "{0:" + formatString; } if (!formatString.EndsWith("}")) { formatString += "}"; } } var inputType = InputType.Text; if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.Id))) { parsedContent = channelId.ToString(); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.SiteId))) { parsedContent = channel.SiteId.ToString(); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.ContentModelPluginId))) { parsedContent = channel.ContentModelPluginId; } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.ParentId))) { parsedContent = channel.ParentId.ToString(); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.ParentsPath))) { parsedContent = ListUtils.ToString(channel.ParentsPath); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.ParentsCount))) { parsedContent = channel.ParentsCount.ToString(); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.ChildrenCount))) { parsedContent = channel.ChildrenCount.ToString(); } else if (StringUtils.EqualsIgnoreCase(type, nameof(ColumnsManager.NavigationUrl)))//栏目链接地址 { parsedContent = await parseManager.PathManager.GetChannelUrlAsync(pageInfo.Site, channel, pageInfo.IsLocal); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.IndexName)) || StringUtils.EqualsIgnoreCase(type, "ChannelIndex")) { parsedContent = channel.IndexName; if (!string.IsNullOrEmpty(replace)) { parsedContent = StringUtils.Replace(parsedContent, replace, to); } if (!string.IsNullOrEmpty(parsedContent) && wordNum > 0) { parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis); } } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.GroupNames))) { parsedContent = ListUtils.ToString(channel.GroupNames); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.Taxis))) { parsedContent = channel.Taxis.ToString(); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.AddDate))) { inputType = InputType.DateTime; parsedContent = DateUtils.Format(channel.AddDate, formatString); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.ImageUrl))) { //inputType = InputType.Image; //var inputParser = new InputParserManager(parseManager.PathManager); //parsedContent = await inputParser.GetImageOrFlashHtmlAsync(pageInfo.Site, channel.ImageUrl, attributes, contextInfo.IsStlEntity); var inputParser = new InputParserManager(parseManager.PathManager); if (no == "all") { var sbParsedContent = new StringBuilder(); //第一条 sbParsedContent.Append(contextInfo.IsStlEntity ? await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, channel.ImageUrl, pageInfo.IsLocal) : await inputParser.GetImageOrFlashHtmlAsync(pageInfo.Site, channel.ImageUrl, attributes, false)); //第n条 var countName = ColumnsManager.GetCountName(nameof(Content.ImageUrl)); var count = channel.Get <int>(countName); for (var i = 1; i <= count; i++) { var extendName = ColumnsManager.GetExtendName(nameof(Content.ImageUrl), i); var extend = channel.Get <string>(extendName); sbParsedContent.Append(contextInfo.IsStlEntity ? await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, extend, pageInfo.IsLocal) : await inputParser.GetImageOrFlashHtmlAsync(pageInfo.Site, extend, attributes, false)); } parsedContent = sbParsedContent.ToString(); } else { var num = TranslateUtils.ToInt(no); if (num <= 1) { parsedContent = contextInfo.IsStlEntity ? await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, channel.ImageUrl, pageInfo.IsLocal) : await inputParser.GetImageOrFlashHtmlAsync(pageInfo.Site, channel.ImageUrl, attributes, false); } else { var extendName = ColumnsManager.GetExtendName(nameof(Site.ImageUrl), num - 1); var extend = channel.Get <string>(extendName); if (!string.IsNullOrEmpty(extend)) { parsedContent = contextInfo.IsStlEntity ? await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, extend, pageInfo.IsLocal) : await inputParser.GetImageOrFlashHtmlAsync(pageInfo.Site, extend, attributes, false); } } } } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.Content))) { parsedContent = await parseManager.PathManager.DecodeTextEditorAsync(pageInfo.Site, channel.Content, pageInfo.IsLocal); if (isClearTags) { parsedContent = StringUtils.StripTags(parsedContent); } if (!string.IsNullOrEmpty(replace)) { parsedContent = StringUtils.Replace(parsedContent, replace, to); } if (!string.IsNullOrEmpty(parsedContent) && wordNum > 0) { parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis); } } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.FilePath))) { parsedContent = channel.FilePath; } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.ChannelFilePathRule))) { parsedContent = channel.ChannelFilePathRule; } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.ContentFilePathRule))) { parsedContent = channel.ContentFilePathRule; } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.LinkUrl))) { parsedContent = channel.LinkUrl; } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.LinkType))) { parsedContent = channel.LinkType.GetValue(); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.ChannelTemplateId))) { parsedContent = channel.ChannelTemplateId.ToString(); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.ContentTemplateId))) { parsedContent = channel.ContentTemplateId.ToString(); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.Keywords))) { parsedContent = channel.Keywords; } else if (StringUtils.EqualsIgnoreCase(type, nameof(Channel.Description))) { parsedContent = channel.Description; } else if (StringUtils.EqualsIgnoreCase(type, StlParserUtility.Title) || StringUtils.EqualsIgnoreCase(type, nameof(Channel.ChannelName))) { parsedContent = channel.ChannelName; if (isClearTags) { parsedContent = StringUtils.StripTags(parsedContent); } if (!string.IsNullOrEmpty(replace)) { parsedContent = StringUtils.Replace(parsedContent, replace, to); } if (!string.IsNullOrEmpty(parsedContent) && wordNum > 0) { parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis); } } else if (StringUtils.EqualsIgnoreCase(type, StlParserUtility.PageContent)) { if (contextInfo.IsInnerElement || pageInfo.Template.TemplateType != TemplateType.ChannelTemplate) { parsedContent = await parseManager.PathManager.DecodeTextEditorAsync(pageInfo.Site, channel.Content, pageInfo.IsLocal); if (isClearTags) { parsedContent = StringUtils.StripTags(parsedContent); } if (!string.IsNullOrEmpty(replace)) { parsedContent = StringUtils.Replace(parsedContent, replace, to); } if (!string.IsNullOrEmpty(parsedContent) && wordNum > 0) { parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis); } } else { return(contextInfo.OuterHtml); } } else if (StringUtils.StartsWithIgnoreCase(type, StlParserUtility.ItemIndex) && contextInfo.ItemContainer?.ChannelItem != null) { var itemIndex = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.ChannelItem.Key, type, contextInfo); parsedContent = !string.IsNullOrEmpty(formatString) ? string.Format(formatString, itemIndex) : itemIndex.ToString(); } else if (StringUtils.EqualsIgnoreCase(type, StlParserUtility.CountOfChannels)) { parsedContent = channel.ChildrenCount.ToString(); } else if (StringUtils.EqualsIgnoreCase(type, StlParserUtility.CountOfContents)) { var count = await databaseManager.ContentRepository.GetCountAsync(pageInfo.Site, channel); parsedContent = count.ToString(); } else if (StringUtils.EqualsIgnoreCase(type, StlParserUtility.CountOfImageContents)) { var count = await databaseManager.ContentRepository.GetCountCheckedImageAsync(pageInfo.Site, channel); parsedContent = count.ToString(); } else { var attributeName = type; var styleInfo = await databaseManager.TableStyleRepository.GetTableStyleAsync(databaseManager.ChannelRepository.TableName, attributeName, databaseManager.TableStyleRepository.GetRelatedIdentities(channel)); if (styleInfo.Id > 0) { parsedContent = GetValue(attributeName, channel, false, styleInfo.DefaultValue); if (!string.IsNullOrEmpty(parsedContent)) { var inputParser = new InputParserManager(parseManager.PathManager); parsedContent = await inputParser.GetContentByTableStyleAsync(parsedContent, separator, pageInfo.Site, styleInfo, formatString, attributes, contextInfo.InnerHtml, contextInfo.IsStlEntity); inputType = styleInfo.InputType; } } } if (string.IsNullOrEmpty(parsedContent)) { return(string.Empty); } parsedContent = InputTypeUtils.ParseString(inputType, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); return(leftText + parsedContent + rightText); }
private TableStyleInfo GetTableStyleInfoByReader(IDataReader rdr) { var i = 0; var id = GetInt(rdr, i++); var relatedIdentity = GetInt(rdr, i++); var tableName = GetString(rdr, i++); var attributeName = GetString(rdr, i++); var taxis = GetInt(rdr, i++); var displayName = GetString(rdr, i++); var helpText = GetString(rdr, i++); var isVisibleInList = GetBool(rdr, i++); var inputType = GetString(rdr, i++); var defaultValue = GetString(rdr, i++); var isHorizontal = GetBool(rdr, i++); var extendValues = GetString(rdr, i); var styleInfo = new TableStyleInfo(id, relatedIdentity, tableName, attributeName, taxis, displayName, helpText, isVisibleInList, InputTypeUtils.GetEnumType(inputType), defaultValue, isHorizontal, extendValues); return(styleInfo); }
private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, string leftText, string rightText, 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, ChannelInfo channel, int channelId) { if (string.IsNullOrEmpty(type)) { type = ChannelAttribute.Title; } type = type.ToLower(); var parsedContent = string.Empty; if (!string.IsNullOrEmpty(formatString)) { formatString = formatString.Trim(); if (!formatString.StartsWith("{0")) { formatString = "{0:" + formatString; } if (!formatString.EndsWith("}")) { formatString = formatString + "}"; } } var inputType = InputType.Text; if (type.Equals(ChannelAttribute.Id.ToLower())) { parsedContent = channelId.ToString(); } else if (type.Equals(ChannelAttribute.SiteId.ToLower())) { parsedContent = channel.SiteId.ToString(); } else if (type.Equals(ChannelAttribute.ContentModelPluginId.ToLower())) { parsedContent = channel.ContentModelPluginId; } else if (type.Equals(ChannelAttribute.ContentRelatedPluginIds.ToLower())) { parsedContent = channel.ContentRelatedPluginIds; } else if (type.Equals(ChannelAttribute.ParentId.ToLower())) { parsedContent = channel.ParentId.ToString(); } else if (type.Equals(ChannelAttribute.ParentsPath.ToLower())) { parsedContent = channel.ParentsPath; } else if (type.Equals(ChannelAttribute.ParentsCount.ToLower())) { parsedContent = channel.ParentsCount.ToString(); } else if (type.Equals(ChannelAttribute.ChildrenCount.ToLower())) { parsedContent = channel.ChildrenCount.ToString(); } else if (type.Equals(ChannelAttribute.IsLastNode.ToLower())) { parsedContent = channel.IsLastNode.ToString(); } else if (type.Equals(ChannelAttribute.ChannelIndex.ToLower()) || type.Equals(ChannelAttribute.IndexName.ToLower())) { parsedContent = channel.IndexName; 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.Equals(ChannelAttribute.GroupNameCollection.ToLower())) { parsedContent = channel.GroupNameCollection; } else if (type.Equals(ChannelAttribute.Taxis.ToLower())) { parsedContent = channel.Taxis.ToString(); } else if (type.Equals(ChannelAttribute.AddDate.ToLower())) { inputType = InputType.DateTime; parsedContent = DateUtils.Format(channel.AddDate, formatString); } else if (type.Equals(ChannelAttribute.ImageUrl.ToLower())) { inputType = InputType.Image; parsedContent = InputParserUtility.GetImageOrFlashHtml(pageInfo.SiteInfo, channel.ImageUrl, contextInfo.Attributes, contextInfo.IsStlEntity); // contextInfo.IsStlEntity = true 表示实体标签 } else if (type.Equals(ChannelAttribute.Content.ToLower())) { parsedContent = ContentUtility.TextEditorContentDecode(pageInfo.SiteInfo, channel.Content, pageInfo.IsLocal); 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.Equals(ChannelAttribute.FilePath.ToLower())) { parsedContent = channel.FilePath; } else if (type.Equals(ChannelAttribute.ChannelFilePathRule.ToLower())) { parsedContent = channel.ChannelFilePathRule; } else if (type.Equals(ChannelAttribute.ContentFilePathRule.ToLower())) { parsedContent = channel.ContentFilePathRule; } else if (type.Equals(ChannelAttribute.LinkUrl.ToLower())) { parsedContent = channel.LinkUrl; } else if (type.Equals(ChannelAttribute.LinkType.ToLower())) { parsedContent = channel.LinkType; } else if (type.Equals(ChannelAttribute.ChannelTemplateId.ToLower())) { parsedContent = channel.ChannelTemplateId.ToString(); } else if (type.Equals(ChannelAttribute.ContentTemplateId.ToLower())) { parsedContent = channel.ContentTemplateId.ToString(); } else if (type.Equals(ChannelAttribute.Keywords.ToLower())) { parsedContent = channel.Keywords; } else if (type.Equals(ChannelAttribute.Description.ToLower())) { parsedContent = channel.Description; } else if (type.Equals(ChannelAttribute.ExtendValues.ToLower())) { parsedContent = channel.Additional.ToString(); } else if (type.Equals(ChannelAttribute.Title.ToLower()) || type.Equals(ChannelAttribute.ChannelName.ToLower())) { parsedContent = channel.ChannelName; 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.Equals(ChannelAttribute.PageContent.ToLower())) { if (contextInfo.IsInnerElement || pageInfo.TemplateInfo.TemplateType != TemplateType.ChannelTemplate) { parsedContent = ContentUtility.TextEditorContentDecode(pageInfo.SiteInfo, channel.Content, pageInfo.IsLocal); 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(contextInfo.OuterHtml); } } else if (StringUtils.StartsWithIgnoreCase(type, ChannelAttribute.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.Equals(ChannelAttribute.CountOfChannels.ToLower())) { parsedContent = channel.ChildrenCount.ToString(); } else if (type.Equals(ChannelAttribute.CountOfContents.ToLower())) { var count = ContentManager.GetCount(pageInfo.SiteInfo, channel, true); parsedContent = count.ToString(); } else if (type.Equals(ChannelAttribute.CountOfImageContents.ToLower())) { var count = StlContentCache.GetCountCheckedImage(pageInfo.SiteId, channel.Id); parsedContent = count.ToString(); } else { var attributeName = type; var styleInfo = TableStyleManager.GetTableStyleInfo(DataProvider.ChannelDao.TableName, attributeName, TableStyleManager.GetRelatedIdentities(channel)); // 如果 styleInfo.TableStyleId <= 0,表示此字段已经被删除了,不需要再显示值了 ekun008 if (styleInfo.Id > 0) { parsedContent = GetValue(attributeName, channel.Additional, false, styleInfo.DefaultValue); if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, separator, pageInfo.SiteInfo, styleInfo, formatString, contextInfo.Attributes, contextInfo.InnerHtml, false); inputType = styleInfo.InputType; } } } if (string.IsNullOrEmpty(parsedContent)) { return(string.Empty); } parsedContent = InputTypeUtils.ParseString(inputType, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); return(leftText + parsedContent + rightText); }
private static async Task <string> ParseImplAsync(IParseManager parseManager, 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, Content content, int contentId) { var pageInfo = parseManager.PageInfo; var contextInfo = parseManager.ContextInfo; var databaseManager = parseManager.DatabaseManager; if (content == null) { return(string.Empty); } var parsedContent = string.Empty; if (string.IsNullOrEmpty(type)) { type = nameof(Content.Title); } var isReturnToBr = false; if (string.IsNullOrEmpty(isReturnToBrStr)) { if (StringUtils.EqualsIgnoreCase(type, nameof(Content.Summary))) { isReturnToBr = true; } } else { isReturnToBr = TranslateUtils.ToBool(isReturnToBrStr, true); } if (isOriginal) { if (content.ReferenceId > 0 && content.SourceId > 0 && TranslateType.Reference.GetValue() == content.Get <string>(ColumnsManager.TranslateContentType)) { var targetChannelId = content.SourceId; //var targetSiteId = databaseManager.ChannelRepository.GetSiteId(targetChannelId); var targetSiteId = await databaseManager.ChannelRepository.GetSiteIdAsync(targetChannelId); var targetSite = await databaseManager.SiteRepository.GetAsync(targetSiteId); var targetNodeInfo = await databaseManager.ChannelRepository.GetAsync(targetChannelId); //var targetContentInfo = databaseManager.ContentRepository.GetContentInfo(tableStyle, tableName, content.ReferenceId); var targetContentInfo = await databaseManager.ContentRepository.GetAsync(targetSite, targetNodeInfo, content.ReferenceId); if (targetContentInfo != null && targetContentInfo.ChannelId > 0) { //标题可以使用自己的 targetContentInfo.Title = content.Title; content = targetContentInfo; } } } if (!string.IsNullOrEmpty(formatString)) { formatString = formatString.Trim(); if (!formatString.StartsWith("{0")) { formatString = "{0:" + formatString; } if (!formatString.EndsWith("}")) { formatString = formatString + "}"; } } if (contentId != 0) { if (StringUtils.EqualsIgnoreCase(type, nameof(Content.Title))) { var channel = await databaseManager.ChannelRepository.GetAsync(content.ChannelId); var relatedIdentities = databaseManager.TableStyleRepository.GetRelatedIdentities(channel); var tableName = databaseManager.ChannelRepository.GetTableName(pageInfo.Site, channel); var styleInfo = await databaseManager.TableStyleRepository.GetTableStyleAsync(tableName, type, relatedIdentities); var inputParser = new InputParserManager(parseManager.PathManager); parsedContent = await inputParser.GetContentByTableStyleAsync(content.Title, separator, pageInfo.Site, styleInfo, formatString, contextInfo.Attributes, contextInfo.InnerHtml, false); parsedContent = InputTypeUtils.ParseString(styleInfo.InputType, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); if (!isClearTags && !string.IsNullOrEmpty(content.Get <string>(ColumnsManager.GetFormatStringAttributeName(nameof(Content.Title))))) { parsedContent = ContentUtility.FormatTitle(content.Get <string>(ColumnsManager.GetFormatStringAttributeName(nameof(Content.Title))), parsedContent); } if (pageInfo.Site.IsContentTitleBreakLine) { parsedContent = parsedContent.Replace(" ", !contextInfo.IsInnerElement ? "<br />" : string.Empty); } } else if (StringUtils.EqualsIgnoreCase(type, nameof(Content.SubTitle))) { parsedContent = InputTypeUtils.ParseString(InputType.Text, content.SubTitle, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); if (pageInfo.Site.IsContentSubTitleBreakLine) { parsedContent = parsedContent.Replace(" ", !contextInfo.IsInnerElement ? "<br />" : string.Empty); } } else if (StringUtils.EqualsIgnoreCase(type, nameof(Content.Summary))) { parsedContent = InputTypeUtils.ParseString(InputType.TextArea, content.Summary, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Content.Body)) || StringUtils.EqualsIgnoreCase(type, nameof(Content))) { parsedContent = await parseManager.PathManager.DecodeTextEditorAsync(pageInfo.Site, content.Body, pageInfo.IsLocal); if (isClearTags) { parsedContent = StringUtils.StripTags(parsedContent); } if (!string.IsNullOrEmpty(replace)) { parsedContent = StringUtils.Replace(parsedContent, replace, to); } if (wordNum > 0 && !string.IsNullOrEmpty(parsedContent)) { parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis); } if (!string.IsNullOrEmpty(formatString)) { parsedContent = string.Format(formatString, parsedContent); } parsedContent = await EditorUtility.ParseAsync(pageInfo, parsedContent); } else if (StringUtils.EqualsIgnoreCase(type, nameof(ColumnsManager.PageContent))) { //if (contextInfo.IsInnerElement) // { parsedContent = await parseManager.PathManager.DecodeTextEditorAsync(pageInfo.Site, content.Body, pageInfo.IsLocal); if (isClearTags) { parsedContent = StringUtils.StripTags(parsedContent); } if (!string.IsNullOrEmpty(replace)) { parsedContent = StringUtils.Replace(parsedContent, replace, to); } if (wordNum > 0 && !string.IsNullOrEmpty(parsedContent)) { parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis); } if (!string.IsNullOrEmpty(formatString)) { parsedContent = string.Format(formatString, parsedContent); } parsedContent = await EditorUtility.ParseAsync(pageInfo, parsedContent); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Content.AddDate))) { parsedContent = DateUtils.Format(content.AddDate, formatString); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Content.LastModifiedDate))) { parsedContent = DateUtils.Format(content.LastModifiedDate, formatString); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Content.LastHitsDate))) { parsedContent = DateUtils.Format(content.LastHitsDate, formatString); } else if (StringUtils.EqualsIgnoreCase(type, nameof(Content.ImageUrl))) { var inputParser = new InputParserManager(parseManager.PathManager); if (no == "all") { var sbParsedContent = new StringBuilder(); //第一条 sbParsedContent.Append(contextInfo.IsStlEntity ? await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, content.ImageUrl, pageInfo.IsLocal) : await inputParser.GetImageOrFlashHtmlAsync(pageInfo.Site, content.ImageUrl, contextInfo.Attributes, false)); //第n条 var countName = ColumnsManager.GetCountName(nameof(Content.ImageUrl)); var count = content.Get <int>(countName); for (var i = 1; i <= count; i++) { var extendName = ColumnsManager.GetExtendName(nameof(Content.ImageUrl), i); var extend = content.Get <string>(extendName); sbParsedContent.Append(contextInfo.IsStlEntity ? await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, extend, pageInfo.IsLocal) : await inputParser.GetImageOrFlashHtmlAsync(pageInfo.Site, extend, contextInfo.Attributes, false)); } //var extendAttributeName = ColumnsManager.GetExtendAttributeName(nameof(Content.ImageUrl)); //var extendValues = content.Get<string>(extendAttributeName); //if (!string.IsNullOrEmpty(extendValues)) //{ // foreach (var extendValue in ListUtils.GetStringList(extendValues)) // { // var newExtendValue = extendValue; // sbParsedContent.Append(contextInfo.IsStlEntity // ? await parseManager.PathManager.ParseNavigationUrlAsync(pageInfo.Site, newExtendValue, pageInfo.IsLocal) // : await inputParser.GetImageOrFlashHtmlAsync(pageInfo.Site, newExtendValue, contextInfo.Attributes, false)); // } //} parsedContent = sbParsedContent.ToString(); } else { var num = TranslateUtils.ToInt(no); if (num <= 1) { parsedContent = contextInfo.IsStlEntity ? await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, content.ImageUrl, pageInfo.IsLocal) : await inputParser.GetImageOrFlashHtmlAsync(pageInfo.Site, content.ImageUrl, contextInfo.Attributes, false); } else { var extendName = ColumnsManager.GetExtendName(nameof(Content.ImageUrl), num - 1); var extend = content.Get <string>(extendName); if (!string.IsNullOrEmpty(extend)) { parsedContent = contextInfo.IsStlEntity ? await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, extend, pageInfo.IsLocal) : await inputParser.GetImageOrFlashHtmlAsync(pageInfo.Site, extend, contextInfo.Attributes, false); } //var extendAttributeName = ColumnsManager.GetExtendAttributeName(nameof(Content.ImageUrl)); //var extendValues = content.Get<string>(extendAttributeName); //if (!string.IsNullOrEmpty(extendValues)) //{ // var index = 2; // foreach (var extendValue in ListUtils.GetStringList(extendValues)) // { // var newExtendValue = extendValue; // if (index == num) // { // parsedContent = contextInfo.IsStlEntity ? await parseManager.PathManager.ParseNavigationUrlAsync(pageInfo.Site, newExtendValue, pageInfo.IsLocal) : await inputParser.GetImageOrFlashHtmlAsync(pageInfo.Site, newExtendValue, contextInfo.Attributes, false); // break; // } // index++; // } //} } } } else if (StringUtils.EqualsIgnoreCase(type, nameof(Content.VideoUrl))) { var inputParser = new InputParserManager(parseManager.PathManager); if (no == "all") { var sbParsedContent = new StringBuilder(); //第一条 sbParsedContent.Append(await inputParser.GetVideoHtmlAsync(pageInfo.Site, content.VideoUrl, contextInfo.Attributes, contextInfo.IsStlEntity)); //第n条 var countName = ColumnsManager.GetCountName(nameof(Content.VideoUrl)); var count = content.Get <int>(countName); for (var i = 1; i <= count; i++) { var extendName = ColumnsManager.GetExtendName(nameof(Content.VideoUrl), i); var extend = content.Get <string>(extendName); sbParsedContent.Append(await inputParser.GetVideoHtmlAsync(pageInfo.Site, extend, contextInfo.Attributes, contextInfo.IsStlEntity)); } //var extendAttributeName = ColumnsManager.GetExtendAttributeName(nameof(Content.VideoUrl)); //var extendValues = content.Get<string>(extendAttributeName); //if (!string.IsNullOrEmpty(extendValues)) //{ // foreach (string extendValue in ListUtils.GetStringList(extendValues)) // { // sbParsedContent.Append(await inputParser.GetVideoHtmlAsync(pageInfo.Config, pageInfo.Site, extendValue, contextInfo.Attributes, contextInfo.IsStlEntity)); // } //} parsedContent = sbParsedContent.ToString(); } else { var num = TranslateUtils.ToInt(no); if (num <= 1) { parsedContent = await inputParser.GetVideoHtmlAsync(pageInfo.Site, content.VideoUrl, contextInfo.Attributes, contextInfo.IsStlEntity); } else { var extendName = ColumnsManager.GetExtendName(nameof(Content.VideoUrl), num - 1); var extend = content.Get <string>(extendName); if (!string.IsNullOrEmpty(extend)) { parsedContent = await inputParser.GetVideoHtmlAsync(pageInfo.Site, extend, contextInfo.Attributes, contextInfo.IsStlEntity); } } } } else if (StringUtils.EqualsIgnoreCase(type, nameof(Content.FileUrl))) { if (no == "all") { var sbParsedContent = new StringBuilder(); if (contextInfo.IsStlEntity) { //第一条 sbParsedContent.Append(content.FileUrl); //第n条 var countName = ColumnsManager.GetCountName(nameof(Content.FileUrl)); var count = content.Get <int>(countName); for (var i = 1; i <= count; i++) { var extendName = ColumnsManager.GetExtendName(nameof(Content.FileUrl), i); var extend = content.Get <string>(extendName); sbParsedContent.Append(extend); } } else { var inputParser = new InputParserManager(parseManager.PathManager); //第一条 sbParsedContent.Append(inputParser.GetFileHtmlWithCount(pageInfo.Site, content.ChannelId, content.Id, content.FileUrl, contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper)); //第n条 var countName = ColumnsManager.GetCountName(nameof(Content.FileUrl)); var count = content.Get <int>(countName); for (var i = 1; i <= count; i++) { var extendName = ColumnsManager.GetExtendName(nameof(Content.FileUrl), i); var extend = content.Get <string>(extendName); sbParsedContent.Append(inputParser.GetFileHtmlWithCount(pageInfo.Site, content.ChannelId, content.Id, extend, contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper)); } } parsedContent = sbParsedContent.ToString(); } else { var num = TranslateUtils.ToInt(no); if (contextInfo.IsStlEntity) { if (num <= 1) { parsedContent = content.FileUrl; } else { var extendName = ColumnsManager.GetExtendName(nameof(Content.FileUrl), num - 1); var extend = content.Get <string>(extendName); if (!string.IsNullOrEmpty(extend)) { parsedContent = extend; } } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, parsedContent, pageInfo.IsLocal); } } else { var inputParser = new InputParserManager(parseManager.PathManager); if (num <= 1) { parsedContent = inputParser.GetFileHtmlWithCount(pageInfo.Site, content.ChannelId, content.Id, content.FileUrl, contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper); } else { var extendName = ColumnsManager.GetExtendName(nameof(Content.FileUrl), num - 1); var extend = content.Get <string>(extendName); if (!string.IsNullOrEmpty(extend)) { parsedContent = inputParser.GetFileHtmlWithCount(pageInfo.Site, content.ChannelId, content.Id, extend, contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper); } } } } } else if (StringUtils.EqualsIgnoreCase(type, nameof(ColumnsManager.NavigationUrl))) { if (contextInfo.Content != null) { parsedContent = await parseManager.PathManager.GetContentUrlAsync(pageInfo.Site, contextInfo.Content, pageInfo.IsLocal); } else { var channelInfo = await databaseManager.ChannelRepository.GetAsync(contextInfo.ChannelId); parsedContent = await parseManager.PathManager.GetContentUrlAsync(pageInfo.Site, channelInfo, contextInfo.ContentId, pageInfo.IsLocal); } } else if (StringUtils.EqualsIgnoreCase(type, nameof(Content.TagNames))) { parsedContent = ListUtils.ToString(content.TagNames); } else if (StringUtils.StartsWithIgnoreCase(type, StlParserUtility.ItemIndex) && contextInfo.ItemContainer?.ContentItem != null) { var itemIndex = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.ContentItem.Key, type, contextInfo); parsedContent = !string.IsNullOrEmpty(formatString) ? string.Format(formatString, itemIndex) : itemIndex.ToString(); } else { var channel = await databaseManager.ChannelRepository.GetAsync(content.ChannelId); if (content.ContainsKey(type)) { if (!ListUtils.ContainsIgnoreCase(ColumnsManager.MetadataAttributes.Value, type)) { var relatedIdentities = databaseManager.TableStyleRepository.GetRelatedIdentities(channel); var tableName = databaseManager.ChannelRepository.GetTableName(pageInfo.Site, channel); var styleInfo = await databaseManager.TableStyleRepository.GetTableStyleAsync(tableName, type, relatedIdentities); //styleInfo.IsVisible = false 表示此字段不需要显示 styleInfo.TableStyleId = 0 不能排除,因为有可能是直接辅助表字段没有添加显示样式 var num = TranslateUtils.ToInt(no); var inputParser = new InputParserManager(parseManager.PathManager); parsedContent = await inputParser.GetContentByTableStyleAsync(content, separator, pageInfo.Site, styleInfo, formatString, num, contextInfo.Attributes, contextInfo.InnerHtml, false); parsedContent = InputTypeUtils.ParseString(styleInfo.InputType, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); } else { parsedContent = content.Get <string>(type); parsedContent = InputTypeUtils.ParseString(InputType.Text, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); } } } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = leftText + parsedContent + rightText; } } return(parsedContent); }
public async Task <ActionResult <GetResult> > Get([FromQuery] GetRequest request) { var relatedIdentities = ListUtils.GetIntList(request.RelatedIdentities); var style = await _tableStyleRepository.GetTableStyleAsync(request.TableName, request.AttributeName, relatedIdentities) ?? new Models.TableStyle { InputType = InputType.Text }; if (style.Items == null) { style.Items = new List <InputStyleItem>(); } var isRapid = true; var rapidValues = string.Empty; if (style.Items.Count == 0) { style.Items.Add(new InputStyleItem { Label = string.Empty, Value = string.Empty, Selected = false }); } else { var isSelected = false; var isNotEquals = false; var list = new List <string>(); foreach (var item in style.Items) { list.Add(item.Value); if (item.Selected) { isSelected = true; } if (item.Value != item.Label) { isNotEquals = true; } } isRapid = !isSelected && !isNotEquals; rapidValues = ListUtils.ToStringByReturnAndNewline(list); } var form = new SubmitRequest { TableName = style.TableName, AttributeName = style.AttributeName, RelatedIdentities = request.RelatedIdentities, IsRapid = isRapid, RapidValues = rapidValues, Taxis = style.Taxis, DisplayName = style.DisplayName, HelpText = style.HelpText, InputType = style.InputType, DefaultValue = style.DefaultValue, Horizontal = style.Horizontal, Items = style.Items, Height = style.Height, CustomizeLeft = style.CustomizeLeft, CustomizeRight = style.CustomizeRight }; return(new GetResult { InputTypes = InputTypeUtils.GetInputTypes(), Form = form }); }
internal static string Parse(string stlEntity, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; try { var entityName = StlParserUtility.GetNameFromEntity(stlEntity); var attributeName = entityName.Substring(5, entityName.Length - 6); if (StringUtils.EqualsIgnoreCase(PoweredBy, attributeName))//支持信息 { parsedContent = @"Powered by <a href=""http://www.siteserver.cn"" target=""_blank"">SiteServer CMS</a>"; } else if (StringUtils.EqualsIgnoreCase(RootUrl, attributeName))//系统根目录地址 { parsedContent = PageUtils.ParseConfigRootUrl("~"); if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = parsedContent.TrimEnd('/'); } } else if (StringUtils.EqualsIgnoreCase(ApiUrl, attributeName))//API地址 { parsedContent = pageInfo.ApiUrl.TrimEnd('/'); } else if (StringUtils.EqualsIgnoreCase(SiteId, attributeName))//ID { parsedContent = pageInfo.SiteId.ToString(); } else if (StringUtils.EqualsIgnoreCase(SiteName, attributeName))//名称 { parsedContent = pageInfo.SiteInfo.SiteName; } else if (StringUtils.EqualsIgnoreCase(SiteUrl, attributeName))//域名地址 { parsedContent = PageUtility.GetSiteUrl(pageInfo.SiteInfo, pageInfo.IsLocal).TrimEnd('/'); } else if (StringUtils.EqualsIgnoreCase(SiteDir, attributeName))//文件夹 { parsedContent = pageInfo.SiteInfo.SiteDir; } else if (StringUtils.EqualsIgnoreCase(CurrentUrl, attributeName))//当前页地址 { parsedContent = StlParserUtility.GetStlCurrentUrl(pageInfo.SiteInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo, pageInfo.TemplateInfo.TemplateType, pageInfo.TemplateInfo.Id, pageInfo.IsLocal); } else if (StringUtils.EqualsIgnoreCase(ChannelUrl, attributeName))//栏目页地址 { parsedContent = PageUtility.GetChannelUrl(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId), pageInfo.IsLocal); } //else if (StringUtils.EqualsIgnoreCase(HomeUrl, attributeName))//用户中心地址 //{ // parsedContent = pageInfo.HomeUrl.TrimEnd('/'); //} //else if (StringUtils.EqualsIgnoreCase(attributeName, LoginUrl)) //{ // var returnUrl = StlUtility.GetStlCurrentUrl(pageInfo.SiteInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo, pageInfo.TemplateInfo.TemplateType, pageInfo.TemplateInfo.TemplateId); // parsedContent = HomeUtils.GetLoginUrl(pageInfo.HomeUrl, returnUrl); //} //else if (StringUtils.EqualsIgnoreCase(attributeName, LogoutUrl)) //{ // var returnUrl = StlUtility.GetStlCurrentUrl(pageInfo.SiteInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo, pageInfo.TemplateInfo.TemplateType, pageInfo.TemplateInfo.TemplateId); // parsedContent = HomeUtils.GetLogoutUrl(pageInfo.HomeUrl, returnUrl); //} //else if (StringUtils.EqualsIgnoreCase(attributeName, RegisterUrl)) //{ // var returnUrl = StlUtility.GetStlCurrentUrl(pageInfo.SiteInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo, pageInfo.TemplateInfo.TemplateType, pageInfo.TemplateInfo.TemplateId); // parsedContent = HomeUtils.GetRegisterUrl(pageInfo.HomeUrl, returnUrl); //} else if (StringUtils.StartsWithIgnoreCase(attributeName, "TableFor"))// { if (StringUtils.EqualsIgnoreCase(attributeName, "TableForContent")) { parsedContent = pageInfo.SiteInfo.TableName; } } else if (StringUtils.StartsWithIgnoreCase(attributeName, "Site"))// { parsedContent = pageInfo.SiteInfo.Additional.GetString(attributeName.Substring(4)); } else { if (pageInfo.SiteInfo.Additional.ContainsKey(attributeName)) { parsedContent = pageInfo.SiteInfo.Additional.GetString(attributeName); if (!string.IsNullOrEmpty(parsedContent)) { var styleInfo = TableStyleManager.GetTableStyleInfo(DataProvider.SiteDao.TableName, attributeName, RelatedIdentities.GetRelatedIdentities(pageInfo.SiteId, pageInfo.SiteId)); // 如果 styleInfo.TableStyleId <= 0,表示此字段已经被删除了,不需要再显示值了 ekun008 if (styleInfo.Id > 0) { parsedContent = InputTypeUtils.EqualsAny(styleInfo.InputType, InputType.Image, InputType.File) ? PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal) : InputParserUtility.GetContentByTableStyle(parsedContent, string.Empty, pageInfo.SiteInfo, styleInfo, string.Empty, null, string.Empty, true); } else { // 如果字段已经被删除或不再显示了,则此字段的值为空。有时虚拟字段值不会清空 parsedContent = string.Empty; } } } } } catch { // ignored } return(parsedContent); }
public void ImportTableStyles(int siteId) { if (!DirectoryUtils.IsDirectoryExists(_directoryPath)) { return; } var importObject = new ImportObject(siteId, _adminName); var tableNameCollection = importObject.GetTableNameCache(); var styleDirectoryPaths = DirectoryUtils.GetDirectoryPaths(_directoryPath); foreach (var styleDirectoryPath in styleDirectoryPaths) { var tableName = PathUtils.GetDirectoryName(styleDirectoryPath, false); if (tableName == "siteserver_PublishmentSystem") { tableName = DataProvider.SiteDao.TableName; } if (!string.IsNullOrEmpty(tableNameCollection?[tableName])) { tableName = tableNameCollection[tableName]; } var attributeNamePaths = DirectoryUtils.GetDirectoryPaths(styleDirectoryPath); foreach (var attributeNamePath in attributeNamePaths) { var attributeName = PathUtils.GetDirectoryName(attributeNamePath, false); 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, nameof(TableStyleInfo.Taxis)), 0); var displayName = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.DisplayName)); var helpText = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.HelpText)); var isVisibleInList = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.IsVisibleInList))); var inputType = InputTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.InputType))); var defaultValue = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.DefaultValue)); var isHorizontal = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.IsHorizontal))); var extendValues = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyleInfo.ExtendValues)); var orderString = AtomUtility.GetDcElementContent(feed.AdditionalElements, "OrderString"); var relatedIdentity = !string.IsNullOrEmpty(orderString) ? DataProvider.ChannelDao.GetId(siteId, orderString) : siteId; if (relatedIdentity <= 0 || TableStyleManager.IsExists(relatedIdentity, tableName, attributeName)) { continue; } var styleInfo = new TableStyleInfo(0, relatedIdentity, tableName, attributeName, taxis, displayName, helpText, isVisibleInList, inputType, defaultValue, isHorizontal, extendValues); var styleItems = new List <TableStyleItemInfo>(); foreach (AtomEntry entry in feed.Entries) { var itemTitle = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableStyleItemInfo.ItemTitle)); var itemValue = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableStyleItemInfo.ItemValue)); var isSelected = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableStyleItemInfo.IsSelected))); styleItems.Add(new TableStyleItemInfo(0, 0, itemTitle, itemValue, isSelected)); } if (styleItems.Count > 0) { styleInfo.StyleItems = styleItems; } DataProvider.TableStyleDao.Insert(styleInfo); } } } }
private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, 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) { if (string.IsNullOrEmpty(type)) { return(string.Empty); } var parsedContent = string.Empty; if (contextInfo.ContextType == EContextType.Each) { parsedContent = contextInfo.ItemContainer.EachItem.DataItem as string; return(parsedContent); } if (type.ToLower().Equals(TypeSiteName.ToLower())) { parsedContent = pageInfo.SiteInfo.SiteName; } else if (type.ToLower().Equals(TypeSiteUrl.ToLower())) { parsedContent = pageInfo.SiteInfo.Additional.WebUrl; } else if (type.ToLower().Equals(TypeDate.ToLower())) { if (!pageInfo.BodyCodes.ContainsKey("datestring.js")) { pageInfo.BodyCodes.Add("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(TypeDateOfTraditional.ToLower())) { if (!pageInfo.BodyCodes.ContainsKey("datestring")) { pageInfo.BodyCodes.Add("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.Parameters != null && pageInfo.Parameters.ContainsKey(type)) { pageInfo.Parameters.TryGetValue(type, out parsedContent); parsedContent = StringUtils.ParseString(InputType.Text, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); } else { if (pageInfo.SiteInfo.Additional.GetString(type) != null) { parsedContent = pageInfo.SiteInfo.Additional.GetString(type); if (!string.IsNullOrEmpty(parsedContent)) { var styleInfo = TableStyleManager.GetTableStyleInfo(DataProvider.SiteDao.TableName, type, RelatedIdentities.GetRelatedIdentities(pageInfo.SiteId, pageInfo.SiteId)); // 如果 styleInfo.TableStyleId <= 0,表示此字段已经被删除了,不需要再显示值了 ekun008 if (styleInfo.Id > 0) { if (isClearTags && InputTypeUtils.EqualsAny(styleInfo.InputType, InputType.Image, InputType.File)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } else { parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, separator, pageInfo.SiteInfo, styleInfo, formatString, contextInfo.Attributes, contextInfo.InnerXml, false); parsedContent = StringUtils.ParseString(styleInfo.InputType, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); } } else { // 如果字段已经被删除或不再显示了,则此字段的值为空。有时虚拟字段值不会清空 parsedContent = string.Empty; } } } } return(parsedContent); }
internal static async Task <string> ParseAsync(string stlEntity, IParseManager parseManager) { var databaseManager = parseManager.DatabaseManager; var pageInfo = parseManager.PageInfo; var contextInfo = parseManager.ContextInfo; var parsedContent = string.Empty; try { var entityName = StlParserUtility.GetNameFromEntity(stlEntity); var attributeName = entityName.Substring(5, entityName.Length - 6); if (StringUtils.EqualsIgnoreCase(PoweredBy, attributeName))//支持信息 { parsedContent = @$ "Powered by <a href=" "{CloudUtils.Www.Host}" " target=" "_blank" ">SS CMS</a>"; } else if (StringUtils.EqualsIgnoreCase(RootUrl, attributeName))//系统根目录地址 { parsedContent = parseManager.PathManager.ParseUrl("~"); if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = parsedContent.TrimEnd('/'); } } else if (StringUtils.EqualsIgnoreCase(ApiUrl, attributeName))//API地址 { parsedContent = parseManager.PathManager.GetRootUrl(); } else if (StringUtils.EqualsIgnoreCase(SiteId, attributeName))//ID { parsedContent = pageInfo.SiteId.ToString(); } else if (StringUtils.EqualsIgnoreCase(SiteName, attributeName))//名称 { parsedContent = pageInfo.Site.SiteName; } else if (StringUtils.EqualsIgnoreCase(SiteUrl, attributeName))//域名地址 { parsedContent = (await parseManager.PathManager.GetSiteUrlAsync(pageInfo.Site, pageInfo.IsLocal)).TrimEnd('/'); } else if (StringUtils.EqualsIgnoreCase(SiteDir, attributeName))//文件夹 { parsedContent = pageInfo.Site.SiteDir; } else if (StringUtils.EqualsIgnoreCase(CurrentUrl, attributeName))//当前页地址 { var contentInfo = await parseManager.GetContentAsync(); parsedContent = await StlParserUtility.GetStlCurrentUrlAsync(parseManager, pageInfo.Site, contextInfo.ChannelId, contextInfo.ContentId, contentInfo, pageInfo.Template.TemplateType, pageInfo.Template.Id, pageInfo.IsLocal); } else if (StringUtils.EqualsIgnoreCase(ChannelUrl, attributeName))//栏目页地址 { parsedContent = await parseManager.PathManager.GetChannelUrlAsync(pageInfo.Site, await databaseManager.ChannelRepository.GetAsync(contextInfo.ChannelId), pageInfo.IsLocal); } else if (StringUtils.EqualsIgnoreCase(HomeUrl, attributeName))//用户中心地址 { parsedContent = parseManager.PathManager.GetHomeUrl(string.Empty).TrimEnd('/'); } else if (StringUtils.EqualsIgnoreCase(LoginUrl, attributeName)) { var contentInfo = await parseManager.GetContentAsync(); var returnUrl = await StlParserUtility.GetStlCurrentUrlAsync(parseManager, pageInfo.Site, contextInfo.ChannelId, contextInfo.ContentId, contentInfo, pageInfo.Template.TemplateType, pageInfo.Template.Id, pageInfo.IsLocal); parsedContent = parseManager.PathManager.GetHomeUrl($"pages/login.html?returnUrl={PageUtils.UrlEncode(returnUrl)}"); } else if (StringUtils.EqualsIgnoreCase(LogoutUrl, attributeName)) { var contentInfo = await parseManager.GetContentAsync(); var returnUrl = await StlParserUtility.GetStlCurrentUrlAsync(parseManager, pageInfo.Site, contextInfo.ChannelId, contextInfo.ContentId, contentInfo, pageInfo.Template.TemplateType, pageInfo.Template.Id, pageInfo.IsLocal); parsedContent = parseManager.PathManager.GetHomeUrl($"pages/logout.html?returnUrl={PageUtils.UrlEncode(returnUrl)}"); } else if (StringUtils.EqualsIgnoreCase(RegisterUrl, attributeName)) { var contentInfo = await parseManager.GetContentAsync(); var returnUrl = await StlParserUtility.GetStlCurrentUrlAsync(parseManager, pageInfo.Site, contextInfo.ChannelId, contextInfo.ContentId, contentInfo, pageInfo.Template.TemplateType, pageInfo.Template.Id, pageInfo.IsLocal); parsedContent = parseManager.PathManager.GetHomeUrl($"pages/register.html?returnUrl={PageUtils.UrlEncode(returnUrl)}"); } else if (StringUtils.StartsWithIgnoreCase(attributeName, "TableFor"))// { if (StringUtils.EqualsIgnoreCase(attributeName, "TableForContent")) { parsedContent = pageInfo.Site.TableName; } } else if (StringUtils.StartsWithIgnoreCase(attributeName, "Site"))// { parsedContent = pageInfo.Site.Get <string>(attributeName.Substring(4)); } else if (pageInfo.Parameters != null && pageInfo.Parameters.ContainsKey(attributeName)) { pageInfo.Parameters.TryGetValue(attributeName, out parsedContent); } else { if (pageInfo.Site.ContainsKey(attributeName)) { parsedContent = pageInfo.Site.Get <string>(attributeName); if (!string.IsNullOrEmpty(parsedContent)) { var styleInfo = await databaseManager.TableStyleRepository.GetTableStyleAsync(databaseManager.SiteRepository.TableName, attributeName, databaseManager.TableStyleRepository.GetRelatedIdentities(pageInfo.SiteId)); if (styleInfo.Id > 0) { var inputParser = new InputParserManager(parseManager.PathManager); parsedContent = InputTypeUtils.EqualsAny(styleInfo.InputType, InputType.Image, InputType.File) ? await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, parsedContent, pageInfo.IsLocal) : await inputParser.GetContentByTableStyleAsync(parsedContent, string.Empty, pageInfo.Site, styleInfo, string.Empty, null, string.Empty, true); } else { // 如果字段已经被删除或不再显示了,则此字段的值为空。有时虚拟字段值不会清空 parsedContent = string.Empty; } } } } } catch { // ignored } return(parsedContent); }