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 void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId", "channelId", "ReturnUrl"); _channelId = AuthRequest.GetQueryInt("channelId"); ReturnUrl = StringUtils.ValueFromUrl(PageUtils.FilterSqlAndXss(AuthRequest.GetQueryString("ReturnUrl"))); //if (!base.HasChannelPermissions(this.channelId, AppManager.CMS.Permission.Channel.ChannelAdd)) //{ // PageUtils.RedirectToErrorPage("您没有添加栏目的权限!"); // return; //} var parentNodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); if (parentNodeInfo.Additional.IsChannelAddable == false) { PageUtils.RedirectToErrorPage("此栏目不能添加子栏目!"); return; } CacAttributes.SiteInfo = SiteInfo; CacAttributes.ChannelId = _channelId; if (!IsPostBack) { ChannelManager.AddListItems(DdlParentChannelId.Items, SiteInfo, true, true, AuthRequest.AdminPermissions); ControlUtils.SelectSingleItem(DdlParentChannelId, _channelId.ToString()); DdlContentModelPluginId.Items.Add(new ListItem("<默认>", string.Empty)); var contentTables = PluginContentManager.GetContentModelPlugins(); foreach (var contentTable in contentTables) { DdlContentModelPluginId.Items.Add(new ListItem(contentTable.Title, contentTable.Id)); } ControlUtils.SelectSingleItem(DdlContentModelPluginId, parentNodeInfo.ContentModelPluginId); var plugins = PluginContentManager.GetAllContentRelatedPlugins(false); if (plugins.Count > 0) { foreach (var pluginMetadata in plugins) { CblContentRelatedPluginIds.Items.Add(new ListItem(pluginMetadata.Title, pluginMetadata.Id)); } } else { PhContentRelatedPluginIds.Visible = false; } CacAttributes.Attributes = new ExtendedAttributes(); TbImageUrl.Attributes.Add("onchange", GetShowImageScript("preview_NavigationPicPath", SiteInfo.Additional.WebUrl)); var showPopWinString = ModalFilePathRule.GetOpenWindowString(SiteId, _channelId, true, TbChannelFilePathRule.ClientID); BtnCreateChannelRule.Attributes.Add("onclick", showPopWinString); showPopWinString = ModalFilePathRule.GetOpenWindowString(SiteId, _channelId, false, TbContentFilePathRule.ClientID); BtnCreateContentRule.Attributes.Add("onclick", showPopWinString); showPopWinString = ModalSelectImage.GetOpenWindowString(SiteInfo, TbImageUrl.ClientID); BtnSelectImage.Attributes.Add("onclick", showPopWinString); showPopWinString = ModalUploadImage.GetOpenWindowString(SiteId, TbImageUrl.ClientID); BtnUploadImage.Attributes.Add("onclick", showPopWinString); ELinkTypeUtils.AddListItems(DdlLinkType); ETaxisTypeUtils.AddListItemsForChannelEdit(DdlTaxisType); ControlUtils.SelectSingleItem(DdlTaxisType, ETaxisTypeUtils.GetValue(ETaxisType.OrderByTaxisDesc)); CblNodeGroupNameCollection.DataSource = DataProvider.ChannelGroupDao.GetDataSource(SiteId); DdlChannelTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ChannelTemplate); DdlContentTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ContentTemplate); DataBind(); DdlChannelTemplateId.Items.Insert(0, new ListItem("<默认>", "0")); DdlChannelTemplateId.Items[0].Selected = true; DdlContentTemplateId.Items.Insert(0, new ListItem("<默认>", "0")); DdlContentTemplateId.Items[0].Selected = true; TbContent.SetParameters(SiteInfo, ChannelAttribute.Content, string.Empty); } else { CacAttributes.Attributes = new ExtendedAttributes(Request.Form); } }
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); }