public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId", "channelId"); var channelId = AuthRequest.GetQueryInt("channelId"); _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, channelId); _channelInfo = ChannelManager.GetChannelInfo(SiteId, channelId); _tableName = ChannelManager.GetTableName(SiteInfo, _channelInfo); _styleInfoList = TableStyleManager.GetTableStyleInfoList(_tableName, _relatedIdentities); _attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(ChannelManager.GetContentAttributesOfDisplay(SiteId, channelId)); _allStyleInfoList = ContentUtility.GetAllTableStyleInfoList(_styleInfoList); _pluginLinks = PluginContentManager.GetContentLinks(_channelInfo); _isEdit = TextUtility.IsEdit(SiteInfo, channelId, AuthRequest.AdminPermissions); if (_channelInfo.Additional.IsPreviewContents) { new Action(() => { DataProvider.ContentDao.DeletePreviewContents(SiteId, _tableName, _channelInfo); }).BeginInvoke(null, null); } if (!HasChannelPermissions(channelId, ConfigManager.ChannelPermissions.ContentView, ConfigManager.ChannelPermissions.ContentAdd, ConfigManager.ChannelPermissions.ContentEdit, ConfigManager.ChannelPermissions.ContentDelete, ConfigManager.ChannelPermissions.ContentTranslate)) { if (!AuthRequest.IsAdminLoggin) { PageUtils.RedirectToLoginPage(); return; } PageUtils.RedirectToErrorPage("您无此栏目的操作权限!"); return; } RptContents.ItemDataBound += RptContents_ItemDataBound; var allLowerAttributeNameList = TableMetadataManager.GetAllLowerAttributeNameListExcludeText(_tableName); var pagerParam = new PagerParam { ControlToPaginate = RptContents, TableName = _tableName, PageSize = SiteInfo.Additional.PageSize, Page = AuthRequest.GetQueryInt(Pager.QueryNamePage, 1), OrderSqlString = DataProvider.ContentDao.GetPagerOrderSqlString(_channelInfo), ReturnColumnNames = TranslateUtils.ObjectCollectionToString(allLowerAttributeNameList) }; var administratorName = AuthRequest.AdminPermissions.IsViewContentOnlySelf(SiteId, channelId) ? AuthRequest.AdminName : string.Empty; if (AuthRequest.IsQueryExists("searchType")) { pagerParam.WhereSqlString = DataProvider.ContentDao.GetPagerWhereSqlString(allLowerAttributeNameList, SiteId, channelId, AuthRequest.AdminPermissions.IsSystemAdministrator, new List <int> { channelId }, AuthRequest.GetQueryString("searchType"), AuthRequest.GetQueryString("keyword"), AuthRequest.GetQueryString("dateFrom"), string.Empty, false, ETriState.All, false, false, administratorName); pagerParam.TotalCount = DataProvider.DatabaseDao.GetPageTotalCount(_tableName, pagerParam.WhereSqlString); } else { pagerParam.WhereSqlString = DataProvider.ContentDao.GetPagerWhereSqlString(channelId, ETriState.All, administratorName); pagerParam.TotalCount = _channelInfo.ContentNum; } PgContents.Param = pagerParam; if (IsPostBack) { return; } LtlButtons.Text = WebUtils.GetContentCommands(AuthRequest.AdminPermissions, SiteInfo, _channelInfo, PageUrl); LtlMoreButtons.Text = WebUtils.GetContentMoreCommands(AuthRequest.AdminPermissions, SiteInfo, _channelInfo, PageUrl); PgContents.DataBind(); foreach (var styleInfo in _allStyleInfoList) { if (styleInfo.InputType == InputType.TextEditor) { continue; } var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName); DdlSearchType.Items.Add(listitem); } if (AuthRequest.IsQueryExists("searchType")) { TbDateFrom.Text = AuthRequest.GetQueryString("dateFrom"); ControlUtils.SelectSingleItem(DdlSearchType, AuthRequest.GetQueryString("searchType")); TbKeyword.Text = AuthRequest.GetQueryString("keyword"); if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("searchType")) || !string.IsNullOrEmpty(TbDateFrom.Text) || !string.IsNullOrEmpty(TbKeyword.Text)) { LtlButtons.Text += @" <script> $(document).ready(function() { $('#contentSearch').show(); }); </script> "; } } else { ControlUtils.SelectSingleItem(DdlSearchType, ContentAttribute.Title); } LtlColumnsHead.Text = TextUtility.GetColumnsHeadHtml(_styleInfoList, _attributesOfDisplay, SiteInfo); }
public IHttpActionResult Submit() { try { var request = new AuthenticatedRequest(); var downloadUrl = string.Empty; var siteId = request.GetPostInt("siteId"); var channelId = request.GetPostInt("channelId"); var channelContentIds = MinContentInfo.ParseMinContentInfoList(request.GetPostString("channelContentIds")); var exportType = request.GetPostString("exportType"); var isAllCheckedLevel = request.GetPostBool("isAllCheckedLevel"); var checkedLevelKeys = request.GetPostObject <List <int> >("checkedLevelKeys"); var isAllDate = request.GetPostBool("isAllDate"); var startDate = request.GetPostDateTime("startDate", DateTime.Now); var endDate = request.GetPostDateTime("endDate", DateTime.Now); var columnNames = request.GetPostObject <List <string> >("columnNames"); if (!request.IsAdminLoggin || !request.AdminPermissions.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ChannelEdit)) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } var adminId = channelInfo.Additional.IsSelfOnly ? request.AdminId : request.AdminPermissionsImpl.GetAdminId(siteId, channelId); var isAllContents = channelInfo.Additional.IsAllContents; var columns = ContentManager.GetContentColumns(siteInfo, channelInfo, true); var pluginIds = PluginContentManager.GetContentPluginIds(channelInfo); var pluginColumns = PluginContentManager.GetContentColumns(pluginIds); var contentInfoList = new List <ContentInfo>(); var calculatedContentInfoList = new List <ContentInfo>(); if (channelContentIds.Count == 0) { var ccIds = DataProvider.ContentDao.GetCacheChannelContentIdList(siteInfo, channelInfo, adminId, isAllContents, string.Empty, string.Empty); var count = ccIds.Count; var pages = Convert.ToInt32(Math.Ceiling((double)count / siteInfo.Additional.PageSize)); if (pages == 0) { pages = 1; } if (count > 0) { for (var page = 1; page <= pages; page++) { var offset = siteInfo.Additional.PageSize * (page - 1); var limit = siteInfo.Additional.PageSize; var pageCcIds = ccIds.Skip(offset).Take(limit).ToList(); var sequence = offset + 1; foreach (var channelContentId in pageCcIds) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelContentId.ChannelId, channelContentId.ContentId); if (contentInfo == null) { continue; } if (!isAllCheckedLevel) { var checkedLevel = contentInfo.CheckedLevel; if (contentInfo.IsChecked) { checkedLevel = siteInfo.Additional.CheckContentLevel; } if (!checkedLevelKeys.Contains(checkedLevel)) { continue; } } if (!isAllDate) { if (contentInfo.AddDate < startDate || contentInfo.AddDate > endDate) { continue; } } contentInfoList.Add(contentInfo); calculatedContentInfoList.Add(ContentManager.Calculate(sequence++, contentInfo, columns, pluginColumns)); } } } } else { var sequence = 1; foreach (var channelContentId in channelContentIds) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelContentId.ChannelId, channelContentId.Id); if (contentInfo == null) { continue; } if (!isAllCheckedLevel) { var checkedLevel = contentInfo.CheckedLevel; if (contentInfo.IsChecked) { checkedLevel = siteInfo.Additional.CheckContentLevel; } if (!checkedLevelKeys.Contains(checkedLevel)) { continue; } } if (!isAllDate) { if (contentInfo.AddDate < startDate || contentInfo.AddDate > endDate) { continue; } } contentInfoList.Add(contentInfo); calculatedContentInfoList.Add(ContentManager.Calculate(sequence++, contentInfo, columns, pluginColumns)); } } if (contentInfoList.Count > 0) { if (exportType == "zip") { var fileName = $"{channelInfo.ChannelName}.zip"; var filePath = PathUtils.GetTemporaryFilesPath(fileName); var exportObject = new ExportObject(siteId, request.AdminName); contentInfoList.Reverse(); if (exportObject.ExportContents(filePath, contentInfoList)) { downloadUrl = PageUtils.GetTemporaryFilesUrl(fileName); } } else if (exportType == "excel") { var fileName = $"{channelInfo.ChannelName}.csv"; var filePath = PathUtils.GetTemporaryFilesPath(fileName); ExcelObject.CreateExcelFileForContents(filePath, siteInfo, channelInfo, calculatedContentInfoList, columnNames); downloadUrl = PageUtils.GetTemporaryFilesUrl(fileName); } } return(Ok(new { Value = downloadUrl, IsSuccess = !string.IsNullOrEmpty(downloadUrl) })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
public IHttpActionResult List() { try { var request = new AuthenticatedRequest(); var siteId = request.GetQueryInt("siteId"); var channelId = request.GetQueryInt("channelId"); var page = request.GetQueryInt("page"); if (!request.IsUserLoggin || !request.UserPermissionsImpl.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentView)) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } var adminId = request.AdminPermissionsImpl.GetAdminId(siteId, channelId); var columns = ContentManager.GetContentColumns(siteInfo, channelInfo, false); var pluginIds = PluginContentManager.GetContentPluginIds(channelInfo); var pluginColumns = PluginContentManager.GetContentColumns(pluginIds); var pageContentInfoList = new List <ContentInfo>(); var ccIds = DataProvider.ContentDao.GetCacheChannelContentIdList(siteInfo, channelInfo, adminId, true, string.Empty, string.Empty); var count = ccIds.Count; var pages = Convert.ToInt32(Math.Ceiling((double)count / siteInfo.Additional.PageSize)); if (pages == 0) { pages = 1; } if (count > 0) { var offset = siteInfo.Additional.PageSize * (page - 1); var limit = siteInfo.Additional.PageSize; var pageCcIds = ccIds.Skip(offset).Take(limit).ToList(); var sequence = offset + 1; foreach (var channelContentId in pageCcIds) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelContentId.ChannelId, channelContentId.ContentId); if (contentInfo == null) { continue; } var channelName = ChannelManager.GetChannelNameNavigation(siteId, channelId, channelContentId.ChannelId); contentInfo.Set("ChannelName", channelName); pageContentInfoList.Add(ContentManager.Calculate(sequence++, contentInfo, columns, pluginColumns)); } } var permissions = new { IsAdd = request.UserPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentAdd) && channelInfo.Additional.IsContentAddable, IsDelete = request.UserPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentDelete), IsEdit = request.UserPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentEdit), IsTranslate = request.UserPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentTranslate), IsCheck = request.UserPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentCheck), IsCreate = request.UserPermissionsImpl.HasSitePermissions(siteInfo.Id, ConfigManager.SitePermissions.CreateContents) || request.UserPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.CreatePage), IsChannelEdit = request.UserPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ChannelEdit) }; return(Ok(new { Value = pageContentInfoList, Count = count, Pages = pages, Permissions = permissions, Columns = columns })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId"); _channelId = AuthRequest.IsQueryExists("channelId") ? AuthRequest.GetQueryInt("channelId") : SiteId; _isCheckOnly = AuthRequest.GetQueryBool("isCheckOnly"); _isTrashOnly = AuthRequest.GetQueryBool("isTrashOnly"); _isWritingOnly = AuthRequest.GetQueryBool("isWritingOnly"); _isAdminOnly = AuthRequest.GetQueryBool("isAdminOnly"); _channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); var tableName = ChannelManager.GetTableName(SiteInfo, _channelInfo); _styleInfoList = TableStyleManager.GetContentStyleInfoList(SiteInfo, _channelInfo); _attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(ChannelManager.GetContentAttributesOfDisplay(SiteId, _channelId)); _allStyleInfoList = ContentUtility.GetAllTableStyleInfoList(_styleInfoList); _pluginIds = PluginContentManager.GetContentPluginIds(_channelInfo); _pluginColumns = PluginContentManager.GetContentColumns(_pluginIds); _isEdit = TextUtility.IsEdit(SiteInfo, _channelId, AuthRequest.AdminPermissionsImpl); var state = AuthRequest.IsQueryExists("state") ? AuthRequest.GetQueryInt("state") : CheckManager.LevelInt.All; var searchType = AuthRequest.IsQueryExists("searchType") ? AuthRequest.GetQueryString("searchType") : ContentAttribute.Title; var dateFrom = AuthRequest.IsQueryExists("dateFrom") ? AuthRequest.GetQueryString("dateFrom") : string.Empty; var dateTo = AuthRequest.IsQueryExists("dateTo") ? AuthRequest.GetQueryString("dateTo") : string.Empty; var keyword = AuthRequest.IsQueryExists("keyword") ? AuthRequest.GetQueryString("keyword") : string.Empty; var checkedLevel = 5; var isChecked = true; foreach (var owningChannelId in AuthRequest.AdminPermissionsImpl.ChannelIdList) { int checkedLevelByChannelId; var isCheckedByChannelId = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissionsImpl, SiteInfo, owningChannelId, out checkedLevelByChannelId); if (checkedLevel > checkedLevelByChannelId) { checkedLevel = checkedLevelByChannelId; } if (!isCheckedByChannelId) { isChecked = false; } } RptContents.ItemDataBound += RptContents_ItemDataBound; var allAttributeNameList = TableColumnManager.GetTableColumnNameList(tableName, DataType.Text); var adminId = _isAdminOnly ? AuthRequest.AdminId : AuthRequest.AdminPermissionsImpl.GetAdminId(SiteInfo.Id, _channelInfo.Id); var whereString = DataProvider.ContentDao.GetPagerWhereSqlString(SiteInfo, _channelInfo, searchType, keyword, dateFrom, dateTo, state, _isCheckOnly, false, _isTrashOnly, _isWritingOnly, adminId, AuthRequest.AdminPermissionsImpl, allAttributeNameList); PgContents.Param = new PagerParam { ControlToPaginate = RptContents, TableName = tableName, PageSize = SiteInfo.Additional.PageSize, Page = AuthRequest.GetQueryInt(Pager.QueryNamePage, 1), OrderSqlString = ETaxisTypeUtils.GetContentOrderByString(ETaxisType.OrderByIdDesc), ReturnColumnNames = TranslateUtils.ObjectCollectionToString(allAttributeNameList), WhereSqlString = whereString, TotalCount = DataProvider.DatabaseDao.GetPageTotalCount(tableName, whereString) }; if (IsPostBack) { return; } if (_isTrashOnly) { if (AuthRequest.IsQueryExists("IsDeleteAll")) { //DataProvider.ContentDao.DeleteContentsByTrash(SiteId, _channelId, tableName); var list = DataProvider.ContentDao.GetContentIdListByTrash(SiteId, tableName); foreach (var(contentChannelId, contentId) in list) { ContentUtility.Delete(tableName, SiteInfo, contentChannelId, contentId); } AuthRequest.AddSiteLog(SiteId, "清空回收站"); SuccessMessage("成功清空回收站!"); } else if (AuthRequest.IsQueryExists("IsRestore")) { var idsDictionary = ContentUtility.GetIDsDictionary(Request.QueryString); foreach (var channelId in idsDictionary.Keys) { var contentIdList = idsDictionary[channelId]; DataProvider.ContentDao.UpdateTrashContents(SiteId, channelId, ChannelManager.GetTableName(SiteInfo, channelId), contentIdList); } AuthRequest.AddSiteLog(SiteId, "从回收站还原内容"); SuccessMessage("成功还原内容!"); } else if (AuthRequest.IsQueryExists("IsRestoreAll")) { DataProvider.ContentDao.UpdateRestoreContentsByTrash(SiteId, _channelId, tableName); AuthRequest.AddSiteLog(SiteId, "从回收站还原所有内容"); SuccessMessage("成功还原所有内容!"); } } ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, true, true, AuthRequest.AdminPermissionsImpl); if (_isCheckOnly) { CheckManager.LoadContentLevelToCheck(DdlState, SiteInfo, isChecked, checkedLevel); } else { CheckManager.LoadContentLevelToList(DdlState, SiteInfo, _isCheckOnly, isChecked, checkedLevel); } ControlUtils.SelectSingleItem(DdlState, state.ToString()); foreach (var styleInfo in _allStyleInfoList) { if (styleInfo.InputType == InputType.TextEditor) { continue; } var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName); DdlSearchType.Items.Add(listitem); } //ETriStateUtils.AddListItems(DdlState, "全部", "已审核", "待审核"); if (SiteId != _channelId) { ControlUtils.SelectSingleItem(DdlChannelId, _channelId.ToString()); } //ControlUtils.SelectSingleItem(DdlState, AuthRequest.GetQueryString("State")); ControlUtils.SelectSingleItem(DdlSearchType, searchType); TbKeyword.Text = keyword; TbDateFrom.Text = dateFrom; TbDateTo.Text = dateTo; PgContents.DataBind(); LtlColumnsHead.Text += TextUtility.GetColumnsHeadHtml(_styleInfoList, _pluginColumns, _attributesOfDisplay); BtnSelect.Attributes.Add("onclick", ModalSelectColumns.GetOpenWindowString(SiteId, _channelId)); if (_isTrashOnly) { LtlColumnsHead.Text += @"<th class=""text-center text-nowrap"" width=""150"">删除时间</th>"; BtnAddToGroup.Visible = BtnTranslate.Visible = BtnCheck.Visible = false; PhTrash.Visible = true; if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentDelete)) { BtnDelete.Visible = false; BtnDeleteAll.Visible = false; } else { BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(SiteId, true, PageUrl)); BtnDeleteAll.Attributes.Add("onclick", PageUtils.GetRedirectStringWithConfirm(PageUtils.AddQueryString(PageUrl, "IsDeleteAll", "True"), "确实要清空回收站吗?")); } BtnRestore.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValue(PageUtils.AddQueryString(PageUrl, "IsRestore", "True"), "IDsCollection", "IDsCollection", "请选择需要还原的内容!")); BtnRestoreAll.Attributes.Add("onclick", PageUtils.GetRedirectStringWithConfirm(PageUtils.AddQueryString(PageUrl, "IsRestoreAll", "True"), "确实要还原所有内容吗?")); } else { LtlColumnsHead.Text += @"<th class=""text-center text-nowrap"" width=""100"">操作</th>"; BtnAddToGroup.Attributes.Add("onclick", ModalAddToGroup.GetOpenWindowStringToContentForMultiChannels(SiteId)); if (HasChannelPermissions(SiteId, ConfigManager.ChannelPermissions.ContentCheck)) { BtnCheck.Attributes.Add("onclick", ModalContentCheck.GetOpenWindowStringForMultiChannels(SiteId, PageUrl)); if (_isCheckOnly) { BtnCheck.CssClass = "btn m-r-5 btn-success"; } } else { PhCheck.Visible = false; } if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentTranslate)) { BtnTranslate.Visible = false; } else { BtnTranslate.Attributes.Add("onclick", PageContentTranslate.GetRedirectClickStringForMultiChannels(SiteId, PageUrl)); } if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentDelete)) { BtnDelete.Visible = false; } else { BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(SiteId, false, PageUrl)); } } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } var permissions = PermissionsManager.GetPermissions(Body.AdminName); PageUtils.CheckRequestParameter("SiteId"); _channelId = Body.IsQueryExists("ChannelId") ? Body.GetQueryInt("ChannelId") : SiteId; _isWritingOnly = Body.GetQueryBool("isWritingOnly"); var administratorName = string.Empty; _isSelfOnly = Body.GetQueryBool("isSelfOnly"); if (!_isSelfOnly) { administratorName = AdminUtility.IsViewContentOnlySelf(Body.AdminName, SiteId, _channelId) ? Body.AdminName : string.Empty; } _nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); var tableName = ChannelManager.GetTableName(SiteInfo, _nodeInfo); _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId); _styleInfoList = TableStyleManager.GetTableStyleInfoList(tableName, _relatedIdentities); _attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(ChannelManager.GetContentAttributesOfDisplay(SiteId, _channelId)); _attributesOfDisplayStyleInfoList = ContentUtility.GetColumnTableStyleInfoList(SiteInfo, _styleInfoList); _pluginLinks = PluginContentManager.GetContentLinks(_nodeInfo); _isEdit = TextUtility.IsEdit(SiteInfo, _channelId, Body.AdminName); var stateType = Body.IsQueryExists("state") ? ETriStateUtils.GetEnumType(Body.GetQueryString("state")) : ETriState.All; var searchType = Body.IsQueryExists("searchType") ? Body.GetQueryString("searchType") : ContentAttribute.Title; var dateFrom = Body.IsQueryExists("dateFrom") ? Body.GetQueryString("dateFrom") : string.Empty; var dateTo = Body.IsQueryExists("dateTo") ? Body.GetQueryString("dateTo") : string.Empty; var isDuplicate = Body.IsQueryExists("isDuplicate") && Body.GetQueryBool("isDuplicate"); var keyword = Body.IsQueryExists("keyword") ? Body.GetQueryString("keyword") : string.Empty; SpContents.ControlToPaginate = RptContents; SpContents.SelectCommand = DataProvider.ContentDao.GetSqlString(tableName, SiteId, _channelId, permissions.IsSystemAdministrator, ProductPermissionsManager.Current.OwningChannelIdList, searchType, keyword, dateFrom, dateTo, true, stateType, !isDuplicate, false, _isWritingOnly, administratorName); SpContents.ItemsPerPage = SiteInfo.Additional.PageSize; SpContents.SortField = ContentAttribute.Id; SpContents.SortMode = SortMode.DESC; SpContents.OrderByString = ETaxisTypeUtils.GetContentOrderByString(ETaxisType.OrderByIdDesc); RptContents.ItemDataBound += RptContents_ItemDataBound; if (!IsPostBack) { ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, true, true, Body.AdminName); DdlSearchType.Items.Add(new ListItem("标题", ContentAttribute.Title)); if (_styleInfoList != null) { foreach (var styleInfo in _styleInfoList) { if (styleInfo.AttributeName != ContentAttribute.AddDate) { var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName); DdlSearchType.Items.Add(listitem); } } } DdlSearchType.Items.Add(new ListItem("内容ID", ContentAttribute.Id)); DdlSearchType.Items.Add(new ListItem("添加者", ContentAttribute.AddUserName)); DdlSearchType.Items.Add(new ListItem("最后修改者", ContentAttribute.LastEditUserName)); ETriStateUtils.AddListItems(DdlState, "全部", "已审核", "待审核"); if (SiteId != _channelId) { ControlUtils.SelectSingleItem(DdlChannelId, _channelId.ToString()); } ControlUtils.SelectSingleItem(DdlState, Body.GetQueryString("State")); CbIsDuplicate.Checked = isDuplicate; ControlUtils.SelectSingleItem(DdlSearchType, searchType); TbKeyword.Text = keyword; TbDateFrom.Text = dateFrom; TbDateTo.Text = dateTo; SpContents.DataBind(); var showPopWinString = ModalAddToGroup.GetOpenWindowStringToContentForMultiChannels(SiteId); BtnAddToGroup.Attributes.Add("onclick", showPopWinString); showPopWinString = ModalSelectColumns.GetOpenWindowString(SiteId, _channelId, true); BtnSelect.Attributes.Add("onclick", showPopWinString); if (AdminUtility.HasChannelPermissions(Body.AdminName, SiteId, SiteId, ConfigManager.Permissions.Channel.ContentCheck)) { showPopWinString = ModalContentCheck.GetOpenWindowStringForMultiChannels(SiteId, PageUrl); BtnCheck.Attributes.Add("onclick", showPopWinString); } else { PhCheck.Visible = false; } LtlColumnsHead.Text = TextUtility.GetColumnsHeadHtml(_styleInfoList, _attributesOfDisplay, SiteInfo); } if (!HasChannelPermissions(_channelId, ConfigManager.Permissions.Channel.ContentAdd)) { BtnAddContent.Visible = false; } if (!HasChannelPermissions(_channelId, ConfigManager.Permissions.Channel.ContentTranslate)) { BtnTranslate.Visible = false; } else { BtnTranslate.Attributes.Add("onclick", PageContentTranslate.GetRedirectClickStringForMultiChannels(SiteId, PageUrl)); } if (!HasChannelPermissions(_channelId, ConfigManager.Permissions.Channel.ContentDelete)) { BtnDelete.Visible = false; } else { BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(SiteId, false, PageUrl)); } }
public static List <InputListItem> GetContentsColumns(SiteInfo siteInfo, ChannelInfo channelInfo, bool includeAll) { var items = new List <InputListItem>(); var attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(channelInfo.Additional.ContentAttributesOfDisplay); var pluginIds = PluginContentManager.GetContentPluginIds(channelInfo); var pluginColumns = PluginContentManager.GetContentColumns(pluginIds); var styleInfoList = ContentUtility.GetAllTableStyleInfoList(TableStyleManager.GetContentStyleInfoList(siteInfo, channelInfo)); styleInfoList.Insert(0, new TableStyleInfo { AttributeName = ContentAttribute.Sequence, DisplayName = "序号" }); foreach (var styleInfo in styleInfoList) { if (styleInfo.InputType == InputType.TextEditor) { continue; } var listitem = new InputListItem { Text = styleInfo.DisplayName, Value = styleInfo.AttributeName }; if (styleInfo.AttributeName == ContentAttribute.Title) { listitem.Selected = true; } else { if (attributesOfDisplay.Contains(styleInfo.AttributeName)) { listitem.Selected = true; } } if (includeAll || listitem.Selected) { items.Add(listitem); } } if (pluginColumns != null) { foreach (var pluginId in pluginColumns.Keys) { var contentColumns = pluginColumns[pluginId]; if (contentColumns == null || contentColumns.Count == 0) { continue; } foreach (var columnName in contentColumns.Keys) { var attributeName = $"{pluginId}:{columnName}"; var listitem = new InputListItem { Text = $"{columnName}({pluginId})", Value = attributeName }; if (attributesOfDisplay.Contains(attributeName)) { listitem.Selected = true; } if (includeAll || listitem.Selected) { items.Add(listitem); } } } } return(items); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("SiteId"); _channelId = AuthRequest.IsQueryExists("ChannelId") ? AuthRequest.GetQueryInt("ChannelId") : SiteId; _isWritingOnly = AuthRequest.GetQueryBool("isWritingOnly"); var administratorName = string.Empty; _isSelfOnly = AuthRequest.GetQueryBool("isSelfOnly"); if (!_isSelfOnly) { administratorName = AuthRequest.AdminPermissions.IsViewContentOnlySelf(SiteId, _channelId) ? AuthRequest.AdminName : string.Empty; } _channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); var tableName = ChannelManager.GetTableName(SiteInfo, _channelInfo); _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId); _styleInfoList = TableStyleManager.GetTableStyleInfoList(tableName, _relatedIdentities); _attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(ChannelManager.GetContentAttributesOfDisplay(SiteId, _channelId)); _allStyleInfoList = ContentUtility.GetAllTableStyleInfoList(_styleInfoList); _pluginLinks = PluginContentManager.GetContentLinks(_channelInfo); _isEdit = TextUtility.IsEdit(SiteInfo, _channelId, AuthRequest.AdminPermissions); var stateType = AuthRequest.IsQueryExists("state") ? ETriStateUtils.GetEnumType(AuthRequest.GetQueryString("state")) : ETriState.All; var searchType = AuthRequest.IsQueryExists("searchType") ? AuthRequest.GetQueryString("searchType") : ContentAttribute.Title; var dateFrom = AuthRequest.IsQueryExists("dateFrom") ? AuthRequest.GetQueryString("dateFrom") : string.Empty; var dateTo = AuthRequest.IsQueryExists("dateTo") ? AuthRequest.GetQueryString("dateTo") : string.Empty; var keyword = AuthRequest.IsQueryExists("keyword") ? AuthRequest.GetQueryString("keyword") : string.Empty; RptContents.ItemDataBound += RptContents_ItemDataBound; var allLowerAttributeNameList = TableMetadataManager.GetAllLowerAttributeNameListExcludeText(tableName); var pagerParam = new PagerParam { ControlToPaginate = RptContents, TableName = tableName, PageSize = SiteInfo.Additional.PageSize, Page = AuthRequest.GetQueryInt(Pager.QueryNamePage, 1), OrderSqlString = ETaxisTypeUtils.GetContentOrderByString(ETaxisType.OrderByIdDesc), ReturnColumnNames = TranslateUtils.ObjectCollectionToString(allLowerAttributeNameList) }; var channelIdList = ChannelManager.GetChannelIdList(_channelInfo, EScopeType.All, string.Empty, string.Empty, _channelInfo.ContentModelPluginId); var searchChannelIdList = new List <int>(); if (AuthRequest.AdminPermissions.IsSystemAdministrator) { searchChannelIdList = channelIdList; } else { foreach (var theChannelId in channelIdList) { if (AuthRequest.AdminPermissions.OwningChannelIdList.Contains(theChannelId)) { searchChannelIdList.Add(theChannelId); } } } pagerParam.WhereSqlString = DataProvider.ContentDao.GetPagerWhereSqlString(allLowerAttributeNameList, SiteId, _channelInfo, AuthRequest.AdminPermissions.IsSystemAdministrator, searchChannelIdList, searchType, keyword, dateFrom, dateTo, true, stateType, false, _isWritingOnly, administratorName); pagerParam.TotalCount = DataProvider.DatabaseDao.GetPageTotalCount(tableName, pagerParam.WhereSqlString); PgContents.Param = pagerParam; if (!IsPostBack) { ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, true, true, AuthRequest.AdminPermissions); foreach (var styleInfo in _allStyleInfoList) { if (styleInfo.InputType == InputType.TextEditor) { continue; } var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName); DdlSearchType.Items.Add(listitem); } ETriStateUtils.AddListItems(DdlState, "全部", "已审核", "待审核"); if (SiteId != _channelId) { ControlUtils.SelectSingleItem(DdlChannelId, _channelId.ToString()); } ControlUtils.SelectSingleItem(DdlState, AuthRequest.GetQueryString("State")); ControlUtils.SelectSingleItem(DdlSearchType, searchType); TbKeyword.Text = keyword; TbDateFrom.Text = dateFrom; TbDateTo.Text = dateTo; PgContents.DataBind(); var showPopWinString = ModalAddToGroup.GetOpenWindowStringToContentForMultiChannels(SiteId); BtnAddToGroup.Attributes.Add("onclick", showPopWinString); showPopWinString = ModalSelectColumns.GetOpenWindowString(SiteId, _channelId, true); BtnSelect.Attributes.Add("onclick", showPopWinString); if (HasChannelPermissions(SiteId, ConfigManager.ChannelPermissions.ContentCheck)) { showPopWinString = ModalContentCheck.GetOpenWindowStringForMultiChannels(SiteId, PageUrl); BtnCheck.Attributes.Add("onclick", showPopWinString); } else { PhCheck.Visible = false; } LtlColumnsHead.Text = TextUtility.GetColumnsHeadHtml(_styleInfoList, _attributesOfDisplay, SiteInfo); } if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentAdd)) { BtnAddContent.Visible = false; } if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentTranslate)) { BtnTranslate.Visible = false; } else { BtnTranslate.Attributes.Add("onclick", PageContentTranslate.GetRedirectClickStringForMultiChannels(SiteId, PageUrl)); } if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentDelete)) { BtnDelete.Visible = false; } else { BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(SiteId, false, PageUrl)); } }
public static List <ContentColumn> GetContentColumns(SiteInfo siteInfo, ChannelInfo channelInfo, bool includeAll) { var columns = new List <ContentColumn>(); var attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(channelInfo.Additional.ContentAttributesOfDisplay); var pluginIds = PluginContentManager.GetContentPluginIds(channelInfo); var pluginColumns = PluginContentManager.GetContentColumns(pluginIds); var styleInfoList = ContentUtility.GetAllTableStyleInfoList(TableStyleManager.GetContentStyleInfoList(siteInfo, channelInfo)); styleInfoList.Insert(0, new TableStyleInfo { AttributeName = ContentAttribute.Sequence, DisplayName = "序号" }); foreach (var styleInfo in styleInfoList) { if (styleInfo.InputType == InputType.TextEditor) { continue; } var column = new ContentColumn { AttributeName = styleInfo.AttributeName, DisplayName = styleInfo.DisplayName, InputType = styleInfo.InputType }; if (styleInfo.AttributeName == ContentAttribute.Title) { column.IsList = true; } else { if (attributesOfDisplay.Contains(styleInfo.AttributeName)) { column.IsList = true; } } if (StringUtils.ContainsIgnoreCase(ContentAttribute.CalculateAttributes.Value, styleInfo.AttributeName)) { column.IsCalculate = true; } if (includeAll || column.IsList) { columns.Add(column); } } if (pluginColumns != null) { foreach (var pluginId in pluginColumns.Keys) { var contentColumns = pluginColumns[pluginId]; if (contentColumns == null || contentColumns.Count == 0) { continue; } foreach (var columnName in contentColumns.Keys) { var attributeName = $"{pluginId}:{columnName}"; var column = new ContentColumn { AttributeName = attributeName, DisplayName = $"{columnName}({pluginId})", InputType = InputType.Text, IsCalculate = true }; if (attributesOfDisplay.Contains(attributeName)) { column.IsList = true; } if (includeAll || column.IsList) { columns.Add(column); } } } } return(columns); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId", "channelId", "ReturnUrl"); _channelId = Body.GetQueryInt("channelId"); ReturnUrl = StringUtils.ValueFromUrl(Body.GetQueryString("ReturnUrl")); if (Body.GetQueryString("CanNotEdit") == null && Body.GetQueryString("UncheckedChannel") == null) { if (!HasChannelPermissions(_channelId, ConfigManager.Permissions.Channel.ChannelEdit)) { PageUtils.RedirectToErrorPage("您没有修改栏目的权限!"); return; } } if (Body.IsQueryExists("CanNotEdit")) { BtnSubmit.Visible = false; } var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); if (nodeInfo == null) { return; } CacAttributes.SiteInfo = SiteInfo; CacAttributes.ChannelId = _channelId; if (!IsPostBack) { 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, nodeInfo.ContentModelPluginId); var plugins = PluginContentManager.GetAllContentRelatedPlugins(false); if (plugins.Count > 0) { var relatedPluginIds = TranslateUtils.StringCollectionToStringList(nodeInfo.ContentRelatedPluginIds); foreach (var pluginMetadata in plugins) { CblContentRelatedPluginIds.Items.Add(new ListItem(pluginMetadata.Title, pluginMetadata.Id) { Selected = relatedPluginIds.Contains(pluginMetadata.Id) }); } } else { PhContentRelatedPluginIds.Visible = false; } CacAttributes.Attributes = nodeInfo.Additional; 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); 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")); ControlUtils.SelectSingleItem(DdlChannelTemplateId, nodeInfo.ChannelTemplateId.ToString()); DdlContentTemplateId.Items.Insert(0, new ListItem("<未设置>", "0")); ControlUtils.SelectSingleItem(DdlContentTemplateId, nodeInfo.ContentTemplateId.ToString()); TbNodeName.Text = nodeInfo.ChannelName; TbNodeIndexName.Text = nodeInfo.IndexName; TbLinkUrl.Text = nodeInfo.LinkUrl; foreach (ListItem item in CblNodeGroupNameCollection.Items) { item.Selected = CompareUtils.Contains(nodeInfo.GroupNameCollection, item.Value); } TbFilePath.Text = nodeInfo.FilePath; TbChannelFilePathRule.Text = nodeInfo.ChannelFilePathRule; TbContentFilePathRule.Text = nodeInfo.ContentFilePathRule; ControlUtils.SelectSingleItem(DdlLinkType, nodeInfo.LinkType); ControlUtils.SelectSingleItem(DdlTaxisType, nodeInfo.Additional.DefaultTaxisType); ControlUtils.SelectSingleItem(RblIsChannelAddable, nodeInfo.Additional.IsChannelAddable.ToString()); ControlUtils.SelectSingleItem(RblIsContentAddable, nodeInfo.Additional.IsContentAddable.ToString()); TbImageUrl.Text = nodeInfo.ImageUrl; TbContent.SetParameters(SiteInfo, ChannelAttribute.Content, nodeInfo.Content); TbKeywords.Text = nodeInfo.Keywords; TbDescription.Text = nodeInfo.Description; //this.Content.SiteId = base.SiteId; //this.Content.Text = StringUtility.TextEditorContentDecode(nodeInfo.Content, ConfigUtils.Instance.ApplicationPath, base.SiteInfo.SiteUrl); } else { CacAttributes.Attributes = new ExtendedAttributes(Request.Form); } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId"); _channelId = AuthRequest.IsQueryExists("ChannelId") ? AuthRequest.GetQueryInt("ChannelId") : SiteId; _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId); _nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); _tableName = ChannelManager.GetTableName(SiteInfo, _nodeInfo); _styleInfoList = TableStyleManager.GetTableStyleInfoList(_tableName, _relatedIdentities); _attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(ChannelManager.GetContentAttributesOfDisplay(SiteId, _channelId)); _attributesOfDisplayStyleInfoList = ContentUtility.GetAllTableStyleInfoList(_styleInfoList); _pluginLinks = PluginContentManager.GetContentLinks(_nodeInfo); _isEdit = TextUtility.IsEdit(SiteInfo, _channelId, AuthRequest.AdminPermissions); if (IsPostBack) { return; } var checkedLevel = 5; var isChecked = true; foreach (var owningChannelId in AuthRequest.AdminPermissions.OwningChannelIdList) { int checkedLevelByChannelId; var isCheckedByChannelId = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissions, SiteInfo, owningChannelId, out checkedLevelByChannelId); if (checkedLevel > checkedLevelByChannelId) { checkedLevel = checkedLevelByChannelId; } if (!isCheckedByChannelId) { isChecked = false; } } ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, true, true, AuthRequest.AdminPermissions); CheckManager.LoadContentLevelToList(DdlState, SiteInfo, SiteId, isChecked, checkedLevel); var checkLevelList = new List <int>(); if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("channelId"))) { ControlUtils.SelectSingleItem(DdlChannelId, AuthRequest.GetQueryString("channelId")); } if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("state"))) { ControlUtils.SelectSingleItem(DdlState, AuthRequest.GetQueryString("state")); checkLevelList.Add(AuthRequest.GetQueryInt("state")); } else { checkLevelList = CheckManager.LevelInt.GetCheckLevelList(SiteInfo, isChecked, checkedLevel); } SpContents.ControlToPaginate = RptContents; SpContents.ItemsPerPage = SiteInfo.Additional.PageSize; var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); var tableName = ChannelManager.GetTableName(SiteInfo, nodeInfo); var channelIdList = ChannelManager.GetChannelIdList(nodeInfo, EScopeType.All, string.Empty, string.Empty, nodeInfo.ContentModelPluginId); var list = new List <int>(); if (AuthRequest.AdminPermissions.IsSystemAdministrator) { list = channelIdList; } else { var owningChannelIdList = new List <int>(); foreach (var owningChannelId in AuthRequest.AdminPermissions.OwningChannelIdList) { if (HasChannelPermissions(owningChannelId, ConfigManager.ChannelPermissions.ContentCheck)) { owningChannelIdList.Add(owningChannelId); } } foreach (var theChannelId in channelIdList) { if (owningChannelIdList.Contains(theChannelId)) { list.Add(theChannelId); } } } SpContents.SelectCommand = DataProvider.ContentDao.GetSelectedCommendByCheck(tableName, SiteId, list, checkLevelList); SpContents.SortField = ContentAttribute.LastEditDate; SpContents.SortMode = SortMode.DESC; RptContents.ItemDataBound += RptContents_ItemDataBound; SpContents.DataBind(); var showPopWinString = ModalContentCheck.GetOpenWindowStringForMultiChannels(SiteId, PageUrl); BtnCheck.Attributes.Add("onclick", showPopWinString); LtlColumnsHead.Text = TextUtility.GetColumnsHeadHtml(_styleInfoList, _attributesOfDisplay, SiteInfo); if (!HasChannelPermissions(SiteId, ConfigManager.ChannelPermissions.ContentDelete)) { BtnDelete.Visible = false; } else { BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(SiteId, false, PageUrl)); } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId"); _channelId = AuthRequest.GetQueryInt("channelId"); var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); var tableName = ChannelManager.GetTableName(SiteInfo, channelInfo); _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId); var attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(channelInfo.Additional.ContentAttributesOfDisplay); _pluginColumns = PluginContentManager.GetContentColumns(channelInfo); if (IsPostBack) { return; } var styleInfoList = ContentUtility.GetAllTableStyleInfoList(TableStyleManager.GetTableStyleInfoList(tableName, _relatedIdentities)); foreach (var styleInfo in styleInfoList) { if (styleInfo.InputType == InputType.TextEditor) { continue; } var listitem = new ListItem($"{styleInfo.DisplayName}({styleInfo.AttributeName})", styleInfo.AttributeName); if (styleInfo.AttributeName == ContentAttribute.Title) { listitem.Selected = true; } else { if (attributesOfDisplay.Contains(styleInfo.AttributeName)) { listitem.Selected = true; } } CblDisplayAttributes.Items.Add(listitem); } if (_pluginColumns != null) { foreach (var pluginId in _pluginColumns.Keys) { var contentColumns = _pluginColumns[pluginId]; if (contentColumns == null || contentColumns.Count == 0) { continue; } foreach (var columnName in contentColumns.Keys) { var attributeName = $"{pluginId}:{columnName}"; var listitem = new ListItem($"{columnName}({pluginId})", attributeName); if (attributesOfDisplay.Contains(attributeName)) { listitem.Selected = true; } CblDisplayAttributes.Items.Add(listitem); } } } }
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 void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId", "channelId"); var channelId = AuthRequest.GetQueryInt("channelId"); _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, channelId); _channelInfo = ChannelManager.GetChannelInfo(SiteId, channelId); _tableName = ChannelManager.GetTableName(SiteInfo, _channelInfo); _styleInfoList = TableStyleManager.GetTableStyleInfoList(_tableName, _relatedIdentities); _attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(ChannelManager.GetContentAttributesOfDisplay(SiteId, channelId)); _attributesOfDisplayStyleInfoList = ContentUtility.GetAllTableStyleInfoList(_styleInfoList); _pluginLinks = PluginContentManager.GetContentLinks(_channelInfo); _isEdit = TextUtility.IsEdit(SiteInfo, channelId, AuthRequest.AdminPermissions); if (_channelInfo.Additional.IsPreviewContents) { new Action(() => { DataProvider.ContentDao.DeletePreviewContents(SiteId, _tableName, _channelInfo); }).BeginInvoke(null, null); } if (!HasChannelPermissions(channelId, ConfigManager.ChannelPermissions.ContentView, ConfigManager.ChannelPermissions.ContentAdd, ConfigManager.ChannelPermissions.ContentEdit, ConfigManager.ChannelPermissions.ContentDelete, ConfigManager.ChannelPermissions.ContentTranslate)) { if (!AuthRequest.IsAdminLoggin) { PageUtils.RedirectToLoginPage(); return; } PageUtils.RedirectToErrorPage("您无此栏目的操作权限!"); return; } SpContents.ControlToPaginate = RptContents; RptContents.ItemDataBound += RptContents_ItemDataBound; SpContents.ItemsPerPage = SiteInfo.Additional.PageSize; var administratorName = AuthRequest.AdminPermissions.IsViewContentOnlySelf(SiteId, channelId) ? AuthRequest.AdminName : string.Empty; if (AuthRequest.IsQueryExists("searchType")) { var owningChannelIdList = new List <int> { channelId }; SpContents.SelectCommand = DataProvider.ContentDao.GetSqlString(_tableName, SiteId, channelId, AuthRequest.AdminPermissions.IsSystemAdministrator, owningChannelIdList, AuthRequest.GetQueryString("searchType"), AuthRequest.GetQueryString("keyword"), AuthRequest.GetQueryString("dateFrom"), string.Empty, false, ETriState.All, false, false, false, administratorName); } else { SpContents.SelectCommand = DataProvider.ContentDao.GetSqlString(_tableName, channelId, ETriState.All, administratorName); } //spContents.SortField = DataProvider.ContentDao.GetSortFieldName(); //spContents.SortMode = SortMode.DESC; //spContents.OrderByString = ETaxisTypeUtils.GetOrderByString(tableStyle, ETaxisType.OrderByTaxisDesc); SpContents.OrderByString = ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(_channelInfo.Additional.DefaultTaxisType)); SpContents.TotalCount = _channelInfo.ContentNum; if (IsPostBack) { return; } LtlButtons.Text = WebUtils.GetContentCommands(AuthRequest.AdminPermissions, SiteInfo, _channelInfo, PageUrl); LtlMoreButtons.Text = WebUtils.GetContentMoreCommands(AuthRequest.AdminPermissions, SiteInfo, _channelInfo, PageUrl); SpContents.DataBind(); if (_styleInfoList != null) { foreach (var styleInfo in _styleInfoList) { var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName); DdlSearchType.Items.Add(listitem); } } //添加隐藏属性 DdlSearchType.Items.Add(new ListItem("内容ID", ContentAttribute.Id)); DdlSearchType.Items.Add(new ListItem("添加者", ContentAttribute.AddUserName)); DdlSearchType.Items.Add(new ListItem("最后修改者", ContentAttribute.LastEditUserName)); DdlSearchType.Items.Add(new ListItem("内容组", ContentAttribute.GroupNameCollection)); if (AuthRequest.IsQueryExists("searchType")) { TbDateFrom.Text = AuthRequest.GetQueryString("dateFrom"); ControlUtils.SelectSingleItem(DdlSearchType, AuthRequest.GetQueryString("searchType")); TbKeyword.Text = AuthRequest.GetQueryString("keyword"); if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("searchType")) || !string.IsNullOrEmpty(TbDateFrom.Text) || !string.IsNullOrEmpty(TbKeyword.Text)) { LtlButtons.Text += @" <script> $(document).ready(function() { $('#contentSearch').show(); }); </script> "; } } LtlColumnsHead.Text = TextUtility.GetColumnsHeadHtml(_styleInfoList, _attributesOfDisplay, SiteInfo); }
public IHttpActionResult Get() { try { var request = new RequestImpl(); var siteId = request.GetQueryInt("siteId"); var channelId = request.GetQueryInt("channelId"); var page = request.GetQueryInt("page"); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentView)) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } var onlyAdminId = request.AdminPermissionsImpl.GetOnlyAdminId(siteId, channelId); var pluginIds = PluginContentManager.GetContentPluginIds(channelInfo); var pluginColumns = PluginContentManager.GetContentColumns(pluginIds); var columns = ContentManager.GetContentColumns(siteInfo, channelInfo, false); var pageContentInfoList = new List <ContentInfo>(); var count = ContentManager.GetCount(siteInfo, channelInfo, onlyAdminId); var pages = Convert.ToInt32(Math.Ceiling((double)count / siteInfo.Additional.PageSize)); if (pages == 0) { pages = 1; } if (count > 0) { var offset = siteInfo.Additional.PageSize * (page - 1); var limit = siteInfo.Additional.PageSize; var pageContentIds = ContentManager.GetContentIdList(siteInfo, channelInfo, onlyAdminId, offset, limit); var sequence = offset + 1; foreach (var contentId in pageContentIds) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); if (contentInfo == null) { continue; } var menus = PluginMenuManager.GetContentMenus(pluginIds, contentInfo); contentInfo.Set("PluginMenus", menus); pageContentInfoList.Add(ContentManager.Calculate(sequence++, contentInfo, columns, pluginColumns)); } } var permissions = new { IsAdd = request.AdminPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentAdd) && channelInfo.Additional.IsContentAddable, IsDelete = request.AdminPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentDelete), IsEdit = request.AdminPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentEdit), IsTranslate = request.AdminPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentTranslate), IsCheck = request.AdminPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentCheck), IsCreate = request.AdminPermissionsImpl.HasSitePermissions(siteInfo.Id, ConfigManager.WebSitePermissions.Create) || request.AdminPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.CreatePage), IsChannelEdit = request.AdminPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ChannelEdit) }; return(Ok(new { Value = pageContentInfoList, Count = count, Pages = pages, Permissions = permissions, Columns = columns })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }