コード例 #1
0
        public ContentReference LoadUnpublishedVersion(ContentReference baseReference)
        {
            if (ExternalReview.ProjectId.HasValue)
            {
                // load version from project
                return(_projectContentResolver.GetProjectReference(baseReference,
                                                                   ExternalReview.ProjectId.Value, _languageResolver.GetPreferredCulture().Name));
            }

            // load common draft instead of published version
            ContentVersion loadCommonDraft;

            try
            {
                loadCommonDraft = _contentVersionRepository.LoadCommonDraft(baseReference, _languageResolver.GetPreferredCulture().Name);
            }
            catch (ContentNotFoundException)
            {
                _log.Debug($"Advanced Reviews: Content {baseReference} not found for LoadUnpublishedVersion");
                loadCommonDraft = null;
            }

            if (loadCommonDraft == null)
            {
                // fallback to default implementation if there is no common draft in a given language
                return(null);
            }

            return(loadCommonDraft.ContentLink);
        }
コード例 #2
0
        public object RoutePartial(PageData content, SegmentContext segmentContext)
        {
            if (!_externalReviewOptions.IsEnabled)
            {
                return(null);
            }

            var nextSegment = segmentContext.GetNextValue(segmentContext.RemainingPath);

            if (nextSegment.Next != _externalReviewOptions.ContentIframeEditUrlSegment)
            {
                return(null);
            }

            nextSegment = segmentContext.GetNextValue(nextSegment.Remaining);
            var token = nextSegment.Next;

            var externalReviewLink = _externalReviewLinksRepository.GetContentByToken(token);

            if (!externalReviewLink.IsEditableLink())
            {
                return(null);
            }

            if (externalReviewLink.VisitorGroups != null)
            {
                System.Web.HttpContext.Current.Items["ImpersonatedVisitorGroupsById"] = externalReviewLink.VisitorGroups;
            }

            var contentReference = externalReviewLink.ContentLink;

            if (externalReviewLink.ProjectId.HasValue)
            {
                var languageID = content.Language.Name;

                var contentContentLink = PreviewUrlResolver.IsGenerated(segmentContext.QueryString) ? content.ContentLink : contentReference;
                contentReference         = _projectContentResolver.GetProjectReference(contentContentLink, externalReviewLink.ProjectId.Value, languageID);
                ExternalReview.ProjectId = externalReviewLink.ProjectId;
            }

            try
            {
                var page = _contentLoader.Get <IContent>(contentReference, content.Language);
                segmentContext.RemainingPath = nextSegment.Remaining;

                // We can't set the Edit context here because it breaks the routing if you have useClaims=true in virtualRoles setting
                // and when you have a custom VirtualRole class that uses IPageRouteHelper to fetch the current language from url
                // segmentContext.ContextMode = ContextMode.Edit;
                segmentContext.RouteData.DataTokens[RoutingConstants.NodeKey] = page.ContentLink;

                ExternalReview.IsEditLink = true;
                ExternalReview.Token      = token;

                return(page);
            }
            catch
            {
                return(null);
            }
        }
コード例 #3
0
        public IContent Get(ContentAreaItem contentAreaItem)
        {
            if (!ExternalReview.IsInExternalReviewContext)
            {
                return(_defaultContentAreaLoader.Get(contentAreaItem));
            }

            ContentReference referenceToLoad;

            if (ExternalReview.ProjectId.HasValue)
            {
                // load version from project
                referenceToLoad = _projectContentResolver.GetProjectReference(contentAreaItem.ContentLink,
                                                                              ExternalReview.ProjectId.Value);
            }
            else
            {
                // load common draft instead of published version
                var loadCommonDraft = _contentVersionRepository.LoadCommonDraft(contentAreaItem.ContentLink,
                                                                                _languageResolver.GetPreferredCulture().Name);
                if (loadCommonDraft == null)
                {
                    // fallback to default implementation if there is no common draft in a given language
                    return(_defaultContentAreaLoader.Get(contentAreaItem));
                }
                referenceToLoad = loadCommonDraft.ContentLink;
            }

            if (referenceToLoad != null)
            {
                var content = _contentLoader.Get <IContent>(referenceToLoad);
                if (HasExpired(content as IVersionable))
                {
                    return(null);
                }

                if (content.IsPublished())
                {
                    // for published version return the original method result
                    return(_defaultContentAreaLoader.Get(contentAreaItem));
                }

                if (!contentAreaItem.IsReadOnly)
                {
                    contentAreaItem.ContentLink = referenceToLoad;
                }

                return(content);
            }

            return(_defaultContentAreaLoader.Get(contentAreaItem));
        }
コード例 #4
0
        public ContentReference LoadUnpublishedVersion(ContentReference baseReference)
        {
            if (ExternalReview.ProjectId.HasValue)
            {
                // load version from project
                return(_projectContentResolver.GetProjectReference(baseReference,
                                                                   ExternalReview.ProjectId.Value, _languageResolver.GetPreferredCulture().Name));
            }

            // load common draft instead of published version
            var loadCommonDraft = _contentVersionRepository.LoadCommonDraft(baseReference, _languageResolver.GetPreferredCulture().Name);

            if (loadCommonDraft == null)
            {
                // fallback to default implementation if there is no common draft in a given language
                return(null);
            }

            return(loadCommonDraft.ContentLink);
        }
コード例 #5
0
        public IContent Get(ContentAreaItem contentAreaItem)
        {
            if (!ExternalReview.IsInExternalReviewContext)
            {
                return(_defaultContentAreaLoader.Get(contentAreaItem));
            }

            ContentReference referenceToLoad;

            if (ExternalReview.ProjectId.HasValue)
            {
                // load version from project
                referenceToLoad = _projectContentResolver.GetProjectReference(contentAreaItem.ContentLink,
                                                                              ExternalReview.ProjectId.Value);
            }
            else
            {
                // load common draft instead of published version
                referenceToLoad = _contentVersionRepository.LoadCommonDraft(contentAreaItem.ContentLink,
                                                                            _languageResolver.GetPreferredCulture().Name).ContentLink;
            }

            if (referenceToLoad != null)
            {
                var content = _contentLoader.Get <IContent>(referenceToLoad);
                if (content.IsPublished())
                {
                    // for published version return the original method result
                    var defaultContent = _defaultContentAreaLoader.Get(contentAreaItem);
                    return(defaultContent);
                }

                contentAreaItem.ContentLink = referenceToLoad;

                return(content);
            }

            return(_defaultContentAreaLoader.Get(contentAreaItem));
        }