public virtual ApplicationPath GetApplicationPath(ContentMap map, EntityNode node)
        {
            var link = node as WebLinkNode;

            if (link != null)
            {
                if (!string.IsNullOrWhiteSpace(link.ExternalUrl))
                {
                    return(ApplicationPath.FromExternalUrl(link.ExternalUrl));
                }

                ApplicationPath path = null;
                // Check .IsReference incase the linked-to root WebPage is deactivated.
                if (link.WebPage != null && !link.WebPage.IsReference)
                {
                    // If language content page exists, replace web link page with the content page
                    var langInfo    = HttpContext.Current.GetContextLanguageInfo();
                    var linkWebPage = langInfo.FindLanguageSpecificWebPageNode(link.WebPage, false);
                    // If web page doesn't exist for current language, return null path
                    if (linkWebPage != null)
                    {
                        path = GetApplicationPath(linkWebPage);
                    }
                }
                return(path);
            }

            var page = node as WebPageNode;

            if (page != null)
            {
                var path = GetApplicationPath(page);

                return(path);
            }

            var file = node as WebFileNode;

            if (file != null)
            {
                var path = GetApplicationPath(file);

                return(path);
            }

            var shortcut = node as ShortcutNode;

            if (shortcut != null)
            {
                var path = GetApplicationPath(shortcut);

                return(path);
            }

            return(null);
        }
Ejemplo n.º 2
0
        private ApplicationPath GetWebLinkUrl(OrganizationServiceContext context, Entity webLink)
        {
            webLink.AssertEntityName("adx_weblink");

            var externalUrl = webLink.GetAttributeValue <string>("adx_externalurl");

            if (!string.IsNullOrWhiteSpace(externalUrl))
            {
                return(ApplicationPath.FromExternalUrl(externalUrl));
            }

            var page = webLink.GetRelatedEntity(context, "adx_webpage_weblink");

            return(page == null ? null : GetApplicationPath(context, page));
        }
        private ApplicationPath GetApplicationPath(ShortcutNode shortcut)
        {
            if (shortcut.WebPage != null && !shortcut.WebPage.IsReference)
            {
                return(GetApplicationPath(shortcut.WebPage));
            }

            if (shortcut.WebFile != null && !shortcut.WebFile.IsReference)
            {
                return(GetApplicationPath(shortcut.WebFile));
            }

            if (!string.IsNullOrEmpty(shortcut.ExternalUrl))
            {
                return(ApplicationPath.FromExternalUrl(shortcut.ExternalUrl));
            }

            return(null);
        }
Ejemplo n.º 4
0
        private ApplicationPath GetShortcutApplicationPath(OrganizationServiceContext context, Entity shortcut)
        {
            shortcut.AssertEntityName("adx_shortcut");

            var relatedWebPage = shortcut.GetRelatedEntity(context, "adx_webpage_shortcut".ToRelationship());

            if (relatedWebPage != null)
            {
                return(GetApplicationPath(context, relatedWebPage));
            }

            var relatedWebFile = shortcut.GetRelatedEntity(context, "adx_webfile_shortcut".ToRelationship());

            if (relatedWebFile != null)
            {
                return(GetApplicationPath(context, relatedWebFile));
            }

            var relatedEvent = shortcut.GetRelatedEntity(context, "adx_event_shortcut".ToRelationship());

            if (relatedEvent != null)
            {
                return(GetApplicationPath(context, relatedEvent));
            }

            var relatedForum = shortcut.GetRelatedEntity(context, "adx_communityforum_shortcut".ToRelationship());

            if (relatedForum != null)
            {
                return(GetApplicationPath(context, relatedForum));
            }

            var externalUrl = shortcut.GetAttributeValue <string>("adx_externalurl");

            if (!string.IsNullOrEmpty(externalUrl))
            {
                return(ApplicationPath.FromExternalUrl(externalUrl));
            }

            return(null);
        }