public static Dictionary <string, object> SaveAttributes(SiteInfo siteInfo, List <TableStyleInfo> styleInfoList, NameValueCollection formCollection, List <string> dontAddAttributes) { var dict = new Dictionary <string, object>(); if (dontAddAttributes == null) { dontAddAttributes = new List <string>(); } foreach (var styleInfo in styleInfoList) { if (StringUtils.ContainsIgnoreCase(dontAddAttributes, styleInfo.AttributeName)) { continue; } //var theValue = GetValueByForm(styleInfo, siteInfo, formCollection); var theValue = formCollection[styleInfo.AttributeName] ?? string.Empty; var inputType = styleInfo.InputType; if (inputType == InputType.TextEditor) { theValue = ContentUtility.TextEditorContentEncode(siteInfo, theValue); theValue = UEditorUtils.TranslateToStlElement(theValue); } if (inputType != InputType.TextEditor && inputType != InputType.Image && inputType != InputType.File && inputType != InputType.Video && styleInfo.AttributeName != ContentAttribute.LinkUrl) { theValue = AttackUtils.FilterXss(theValue); } dict[styleInfo.AttributeName] = theValue; if (styleInfo.Additional.IsFormatString) { var formatString = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatStrong"]); var formatEm = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatEM"]); var formatU = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatU"]); var formatColor = formCollection[styleInfo.AttributeName + "_formatColor"]; var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor); dict[ContentAttribute.GetFormatStringAttributeName(styleInfo.AttributeName)] = theFormatString; } if (inputType == InputType.Image || inputType == InputType.File || inputType == InputType.Video) { var attributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName); dict[attributeName] = formCollection[attributeName]; } } return(dict); }
public static void SaveAttributes(IAttributes attributes, SiteInfo siteInfo, List <TableStyleInfo> styleInfoList, NameValueCollection formCollection, List <string> dontAddAttributesLowercase) { if (dontAddAttributesLowercase == null) { dontAddAttributesLowercase = new List <string>(); } foreach (var styleInfo in styleInfoList) { if (dontAddAttributesLowercase.Contains(styleInfo.AttributeName.ToLower())) { continue; } //var theValue = GetValueByForm(styleInfo, siteInfo, formCollection); var theValue = formCollection[styleInfo.AttributeName] ?? string.Empty; var inputType = styleInfo.InputType; if (inputType == InputType.TextEditor) { theValue = ContentUtility.TextEditorContentEncode(siteInfo, theValue); theValue = UEditorUtils.TranslateToStlElement(theValue); } if (inputType != InputType.TextEditor && inputType != InputType.Image && inputType != InputType.File && inputType != InputType.Video && styleInfo.AttributeName != ContentAttribute.LinkUrl) { theValue = AttackUtils.FilterSqlAndXss(theValue); } attributes.Set(styleInfo.AttributeName, theValue); //TranslateUtils.SetOrRemoveAttributeLowerCase(attributes, styleInfo.AttributeName, theValue); if (styleInfo.Additional.IsFormatString) { var formatString = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatStrong"]); var formatEm = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatEM"]); var formatU = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatU"]); var formatColor = formCollection[styleInfo.AttributeName + "_formatColor"]; var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor); attributes.Set(ContentAttribute.GetFormatStringAttributeName(styleInfo.AttributeName), theFormatString); //TranslateUtils.SetOrRemoveAttributeLowerCase(attributes, ContentAttribute.GetFormatStringAttributeName(styleInfo.AttributeName), theFormatString); } if (inputType == InputType.Image || inputType == InputType.File || inputType == InputType.Video) { var attributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName); attributes.Set(attributeName, formCollection[attributeName]); //TranslateUtils.SetOrRemoveAttributeLowerCase(attributes, attributeName, formCollection[attributeName]); } } }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } var isChanged = false; try { var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); if (!nodeInfo.IndexName.Equals(TbNodeIndexName.Text) && TbNodeIndexName.Text.Length != 0) { var nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId); if (nodeIndexNameList.IndexOf(TbNodeIndexName.Text) != -1) { FailMessage("栏目修改失败,栏目索引已存在!"); return; } } if (PhFilePath.Visible) { TbFilePath.Text = TbFilePath.Text.Trim(); if (!nodeInfo.FilePath.Equals(TbFilePath.Text) && TbFilePath.Text.Length != 0) { if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text)) { FailMessage("栏目页面路径不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(TbFilePath.Text)) { TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html"); } var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId); if (filePathArrayList.IndexOf(TbFilePath.Text) != -1) { FailMessage("栏目修改失败,栏目页面路径已存在!"); return; } } } var extendedAttributes = new ExtendedAttributes(); var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId); var styleInfoList = TableStyleManager.GetTableStyleInfoList(DataProvider.ChannelDao.TableName, relatedIdentities); BackgroundInputTypeParser.SaveAttributes(extendedAttributes, SiteInfo, styleInfoList, Request.Form, null); if (extendedAttributes.ToNameValueCollection().Count > 0) { nodeInfo.Additional.Load(extendedAttributes.ToNameValueCollection()); } nodeInfo.ChannelName = TbNodeName.Text; nodeInfo.IndexName = TbNodeIndexName.Text; if (PhFilePath.Visible) { nodeInfo.FilePath = TbFilePath.Text; } var list = new ArrayList(); foreach (ListItem item in CblNodeGroupNameCollection.Items) { if (item.Selected) { list.Add(item.Value); } } nodeInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list); nodeInfo.ImageUrl = TbImageUrl.Text; nodeInfo.Content = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]); if (TbKeywords.Visible) { nodeInfo.Keywords = TbKeywords.Text; } if (TbDescription.Visible) { nodeInfo.Description = TbDescription.Text; } if (PhLinkUrl.Visible) { nodeInfo.LinkUrl = TbLinkUrl.Text; } if (PhLinkType.Visible) { nodeInfo.LinkType = DdlLinkType.SelectedValue; } nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue)); if (PhChannelTemplateId.Visible) { nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0; } nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0; DataProvider.ChannelDao.Update(nodeInfo); AuthRequest.AddSiteLog(SiteId, _channelId, 0, "修改栏目", $"栏目:{nodeInfo.ChannelName}"); isChanged = true; } catch (Exception ex) { FailMessage(ex, $"栏目修改失败:{ex.Message}"); LogUtils.AddErrorLog(ex); } if (isChanged) { CreateManager.CreateChannel(SiteId, _channelId); if (string.IsNullOrEmpty(_returnUrl)) { LayerUtils.Close(Page); } else { LayerUtils.CloseAndRedirect(Page, _returnUrl); } } }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } ChannelInfo nodeInfo; try { nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); if (!nodeInfo.IndexName.Equals(TbNodeIndexName.Text) && TbNodeIndexName.Text.Length != 0) { var nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId); if (nodeIndexNameList.IndexOf(TbNodeIndexName.Text) != -1) { FailMessage("栏目属性修改失败,栏目索引已存在!"); return; } } if (nodeInfo.ContentModelPluginId != DdlContentModelPluginId.SelectedValue) { nodeInfo.ContentModelPluginId = DdlContentModelPluginId.SelectedValue; nodeInfo.ContentNum = DataProvider.ContentDao.GetCount(ChannelManager.GetTableName(SiteInfo, nodeInfo.ContentModelPluginId), nodeInfo.Id); } nodeInfo.ContentRelatedPluginIds = ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds); TbFilePath.Text = TbFilePath.Text.Trim(); if (!nodeInfo.FilePath.Equals(TbFilePath.Text) && TbFilePath.Text.Length != 0) { if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text)) { FailMessage("栏目页面路径不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(TbFilePath.Text)) { TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html"); } var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId); if (filePathArrayList.IndexOf(TbFilePath.Text) != -1) { FailMessage("栏目修改失败,栏目页面路径已存在!"); return; } } if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text)) { var filePathRule = TbChannelFilePathRule.Text.Replace("|", string.Empty); if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule)) { FailMessage("栏目页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(filePathRule)) { FailMessage("栏目页面命名规则必须包含生成文件的后缀!"); return; } } if (!string.IsNullOrEmpty(TbContentFilePathRule.Text)) { var filePathRule = TbContentFilePathRule.Text.Replace("|", string.Empty); if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule)) { FailMessage("内容页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(filePathRule)) { FailMessage("内容页面命名规则必须包含生成文件的后缀!"); return; } } var extendedAttributes = new ExtendedAttributes(); var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId); var styleInfoList = TableStyleManager.GetTableStyleInfoList(DataProvider.ChannelDao.TableName, relatedIdentities); BackgroundInputTypeParser.SaveAttributes(extendedAttributes, SiteInfo, styleInfoList, Request.Form, null); var attributes = extendedAttributes.ToNameValueCollection(); foreach (string key in attributes) { nodeInfo.Additional.Set(key, attributes[key]); } nodeInfo.ChannelName = TbNodeName.Text; nodeInfo.IndexName = TbNodeIndexName.Text; nodeInfo.FilePath = TbFilePath.Text; nodeInfo.ChannelFilePathRule = TbChannelFilePathRule.Text; nodeInfo.ContentFilePathRule = TbContentFilePathRule.Text; var list = new ArrayList(); foreach (ListItem item in CblNodeGroupNameCollection.Items) { if (item.Selected) { list.Add(item.Value); } } nodeInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list); nodeInfo.ImageUrl = TbImageUrl.Text; nodeInfo.Content = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]); nodeInfo.Keywords = TbKeywords.Text; nodeInfo.Description = TbDescription.Text; nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(RblIsChannelAddable.SelectedValue); nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(RblIsContentAddable.SelectedValue); nodeInfo.LinkUrl = TbLinkUrl.Text; nodeInfo.LinkType = DdlLinkType.SelectedValue; nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue)); nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0; nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0; DataProvider.ChannelDao.Update(nodeInfo); } catch (Exception ex) { FailMessage(ex, $"栏目修改失败:{ex.Message}"); LogUtils.AddSystemErrorLog(ex); return; } CreateManager.CreateChannel(SiteId, nodeInfo.Id); Body.AddSiteLog(SiteId, "修改栏目", $"栏目:{TbNodeName.Text}"); SuccessMessage("栏目修改成功!"); PageUtils.Redirect(ReturnUrl); }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } ChannelInfo channelInfo; try { var channelName = TbNodeName.Text; var indexName = TbNodeIndexName.Text; var filePath = TbFilePath.Text; var channelFilePathRule = TbChannelFilePathRule.Text; var contentFilePathRule = TbContentFilePathRule.Text; var contentModelPluginId = DdlContentModelPluginId.SelectedValue; var contentRelatedPluginIds = ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds); var groupNameCollection = TranslateUtils.ObjectCollectionToString(ControlUtils.GetSelectedListControlValueStringList(CblNodeGroupNameCollection)); var imageUrl = TbImageUrl.Text; var content = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]); var keywords = TbKeywords.Text; var description = TbDescription.Text; var isChannelAddable = TranslateUtils.ToBool(RblIsChannelAddable.SelectedValue); var isContentAddable = TranslateUtils.ToBool(RblIsContentAddable.SelectedValue); var linkUrl = TbLinkUrl.Text; var linkType = DdlLinkType.SelectedValue; var defaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue)); var channelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0; var contentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0; channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); if (!channelInfo.IndexName.Equals(indexName) && !string.IsNullOrEmpty(indexName)) { var indexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId); if (indexNameList.IndexOf(indexName) != -1) { FailMessage("栏目属性修改失败,栏目索引已存在!"); return; } } if (channelInfo.ContentModelPluginId != contentModelPluginId) { channelInfo.ContentModelPluginId = contentModelPluginId; } channelInfo.ContentRelatedPluginIds = contentRelatedPluginIds; filePath = filePath.Trim(); if (!channelInfo.FilePath.Equals(filePath) && !string.IsNullOrEmpty(filePath)) { if (!DirectoryUtils.IsDirectoryNameCompliant(filePath)) { FailMessage("栏目页面路径不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(filePath)) { filePath = PageUtils.Combine(filePath, "index.html"); } var filePathList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId); if (filePathList.IndexOf(filePath) != -1) { FailMessage("栏目修改失败,栏目页面路径已存在!"); return; } } if (!string.IsNullOrEmpty(channelFilePathRule)) { var filePathRule = channelFilePathRule.Replace("|", string.Empty); if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule)) { FailMessage("栏目页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(filePathRule)) { FailMessage("栏目页面命名规则必须包含生成文件的后缀!"); return; } } if (!string.IsNullOrEmpty(contentFilePathRule)) { var filePathRule = contentFilePathRule.Replace("|", string.Empty); if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule)) { FailMessage("内容页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(filePathRule)) { FailMessage("内容页面命名规则必须包含生成文件的后缀!"); return; } } var styleInfoList = TableStyleManager.GetChannelStyleInfoList(channelInfo); var extendedAttributes = BackgroundInputTypeParser.SaveAttributes(SiteInfo, styleInfoList, Request.Form, null); channelInfo.Additional.Load(extendedAttributes); channelInfo.ChannelName = channelName; channelInfo.IndexName = indexName; channelInfo.FilePath = filePath; channelInfo.ChannelFilePathRule = channelFilePathRule; channelInfo.ContentFilePathRule = contentFilePathRule; channelInfo.GroupNameCollection = groupNameCollection; channelInfo.ImageUrl = imageUrl; channelInfo.Content = content; channelInfo.Keywords = keywords; channelInfo.Description = description; channelInfo.Additional.IsChannelAddable = isChannelAddable; channelInfo.Additional.IsContentAddable = isContentAddable; channelInfo.LinkUrl = linkUrl; channelInfo.LinkType = linkType; channelInfo.Additional.DefaultTaxisType = defaultTaxisType; channelInfo.ChannelTemplateId = channelTemplateId; channelInfo.ContentTemplateId = contentTemplateId; DataProvider.ChannelDao.Update(channelInfo); } catch (Exception ex) { FailMessage(ex, $"栏目修改失败:{ex.Message}"); LogUtils.AddErrorLog(ex); return; } CreateManager.CreateChannel(SiteId, channelInfo.Id); AuthRequest.AddSiteLog(SiteId, "修改栏目", $"栏目:{TbNodeName.Text}"); SuccessMessage("栏目修改成功!"); PageUtils.Redirect(ReturnUrl); }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } int insertChannelId; try { var channelId = AuthRequest.GetQueryInt("ChannelId"); var nodeInfo = new ChannelInfo { ParentId = channelId, ContentModelPluginId = DdlContentModelPluginId.SelectedValue, ContentRelatedPluginIds = ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds) }; if (TbNodeIndexName.Text.Length != 0) { var nodeIndexNameArrayList = DataProvider.ChannelDao.GetIndexNameList(SiteId); if (nodeIndexNameArrayList.IndexOf(TbNodeIndexName.Text) != -1) { FailMessage("栏目添加失败,栏目索引已存在!"); return; } } if (TbFilePath.Text.Length != 0) { if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text)) { FailMessage("栏目页面路径不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(TbFilePath.Text)) { TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html"); } var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId); if (filePathArrayList.IndexOf(TbFilePath.Text) != -1) { FailMessage("栏目添加失败,栏目页面路径已存在!"); return; } } if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text)) { if (!DirectoryUtils.IsDirectoryNameCompliant(TbChannelFilePathRule.Text)) { FailMessage("栏目页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(TbChannelFilePathRule.Text)) { FailMessage("栏目页面命名规则必须包含生成文件的后缀!"); return; } } if (!string.IsNullOrEmpty(TbContentFilePathRule.Text)) { if (!DirectoryUtils.IsDirectoryNameCompliant(TbContentFilePathRule.Text)) { FailMessage("内容页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(TbContentFilePathRule.Text)) { FailMessage("内容页面命名规则必须包含生成文件的后缀!"); return; } } var extendedAttributes = new ExtendedAttributes(); var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId); var styleInfoList = TableStyleManager.GetTableStyleInfoList(DataProvider.ChannelDao.TableName, relatedIdentities); BackgroundInputTypeParser.SaveAttributes(extendedAttributes, SiteInfo, styleInfoList, Request.Form, null); var attributes = extendedAttributes.ToNameValueCollection(); nodeInfo.Additional.Load(attributes); //foreach (string key in attributes) //{ // nodeInfo.Additional.SetExtendedAttribute(key, attributes[key]); //} nodeInfo.ChannelName = TbNodeName.Text; nodeInfo.IndexName = TbNodeIndexName.Text; nodeInfo.FilePath = TbFilePath.Text; nodeInfo.ChannelFilePathRule = TbChannelFilePathRule.Text; nodeInfo.ContentFilePathRule = TbContentFilePathRule.Text; var list = new ArrayList(); foreach (ListItem item in CblNodeGroupNameCollection.Items) { if (item.Selected) { list.Add(item.Value); } } nodeInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list); nodeInfo.ImageUrl = TbImageUrl.Text; nodeInfo.Content = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]); nodeInfo.Keywords = TbKeywords.Text; nodeInfo.Description = TbDescription.Text; nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(RblIsChannelAddable.SelectedValue); nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(RblIsContentAddable.SelectedValue); nodeInfo.LinkUrl = TbLinkUrl.Text; nodeInfo.LinkType = DdlLinkType.SelectedValue; nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue)); nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0; nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0; nodeInfo.AddDate = DateTime.Now; insertChannelId = DataProvider.ChannelDao.Insert(nodeInfo); //栏目选择投票样式后,内容 } catch (Exception ex) { LogUtils.AddErrorLog(ex); FailMessage(ex, $"栏目添加失败:{ex.Message}"); return; } CreateManager.CreateChannel(SiteId, insertChannelId); AuthRequest.AddSiteLog(SiteId, "添加栏目", $"栏目:{TbNodeName.Text}"); SuccessMessage("栏目添加成功!"); AddWaitAndRedirectScript(ReturnUrl); }