Ejemplo n.º 1
0
        public NavigableTreeNode(Node node, string referenceParentPath, string currentPath)
        {
            NodeType = node.NodeType.Name;

            var content = node as GenericContent;

            if (content != null)
            {
                this.Name     = content.DisplayName;
                this.IsHidden = content.Hidden;
            }
            else
            {
                this.Name = node.Name;
            }

            var page = node as SNP.Page;

            if (page != null)
            {
                this.IsExternal = page.GetProperty <int>("IsExternal") != 0;
                this.Url        = IsExternal ? Convert.ToString(page["OuterUrl"]) : page.Path.Replace(referenceParentPath, string.Empty);
            }
            else
            {
                this.Url = node.Path.Replace(referenceParentPath, string.Empty);
            }

            this.Index       = node.Index;
            this.IsCurrent   = node.Path == currentPath;
            this.IsTraversal = RepositoryPath.IsInTree(currentPath, node.Path) && !IsCurrent;
        }
Ejemplo n.º 2
0
        public NavigableTreeNode(Node node, string referenceParentPath, string currentPath)
        {
            NodeType = node.NodeType.Name;
            Content content;

            // elevation: we need to access the Hidden field here, which
            // is not accessible for users with only See permission
            using (new SystemAccount())
            {
                content = Content.Load(node.Id);
            }

            this.Name = content.DisplayName;

            var genericContent = content.ContentHandler as GenericContent;

            if (genericContent != null)
            {
                this.IsHidden = genericContent.Hidden;
            }

            var page        = content.ContentHandler as Page;
            var contentLink = content.ContentHandler as ContentLink;
            var isOuterLink = content.ContentType.IsInstaceOfOrDerivedFrom("Link");

            if (page != null)
            {
                this.IsExternal = page.GetProperty <int>("IsExternal") != 0;
                this.Url        = IsExternal ? Convert.ToString(page["OuterUrl"]) : page.Path.Replace(referenceParentPath, string.Empty);
            }
            else if (contentLink != null)
            {
                if (contentLink.GetReference <Node>("Link") != null)
                {
                    this.Url = contentLink.GetReference <Node>("Link").Path;
                }
                else
                {
                    this.Url = node.Path.Replace(referenceParentPath, string.Empty);
                }
            }
            else if (isOuterLink)
            {
                this.Url = content["Url"] as String;
            }
            else
            {
                this.Url = node.Path.Replace(referenceParentPath, string.Empty);
            }

            this.Index       = node.Index;
            this.IsCurrent   = node.Path == currentPath;
            this.IsTraversal = RepositoryPath.IsInTree(currentPath, node.Path) && !IsCurrent;
        }