Пример #1
0
        public async Task <ActionResult <GetResult> > Get([FromQuery] GetRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId,
                                                            Types.SitePermissions.SettingsContentTag))
            {
                return(Unauthorized());
            }

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

            var pageTagNames = new List <string>();
            var total        = tagNames.Count;

            if (total > 0)
            {
                var offset = request.PerPage * (request.Page - 1);
                var limit  = request.PerPage;
                pageTagNames = tagNames.Skip(offset).Take(limit).ToList();
            }

            return(new GetResult
            {
                Total = total,
                TagNames = pageTagNames
            });
        }
Пример #2
0
        public async Task <ActionResult <ObjectResult <IEnumerable <string> > > > Get([FromQuery] ChannelRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId,
                                                            Types.SitePermissions.Contents) ||
                !await _authManager.HasContentPermissionsAsync(request.SiteId, request.ChannelId, Types.ContentPermissions.Edit))
            {
                return(Unauthorized());
            }

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

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

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

            return(new ObjectResult <IEnumerable <string> >
            {
                Value = tagNames
            });
        }
Пример #3
0
        private async Task <SortedList> ReadContentAsync(int siteId)
        {
            var arrText = new SortedList();

            var tagList = await _contentTagRepository.GetTagNamesAsync(siteId);

            if (tagList.Any())
            {
                foreach (var line in tagList)
                {
                    if (!string.IsNullOrEmpty(line))
                    {
                        arrText.Add(line.Trim(), line.Trim());
                    }
                }
            }

            return(arrText);
        }
Пример #4
0
        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
            });
        }