Esempio n. 1
0
	protected override void Clear ()
	{
		lock (rootNodeLock) {
			rootNode = null;
			base.Clear ();
		}
	}
Esempio n. 2
0
        private static IHtmlElement CreateBreadcrumpNode(SiteMapNode siteMapNode, Predicate<IHtmlElement> isLastCondition)
        {
            var wrapper = new HtmlElement("li")
                .AddCssClass("toolbar-menu-item")
                .ToggleCssClass("toolbar-menu-current", element => ReferenceEquals(siteMapNode, System.Web.SiteMap.CurrentNode));

            var url = String.IsNullOrEmpty(siteMapNode.Url)
                          ? "javascript:void(0);"
                          : VirtualPathUtility.ToAbsolute(siteMapNode.Url);
            var anchor = new HtmlElement("a", TagRenderMode.Normal)
                .Attribute("href", url)
                .Attribute("title", siteMapNode.Description)
                .ToggleCssClass("home", element => ReferenceEquals(siteMapNode, System.Web.SiteMap.RootNode))
                .ToggleCssClass("last", isLastCondition)
                .AppendTo(wrapper);

            if (String.IsNullOrEmpty(siteMapNode.Title))
            {
                anchor.Html("&nbsp;");
            }
            else
            {
                anchor.Text(siteMapNode.Title);
            }

            return wrapper;
        }
        public bool IsVisible(SiteMapNode node, HttpContext context, IDictionary<string, object> sourceMetadata)
        {
            bool returnMe = false;
            var mvcNode = node as MvcSiteMapNode;
            Models.User user = context.Session["CurrentUser"] as Models.User;
            string visibilitySettings = mvcNode == null ? "" : mvcNode["requireLoggedIn"];
            string roleSettings = mvcNode == null ? "" : mvcNode["customRoles"];
            string[] allowedRoles = (roleSettings ?? "").Split(',').Select(x => x.Trim()).ToArray();
            List<string> currentRoles = new List<string>();
            if (user != null && user.Roles != null)
                currentRoles = user.Roles.Select(x => x.Name).ToList();

            if (visibilitySettings == "true" && user == null)
            {
                returnMe = false;
            }
            else
            {
                if (allowedRoles.Contains("*"))
                {
                    returnMe = true;
                }
                else if (allowedRoles.Intersect(currentRoles).Any())
                {
                    returnMe = true;
                }
                else
                {
                    returnMe = false;
                }
            }

            return returnMe;
        }
        public static string BuildForStore(MerchantTribeApplication app)
        {
            if (app == null) return string.Empty;

            string root = app.CurrentStore.RootUrl();
            SiteMapNode rootNode = new SiteMapNode();

            // home
            rootNode.AddUrl(root);
            // sitemap
            rootNode.AddUrl(root + "sitemap");

            // Categories
            foreach (Catalog.CategorySnapshot cat in app.CatalogServices.Categories.FindAll())
            {
                string caturl = Utilities.UrlRewriter.BuildUrlForCategory(cat, app.CurrentRequestContext.RoutingContext);
                rootNode.AddUrl(root.TrimEnd('/') + caturl);
            }

            // Products
            foreach (Catalog.Product p in app.CatalogServices.Products.FindAllPaged(1,3000))
            {
                string produrl = Utilities.UrlRewriter.BuildUrlForProduct(p, app.CurrentRequestContext.RoutingContext, string.Empty);
                rootNode.AddUrl(root.TrimEnd('/') + produrl);
            }
            return rootNode.RenderAsXmlSiteMap();
        }
        /// <summary>
        /// Determines whether node is accessible to user.
        /// </summary>
        /// <param name="controllerTypeResolver">The controller type resolver.</param>
        /// <param name="provider">The provider.</param>
        /// <param name="context">The context.</param>
        /// <param name="node">The node.</param>
        /// <returns>
        /// 	<c>true</c> if accessible to user; otherwise, <c>false</c>.
        /// </returns>
        public virtual bool IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, DefaultSiteMapProvider provider, HttpContext context, SiteMapNode node)
        {
            // Is security trimming enabled?
            if (!provider.SecurityTrimmingEnabled)
            {
                return true;
            }

            // Use child modules
            bool result = true;
            foreach (var module in ChildModules)
            {
                try
                {
                    result &= module.IsAccessibleToUser(controllerTypeResolver, provider, context, node);
                }
                catch (AclModuleNotSupportedException)
                {
                    result &= true; // Convention throughout the provider: if the IAclModule can not authenticate a user, true is returned.
                }
                if (result == false)
                {
                    return false;
                }
            }

            // Return
            return result;
        }
Esempio n. 6
0
        public static string BuildForStore(MerchantTribeApplication app)
        {
            if (app == null) return string.Empty;

            string root = app.CurrentStore.RootUrl();
            SiteMapNode rootNode = new SiteMapNode();
            
            // home
            rootNode.AddUrl(root);
            // sitemap
            rootNode.AddUrl(root + "sitemap");

            // Categories
            foreach (Catalog.CategorySnapshot cat in app.CatalogServices.Categories.FindAll())
            {                
                string caturl = Utilities.UrlRewriter.BuildUrlForCategory(cat, app.CurrentRequestContext.RoutingContext);
                
                // Skip Pages with Outbound links as they aren't supported in sitemap format
                string temp = caturl.ToUpperInvariant();
                if (temp.StartsWith("HTTP:") || temp.StartsWith("HTTPS:")) continue;

                rootNode.AddUrl(root.TrimEnd('/') + caturl);
            }

            // Products
            foreach (Catalog.Product p in app.CatalogServices.Products.FindAllPaged(1,3000))
            {
                string produrl = Utilities.UrlRewriter.BuildUrlForProduct(p, app.CurrentRequestContext.RoutingContext, string.Empty);
                rootNode.AddUrl(root.TrimEnd('/') + produrl);
            }
            return rootNode.RenderAsXmlSiteMap();                        
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="XmlSiteMapResult"/> class.
 /// </summary>
 /// <param name="rootNode">The root node.</param>
 /// <param name="url">The base URL.</param>
 /// <param name="siteMapUrlTemplate">The site map URL template.</param>
 public XmlSiteMapResult(SiteMapNode rootNode, string url, string siteMapUrlTemplate)
 {
     Ns = "http://www.sitemaps.org/schemas/sitemap/0.9";
     RootNode = rootNode;
     Url = url;
     SiteMapUrlTemplate = siteMapUrlTemplate;
 }
Esempio n. 8
0
        private static string Generate(RequestContext requestContext, SiteMapNode navigationItem, RouteValueDictionary routeValues)
        {
            Check.Argument.IsNotNull(requestContext, "requestContext");
            Check.Argument.IsNotNull(navigationItem, "navigationItem");

            var urlHelper = new UrlHelper(requestContext);
            string generatedUrl = null;

            if (!string.IsNullOrEmpty(navigationItem.RouteName))
            {
                generatedUrl = urlHelper.RouteUrl(navigationItem.RouteName, routeValues);
            }
            else if (!string.IsNullOrEmpty(navigationItem.ControllerName) && !string.IsNullOrEmpty(navigationItem.ActionName))
            {
                generatedUrl = urlHelper.Action(navigationItem.ActionName, navigationItem.ControllerName, routeValues, null, null);
            }
            else if (!string.IsNullOrEmpty(navigationItem.Url))
            {
                generatedUrl = navigationItem.Url.StartsWith("~/", StringComparison.Ordinal) ?
                               urlHelper.Content(navigationItem.Url) :
                               navigationItem.Url;
                //var rgx = new Regex(@"#.*$");
                //if(rgx.IsMatch(generatedUrl))
                //{
                //    generatedUrl = rgx.Match(generatedUrl).Value;
                //}
            }
            else if (routeValues.Any())
            {
                generatedUrl = urlHelper.RouteUrl(routeValues);
            }

            return generatedUrl;
        }
    public void AddChildNodes(ref SiteMapNode parentNode, PageCollection links)
    {
        //you can change this as needed
        string rewrittenDirectory = "~/view/";
        foreach (Page link in links)
        {
            if (link.ParentID.HasValue)
            {
                if (link.ParentID.Value.ToString() == parentNode.Key)
                {
                    string url = link.PageUrl;
                    var rolelist = link.Roles.Split(new char[] { ',', ';' }, 512);
                    if (!url.Contains("registered/") & !url.Contains("admin/"))
                    {
                        url = rewrittenDirectory + url;
                    }
                    // Create a SiteMapNode
                    SiteMapNode node = new SiteMapNode(this, link.PageID.ToString(), url, link.MenuTitle, link.Summary, rolelist, null, null, null);
                    AddNode(node, parentNode);
                    AddChildNodes(ref node, links);
                }
            }

        }
    }
Esempio n. 10
0
        public bool IsVisible(SiteMapNode node, HttpContext context, IDictionary<string, object> sourceMetadata)
        {
            // Convert to MvcSiteMapNode
            var mvcNode = node as MvcSiteMapNode;
            if (mvcNode == null)
                return true;

            // Is visibility attribute specified?
            string visibility = mvcNode["visibility"];

            if (string.IsNullOrEmpty(visibility))
                return true;

            visibility = visibility.Trim();

            //Process visibility
            switch (visibility)
            {
                case "Auth":

                    return context.Request.IsAuthenticated;

                case "!Auth":

                    return !context.Request.IsAuthenticated;

                default:

                    return context.Request.IsAuthenticated && Roles.GetRolesForUser().Intersect(visibility.Split(',')).Count() > 0;
            }
        }
        protected virtual RouteData FindRoutesForNode(SiteMapNode node, HttpContextBase httpContext)
        {
            RouteData routeData = null;

            // create a uri for the current node.  If we have an absoluteURL,
            // it will be used instead of the baseUri
            var nodeUri = new Uri(httpContext.Request.Url, node.Url);

            // create textwriter with null stream, we don't want to output anything to it
            using (var nullWriter = new StreamWriter(Stream.Null))
            {
                // create a new http context using the node's URL instead of the current one.
                var nodeRequest = new HttpRequest(string.Empty, nodeUri.ToString(), nodeUri.Query);
                var nodeResponse = new HttpResponse(nullWriter);
                var nodeContext = new HttpContext(nodeRequest, nodeResponse);
                var nodeHttpContext = new HttpContextWrapper(nodeContext);

                var routes = RouteTable.Routes;
                //if(!string.IsNullOrEmpty(node.Route))
                //{
                //    routeData = routes[node.Route].GetRouteData(nodeHttpContext);
                //}
                //else
                //{
                routeData = routes.GetRouteData(nodeHttpContext);
                //}

                return routeData;
            }
        }
        /// <summary>
        /// Builds the model.
        /// </summary>
        /// <param name="helper">The helper.</param>
        /// <param name="startingNode">The starting node.</param>
        /// <returns>The model.</returns>
        private static SiteMapPathHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SiteMapNode startingNode)
        {
            // Build model
            var model = new SiteMapPathHelperModel();
            var node = startingNode;
            while (node != null)
            {
                var mvcNode = node as MvcSiteMapNode;

                // Check visibility
                bool nodeVisible = true;
                if (mvcNode != null)
                {
                    nodeVisible = mvcNode.VisibilityProvider.IsVisible(
                        node, HttpContext.Current, SourceMetadata);
                }

                // Check ACL
                if (nodeVisible && node.IsAccessibleToUser(HttpContext.Current))
                {
                    // Add node
                    var nodeToAdd = SiteMapNodeModelMapper.MapToSiteMapNodeModel(node, mvcNode, SourceMetadata);
                    model.Nodes.Add(nodeToAdd);
                }
                node = node.ParentNode;
            }
            model.Nodes.Reverse();

            return model;
        }
Esempio n. 13
0
        public void Test_Add_SubCategory_AutoCreateParent()
        {
            SiteMap siteMap = new SiteMap();
            siteMap.UrlCreator = new MockUrlCreator(this);

            // Create the sub node and add it
            SiteMapNode subNode = new SiteMapNode("Category/SubCategory", "SubNode", "TestAction", "TestType");

            // Add the sub node - it should be placed within the sub category
            siteMap.Add(subNode);

            Assert.IsNotNull(siteMap.ChildNodes, "Child nodes collection is null");

            Assert.AreEqual(1, siteMap.ChildNodes.Count, "Wrong number of nodes found.");

            Assert.AreEqual("Category", siteMap.ChildNodes[0].Title, "First level category title is incorrect.");

            Assert.IsNotNull(siteMap.ChildNodes[0].ChildNodes, "Second level child nodes collection is null");

            Assert.AreEqual(1, siteMap.ChildNodes[0].ChildNodes.Count, "Wrong number of second level nodes found.");

            Assert.AreEqual("SubCategory", siteMap.ChildNodes[0].ChildNodes[0].Title, "Second level category title is incorrect.");

            Assert.IsNotNull(siteMap.ChildNodes[0].ChildNodes[0].ChildNodes, "Third level child nodes collection is null");

            Assert.AreEqual(1, siteMap.ChildNodes[0].ChildNodes[0].ChildNodes.Count, "Wrong number of third level nodes found.");
        }
Esempio n. 14
0
        public void Test_Add_SubCategory()
        {
            SiteMap siteMap = new SiteMap();
            siteMap.UrlCreator = new MockUrlCreator(this);

            // Create the base node and add it
            SiteMapNode baseNode = new SiteMapNode("Category", "TestUrl");

            List<SiteMapNode> baseNodes = new List<SiteMapNode>();
            baseNodes.Add(baseNode);

            siteMap.ChildNodes = baseNodes;

            // Create the sub category node and add it
            SiteMapNode subCategoryNode = new SiteMapNode("Category", "SubCategory", "TestAction", "TestType");

            List<SiteMapNode> subCategoryNodes = new List<SiteMapNode>();
            subCategoryNodes.Add(subCategoryNode);

            baseNode.ChildNodes = subCategoryNodes;

            // Create the sub node and add it
            SiteMapNode subNode = new SiteMapNode("Category/SubCategory", "SubNode", "TestAction", "TestType");

            // Add the sub node - it should be placed within the sub category
            siteMap.Add(subNode);

            Assert.IsNotNull(subCategoryNode.ChildNodes, "Child nodes collection is null");

            Assert.AreEqual(1, subCategoryNode.ChildNodes.Count, "Wrong number of sub nodes found.");
        }
Esempio n. 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SiteMapBase"/> class.
        /// </summary>
        protected SiteMapBase()
        {
            CacheDurationInMinutes = DefaultCacheDurationInMinutes;
            Compress = DefaultCompress;
            GenerateSearchEngineMap = DefaultGenerateSearchEngineMap;

            RootNode = new SiteMapNode();
        }
Esempio n. 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        currentNode = SiteMap.CurrentNode;

        // See if we are viewing the home node
           // if (currentNode != null && currentNode.ParentNode == null)
           // liHome.Attributes["class"] = "highlight";
    }
Esempio n. 17
0
 protected override void Clear()
 {
     lock (this)
     {
       fRootNode = null;
       base.Clear();
     }
 }
 private bool IsModuleActive(SiteMapNode siteMapNode)
 {
     if (SiteMap.CurrentNode != null)
     {
         return SiteMap.CurrentNode.Equals(siteMapNode) || SiteMap.CurrentNode.IsDescendantOf(siteMapNode);
     }
     return false;
 }
        public SiteMapNodeBuilder Add()
        {
            SiteMapNode node = new SiteMapNode();

            parent.ChildNodes.Add(node);

            return new SiteMapNodeBuilder(node);
        }
Esempio n. 20
0
 /// <summary>
 /// Builds the model.
 /// </summary>
 /// <param name="helper">The helper.</param>
 /// <param name="startingNode">The starting node.</param>
 /// <returns>The model.</returns>
 private static SiteMapTitleHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SiteMapNode startingNode)
 {
     // Map to model
     var mvcNode = startingNode as MvcSiteMapNode;
     return new SiteMapTitleHelperModel
     {
         CurrentNode = SiteMapNodeModelMapper.MapToSiteMapNodeModel(startingNode, mvcNode, SourceMetadata)
     };
 }
Esempio n. 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NavigatorWidget"/> class.
 /// </summary>
 public NavigatorWidgetViewModel()
     : base()
 {
     if (!DesignMode.IsInDesignMode)
     {
         this.rootOption         = SiteMapService.SiteMap.RootNode;
         this.filteredFunctions  = new List<NavigationNode>();
         this.functions          = new ReadOnlyCollection<NavigationNode>(this.rootOption.ChildNodes.OfType<NavigationNode>().ToArray());
     }
 }
Esempio n. 22
0
 private SiteMapNode ModifyPath(object sender, SiteMapResolveEventArgs e)
 {
     // 克隆当前结点和父节点
     SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true);
     // 创建新节点
     SiteMapNode newNode = new SiteMapNode(e.Provider, "FAQ", "OthrePage.aspx", "FAQ");
     newNode.ParentNode = currentNode;
     currentNode = newNode;
     return currentNode;
 }
 private void RenderSiteMapNode(HtmlTextWriter writer, SiteMapPath path, SiteMapNode node)
 {
     writer.WriteBeginTag("a");
     if(node.Url != "")
         writer.WriteAttribute("href", node.Url);
     if (node.Description != "")
         writer.WriteAttribute("title", node.Description);
     writer.Write(HtmlTextWriter.TagRightChar);
     writer.Write(node.Title);
     writer.WriteEndTag("a");
 }
Esempio n. 24
0
 private MenuItemData GenerateMenuItemFromSiteMapNode(ActionExecutingContext filterContext, MvcSiteMapNode node, SiteMapNode currentNode, UrlHelper urlHelper)
 {
     // HACK: it's possible that we have a querystring ?container=true. This is required when for a top-level
     // menu item with the same action and controller as one of the children. Leaving the parameter out causes the
     // sitemapprovider to crash because it doesn't allow duplicate url's.
     string url = node.Url.Replace("?container=true", String.Empty);
     return new MenuItemData(VirtualPathUtility.ToAbsolute(url)
                             , GlobalResources.ResourceManager.GetString(node.ResourceKey, Thread.CurrentThread.CurrentUICulture)
                             , CheckInPath(node, currentNode, filterContext.RouteData)
                             , node.Icon != null ? urlHelper.Content("~/manager/Content/images/" + node.Icon) : null);
 }
Esempio n. 25
0
        private static string Generate(RequestContext requestContext, SiteMapNode navigationItem)
        {
            var routeValues = new RouteValueDictionary();

            if (navigationItem.RouteValues.Any())
            {
                routeValues.Merge(navigationItem.RouteValues);
            }

            return Generate(requestContext, navigationItem, routeValues);
        }
Esempio n. 26
0
	public override SiteMapNode BuildSiteMap ()
	{
		lock (rootNodeLock) {
			if (rootNode == null) {
				rootNode = new SiteMapNode (this, "DynamicRoot", String.Empty, "Dynamic");
				Populate ();
				AddNode (rootNode);
			}
			return rootNode;
		}
	}
 protected void rptMenu_ItemCreated(object sender, RepeaterItemEventArgs e)
 {
     if ((e.Item.ItemType != ListItemType.Separator) && (!IsPostBack))
     {
         SiteMapNode nodeInfo = new SiteMapNode(srcSiteMap.Provider, SiteMap.CurrentNode.ResourceKey);
         nodeInfo.Url = ((SiteMapNode)e.Item.DataItem).Url;
         nodeInfo.Description = (Request.FilePath == ((SiteMapNode)e.Item.DataItem).Url) || (SiteMap.CurrentNode.ParentNode.Url == ((SiteMapNode)e.Item.DataItem).Url) ? "activeItem" : "";
         if(((SiteMapNode)e.Item.DataItem).ResourceKey == "Login") nodeInfo.Description = "hide";
         nodeInfo.Title = ((SiteMapNode)e.Item.DataItem).Title;
         e.Item.DataItem = nodeInfo;
     }
 }
Esempio n. 28
0
        public bool IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, DefaultSiteMapProvider provider, HttpContext context, SiteMapNode node)
        {
            Ensure.ThatTypeFor(() => node).IsOfType<MvcSiteMapNode>();

            HttpContextBase contextBase = context.Wrap();
            MvcSiteMapNode mvc = (MvcSiteMapNode)node;
            string controller = mvc.Controller;
            string action = mvc.Action;

            bool accessible = IsActionAccessibleToUser(controllerTypeResolver, contextBase, controller, action);
            return accessible;
        }
        private void ResolveUrl(SiteMapNode rootNode)
        {
            rootNode.Url = rootNode.ResolveUrl();

            if (rootNode.HasChildNodes)
            {
                foreach (var node in rootNode.ChildNodes)
                {
                    ResolveUrl(node);
                }
            }
        }
Esempio n. 30
0
 /// <summary>
 /// 添加一个面板
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="node"></param>
 private static void AppendPanel(StringBuilder builder, SiteMapNode node)
 {
     builder.AppendFormat("{{title:'{0}',", node.Title);
     if (!string.IsNullOrEmpty(node.Description))
     {
         builder.AppendFormat("tabTip:'{0}',", node.Description);
     }
     // builder.Append("lines:false,rootVisible:true,root:");
     builder.Append("lines:false,rootVisible:false,root:");
     AppendTreeNode(builder, node);
     builder.Append("}");
 }
Esempio n. 31
0
 public CustomNodeViewModel(SiteMapNode node, string url, string target, bool isCurrentlyOpened, bool hasChildOpen)
     : base(node, url, target, isCurrentlyOpened, hasChildOpen)
 {
     this.description = this.GetDescription();
     this.image       = this.GetImage();
 }
Esempio n. 32
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sfContent">The sf content.</param>
        public PageModel(SiteMapNode sfContent)
        {
            Items = new List <PageModel>();

            OriginalContent = sfContent;
        }
        /// <summary>
        /// Builds the model.
        /// </summary>
        /// <param name="helper">The helper.</param>
        /// <param name="startingNode">The starting node.</param>
        /// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param>
        /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param>
        /// <param name="maxDepth">The max depth.</param>
        /// <param name="drillDownToCurrent">Should the model exceed the maxDepth to reach the current node</param>
        /// <returns>The model.</returns>
        private static MenuHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth, bool drillDownToCurrent)
        {
            // Build model
            var model = new MenuHelperModel();
            var node  = startingNode;

            // Check if a starting node has been given
            if (node == null)
            {
                return(model);
            }

            var  mvcNode          = node as MvcSiteMapNode;
            bool continueBuilding = ReachedMaximalNodelevel(maxDepth, node, drillDownToCurrent);

            // Check if maximal node level has not been reached
            if (!continueBuilding)
            {
                return(model);
            }

            // Check visibility
            bool nodeVisible = true;

            if (mvcNode != null)
            {
                nodeVisible = mvcNode.VisibilityProvider.IsVisible(
                    node, HttpContext.Current, SourceMetadata);
            }

            // Check ACL
            if (node.IsAccessibleToUser(HttpContext.Current))
            {
                // Add node?
                var nodeToAdd = SiteMapNodeModelMapper.MapToSiteMapNodeModel(node, mvcNode, SourceMetadata);
                if (nodeVisible)
                {
                    if (showStartingNode || !startingNodeInChildLevel)
                    {
                        model.Nodes.Add(nodeToAdd);
                    }
                }

                // Add child nodes
                if (node.HasChildNodes)
                {
                    foreach (SiteMapNode childNode in node.ChildNodes)
                    {
                        var childNodes = BuildModel(helper, childNode, false, true, maxDepth - 1, drillDownToCurrent).Nodes;
                        foreach (var childNodeToAdd in childNodes)
                        {
                            if (!startingNodeInChildLevel)
                            {
                                nodeToAdd.Children.Add(childNodeToAdd);
                            }
                            else
                            {
                                model.Nodes.Add(childNodeToAdd);
                            }
                        }
                    }
                }
            }

            return(model);
        }
Esempio n. 34
0
        public override SiteMapNode BuildSiteMap()
        {
            lock (this)
            {
                if (rootNode != null)
                {
                    return(rootNode);
                }

                menuPages = CacheHelper.GetMenuPages();
                int depth = 0;
                if (menuPages != null)
                {
                    rootNode = CreateRootNode();
                    //int i = 0;
                    foreach (PageSettings page in menuPages)
                    {
                        if (page.ParentId <= -1)
                        {
                            SiteMapNode node = CreateSiteMapNode(page, depth);

                            try
                            {
                                AddNode(node, GetParentNode(page));
                            }
                            catch (InvalidOperationException ex)
                            {
                                log.Error("failed to add node to sitemap", ex);
                            }
                            catch (HttpException ex)
                            {
                                log.Error("failed to add node to sitemap", ex);
                            }

                            if ((page.UseUrl) && (page.Url.StartsWith("http")))
                            {
                                node.Url = page.Url;
                            }
                        }

                        // i += 1;
                    }
                }
            }

            string cacheKey = CacheHelper.GetSiteMapCacheKey();

            CacheDependency cacheDependency = CacheHelper.GetSiteMapCacheDependency();

            // the site map is cached by the runtime (not in our direct control) so we are caching a simple object and when that object is invalidated
            // we clear the sitemap with the callback event and then it is rebuilt and cached again
            HttpRuntime.Cache.Insert(
                cacheKey,
                new object(),
                cacheDependency,
                Cache.NoAbsoluteExpiration,
                Cache.NoSlidingExpiration,
                CacheItemPriority.Normal,
                new CacheItemRemovedCallback(OnSiteMapChanged));

            return(rootNode);
        }
 /// <summary>
 /// Build a menu, based on the MvcSiteMap
 /// </summary>
 /// <param name="helper">The helper.</param>
 /// <param name="startingNode">The starting node.</param>
 /// <param name="startingNodeInChildLevel">Show starting node in child level if set to <c>true</c>.</param>
 /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param>
 /// <param name="maxDepth">The max depth.</param>
 /// <param name="drillDownToContent">if set to <c>true</c> [drill down to content].</param>
 /// <returns>Html markup</returns>
 public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, SiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth, bool drillDownToContent)
 {
     return(Menu(helper, null, startingNode, startingNodeInChildLevel, showStartingNode, maxDepth, drillDownToContent));
 }
Esempio n. 36
0
        private SiteMapNodeCollection GetNodes()
        {
            SiteMapNode currentNode        = null;
            int         startingNodeOffset = this.StartingNodeOffset;

            if (!string.IsNullOrEmpty(this.StartingNodeUrl) && this.StartFromCurrentNode)
            {
                throw new InvalidOperationException(System.Web.SR.GetString("SiteMapDataSource_StartingNodeUrlAndStartFromcurrentNode_Defined"));
            }
            if (this.StartFromCurrentNode)
            {
                currentNode = this.Provider.CurrentNode;
            }
            else if (!string.IsNullOrEmpty(this.StartingNodeUrl))
            {
                currentNode = this.Provider.FindSiteMapNode(this.MakeUrlAbsolute(this.StartingNodeUrl));
                if (currentNode == null)
                {
                    throw new ArgumentException(System.Web.SR.GetString("SiteMapPath_CannotFindUrl", new object[] { this.StartingNodeUrl }));
                }
            }
            else
            {
                currentNode = this.Provider.RootNode;
            }
            if (currentNode == null)
            {
                return(null);
            }
            if (startingNodeOffset <= 0)
            {
                if (startingNodeOffset != 0)
                {
                    this.Provider.HintNeighborhoodNodes(currentNode, Math.Abs(startingNodeOffset), 0);
                    SiteMapNode parentNode = currentNode.ParentNode;
                    while ((startingNodeOffset < 0) && (parentNode != null))
                    {
                        currentNode = currentNode.ParentNode;
                        parentNode  = currentNode.ParentNode;
                        startingNodeOffset++;
                    }
                }
                return(this.GetNodes(currentNode));
            }
            SiteMapNode currentNodeAndHintAncestorNodes = this.Provider.GetCurrentNodeAndHintAncestorNodes(-1);

            if (((currentNodeAndHintAncestorNodes == null) || !currentNodeAndHintAncestorNodes.IsDescendantOf(currentNode)) || currentNodeAndHintAncestorNodes.Equals(currentNode))
            {
                return(null);
            }
            SiteMapNode node4 = currentNodeAndHintAncestorNodes;

            for (int i = 0; i < startingNodeOffset; i++)
            {
                node4 = node4.ParentNode;
                if ((node4 == null) || node4.Equals(currentNode))
                {
                    return(this.GetNodes(currentNodeAndHintAncestorNodes));
                }
            }
            SiteMapNode node5 = currentNodeAndHintAncestorNodes;

            while ((node4 != null) && !node4.Equals(currentNode))
            {
                node5 = node5.ParentNode;
                node4 = node4.ParentNode;
            }
            return(this.GetNodes(node5));
        }
        /// <summary>
        /// Build a menu, based on the MvcSiteMap
        /// </summary>
        /// <param name="helper">The helper.</param>
        /// <param name="templateName">Name of the template.</param>
        /// <param name="startingNode">The starting node.</param>
        /// <param name="startingNodeInChildLevel">Show starting node in child level if set to <c>true</c>.</param>
        /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param>
        /// <param name="maxDepth">The max depth.</param>
        /// <param name="drillDownToCurrent">Should the model exceed the maxDepth to reach the current node</param>
        /// <returns>Html markup</returns>
        public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, string templateName, SiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth, bool drillDownToCurrent)
        {
            var model = BuildModel(helper, startingNode, startingNodeInChildLevel, showStartingNode, maxDepth, drillDownToCurrent);

            return(helper
                   .CreateHtmlHelperForModel(model)
                   .DisplayFor(m => model, templateName));
        }
Esempio n. 38
0
    private void crearMenu(SiteMapNode stMp, int level, HtmlGenericControl parentControl)
    {
        if (level == -1)
        {
            foreach (SiteMapNode smN in stMp.ChildNodes)
            {
                if (accesso(smN))
                {
                    crearMenu(smN, 0, parentControl);
                }
            }
        }
        else if (stMp.Title != "Home")//Cuando se cumplen ciertas circunstancias y no queremos pintar alguna opción
        {
            HtmlGenericControl lisItem = new HtmlGenericControl("li");
            lisItem.Attributes.Add("data-name", stMp.Title);

            HtmlAnchor         enlace   = new HtmlAnchor();
            HtmlGenericControl spanText = new HtmlGenericControl("span");
            enlace.HRef        = stMp.Url;
            spanText.InnerText = stMp.Title;
            string lisItemClass = "dropdown-submenu";
            if (stMp.ResourceKey != null)//Se usa este campo "ResourceKey" para pintar icono
            {
                enlace.Attributes.Add("class", "dropdown-toggle");
                enlace.Attributes.Add("data-toggle", "dropdown");

                //enlace.Attributes.Add("data-name", stMp.Title);

                //todo revisar
                enlace.HRef = "#";
                HtmlGenericControl span = new HtmlGenericControl("span");
                span.Attributes.Add("class", stMp.ResourceKey);
                enlace.Controls.Add(span);
                lisItemClass = "dropdown";
            }
            enlace.Controls.Add(spanText);

            if (stMp.HasChildNodes)
            {
                lisItem.Attributes.Add("class", lisItemClass);
                if (level == 0)
                {
                    HtmlGenericControl b = new HtmlGenericControl("b");
                    b.Attributes.Add("class", "caret");
                    enlace.Controls.Add(b);
                }
                HtmlGenericControl lisSubItem = new HtmlGenericControl("ul");
                lisSubItem.Attributes.Add("class", "dropdown-menu");
                foreach (SiteMapNode stMpChild in stMp.ChildNodes)
                {
                    if (accesso(stMpChild))
                    {
                        crearMenu(stMpChild, level + 1, lisSubItem);
                    }
                }
                lisItem.Controls.Add(lisSubItem);
            }
            lisItem.Controls.AddAt(0, enlace);
            parentControl.Controls.Add(lisItem);
            if ((stMp.Title == "Evaluaciones de mi equipo" || stMp.Title == "Confirmar mi equipo" || stMp.Title == "Gestionar entradas a mi equipo" || stMp.Title == "Gestionar solicitudes de cambio de rol" || stMp.Title == "Completar evaluaciones abiertas") && Roles.GetRolesForUser().Contains("PEVA"))  //Si es evaluador, en estas opciones se pinta la raya inferior(divider)
            {
                HtmlGenericControl divider = new HtmlGenericControl("div");
                divider.Attributes.Add("class", "divider");
                parentControl.Controls.Add(divider);
            }

            if ((stMp.Title == "Gestionar cambio de responsable" || stMp.Title == "Mantenimiento de maestros"))
            {
                HtmlGenericControl divider = new HtmlGenericControl("div");
                divider.Attributes.Add("class", "divider");
                parentControl.Controls.Add(divider);
            }

            if ((stMp.Title == "Competencias y roles"))
            {
                HtmlGenericControl divider = new HtmlGenericControl("div");
                divider.Attributes.Add("class", "divider");
                parentControl.Controls.Add(divider);
            }

            if ((stMp.Title == "Reconexión"))
            {
                HtmlGenericControl divider = new HtmlGenericControl("div");
                divider.Attributes.Add("class", "divider");
                parentControl.Controls.Add(divider);
            }
        }
    }
Esempio n. 39
0
    protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)
    {
        if (!Page.IsCallback)
        {
            System.Web.UI.WebControls.Menu menu = (System.Web.UI.WebControls.Menu)sender;
            SiteMapNode mapNode = (SiteMapNode)e.Item.DataItem;

            bool bEsMiembro = false;

            foreach (string RolMenu in mapNode.Roles)
            {
                //bEsMiembro = true;
                //if (HttpContext.Current.User.IsInRole("A"))
                //{
                //    bEsMiembro = true;
                //    break;
                //}
                if (RolMenu == "*")
                {
                    //if (mapNode.Title == "Reconexión" && Session["Admin"].ToString() != "A")
                    //    bEsMiembro = false;
                    //else
                    bEsMiembro = true;
                    break;
                }
                string RolMenuAux = RolMenu.Trim();
                if (RolMenuAux != "")
                {
                    foreach (string MiRol in ((RolePrincipal)Page.User).GetRoles())
                    {
                        if (RolMenu == MiRol)
                        {
                            bEsMiembro = true;
                            break;
                        }
                    }
                }
                if (bEsMiembro)
                {
                    break;
                }
            }

            if (!bEsMiembro)
            {
                System.Web.UI.WebControls.MenuItem itemToRemove = menu.FindItem(mapNode.Title);

                if (e.Item.Depth == 0)
                {
                    menu.Items.Remove(e.Item);
                }
                else
                {
                    System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                    if (parent != null)
                    {
                        parent.ChildItems.Remove(e.Item);
                    }
                }
            }
        }
    }
 public SiteMapHierarchicalDataSourceView(SiteMapNode node)
 {
     _collection = new SiteMapNodeCollection(node);
 }
        /// <summary>
        /// Build a menu, based on the MvcSiteMap
        /// </summary>
        /// <param name="helper">The helper.</param>
        /// <param name="startFromCurrentNode">Start from current node if set to <c>true</c>.</param>
        /// <param name="startingNodeInChildLevel">Show starting node in child level if set to <c>true</c>.</param>
        /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param>
        /// <returns>Html markup</returns>
        public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, bool startFromCurrentNode, bool startingNodeInChildLevel, bool showStartingNode)
        {
            SiteMapNode startingNode = startFromCurrentNode ? GetCurrentNode(helper.Provider) : helper.Provider.RootNode;

            return(Menu(helper, startingNode, startingNodeInChildLevel, showStartingNode, Int32.MaxValue, false));
        }
 /// <summary>
 /// Build a menu, based on the MvcSiteMap
 /// </summary>
 /// <param name="helper">The helper.</param>
 /// <param name="startingNode">The starting node.</param>
 /// <param name="startingNodeInChildLevel">Show starting node in child level if set to <c>true</c>.</param>
 /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param>
 /// <returns>Html markup</returns>
 public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, SiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode)
 {
     return(Menu(helper, startingNode, startingNodeInChildLevel, showStartingNode, Int32.MaxValue, false));
 }
 /// <summary>
 /// Exposes the AddChildNodes for testing purposes.
 /// </summary>
 /// <param name="node">The node.</param>
 /// <param name="addParent">if set to <c>true</c> adds the parent node.</param>
 public void PublicAddChildNodes(SiteMapNode node, bool addParent)
 {
     this.AddChildNodes(node, addParent);
 }
 /// <summary>
 /// Builds the model.
 /// </summary>
 /// <param name="helper">The helper.</param>
 /// <param name="startingNode">The starting node.</param>
 /// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param>
 /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param>
 /// <param name="maxDepth">The max depth.</param>
 /// <returns>The model.</returns>
 private static MenuHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth)
 {
     return(BuildModel(helper, startingNode, startingNodeInChildLevel, showStartingNode, maxDepth, false));
 }
Esempio n. 45
0
 public void DoAddNode(SiteMapNode node)
 {
     base.AddNode(node);
 }
Esempio n. 46
0
 public void DoRemoveNode(SiteMapNode node)
 {
     base.RemoveNode(node);
 }
Esempio n. 47
0
        protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)
        {
            System.Web.UI.WebControls.Menu menu = (System.Web.UI.WebControls.Menu)sender;
            SiteMapNode mapNode = (SiteMapNode)e.Item.DataItem;

            System.Web.UI.WebControls.MenuItem itemToRemove = menu.FindItem(mapNode.Title);
            if (NombreUsr.Text != "SuperAdmin")
            {
                if (this.Entity.TiposUsuario.ToString() == "Alumno")
                {
                    if (mapNode.Title == "AlumnoInscripcion")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            e.Item.Text = "Mis Cursos";
                        }
                    }

                    if (mapNode.Title == "Usuarios")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            parent.ChildItems.Remove(e.Item);
                        }
                    }
                    if (mapNode.Title == "Especialidades")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            parent.ChildItems.Remove(e.Item);
                        }
                    }
                    if (mapNode.Title == "Planes")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            parent.ChildItems.Remove(e.Item);
                        }
                    }
                    if (mapNode.Title == "Materias")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            parent.ChildItems.Remove(e.Item);
                        }
                    }
                    if (mapNode.Title == "Comisiones")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            parent.ChildItems.Remove(e.Item);
                        }
                    }
                    if (mapNode.Title == "DocenteCurso")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            parent.ChildItems.Remove(e.Item);
                        }
                    }
                    if (mapNode.Title == "Cursos")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            parent.ChildItems.Remove(e.Item);
                        }
                    }
                }
                if (this.Entity.TiposUsuario.ToString() == "Docente")
                {
                    if (mapNode.Title == "DocenteCurso")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            e.Item.Text = "Mis cursos";
                        }
                    }
                    if (mapNode.Title == "Usuarios")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            parent.ChildItems.Remove(e.Item);
                        }
                    }
                    if (mapNode.Title == "Especialidades")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            parent.ChildItems.Remove(e.Item);
                        }
                    }
                    if (mapNode.Title == "Planes")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            parent.ChildItems.Remove(e.Item);
                        }
                    }
                    if (mapNode.Title == "Materias")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            parent.ChildItems.Remove(e.Item);
                        }
                    }
                    if (mapNode.Title == "Comisiones")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            parent.ChildItems.Remove(e.Item);
                        }
                    }
                    if (mapNode.Title == "AlumnoInscripcion")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            parent.ChildItems.Remove(e.Item);
                        }
                    }

                    if (mapNode.Title == "Cursos")
                    {
                        System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
                        if (parent != null)
                        {
                            parent.ChildItems.Remove(e.Item);
                        }
                    }
                }
            }
        }
Esempio n. 48
0
        private static string GetValue(string key, string filterKey, string filterValue, SiteMapNode node)
        {
            // Look for a child node that has the specified filter key set.

            foreach (SiteMapNode childNode in node.ChildNodes)
            {
                if (string.Compare(childNode[filterKey], filterValue, true) == 0)
                {
                    return(childNode[key]);
                }
            }

            return(null);
        }
Esempio n. 49
0
 public static string GetSetting(this SiteMapNode node, string key)
 {
     return(GetSetting(node, key, includingInheritedSettings: true));
 }
Esempio n. 50
0
 public void DoAddNode(SiteMapNode node, SiteMapNode parentNode)
 {
     base.AddNode(node, parentNode);
 }
Esempio n. 51
0
        /// <summary>
        /// Builds one level of the administration menu
        /// </summary>
        /// <param name="level">The menu level to build</param>
        /// <param name="parent">Parent node for the current page at the specific level</param>
        /// <returns></returns>
        private SiteMapNode BuildMenuLevel(int level, SiteMapNode parent)
        {
            LinkButton  lnk;
            SiteMapNode nextParent = null;
            string      url;

            //Can only have level 1-3
            if ((level == 0) || (level > 3))
            {
                return(null);
            }

            foreach (SiteMapNode node in parent.ChildNodes)
            {
                url      = "";
                lnk      = new LinkButton();
                lnk.Text = GetLocalizedString(node.Title);

                if (string.IsNullOrEmpty(node.Url))
                {
                    //Node in sitemap without a URL - get the URL from it´s first child...
                    url = GetUrlFromChild(node);
                }
                else
                {
                    url = node.Url;
                }

                if (!string.IsNullOrEmpty(url))
                {
                    lnk.PostBackUrl = url;
                    if ((AdminSiteMap.CurrentNode.IsDescendantOf(node)) || (AdminSiteMap.CurrentNode == node))
                    {
                        nextParent   = node;
                        lnk.CssClass = "navigation_selected";
                    }
                    else
                    {
                        lnk.CssClass = "navigation_unselected";
                    }

                    switch (level)
                    {
                    case 1:
                        pnlMenuLevel1.Controls.Add(lnk);
                        break;

                    case 2:
                        pnlMenuLevel2.Controls.Add(lnk);
                        break;

                    case 3:
                        pnlMenuLevel3.Controls.Add(lnk);
                        pnlMenuLevel3.Controls.Add(new LiteralControl("<br />"));
                        break;

                    default:
                        break;
                    }
                }
            }

            return(nextParent);
        }
Esempio n. 52
0
    private ArrayList FetchData()
    {
        ArrayList res = new ArrayList();
        //SiteMapNode nd = SiteMap.CurrentNode;
        SiteMapNode nd = _parentMasterAcc.Provider.CurrentNode;

        if (nd.ChildNodes.Count != 0)
        {
            foreach (SiteMapNode node in nd.ChildNodes)
            {
                if (node.ChildNodes.Count != 0)  //folder
                {
                    PhotoItem item = new PhotoItem(node.Title, node.Description,
                                                   GetClientPathFolder(), GetLink(node), GetDate(node["date"]), string.Empty
                                                   );
                    item.IsFolder = true;
                    item.DetectSize(null);

                    res.Add(item);
                }
                else //image
                {
                    Boolean isExists;
                    String  realPath, origPath;
                    String  path  = GetClientPath(node, true, out isExists, out realPath, out origPath);
                    Boolean isImg = true;

                    if (!isExists)
                    {
                        path     = GetClientPathFolder();
                        isImg    = false;
                        origPath = string.Empty;
                    }

                    PhotoItem item = new PhotoItem(node.Title, node.Description,
                                                   path, GetLink(node), GetDate(node["date"]), origPath, node["lat"], node["long"]
                                                   );
                    item.DetectSize(realPath);
                    if (isImg == true)
                    {
                        item.IsThumb = true;
                    }
                    else
                    {
                        item.IsFolder = true;
                    }

                    item.Shot = node["shot"];

                    res.Add(item);
                }
            }
        }
        else
        {
            //String path = GetClientPath( nd, false );
            Boolean isExists;
            String  realPath, origPath;
            String  path = GetClientPath(nd, false, out isExists, out realPath, out origPath);
            if (isExists)
            {
                PhotoItem item = new PhotoItem(nd.Title, nd.Description,
                                               path, GetLink(nd), GetDate(nd["date"]), string.Empty
                                               );
                item.IsFolder = true;
                item.DetectSize(realPath);
                res.Add(item);
            }
        }

        PhotoItem.CalculateMaxSize((ICollection)res);

        return(ArrayList.Synchronized(res));
    }
Esempio n. 53
0
 public void ManageSiteMap(SiteMapNode rootNode)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Dummies the resolving of the URL.
 /// </summary>
 /// <param name="node">The node.</param>
 /// <returns>url result</returns>
 protected override string ResolveUrl(SiteMapNode node)
 {
     return(node != null ? node.Url : string.Empty);
 }
 /// <summary>
 /// Dummies the link target.
 /// </summary>
 /// <param name="node">The node.</param>
 /// <returns>link result</returns>
 protected override string GetLinkTarget(SiteMapNode node)
 {
     return("_blank");
 }
 /// <summary>
 /// Build a menu, based on the MvcSiteMap
 /// </summary>
 /// <param name="helper">The helper.</param>
 /// <param name="templateName">Name of the template.</param>
 /// <param name="startingNode">The starting node.</param>
 /// <param name="startingNodeInChildLevel">Show starting node in child level if set to <c>true</c>.</param>
 /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param>
 /// <param name="maxDepth">The max depth.</param>
 /// <returns>Html markup</returns>
 public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, string templateName, SiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth)
 {
     return(Menu(helper, templateName, startingNode, startingNodeInChildLevel, showStartingNode, maxDepth, false));
 }
Esempio n. 57
0
        public override SiteMapNode BuildSiteMap()
        {
            lock (_lockObject)
            {
                if (_rootNode != null)
                {
                    return(_rootNode);
                }
                string          sql  = "select Id, Title, Description, Url, Roles, ParentId from my_aspnet_sitemap";
                MySqlConnection conn = new MySqlConnection(_connStr);
                try
                {
                    conn.Open();
                    MySqlCommand cmd = new MySqlCommand(sql, conn);
                    using (MySqlDataReader r = cmd.ExecuteReader())
                    {
                        int IdFld       = r.GetOrdinal("Id");
                        int TitleFld    = r.GetOrdinal("Title");
                        int DescFld     = r.GetOrdinal("Description");
                        int UrlFld      = r.GetOrdinal("Url");
                        int RolesFld    = r.GetOrdinal("Roles");
                        int ParentIdFld = r.GetOrdinal("ParentId");

                        while (r.Read())
                        {
                            int    IdVal;
                            string TitleVal;
                            string DescVal;
                            string UrlVal;
                            string RolesVal;
                            int    ParentIdVal;

                            LoadValue <int>(r, IdFld, out IdVal);
                            LoadValue <string>(r, TitleFld, out TitleVal);
                            LoadValue <string>(r, DescFld, out DescVal);
                            LoadValue <string>(r, UrlFld, out UrlVal);
                            LoadValue <string>(r, RolesFld, out RolesVal);
                            LoadValue <int>(r, ParentIdFld, out ParentIdVal);

                            SiteMapNode node = new SiteMapNode(this, IdVal.ToString(), UrlVal, TitleVal, DescVal);
                            _nodes.Add(IdVal, node);
                            if (ParentIdVal != 0)
                            {
                                SiteMapNode parentNode = _nodes[ParentIdVal];
                                AddNode(node, parentNode);
                            }
                            else
                            {
                                AddNode(node);
                            }
                            if (ParentIdVal == 0)
                            {
                                _rootNode = node;
                            }
                        }
                    }
                }
                catch (MySqlException ex) {
                    HandleMySqlException(ex, "BuildSiteMap");
                } finally {
                    if ((conn.State & ConnectionState.Open) != 0)
                    {
                        conn.Close();
                    }
                }
                return(_rootNode);
            }
        }
Esempio n. 58
0
 private static String GetLink(SiteMapNode nd)
 {
     //Page pg = (Page)HttpContext.Current.Handler;
     //return pg.ClientScript.GetPostBackEventReference( pg.Master, nd.Url );
     return(nd.Url);
 }
 /// <summary>
 /// Gets the starting node.
 /// </summary>
 /// <param name="currentNode">The current node.</param>
 /// <param name="startingNodeLevel">The starting node level.</param>
 /// <param name="allowForwardSearch">if set to <c>true</c> allow forward search. Forward search will search all parent nodes and child nodes, where in other circumstances only parent nodes are searched.</param>
 /// <returns>The starting node.</returns>
 public static SiteMapNode GetStartingNode(SiteMapNode currentNode, int startingNodeLevel)
 {
     return(GetStartingNode(currentNode, startingNodeLevel, false));
 }
 /// <summary>
 /// Checks the site map node.
 /// </summary>
 /// <param name="node">The node.</param>
 /// <returns>boolean result</returns>
 protected override bool CheckSiteMapNode(SiteMapNode node)
 {
     return(true);
 }