Exemplo n.º 1
0
        void DataFactoryMovedPage(object sender, PageEventArgs e)
        {
            var parentLink = e.TargetLink;
            var page       = DataFactory.Instance.GetPage(e.PageLink);

            parentLink = GetNewParent(parentLink, page);

            if (PageReference.IsValue(parentLink) && !e.TargetLink.CompareToIgnoreWorkID(parentLink))
            {
                DataFactory.Instance.Move(page.PageLink, parentLink, AccessLevel.NoAccess, AccessLevel.NoAccess);
            }
        }
        private void ContentEventsOnMovingContent(object sender, ContentEventArgs contentEventArgs)
        {
            if (!(contentEventArgs.Content is PageData))
            {
                return;
            }

            var parentLink = contentEventArgs.TargetLink;
            var page       = GetPage(contentEventArgs.ContentLink) as PageData;

            parentLink = GetNewParent(parentLink as PageReference, page);

            if (!PageReference.IsValue(parentLink as PageReference) || contentEventArgs.TargetLink.CompareToIgnoreWorkID(parentLink))
            {
                return;
            }

            var contentRepository = ServiceLocator.Current.GetInstance <IContentRepository>();

            contentRepository.Move(page.ContentLink, parentLink, AccessLevel.NoAccess, AccessLevel.NoAccess);
        }
Exemplo n.º 3
0
        private PageReference GetNewParent(
            PageReference originalParentLink, PageData page)
        {
            var queriedParents = new List <PageReference>();

            var organizingParent = GetChildrenOrganizer(originalParentLink);

            PageReference parentLink = originalParentLink;

            while (organizingParent != null &&
                   ListContains(queriedParents, parentLink))
            {
                queriedParents.Add(parentLink);
                var newParentLink = organizingParent.GetParentForPage(page);
                if (PageReference.IsValue(newParentLink))
                {
                    parentLink = newParentLink;
                }
                organizingParent = GetChildrenOrganizer(parentLink);
            }
            return(parentLink);
        }