Exemple #1
0
        //public static bool IsComment(SiteInfo siteInfo, int channelId, string administratorName)
        //{
        //    return siteInfo.Additional.IsCommentable && AdminUtility.HasChannelPermissions(administratorName, siteInfo.Id, channelId, ConfigManager.Permissions.Channel.CommentCheck, ConfigManager.Permissions.Channel.CommentDelete);
        //}

        public static string GetColumnsHeadHtml(List <TableStyleInfo> tableStyleInfoList, StringCollection attributesOfDisplay, SiteInfo siteInfo)
        {
            var builder = new StringBuilder();

            var styleInfoList = ContentUtility.GetAllTableStyleInfoList(tableStyleInfoList);

            foreach (var styleInfo in styleInfoList)
            {
                if (!attributesOfDisplay.Contains(styleInfo.AttributeName) || styleInfo.AttributeName == ContentAttribute.Title)
                {
                    continue;
                }
                builder.Append($@"<th class=""text-nowrap"">{styleInfo.DisplayName}</th>");
            }

            return(builder.ToString());
        }
Exemple #2
0
        private void LoadDisplayAttributeCheckBoxList()
        {
            var nodeInfo          = ChannelManager.GetChannelInfo(SiteId, _channelId);
            var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
            var tableName         = ChannelManager.GetTableName(SiteInfo, nodeInfo);
            var styleInfoList     = TableStyleManager.GetTableStyleInfoList(tableName, relatedIdentities);

            styleInfoList = ContentUtility.GetAllTableStyleInfoList(SiteInfo, styleInfoList);

            foreach (var styleInfo in styleInfoList)
            {
                var listItem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName)
                {
                    Selected = true
                };
                CblDisplayAttributes.Items.Add(listItem);
            }
        }
        public static List <InputStyle> GetInputStyles(SiteInfo siteInfo, ChannelInfo channelInfo)
        {
            var items = new List <InputStyle>();

            var styleInfoList = ContentUtility.GetAllTableStyleInfoList(TableStyleManager.GetContentStyleInfoList(siteInfo, channelInfo));

            foreach (var styleInfo in styleInfoList)
            {
                var listitem = new InputStyle
                {
                    DisplayName   = styleInfo.DisplayName,
                    AttributeName = styleInfo.AttributeName
                };
                items.Add(listitem);
            }

            return(items);
        }
Exemple #4
0
        //public static bool IsComment(SiteInfo siteInfo, int channelId, string administratorName)
        //{
        //    return siteInfo.Additional.IsCommentable && AdminUtility.HasChannelPermissions(administratorName, siteInfo.Id, channelId, ConfigManager.Permissions.Channel.CommentCheck, ConfigManager.Permissions.Channel.CommentDelete);
        //}

        public static string GetColumnsHeadHtml(List <TableStyleInfo> tableStyleInfoList, Dictionary <string, Dictionary <string, Func <IContentContext, string> > > pluginColumns, StringCollection attributesOfDisplay)
        {
            var builder = new StringBuilder();

            var styleInfoList = ContentUtility.GetAllTableStyleInfoList(tableStyleInfoList);

            foreach (var styleInfo in styleInfoList)
            {
                if (!attributesOfDisplay.Contains(styleInfo.AttributeName) || styleInfo.AttributeName == ContentAttribute.Title)
                {
                    continue;
                }
                builder.Append($@"<th class=""text-nowrap"">{styleInfo.DisplayName}</th>");
            }

            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}";
                        if (!attributesOfDisplay.Contains(attributeName))
                        {
                            continue;
                        }

                        builder.Append($@"<th class=""text-nowrap"">{columnName}</th>");
                    }
                }
            }

            return(builder.ToString());
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        public static List <ContentInfo> GetContentsByCsvFile(string filePath, SiteInfo siteInfo,
                                                              ChannelInfo nodeInfo)
        {
            var contentInfoList = new List <ContentInfo>();

            CsvUtils.Import(filePath, out var head, out var rows);

            if (rows.Count <= 0)
            {
                return(contentInfoList);
            }

            var styleInfoList       = ContentUtility.GetAllTableStyleInfoList(TableStyleManager.GetContentStyleInfoList(siteInfo, nodeInfo));
            var nameValueCollection = new NameValueCollection();

            foreach (var styleInfo in styleInfoList)
            {
                nameValueCollection[styleInfo.DisplayName] = styleInfo.AttributeName.ToLower();
            }

            var attributeNames = new List <string>();

            foreach (var columnName in head)
            {
                attributeNames.Add(!string.IsNullOrEmpty(nameValueCollection[columnName])
                    ? nameValueCollection[columnName]
                    : columnName);
            }

            foreach (var row in rows)
            {
                if (row.Count != attributeNames.Count)
                {
                    continue;
                }

                var dict = new Dictionary <string, object>();

                for (var i = 0; i < attributeNames.Count; i++)
                {
                    var attributeName = attributeNames[i];
                    if (!string.IsNullOrEmpty(attributeName))
                    {
                        dict[attributeName] = row[i];
                    }
                }

                var contentInfo = new ContentInfo(dict);

                if (!string.IsNullOrEmpty(contentInfo.Title))
                {
                    contentInfo.SiteId       = siteInfo.Id;
                    contentInfo.ChannelId    = nodeInfo.Id;
                    contentInfo.LastEditDate = DateTime.Now;

                    contentInfoList.Add(contentInfo);
                }
            }

            return(contentInfoList);
        }
Exemple #7
0
        public static List <BackgroundContentInfo> GetContentsByCsvFile(string filePath, PublishmentSystemInfo publishmentSystemInfo,
                                                                        NodeInfo nodeInfo)
        {
            var contentInfoList = new List <BackgroundContentInfo>();

            List <string>         head;
            List <List <string> > rows;

            CsvUtils.Import(filePath, out head, out rows);

            if (rows.Count > 0)
            {
                var relatedidentityes =
                    RelatedIdentities.GetChannelRelatedIdentities(
                        publishmentSystemInfo.PublishmentSystemId, nodeInfo.NodeId);
                var modelInfo = ContentModelManager.GetContentModelInfo(publishmentSystemInfo,
                                                                        nodeInfo.ContentModelId);
                var tableStyle = EAuxiliaryTableTypeUtils.GetTableStyle(modelInfo.TableType);
                // ArrayList tableStyleInfoArrayList = TableStyleManager.GetTableStyleInfoArrayList(ETableStyle.BackgroundContent, publishmentSystemInfo.AuxiliaryTableForContent, relatedidentityes);

                var tableStyleInfoList = TableStyleManager.GetTableStyleInfoList(tableStyle,
                                                                                 modelInfo.TableName, relatedidentityes);
                tableStyleInfoList = ContentUtility.GetAllTableStyleInfoList(publishmentSystemInfo,
                                                                             tableStyle, tableStyleInfoList);
                var nameValueCollection = new NameValueCollection();

                foreach (var styleInfo in tableStyleInfoList)
                {
                    nameValueCollection[styleInfo.DisplayName] = styleInfo.AttributeName.ToLower();
                }

                var attributeNames = new List <string>();
                foreach (var columnName in head)
                {
                    if (!string.IsNullOrEmpty(nameValueCollection[columnName]))
                    {
                        attributeNames.Add(nameValueCollection[columnName]);
                    }
                    else
                    {
                        attributeNames.Add(columnName);
                    }
                }

                foreach (var row in rows)
                {
                    var contentInfo = new BackgroundContentInfo();
                    if (row.Count != attributeNames.Count)
                    {
                        continue;
                    }

                    for (var i = 0; i < attributeNames.Count; i++)
                    {
                        var attributeName = attributeNames[i];
                        if (!string.IsNullOrEmpty(attributeName))
                        {
                            var value = row[i];
                            contentInfo.SetExtendedAttribute(attributeName, value);
                        }
                    }

                    if (!string.IsNullOrEmpty(contentInfo.Title))
                    {
                        contentInfo.PublishmentSystemId = publishmentSystemInfo.PublishmentSystemId;
                        contentInfo.NodeId       = nodeInfo.NodeId;
                        contentInfo.LastEditDate = DateTime.Now;

                        contentInfoList.Add(contentInfo);
                    }
                }
            }

            return(contentInfoList);
        }
        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);
        }
Exemple #9
0
        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;
            }

            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));
            }
        }
Exemple #11
0
        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);
        }
Exemple #12
0
        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));
            }
        }
Exemple #13
0
        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);
                    }
                }
            }
        }
Exemple #14
0
        public static List <ContentInfo> GetContentsByCsvFile(string filePath, SiteInfo siteInfo,
                                                              ChannelInfo nodeInfo)
        {
            var contentInfoList = new List <ContentInfo>();

            List <string>         head;
            List <List <string> > rows;

            CsvUtils.Import(filePath, out head, out rows);

            if (rows.Count <= 0)
            {
                return(contentInfoList);
            }

            var relatedidentityes =
                RelatedIdentities.GetChannelRelatedIdentities(
                    siteInfo.Id, nodeInfo.Id);
            var tableName = ChannelManager.GetTableName(siteInfo, nodeInfo);
            // ArrayList tableStyleInfoArrayList = TableStyleManager.GetTableStyleInfoArrayList(ETableStyle.BackgroundContent, siteInfo.AuxiliaryTableForContent, relatedidentityes);

            var styleInfoList       = ContentUtility.GetAllTableStyleInfoList(TableStyleManager.GetTableStyleInfoList(tableName, relatedidentityes));
            var nameValueCollection = new NameValueCollection();

            foreach (var styleInfo in styleInfoList)
            {
                nameValueCollection[styleInfo.DisplayName] = styleInfo.AttributeName.ToLower();
            }

            var attributeNames = new List <string>();

            foreach (var columnName in head)
            {
                attributeNames.Add(!string.IsNullOrEmpty(nameValueCollection[columnName])
                    ? nameValueCollection[columnName]
                    : columnName);
            }

            foreach (var row in rows)
            {
                var contentInfo = new ContentInfo();
                if (row.Count != attributeNames.Count)
                {
                    continue;
                }

                for (var i = 0; i < attributeNames.Count; i++)
                {
                    var attributeName = attributeNames[i];
                    if (!string.IsNullOrEmpty(attributeName))
                    {
                        var value = row[i];
                        contentInfo.Set(attributeName, value);
                    }
                }

                if (!string.IsNullOrEmpty(contentInfo.Title))
                {
                    contentInfo.SiteId       = siteInfo.Id;
                    contentInfo.ChannelId    = nodeInfo.Id;
                    contentInfo.LastEditDate = DateTime.Now;

                    contentInfoList.Add(contentInfo);
                }
            }

            return(contentInfoList);
        }
Exemple #15
0
        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);
        }
Exemple #16
0
        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;
            }

            _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.GetAllTableStyleInfoList(_styleInfoList);
            _pluginLinks = PluginContentManager.GetContentLinks(_nodeInfo);
            _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 isDuplicate = AuthRequest.IsQueryExists("isDuplicate") && AuthRequest.GetQueryBool("isDuplicate");
            var keyword     = AuthRequest.IsQueryExists("keyword") ? AuthRequest.GetQueryString("keyword") : string.Empty;

            SpContents.ControlToPaginate = RptContents;
            SpContents.SelectCommand     = DataProvider.ContentDao.GetSqlString(tableName, SiteId, _channelId, AuthRequest.AdminPermissions.IsSystemAdministrator, AuthRequest.AdminPermissions.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, AuthRequest.AdminPermissions);

                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, AuthRequest.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 (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));
            }
        }