示例#1
0
        private IEnumerable <BreadcrumbItem> GetHierarchy(TreeNode current, bool addSiteLink, bool showContainers, ref ICollection <string> cacheDependencies)
        {
            // Add current page
            var ret = new List <BreadcrumbItem>();

            ret.Add(new BreadcrumbItem()
            {
                Name          = current.DocumentName,
                Url           = null,
                IsCurrentPage = true
            });
            cacheDependencies.Add($"documentid|{current.DocumentID}");

            // Get all pages on current page path
            var pages = pageRetriever.RetrieveMultiple(query =>
                                                       query.Where(TreePathUtils.GetNodesOnPathWhereCondition(current.NodeAliasPath, false, false))
                                                       );

            // Add current page's parents in loop
            var nodeLevel = current.NodeLevel - 1;

            while (nodeLevel > 0)
            {
                var parent = pages.Where(p => p.NodeLevel == nodeLevel).FirstOrDefault();
                var type   = DataClassInfoProvider.GetDataClassInfo(parent.ClassName);
                if (type != null)
                {
                    if (type.ClassIsCoupledClass ||
                        !type.ClassIsCoupledClass && showContainers)
                    {
                        var url = pageUrlRetriever.Retrieve(parent).AbsoluteUrl;
                        ret.Add(new BreadcrumbItem()
                        {
                            Name = parent.DocumentName,
                            Url  = url
                        });
                    }
                }
                cacheDependencies.Add($"documentid|{current.DocumentID}");

                nodeLevel--;
            }

            // Add link to main domain if needed
            if (addSiteLink)
            {
                ret.Add(new BreadcrumbItem()
                {
                    IsSiteLink = true,
                    Name       = current.Site.DisplayName,
                    Url        = current.Site.SitePresentationURL
                });
                cacheDependencies.Add($"cms.site|byid|{current.Site.SiteID}");
            }

            ret.Reverse();
            return(ret);
        }
示例#2
0
        public int GetDocumentIDByNode(string Path, string Culture = null, string SiteName = null)
        {
            Culture  = !string.IsNullOrWhiteSpace(Culture) ? Culture : System.Globalization.CultureInfo.CurrentCulture.Name;
            SiteName = !string.IsNullOrWhiteSpace(SiteName) ? SiteName : SiteContext.CurrentSiteName;
            var Page =
                pageRetriever.RetrieveMultiple(query =>
                                               query.Path(Path, PathTypeEnum.Single)
                                               .Culture(Culture)
                                               .CombineWithDefaultCulture()
                                               .CombineWithAnyCulture()
                                               .OnSite(SiteName)
                                               .Published(false)
                                               , cache =>
                                               cache.Key($"GetDocumentIDByNode|{Path}|{Culture}|{SiteName}")
                                               .Dependencies((pages, deps) => deps.Pages(pages))
                                               ).FirstOrDefault();

            return(Page != null ? Page.DocumentID : 0);
        }
    public static int GetDocumentIDByDocument(this HtmlHelper helper, Guid DocumentGuid)
    {
        IPageRetriever pageRetriever = DependencyResolver.Current.GetService <IPageRetriever>();
        var            Page          =
            pageRetriever.RetrieveMultiple(query =>
                                           query.WhereEquals(nameof(TreeNode.DocumentGUID), DocumentGuid)
                                           .Published(false)
                                           .Columns(nameof(TreeNode.DocumentID))
                                           , cache =>
                                           cache.Key($"GetDocumentIDByDocument|{DocumentGuid}")
                                           .Dependencies((pages, deps) => deps.Pages(pages))
                                           ).FirstOrDefault();

        return(Page != null ? Page.DocumentID : 0);
    }
    public static HtmlString PartialWidgetPageAjax(this HtmlHelper helper, int DocumentID)
    {
        IPageRetriever pageRetriever = DependencyResolver.Current.GetService <IPageRetriever>();
        string         Url           = string.Empty;
        var            Page          = pageRetriever.RetrieveMultiple(query =>
                                                                      query.WhereEquals(nameof(TreeNode.DocumentID), DocumentID)
                                                                      .Published(false)
                                                                      , cache =>
                                                                      cache.Key($"PartialWidgetPageAjaxTagHelperGetDocument|{DocumentID}")
                                                                      .Dependencies((pages, deps) => deps.Pages(pages))
                                                                      ).FirstOrDefault();

        if (Page != null)
        {
            Url = DocumentURLProvider.GetUrl(Page);
        }
        return(PartialWidgetPageAjax(Url));
    }
    public static int GetDocumentIDByNode(this HtmlHelper helper, int NodeID, string Culture = null)
    {
        IPageRetriever pageRetriever = DependencyResolver.Current.GetService <IPageRetriever>();
        var            Page          =
            pageRetriever.RetrieveMultiple(query =>
                                           query.WhereEquals(nameof(TreeNode.NodeID), NodeID)
                                           .Culture(Culture)
                                           .CombineWithDefaultCulture()
                                           .CombineWithAnyCulture()
                                           .Published(false)
                                           .Columns(nameof(TreeNode.DocumentID))
                                           , cache =>
                                           cache.Key($"GetDocumentIDByNode|{NodeID}|{Culture}")
                                           .Dependencies((pages, deps) => deps.Pages(pages))
                                           ).FirstOrDefault();

        return(Page != null ? Page.DocumentID : 0);
    }
    public static int GetDocumentIDByNode(this HtmlHelper helper, Guid NodeGuid, string Culture = null)
    {
        IPageRetriever pageRetriever = DependencyResolver.Current.GetService <IPageRetriever>();

        Culture = !string.IsNullOrWhiteSpace(Culture) ? Culture : System.Globalization.CultureInfo.CurrentCulture.Name;
        var Page =
            pageRetriever.RetrieveMultiple(query =>
                                           query.WhereEquals(nameof(TreeNode.NodeGUID), NodeGuid)
                                           .Culture(Culture)
                                           .CombineWithDefaultCulture()
                                           .CombineWithAnyCulture()
                                           .Published(false)
                                           .Columns(nameof(TreeNode.DocumentID))
                                           , cache =>
                                           cache.Key($"GetDocumentIDByNode|{NodeGuid}|{Culture}")
                                           .Dependencies((pages, deps) => deps.Pages(pages))
                                           ).FirstOrDefault();

        return(Page != null ? Page.DocumentID : 0);
    }