PopulateLocalMenu() public static method

Populates the local menu shapes.
public static PopulateLocalMenu ( dynamic shapeFactory, dynamic parentShape, dynamic menu, IEnumerable menuItems ) : void
shapeFactory dynamic The shape factory.
parentShape dynamic The menu parent shape.
menu dynamic The menu shape.
menuItems IEnumerable The current level to populate.
return void
Esempio n. 1
0
        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            // should only run on a full view rendering result
            if (!(filterContext.Result is ViewResult))
            {
                return;
            }

            WorkContext workContext = _workContextAccessor.GetContext(filterContext);

            const string menuName = "admin";

            if (!AdminFilter.IsApplied(filterContext.RequestContext))
            {
                return;
            }

            IEnumerable <MenuItem> menuItems = _navigationManager.BuildMenu(menuName);

            // adding query string parameters
            var routeData   = new RouteValueDictionary(filterContext.RouteData.Values);
            var queryString = workContext.HttpContext.Request.QueryString;

            if (queryString != null)
            {
                foreach (var key in from string key in queryString.Keys where key != null && !routeData.ContainsKey(key) let value = queryString[key] select key)
                {
                    routeData[key] = queryString[key];
                }
            }

            // Set the currently selected path
            Stack <MenuItem> selectedPath = NavigationHelper.SetSelectedPath(menuItems, routeData);

            // Populate main nav
            dynamic menuShape = _shapeFactory.Menu().MenuName(menuName);

            NavigationHelper.PopulateMenu(_shapeFactory, menuShape, menuShape, menuItems);

            // Add any know image sets to the main nav
            IEnumerable <string> menuImageSets = _navigationManager.BuildImageSets(menuName);

            if (menuImageSets != null && menuImageSets.Any())
            {
                menuShape.ImageSets(menuImageSets);
            }

            workContext.Layout.Navigation.Add(menuShape);

            // Populate local nav
            dynamic localMenuShape = _shapeFactory.LocalMenu().MenuName(string.Format("local_{0}", menuName));

            NavigationHelper.PopulateLocalMenu(_shapeFactory, localMenuShape, localMenuShape, selectedPath);
            workContext.Layout.LocalNavigation.Add(localMenuShape);
        }
Esempio n. 2
0
        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            // should only run on a full view rendering result
            if (!(filterContext.Result is ViewResult))
            {
                return;
            }

            WorkContext workContext = _workContextAccessor.GetContext(filterContext);

            const string menuName = "admin";

            if (!AdminFilter.IsApplied(filterContext.RequestContext))
            {
                return;
            }

            IEnumerable <MenuItem> menuItems = _navigationManager.BuildMenu(menuName);

            // Set the currently selected path
            Stack <MenuItem> selectedPath = NavigationHelper.SetSelectedPath(menuItems, filterContext.RouteData);

            // Populate main nav
            dynamic menuShape = _shapeFactory.Menu().MenuName(menuName);

            NavigationHelper.PopulateMenu(_shapeFactory, menuShape, menuShape, menuItems);

            // Add any know image sets to the main nav
            IEnumerable <string> menuImageSets = _navigationManager.BuildImageSets(menuName);

            if (menuImageSets != null && menuImageSets.Any())
            {
                menuShape.ImageSets(menuImageSets);
            }

            workContext.Layout.Navigation.Add(menuShape);

            // Populate local nav
            dynamic localMenuShape = _shapeFactory.LocalMenu().MenuName(string.Format("local_{0}", menuName));

            NavigationHelper.PopulateLocalMenu(_shapeFactory, localMenuShape, localMenuShape, selectedPath);
            workContext.Layout.LocalNavigation.Add(localMenuShape);
        }