public static bool IsCreatable(SiteInfo siteInfo, ChannelInfo channelInfo) { if (siteInfo == null || channelInfo == null) { return(false); } if (!channelInfo.Additional.IsChannelCreatable || !string.IsNullOrEmpty(channelInfo.LinkUrl)) { return(false); } var isCreatable = false; var linkType = ELinkTypeUtils.GetEnumType(channelInfo.LinkType); if (linkType == ELinkType.None) { isCreatable = true; } else if (linkType == ELinkType.NoLinkIfContentNotExists) { var count = ContentManager.GetCount(siteInfo, channelInfo, true); isCreatable = count != 0; } else if (linkType == ELinkType.LinkToOnlyOneContent) { var count = ContentManager.GetCount(siteInfo, channelInfo, true); isCreatable = count != 1; } else if (linkType == ELinkType.NoLinkIfContentNotExistsAndLinkToOnlyOneContent) { var count = ContentManager.GetCount(siteInfo, channelInfo, true); if (count != 0 && count != 1) { isCreatable = true; } } else if (linkType == ELinkType.LinkToFirstContent) { var count = ContentManager.GetCount(siteInfo, channelInfo, true); isCreatable = count < 1; } else if (linkType == ELinkType.NoLinkIfChannelNotExists) { isCreatable = channelInfo.ChildrenCount != 0; } else if (linkType == ELinkType.LinkToLastAddChannel) { isCreatable = channelInfo.ChildrenCount <= 0; } else if (linkType == ELinkType.LinkToFirstChannel) { isCreatable = channelInfo.ChildrenCount <= 0; } return(isCreatable); }
private void ImportNodeInfo(NodeInfo nodeInfo, ScopedElementCollection additionalElements, int parentId, IList nodeIndexNameArrayList) { nodeInfo.NodeName = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.NodeName); nodeInfo.NodeType = ENodeTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.NodeType)); nodeInfo.PublishmentSystemId = _publishmentSystemInfo.PublishmentSystemId; var contentModelId = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.ContentModelId); if (!string.IsNullOrEmpty(contentModelId)) { nodeInfo.ContentModelId = contentModelId; } nodeInfo.ParentId = parentId; var nodeIndexName = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.NodeIndexName); if (!string.IsNullOrEmpty(nodeIndexName) && nodeIndexNameArrayList.IndexOf(nodeIndexName) == -1) { nodeInfo.NodeIndexName = nodeIndexName; nodeIndexNameArrayList.Add(nodeIndexName); } nodeInfo.NodeGroupNameCollection = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.NodeGroupNameCollection); nodeInfo.AddDate = DateTime.Now; nodeInfo.ImageUrl = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.ImageUrl); nodeInfo.Content = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.Content)); nodeInfo.FilePath = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.FilePath); nodeInfo.ChannelFilePathRule = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.ChannelFilePathRule); nodeInfo.ContentFilePathRule = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.ContentFilePathRule); nodeInfo.LinkUrl = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.LinkUrl); nodeInfo.LinkType = ELinkTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.LinkType)); var channelTemplateName = AtomUtility.GetDcElementContent(additionalElements, ChannelTemplateName); if (!string.IsNullOrEmpty(channelTemplateName)) { nodeInfo.ChannelTemplateId = TemplateManager.GetTemplateIDByTemplateName(_publishmentSystemInfo.PublishmentSystemId, ETemplateType.ChannelTemplate, channelTemplateName); } var contentTemplateName = AtomUtility.GetDcElementContent(additionalElements, ContentTemplateName); if (!string.IsNullOrEmpty(contentTemplateName)) { nodeInfo.ContentTemplateId = TemplateManager.GetTemplateIDByTemplateName(_publishmentSystemInfo.PublishmentSystemId, ETemplateType.ContentTemplate, contentTemplateName); } nodeInfo.Keywords = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.Keywords); nodeInfo.Description = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.Description); nodeInfo.SetExtendValues(AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.ExtendValues)); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId", "channelId"); _channelId = AuthRequest.GetQueryInt("channelId"); if (IsPostBack) { return; } var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); var linkType = ELinkTypeUtils.GetEnumType(channelInfo.LinkType); if (channelInfo.ParentId == 0 || linkType == ELinkType.LinkToFirstChannel || linkType == ELinkType.LinkToFirstContent || linkType == ELinkType.LinkToLastAddChannel || linkType == ELinkType.NoLink) { PhFilePath.Visible = false; } 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); TbFilePath.Text = string.IsNullOrEmpty(channelInfo.FilePath) ? PageUtility.GetInputChannelUrl(SiteInfo, channelInfo, false) : channelInfo.FilePath; TbChannelFilePathRule.Text = string.IsNullOrEmpty(channelInfo.ChannelFilePathRule) ? PathUtility.GetChannelFilePathRule(SiteInfo, _channelId) : channelInfo.ChannelFilePathRule; TbContentFilePathRule.Text = string.IsNullOrEmpty(channelInfo.ContentFilePathRule) ? PathUtility.GetContentFilePathRule(SiteInfo, _channelId) : channelInfo.ContentFilePathRule; }
//得到栏目经过计算后的连接地址 public static string GetChannelUrl(SiteInfo siteInfo, ChannelInfo channelInfo, bool isLocal) { if (channelInfo == null) { return(string.Empty); } if (isLocal) { return(ApiRoutePreview.GetChannelUrl(siteInfo.Id, channelInfo.Id)); } var url = string.Empty; if (channelInfo.ParentId == 0) { url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false); } else { var linkType = ELinkTypeUtils.GetEnumType(channelInfo.LinkType); if (linkType == ELinkType.None) { url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false); } else if (linkType == ELinkType.NoLink) { url = PageUtils.UnclickedUrl; } else { if (linkType == ELinkType.NoLinkIfContentNotExists) { var count = ContentManager.GetCount(siteInfo, channelInfo, true); url = count == 0 ? PageUtils.UnclickedUrl : GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false); } else if (linkType == ELinkType.LinkToOnlyOneContent) { var count = ContentManager.GetCount(siteInfo, channelInfo, true); if (count == 1) { var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var contentId = StlContentCache.GetContentId(tableName, channelInfo.Id, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(channelInfo.Additional.DefaultTaxisType))); url = GetContentUrl(siteInfo, channelInfo, contentId, false); } else { url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false); } } else if (linkType == ELinkType.NoLinkIfContentNotExistsAndLinkToOnlyOneContent) { var count = ContentManager.GetCount(siteInfo, channelInfo, true); if (count == 0) { url = PageUtils.UnclickedUrl; } else if (count == 1) { var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var contentId = StlContentCache.GetContentId(tableName, channelInfo.Id, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(channelInfo.Additional.DefaultTaxisType))); url = GetContentUrl(siteInfo, channelInfo, contentId, false); } else { url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false); } } else if (linkType == ELinkType.LinkToFirstContent) { var count = ContentManager.GetCount(siteInfo, channelInfo, true); if (count >= 1) { var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var contentId = StlContentCache.GetContentId(tableName, channelInfo.Id, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(channelInfo.Additional.DefaultTaxisType))); //var contentId = StlCacheManager.FirstContentId.GetValue(siteInfo, nodeInfo); url = GetContentUrl(siteInfo, channelInfo, contentId, false); } else { url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false); } } else if (linkType == ELinkType.NoLinkIfContentNotExistsAndLinkToFirstContent) { var count = ContentManager.GetCount(siteInfo, channelInfo, true); if (count >= 1) { var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var contentId = StlContentCache.GetContentId(tableName, channelInfo.Id, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(channelInfo.Additional.DefaultTaxisType))); //var contentId = StlCacheManager.FirstContentId.GetValue(siteInfo, nodeInfo); url = GetContentUrl(siteInfo, channelInfo, contentId, false); } else { url = PageUtils.UnclickedUrl; } } else if (linkType == ELinkType.NoLinkIfChannelNotExists) { url = channelInfo.ChildrenCount == 0 ? PageUtils.UnclickedUrl : GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false); } else if (linkType == ELinkType.LinkToLastAddChannel) { var lastAddChannelInfo = StlChannelCache.GetChannelInfoByLastAddDate(channelInfo.Id); url = lastAddChannelInfo != null?GetChannelUrl(siteInfo, lastAddChannelInfo, false) : GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false); } else if (linkType == ELinkType.LinkToFirstChannel) { var firstChannelInfo = StlChannelCache.GetChannelInfoByTaxis(channelInfo.Id); url = firstChannelInfo != null?GetChannelUrl(siteInfo, firstChannelInfo, false) : GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false); } else if (linkType == ELinkType.NoLinkIfChannelNotExistsAndLinkToLastAddChannel) { var lastAddChannelInfo = StlChannelCache.GetChannelInfoByLastAddDate(channelInfo.Id); url = lastAddChannelInfo != null?GetChannelUrl(siteInfo, lastAddChannelInfo, false) : PageUtils.UnclickedUrl; } else if (linkType == ELinkType.NoLinkIfChannelNotExistsAndLinkToFirstChannel) { var firstChannelInfo = StlChannelCache.GetChannelInfoByTaxis(channelInfo.Id); url = firstChannelInfo != null?GetChannelUrl(siteInfo, firstChannelInfo, false) : PageUtils.UnclickedUrl; } } } return(RemoveDefaultFileName(siteInfo, url)); }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { int insertNodeId; try { var nodeId = Body.GetQueryInt("NodeID"); var nodeInfo = new NodeInfo { ParentId = nodeId, ContentModelId = ContentModelID.SelectedValue }; if (NodeIndexName.Text.Length != 0) { var nodeIndexNameArrayList = DataProvider.NodeDao.GetNodeIndexNameList(PublishmentSystemId); if (nodeIndexNameArrayList.IndexOf(NodeIndexName.Text) != -1) { FailMessage("栏目添加失败,栏目索引已存在!"); return; } } if (FilePath.Text.Length != 0) { if (!DirectoryUtils.IsDirectoryNameCompliant(FilePath.Text)) { FailMessage("栏目页面路径不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(FilePath.Text)) { FilePath.Text = PageUtils.Combine(FilePath.Text, "index.html"); } var filePathArrayList = DataProvider.NodeDao.GetAllFilePathByPublishmentSystemId(PublishmentSystemId); if (filePathArrayList.IndexOf(FilePath.Text) != -1) { FailMessage("栏目添加失败,栏目页面路径已存在!"); return; } } if (!string.IsNullOrEmpty(ChannelFilePathRule.Text)) { if (!DirectoryUtils.IsDirectoryNameCompliant(ChannelFilePathRule.Text)) { FailMessage("栏目页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(ChannelFilePathRule.Text)) { FailMessage("栏目页面命名规则必须包含生成文件的后缀!"); return; } } if (!string.IsNullOrEmpty(ContentFilePathRule.Text)) { if (!DirectoryUtils.IsDirectoryNameCompliant(ContentFilePathRule.Text)) { FailMessage("内容页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(ContentFilePathRule.Text)) { FailMessage("内容页面命名规则必须包含生成文件的后缀!"); return; } } var extendedAttributes = new ExtendedAttributes(); var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, _nodeId); BackgroundInputTypeParser.AddValuesToAttributes(ETableStyle.Channel, DataProvider.NodeDao.TableName, PublishmentSystemInfo, relatedIdentities, Request.Form, extendedAttributes.Attributes); var attributes = extendedAttributes.Attributes; foreach (string key in attributes) { nodeInfo.Additional.SetExtendedAttribute(key, attributes[key]); } nodeInfo.NodeName = NodeName.Text; nodeInfo.NodeIndexName = NodeIndexName.Text; nodeInfo.FilePath = FilePath.Text; nodeInfo.ChannelFilePathRule = ChannelFilePathRule.Text; nodeInfo.ContentFilePathRule = ContentFilePathRule.Text; var list = new ArrayList(); foreach (ListItem item in NodeGroupNameCollection.Items) { if (item.Selected) { list.Add(item.Value); } } nodeInfo.NodeGroupNameCollection = TranslateUtils.ObjectCollectionToString(list); nodeInfo.ImageUrl = NavigationPicPath.Text; nodeInfo.Content = StringUtility.TextEditorContentEncode(Request.Form[NodeAttribute.Content], PublishmentSystemInfo, PublishmentSystemInfo.Additional.IsSaveImageInTextEditor); nodeInfo.Keywords = Keywords.Text; nodeInfo.Description = Description.Text; nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(IsChannelAddable.SelectedValue); nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(IsContentAddable.SelectedValue); nodeInfo.LinkUrl = LinkURL.Text; nodeInfo.LinkType = ELinkTypeUtils.GetEnumType(LinkType.SelectedValue); nodeInfo.ChannelTemplateId = (ChannelTemplateID.Items.Count > 0) ? int.Parse(ChannelTemplateID.SelectedValue) : 0; nodeInfo.ContentTemplateId = (ContentTemplateID.Items.Count > 0) ? int.Parse(ContentTemplateID.SelectedValue) : 0; nodeInfo.AddDate = DateTime.Now; insertNodeId = DataProvider.NodeDao.InsertNodeInfo(nodeInfo); //栏目选择投票样式后,内容 } catch (Exception ex) { FailMessage(ex, $"栏目添加失败:{ex.Message}"); LogUtils.AddErrorLog(ex); return; } CreateManager.CreateChannel(PublishmentSystemId, insertNodeId); Body.AddSiteLog(PublishmentSystemId, "添加栏目", $"栏目:{NodeName.Text}"); SuccessMessage("栏目添加成功!"); AddWaitAndRedirectScript(_returnUrl); } }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { var isChanged = false; try { var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, _nodeId); if (NodeIndexNameRow.Visible) { if (!nodeInfo.NodeIndexName.Equals(NodeIndexName.Text) && NodeIndexName.Text.Length != 0) { var nodeIndexNameList = DataProvider.NodeDao.GetNodeIndexNameList(PublishmentSystemId); if (nodeIndexNameList.IndexOf(NodeIndexName.Text) != -1) { FailMessage("栏目修改失败,栏目索引已存在!"); return; } } } if (FilePathRow.Visible) { FilePath.Text = FilePath.Text.Trim(); if (!nodeInfo.FilePath.Equals(FilePath.Text) && FilePath.Text.Length != 0) { if (!DirectoryUtils.IsDirectoryNameCompliant(FilePath.Text)) { FailMessage("栏目页面路径不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(FilePath.Text)) { FilePath.Text = PageUtils.Combine(FilePath.Text, "index.html"); } var filePathArrayList = DataProvider.NodeDao.GetAllFilePathByPublishmentSystemId(PublishmentSystemId); if (filePathArrayList.IndexOf(FilePath.Text) != -1) { FailMessage("栏目修改失败,栏目页面路径已存在!"); return; } } } if (channelControl.Visible) { var extendedAttributes = new ExtendedAttributes(); var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, _nodeId); InputTypeParser.AddValuesToAttributes(ETableStyle.Channel, DataProvider.NodeDao.TableName, PublishmentSystemInfo, relatedIdentities, Request.Form, extendedAttributes.Attributes); if (extendedAttributes.Attributes.Count > 0) { nodeInfo.Additional.SetExtendedAttribute(extendedAttributes.Attributes); } } if (NodeNameRow.Visible) { nodeInfo.NodeName = NodeName.Text; } if (NodeIndexNameRow.Visible) { nodeInfo.NodeIndexName = NodeIndexName.Text; } if (FilePathRow.Visible) { nodeInfo.FilePath = FilePath.Text; } if (NodeGroupNameCollectionRow.Visible) { var list = new ArrayList(); foreach (ListItem item in NodeGroupNameCollection.Items) { if (item.Selected) { list.Add(item.Value); } } nodeInfo.NodeGroupNameCollection = TranslateUtils.ObjectCollectionToString(list); } if (ImageUrlRow.Visible) { nodeInfo.ImageUrl = tbImageUrl.Text; } if (ContentRow.Visible) { nodeInfo.Content = StringUtility.TextEditorContentEncode(Request.Form[NodeAttribute.Content], PublishmentSystemInfo, PublishmentSystemInfo.Additional.IsSaveImageInTextEditor); } if (Keywords.Visible) { nodeInfo.Keywords = Keywords.Text; } if (Description.Visible) { nodeInfo.Description = Description.Text; } if (LinkUrlRow.Visible) { nodeInfo.LinkUrl = LinkUrl.Text; } if (LinkTypeRow.Visible) { nodeInfo.LinkType = ELinkTypeUtils.GetEnumType(LinkType.SelectedValue); } if (ChannelTemplateIDRow.Visible) { nodeInfo.ChannelTemplateId = (ChannelTemplateID.Items.Count > 0) ? int.Parse(ChannelTemplateID.SelectedValue) : 0; } if (ContentTemplateIDRow.Visible) { nodeInfo.ContentTemplateId = (ContentTemplateID.Items.Count > 0) ? int.Parse(ContentTemplateID.SelectedValue) : 0; } DataProvider.NodeDao.UpdateNodeInfo(nodeInfo); Body.AddSiteLog(PublishmentSystemId, _nodeId, 0, "修改栏目", $"栏目:{nodeInfo.NodeName}"); isChanged = true; } catch (Exception ex) { FailMessage(ex, $"栏目修改失败:{ex.Message}"); LogUtils.AddErrorLog(ex); } if (isChanged) { CreateManager.CreateChannel(PublishmentSystemId, _nodeId); if (string.IsNullOrEmpty(_returnUrl)) { PageUtils.CloseModalPage(Page); } else { PageUtils.CloseModalPageAndRedirect(Page, _returnUrl); } } } }