public async Task <ActionResult <GetResult> > Get([FromQuery] GetRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId,
                                                            Types.SitePermissions.Contents) ||
                !await _authManager.HasContentPermissionsAsync(request.SiteId, request.ChannelId, Types.ContentPermissions.View))
            {
                return(Unauthorized());
            }

            var site = await _siteRepository.GetAsync(request.SiteId);

            if (site == null)
            {
                return(NotFound());
            }

            var channel = await _channelRepository.GetAsync(request.ChannelId);

            var content = await _contentRepository.GetAsync(site, channel, request.ContentId);

            if (content == null)
            {
                return(NotFound());
            }

            var channelName = await _channelRepository.GetChannelNameNavigationAsync(request.SiteId, request.ChannelId);

            var columnsManager = new ColumnsManager(_databaseManager, _pathManager);

            var columns = await columnsManager.GetContentListColumnsAsync(site, channel, ColumnsManager.PageType.Contents);

            var calculatedContent =
                await columnsManager.CalculateContentListAsync(1, site, request.ChannelId, content, columns);

            calculatedContent.Body = content.Body;

            var siteUrl = await _pathManager.GetSiteUrlAsync(site, true);

            var groupNames = await _contentGroupRepository.GetGroupNamesAsync(request.SiteId);

            var tagNames = await _contentTagRepository.GetTagNamesAsync(request.SiteId);

            var editorColumns = new List <ContentColumn>();

            var styles = await _tableStyleRepository.GetContentStylesAsync(site, channel);

            foreach (var tableStyle in styles)
            {
                if (tableStyle.InputType != InputType.TextEditor)
                {
                    continue;
                }

                editorColumns.Add(new ContentColumn
                {
                    AttributeName = tableStyle.AttributeName,
                    DisplayName   = tableStyle.DisplayName
                });
            }

            return(new GetResult
            {
                Content = calculatedContent,
                ChannelName = channelName,
                State = CheckManager.GetCheckState(site, content),
                Columns = columns,
                SiteUrl = siteUrl,
                GroupNames = groupNames,
                TagNames = tagNames,
                EditorColumns = editorColumns
            });
        }
예제 #2
0
        public IHttpActionResult GetConfig()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId            = request.GetQueryInt("siteId");
                var channelId         = request.GetQueryInt("channelId");
                var channelContentIds =
                    MinContentInfo.ParseMinContentInfoList(request.GetQueryString("channelContentIds"));

                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                        ConfigManager.ChannelPermissions.ContentTranslate))
                {
                    return(Unauthorized());
                }

                var siteInfo = SiteManager.GetSiteInfo(siteId);
                if (siteInfo == null)
                {
                    return(BadRequest("无法确定内容对应的站点"));
                }

                var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);
                if (channelInfo == null)
                {
                    return(BadRequest("无法确定内容对应的栏目"));
                }

                var retVal = new List <Dictionary <string, object> >();
                foreach (var channelContentId in channelContentIds)
                {
                    var contentChannelInfo = ChannelManager.GetChannelInfo(siteId, channelContentId.ChannelId);
                    var contentInfo        = ContentManager.GetContentInfo(siteInfo, contentChannelInfo, channelContentId.Id);
                    if (contentInfo == null)
                    {
                        continue;
                    }

                    var dict = contentInfo.ToDictionary();
                    dict["checkState"] =
                        CheckManager.GetCheckState(siteInfo, contentInfo);
                    retVal.Add(dict);
                }

                var sites    = new List <object>();
                var channels = new List <object>();

                var siteIdList = request.AdminPermissionsImpl.GetSiteIdList();
                foreach (var permissionSiteId in siteIdList)
                {
                    var permissionSiteInfo = SiteManager.GetSiteInfo(permissionSiteId);
                    if (permissionSiteInfo == null)
                    {
                        continue;
                    }

                    sites.Add(new
                    {
                        permissionSiteInfo.Id,
                        permissionSiteInfo.SiteName
                    });
                }

                var channelIdList = request.AdminPermissionsImpl.GetChannelIdList(siteInfo.Id,
                                                                                  ConfigManager.ChannelPermissions.ContentAdd);
                foreach (var permissionChannelId in channelIdList)
                {
                    var permissionChannelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, permissionChannelId);
                    channels.Add(new
                    {
                        permissionChannelInfo.Id,
                        ChannelName = ChannelManager.GetChannelNameNavigation(siteInfo.Id, permissionChannelId)
                    });
                }

                return(Ok(new
                {
                    Value = retVal,
                    Sites = sites,
                    Channels = channels,
                    Site = siteInfo
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
예제 #3
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId", "channelId", "id", "ReturnUrl");

            _channelId = AuthRequest.GetQueryInt("channelId");
            if (_channelId < 0)
            {
                _channelId = -_channelId;
            }

            var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);

            if (channelInfo == null)
            {
                throw new Exception("栏目已被删除");
            }

            _contentId = AuthRequest.GetQueryInt("id");
            _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("returnUrl"));

            _contentInfo = ContentManager.GetContentInfo(SiteInfo, channelInfo, _contentId);

            if (IsPostBack)
            {
                return;
            }

            var styleInfoList = TableStyleManager.GetContentStyleInfoList(SiteInfo, channelInfo);

            RptContents.DataSource     = styleInfoList;
            RptContents.ItemDataBound += RptContents_ItemDataBound;
            RptContents.DataBind();

            LtlTitle.Text       = _contentInfo.Title;
            LtlChannelName.Text = channelInfo.ChannelName;

            LtlTags.Text = _contentInfo.Tags;
            if (string.IsNullOrEmpty(LtlTags.Text))
            {
                PhTags.Visible = false;
            }

            LtlContentGroup.Text = _contentInfo.GroupNameCollection;
            if (string.IsNullOrEmpty(LtlContentGroup.Text))
            {
                PhContentGroup.Visible = false;
            }

            LtlLastEditDate.Text     = DateUtils.GetDateAndTimeString(_contentInfo.LastEditDate);
            LtlAddUserName.Text      = AdminManager.GetDisplayName(_contentInfo.AddUserName, true);
            LtlLastEditUserName.Text = AdminManager.GetDisplayName(_contentInfo.LastEditUserName, true);

            LtlContentLevel.Text = CheckManager.GetCheckState(SiteInfo, _contentInfo);

            if (_contentInfo.ReferenceId > 0 && _contentInfo.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString())
            {
                var referenceSiteId      = DataProvider.ChannelDao.GetSiteId(_contentInfo.SourceId);
                var referenceSiteInfo    = SiteManager.GetSiteInfo(referenceSiteId);
                var referenceContentInfo = ContentManager.GetContentInfo(referenceSiteInfo, _contentInfo.SourceId, _contentInfo.ReferenceId);

                if (referenceContentInfo != null)
                {
                    var pageUrl           = PageUtility.GetContentUrl(referenceSiteInfo, referenceContentInfo, true);
                    var referenceNodeInfo = ChannelManager.GetChannelInfo(referenceContentInfo.SiteId, referenceContentInfo.ChannelId);
                    var addEditUrl        =
                        WebUtils.GetContentAddEditUrl(referenceSiteInfo.Id,
                                                      referenceNodeInfo.Id, _contentInfo.ReferenceId, AuthRequest.GetQueryString("ReturnUrl"));

                    LtlScripts.Text += $@"
<div class=""tips"">此内容为对内容 (站点:{referenceSiteInfo.SiteName},栏目:{referenceNodeInfo.ChannelName})“<a href=""{pageUrl}"" target=""_blank"">{_contentInfo.Title}</a>”(<a href=""{addEditUrl}"">编辑</a>) 的引用,内容链接将和原始内容链接一致</div>";
                }
            }
        }
예제 #4
0
        public IHttpActionResult GetConfig()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId            = request.GetQueryInt("siteId");
                var channelId         = request.GetQueryInt("channelId");
                var channelContentIds =
                    MinContentInfo.ParseMinContentInfoList(request.GetQueryString("channelContentIds"));

                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                        ConfigManager.ChannelPermissions.ContentCheck))
                {
                    return(Unauthorized());
                }

                var siteInfo = SiteManager.GetSiteInfo(siteId);
                if (siteInfo == null)
                {
                    return(BadRequest("无法确定内容对应的站点"));
                }

                var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);
                if (channelInfo == null)
                {
                    return(BadRequest("无法确定内容对应的栏目"));
                }

                var retVal = new List <Dictionary <string, object> >();
                foreach (var channelContentId in channelContentIds)
                {
                    var contentChannelInfo = ChannelManager.GetChannelInfo(siteId, channelContentId.ChannelId);
                    var contentInfo        = ContentManager.GetContentInfo(siteInfo, contentChannelInfo, channelContentId.Id);
                    if (contentInfo == null)
                    {
                        continue;
                    }

                    var dict = contentInfo.ToDictionary();
                    dict["title"]      = WebUtils.GetContentTitle(siteInfo, contentInfo, string.Empty);
                    dict["checkState"] =
                        CheckManager.GetCheckState(siteInfo, contentInfo);
                    retVal.Add(dict);
                }

                var isChecked     = CheckManager.GetUserCheckLevel(request.AdminPermissionsImpl, siteInfo, channelId, out var checkedLevel);
                var checkedLevels = CheckManager.GetCheckedLevels(siteInfo, isChecked, checkedLevel, true);

                var allChannels =
                    ChannelManager.GetChannels(siteId, request.AdminPermissionsImpl, ConfigManager.ChannelPermissions.ContentAdd);

                return(Ok(new
                {
                    Value = retVal,
                    CheckedLevels = checkedLevels,
                    CheckedLevel = checkedLevel,
                    AllChannels = allChannels
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
예제 #5
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId", "channelId", "ID", "ReturnUrl");

            _channelId = AuthRequest.GetQueryInt("channelId");
            var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);

            _tableName = ChannelManager.GetTableName(SiteInfo, channelInfo);
            _contentId = AuthRequest.GetQueryInt("ID");
            _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("ReturnUrl"));

            _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);

            _contentInfo = DataProvider.ContentDao.GetContentInfo(_tableName, _contentId);

            if (IsPostBack)
            {
                return;
            }

            var styleInfoList        = TableStyleManager.GetTableStyleInfoList(_tableName, _relatedIdentities);
            var myStyleInfoArrayList = new ArrayList();

            if (styleInfoList != null)
            {
                foreach (var styleInfo in styleInfoList)
                {
                    myStyleInfoArrayList.Add(styleInfo);
                }
            }

            RptContents.DataSource     = myStyleInfoArrayList;
            RptContents.ItemDataBound += RptContents_ItemDataBound;
            RptContents.DataBind();

            LtlNodeName.Text = ChannelManager.GetChannelName(SiteId, _channelId);

            LtlTags.Text = _contentInfo.Tags;
            if (string.IsNullOrEmpty(LtlTags.Text))
            {
                PhTags.Visible = false;
            }

            LtlContentGroup.Text = _contentInfo.GroupNameCollection;
            if (string.IsNullOrEmpty(LtlContentGroup.Text))
            {
                PhContentGroup.Visible = false;
            }

            LtlLastEditDate.Text     = DateUtils.GetDateAndTimeString(_contentInfo.LastEditDate);
            LtlAddUserName.Text      = AdminManager.GetDisplayName(_contentInfo.AddUserName, true);
            LtlLastEditUserName.Text = AdminManager.GetDisplayName(_contentInfo.LastEditUserName, true);

            LtlContentLevel.Text = CheckManager.GetCheckState(SiteInfo, _contentInfo.IsChecked, _contentInfo.CheckedLevel);

            if (_contentInfo.ReferenceId > 0 && _contentInfo.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString())
            {
                var referenceSiteId      = DataProvider.ChannelDao.GetSiteId(_contentInfo.SourceId);
                var referenceSiteInfo    = SiteManager.GetSiteInfo(referenceSiteId);
                var referenceTableName   = ChannelManager.GetTableName(referenceSiteInfo, _contentInfo.SourceId);
                var referenceContentInfo = DataProvider.ContentDao.GetContentInfo(referenceTableName, _contentInfo.ReferenceId);

                if (referenceContentInfo != null)
                {
                    var pageUrl           = PageUtility.GetContentUrl(referenceSiteInfo, referenceContentInfo, true);
                    var referenceNodeInfo = ChannelManager.GetChannelInfo(referenceContentInfo.SiteId, referenceContentInfo.ChannelId);
                    var addEditUrl        =
                        WebUtils.GetContentAddEditUrl(referenceSiteInfo.Id,
                                                      referenceNodeInfo, _contentInfo.ReferenceId, AuthRequest.GetQueryString("ReturnUrl"));

                    LtlScripts.Text += $@"
<div class=""tips"">此内容为对内容 (站点:{referenceSiteInfo.SiteName},栏目:{referenceNodeInfo.ChannelName})“<a href=""{pageUrl}"" target=""_blank"">{_contentInfo.Title}</a>”(<a href=""{addEditUrl}"">编辑</a>) 的引用,内容链接将和原始内容链接一致</div>";
                }
            }

            BtnSubmit.Attributes.Add("onclick", ModalContentCheck.GetOpenWindowString(SiteInfo.Id, _channelId, _contentId, _returnUrl));
            HlPreview.NavigateUrl = ApiRoutePreview.GetContentUrl(SiteId, _contentInfo.ChannelId, _contentInfo.Id);
        }
        public async Task <ActionResult <GetResult> > Get([FromQuery] GetRequest request)
        {
            if (!await _authManager.HasContentPermissionsAsync(request.SiteId, request.ChannelId, Types.ContentPermissions.Translate))
            {
                return(Unauthorized());
            }

            var site = await _siteRepository.GetAsync(request.SiteId);

            if (site == null)
            {
                return(NotFound());
            }

            var channelInfo = await _channelRepository.GetAsync(request.ChannelId);

            if (channelInfo == null)
            {
                return(NotFound());
            }

            var retVal = new List <IDictionary <string, object> >();

            foreach (var contentId in request.ContentIds)
            {
                var contentInfo = await _contentRepository.GetAsync(site, channelInfo, contentId);

                if (contentInfo == null)
                {
                    continue;
                }

                var dict = contentInfo.ToDictionary();
                dict["checkState"] =
                    CheckManager.GetCheckState(site, contentInfo);
                retVal.Add(dict);
            }

            var sites    = new List <object>();
            var channels = new List <object>();

            var siteIdList = await _authManager.GetSiteIdsAsync();

            foreach (var permissionSiteId in siteIdList)
            {
                var permissionSite = await _siteRepository.GetAsync(permissionSiteId);

                sites.Add(new
                {
                    permissionSite.Id,
                    permissionSite.SiteName
                });
            }

            var channelIdList = await _authManager.GetChannelIdsAsync(site.Id,
                                                                      Types.ContentPermissions.Add);

            foreach (var permissionChannelId in channelIdList)
            {
                var permissionChannelInfo = await _channelRepository.GetAsync(permissionChannelId);

                channels.Add(new
                {
                    permissionChannelInfo.Id,
                    ChannelName = await _channelRepository.GetChannelNameNavigationAsync(site.Id, permissionChannelId)
                });
            }

            return(new GetResult
            {
                Value = retVal,
                Sites = sites,
                Channels = channels,
                Site = site
            });
        }
예제 #7
0
        private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var contentInfo = new ContentInfo(e.Item.DataItem);

            var ltlTitle    = (Literal)e.Item.FindControl("ltlTitle");
            var ltlChannel  = (Literal)e.Item.FindControl("ltlChannel");
            var ltlColumns  = (Literal)e.Item.FindControl("ltlColumns");
            var ltlStatus   = (Literal)e.Item.FindControl("ltlStatus");
            var ltlCommands = (Literal)e.Item.FindControl("ltlCommands");
            var ltlSelect   = (Literal)e.Item.FindControl("ltlSelect");

            ltlTitle.Text = WebUtils.GetContentTitle(SiteInfo, contentInfo, PageUrl);

            ltlColumns.Text = TextUtility.GetColumnsHtml(_nameValueCacheDict, SiteInfo, contentInfo, _attributesOfDisplay, _allStyleInfoList, _pluginColumns);

            string nodeName;

            if (!_nameValueCacheDict.TryGetValue(contentInfo.ChannelId.ToString(), out nodeName))
            {
                nodeName = ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId);
                _nameValueCacheDict[contentInfo.ChannelId.ToString()] = nodeName;
            }

            ltlChannel.Text = nodeName;

            ltlStatus.Text =
                $@"<a href=""javascript:;"" title=""设置内容状态"" onclick=""{ModalCheckState.GetOpenWindowString(SiteId, contentInfo, PageUrl)}"">{CheckManager.GetCheckState(SiteInfo, contentInfo.IsChecked, contentInfo.CheckedLevel)}</a>";

            ltlCommands.Text = TextUtility.GetCommandsHtml(SiteInfo, _pluginMenus, contentInfo, PageUrl, AuthRequest.AdminName, _isEdit);

            ltlSelect.Text = $@"<input type=""checkbox"" name=""IDsCollection"" value=""{contentInfo.ChannelId}_{contentInfo.Id}"" />";
        }
예제 #8
0
        private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var contentInfo = new ContentInfo(e.Item.DataItem);

            var ltlTitle    = (Literal)e.Item.FindControl("ltlTitle");
            var ltlColumns  = (Literal)e.Item.FindControl("ltlColumns");
            var ltlStatus   = (Literal)e.Item.FindControl("ltlStatus");
            var ltlCommands = (Literal)e.Item.FindControl("ltlCommands");
            var ltlSelect   = (Literal)e.Item.FindControl("ltlSelect");

            ltlTitle.Text = WebUtils.GetContentTitle(SiteInfo, contentInfo, PageUrl);

            ltlColumns.Text = TextUtility.GetColumnsHtml(_nameValueCacheDict, SiteInfo, contentInfo, _attributesOfDisplay, _attributesOfDisplayStyleInfoList);

            ltlStatus.Text =
                $@"<a href=""javascript:;"" title=""设置内容状态"" onclick=""{ModalCheckState.GetOpenWindowString(SiteId, contentInfo, PageUrl)}"">{CheckManager.GetCheckState(SiteInfo, contentInfo.IsChecked, contentInfo.CheckedLevel)}</a>";

            ltlCommands.Text = TextUtility.GetCommandsHtml(SiteInfo, _pluginLinks, contentInfo, PageUrl, Body.AdminName, _isEdit);

            ltlSelect.Text = $@"<input type=""checkbox"" name=""contentIdCollection"" value=""{contentInfo.Id}"" />";
        }