protected override void BuildMenuCore(TreeNode<MenuItem> pluginsNode)
		{
			var menuItem = new MenuItem().ToBuilder()
				.Text("Developer Tools")
				.Icon("code")
				.Action("ConfigurePlugin", "Plugin", new { systemName = "SmartStore.DevTools", area = "Admin" })
				.ToItem();

			pluginsNode.Prepend(menuItem);
		}
		protected override void BuildMenuCore(TreeNode<MenuItem> pluginsNode)
		{
			var menuItem = new MenuItem().ToBuilder()
				.Text("Clickatell SMS Provider")
				.ResKey("Plugins.FriendlyName.Mobile.SMS.Clickatell")
				.Icon("send-o")
				.Action("ConfigurePlugin", "Plugin", new { systemName = "SmartStore.Clickatell", area = "Admin" })
				.ToItem();

			pluginsNode.Prepend(menuItem);
		}
		protected override void BuildMenuCore(TreeNode<MenuItem> pluginsNode)
        {
			var root = pluginsNode.SelectNode(x => x.Value.Id == "promotion-feeds");
			if (root == null)
				return;
			
			var menuItem = new MenuItem().ToBuilder()
                .Text("Google Merchant Center")
				.ResKey("Plugins.FriendlyName.SmartStore.GoogleMerchantCenter")
				.Action("ConfigurePlugin", "Plugin", new { systemName = "SmartStore.GoogleMerchantCenter", area = "Admin" })
                .ToItem();

            root.Append(menuItem);
        }
示例#4
0
        protected override void BuildMenuCore(TreeNode<MenuItem> pluginsNode)
        {
            var menuItem = new MenuItem().ToBuilder()
                .Text("Developer Tools")
                .Icon("code")
                .Action("ConfigurePlugin", "Plugin", new { systemName = "SmartStore.DevTools", area = "Admin" })
                .ToItem();

            pluginsNode.Prepend(menuItem);

            // uncomment to add to admin menu (see plugin sub-menu)
            //var backendExtensionItem = new MenuItem().ToBuilder()
            //	.Text("Backend extension")
            //	.Icon("area-chart")
            //	.Action("BackendExtension", "DevTools", new { area = "SmartStore.DevTools" })
            //	.ToItem();

            //pluginsNode.Append(backendExtensionItem);
        }
示例#5
0
        private bool MenuItemAccessPermitted(MenuItem item)
        {
            var result = true;

			if (_securitySettings.Value.HideAdminMenuItemsBasedOnPermissions && item.PermissionNames.HasValue())
            {
				var permitted = item.PermissionNames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Any(x => _services.Permissions.Authorize(x.Trim()));
                if (!permitted)
                {
                    result = false;
                }
            }

            return result;
        }
示例#6
0
        private TreeNode<MenuItem> ConvertSitemapNodeToMenuItemNode(SiteMapNode node)
        {
            var item = new MenuItem();
            var treeNode = new TreeNode<MenuItem>(item);

            if (node.RouteName.HasValue())
            {
                item.RouteName = node.RouteName;
            }
            else if (node.ActionName.HasValue() && node.ControllerName.HasValue())
            {
                item.ActionName = node.ActionName;
                item.ControllerName = node.ControllerName;
            }
            else if (node.Url.HasValue())
            {
                item.Url = node.Url;
            }
            item.RouteValues = node.RouteValues;
            
            item.Visible = node.Visible;
            item.Text = node.Title;
            item.Attributes.Merge(node.Attributes);

            if (node.Attributes.ContainsKey("permissionNames"))
                item.PermissionNames = node.Attributes["permissionNames"] as string;

            if (node.Attributes.ContainsKey("id"))
                item.Id = node.Attributes["id"] as string;

            if (node.Attributes.ContainsKey("resKey"))
                item.ResKey = node.Attributes["resKey"] as string;

			if (node.Attributes.ContainsKey("iconClass"))
				item.Icon = node.Attributes["iconClass"] as string;

            if (node.Attributes.ContainsKey("imageUrl"))
                item.ImageUrl = node.Attributes["imageUrl"] as string;

            if (node.Attributes.ContainsKey("isGroupHeader"))
                item.IsGroupHeader = Boolean.Parse(node.Attributes["isGroupHeader"] as string);

            // iterate children recursively
            foreach (var childNode in node.ChildNodes)
            {
                var childTreeNode = ConvertSitemapNodeToMenuItemNode(childNode);
                treeNode.Append(childTreeNode);
            }
            
            return treeNode;
        }
        public TreeNode<MenuItem> GetCategoryMenu()
        {
            var customerRolesIds = _services.WorkContext.CurrentCustomer.CustomerRoles.Where(cr => cr.Active).Select(cr => cr.Id).ToList();
            string cacheKey = string.Format(ModelCacheEventConsumer.CATEGORY_NAVIGATION_MODEL_KEY,
                _services.WorkContext.WorkingLanguage.Id,
                string.Join(",", customerRolesIds),
                _services.StoreContext.CurrentStore.Id);

            var model = _services.Cache.Get(cacheKey, () =>
            {
                var curParent = new TreeNode<MenuItem>(new MenuItem
                {
                    EntityId = 0,
                    Text = "Home",
                    RouteName = "HomePage"
                });

                Category prevCat = null;

                var categories = _categoryService.GetAllCategories();
                foreach (var category in categories)
                {
                    var menuItem = new MenuItem
                    {
                        EntityId = category.Id,
                        Text = category.GetLocalized(x => x.Name),
                        RouteName = "Category"
                    };
                    menuItem.RouteValues.Add("SeName", category.GetSeName());

                    // determine parent
                    if (prevCat != null)
                    {
                        if (category.ParentCategoryId != curParent.Value.EntityId)
                        {
                            if (category.ParentCategoryId == prevCat.Id)
                            {
                                // level +1
                                curParent = curParent.LastChild;
                            }
                            else
                            {
                                // level -x
                                while (!curParent.IsRoot)
                                {
                                    if (curParent.Value.EntityId == category.ParentCategoryId)
                                    {
                                        break;
                                    }
                                    curParent = curParent.Parent;
                                }
                            }
                        }
                    }

                    // add to parent
                    curParent.Append(menuItem);

                    prevCat = category;
                }

                var root = curParent.Root;

                // menu publisher
                _menuPublisher.Value.RegisterMenus(root, "catalog");

                // event
                _services.EventPublisher.Publish(new NavigationModelBuiltEvent(root));

                return root;
            });

            return model;
        }
        private TreeNode<MenuItem> PrepareAdminMenu()
        {
            SiteMapBase siteMap;
            if (!SiteMapManager.SiteMaps.TryGetValue("admin", out siteMap))
            {
                SiteMapManager.SiteMaps.Register<XmlSiteMap>("admin", x => x.LoadFrom("~/Administration/sitemap.config"));
                siteMap = SiteMapManager.SiteMaps["admin"];
            }
            
            var rootNode = ConvertSitemapNodeToMenuItemNode(siteMap.RootNode);

            TreeNode<MenuItem> pluginNode = null;

            // "collect" menus from plugins
            if (!_securitySettings.HideAdminMenuItemsBasedOnPermissions || _permissionService.Authorize(StandardPermissionProvider.ManagePlugins))
            {
                var providers = new List<IMenuProvider>();
                var providerTypes = _typeFinder.FindClassesOfType<IMenuProvider>();

                foreach (var type in providerTypes)
                {
                    if (!PluginManager.IsActivePluginAssembly(type.Assembly))
                    {
                        continue;
                    }

                    try
                    {
                        var provider = Activator.CreateInstance(type) as IMenuProvider;
                        providers.Add(provider);
                    }
                    catch { }
                }

                if (providers.Any())
                {
                    var pluginItem = new MenuItem().ToBuilder()
                        .Text("Plugins")
                        .ResKey("Admin.Plugins")
                        .PermissionNames("ManagePlugins")
                        .ToItem();
                    pluginNode = rootNode.Append(pluginItem);

                    providers.Each(x => x.BuildMenu(pluginNode));
                }
            }

            // hide based on permissions
            rootNode.TraverseTree(x => {
                if (!x.IsRoot)
                {
                    if (!MenuItemAccessPermitted(x.Value))
                    {
                        x.Value.Visible = false;
                    }
                }
            });

            // hide plugins node when no child is visible
            if (pluginNode != null)
            {
                if (!pluginNode.Children.Any(x => x.Value.Visible))
                {
                    pluginNode.Value.Visible = false;
                }
            }

            return rootNode;
        }