コード例 #1
0
ファイル: APPVersionPlugin.cs プロジェクト: hsb0307/Nut.NET
 /// <summary>
 /// Manage sitemap. You can use "SystemName" of menu items to manage existing sitemap or add a new menu item.
 /// </summary>
 /// <param name="rootNode">Root node of the sitemap.</param>
 public void ManageSiteMap(SiteMapNode rootNode) {
     rootNode.ChildNodes.Add(new SiteMapNode() {
         ActionName = "List",
         ControllerName = "AppVersion",
         Icon = "chemistry",
         SystemName = "Admin.AppVersion",
         Title = "AppVersion",
         Visible = true,
         RouteValues = new RouteValueDictionary { { "area", "Admin" } }
     });
 }
コード例 #2
0
ファイル: XmlSiteMap.cs プロジェクト: hsb0307/Nut.NET
        private static void Iterate(SiteMapNode siteMapNode, XmlNode xmlNode)
        {
            PopulateNode(siteMapNode, xmlNode);

            foreach (XmlNode xmlChildNode in xmlNode.ChildNodes)
            {
                if (xmlChildNode.LocalName.Equals("siteMapNode", StringComparison.InvariantCultureIgnoreCase))
                {
                    var siteMapChildNode = new SiteMapNode();
                    siteMapNode.ChildNodes.Add(siteMapChildNode);

                    Iterate(siteMapChildNode, xmlChildNode);
                }
            }
        }
コード例 #3
0
ファイル: XmlSiteMap.cs プロジェクト: hsb0307/Nut.NET
        private static void PopulateNode(SiteMapNode siteMapNode, XmlNode xmlNode)
        {
            //system name
            siteMapNode.SystemName = GetStringValueFromAttribute(xmlNode, "SystemName");

            //title
            var nopResource = GetStringValueFromAttribute(xmlNode, "nopResource");
            var localizationService = EngineContext.Current.Resolve<ILocalizationService>();
            siteMapNode.Title = localizationService.GetResource(nopResource);

            //routes, url
            string controllerName = GetStringValueFromAttribute(xmlNode, "controller");
            string actionName = GetStringValueFromAttribute(xmlNode, "action");
            string url = GetStringValueFromAttribute(xmlNode,  "url");

            if (!string.IsNullOrEmpty(controllerName) && !string.IsNullOrEmpty(actionName))
            {
                siteMapNode.ControllerName = controllerName;
                siteMapNode.ActionName = actionName;

                //apply admin area as described here - http://www.nopcommerce.com/boards/t/20478/broken-menus-in-admin-area-whilst-trying-to-make-a-plugin-admin-page.aspx
                siteMapNode.RouteValues = new RouteValueDictionary { {"area", "Admin"} };
            }
            else if (!string.IsNullOrEmpty(url))
            {
                siteMapNode.Url = url;
            }

            //image URL
            siteMapNode.Icon = GetStringValueFromAttribute(xmlNode, "icon");

            //permission name
            var permissionNames = GetStringValueFromAttribute(xmlNode, "PermissionNames");
            if (!string.IsNullOrEmpty(permissionNames))
            {
                var permissionService = EngineContext.Current.Resolve<IPermissionService>();
                siteMapNode.Visible = permissionNames.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                   .Any(permissionName => permissionService.Authorize(permissionName.Trim()));
            }
            else
            {
                siteMapNode.Visible = true;
            }
        }
コード例 #4
0
ファイル: XmlSiteMap.cs プロジェクト: hsb0307/Nut.NET
 public XmlSiteMap()
 {
     RootNode = new SiteMapNode();
 }