protected virtual MenuItem GenerateItem(Site site, ControllerContext controllerContext, DirectoryResource directoryResource)
        {
            var menuItem = new MenuItem
            {
                Text = directoryResource.Name,
                Area = "Sites",
                Action = "Index",
                Controller = "File",
                Initializer = new FileFolderItemInitializer(),
                Localizable = false
            };

            menuItem.RouteValues = new System.Web.Routing.RouteValueDictionary();

            menuItem.RouteValues["folderPath"] = ((DirectoryEntry)directoryResource).RelativePath;
            menuItem.RouteValues["type"] = FileManager.Type;

            var subDirs = FileManager.GetDirectories(site, ((DirectoryEntry)directoryResource).RelativePath);
            if (subDirs != null && subDirs.Count() > 0)
            {
                var subList = new List<MenuItem>();
                foreach (var sub in subDirs)
                {
                    subList.Add(GenerateItem(site, controllerContext, sub));
                }
                menuItem.Items = subList;
            }

            return menuItem;
        }
Beispiel #2
0
        private static void InitModuleMenuItem(MenuItem menuItem, UrlHelper moduleUrlHelper, string moduleName, string scaffoldController, string scaffoldAction, RouteValueDictionary scaffoldRouteValues, string siteName)
        {
            var routeValues = new RouteValueDictionary(menuItem.RouteValues);
            routeValues.Merge("SiteName", siteName);
            routeValues.Merge("ModuleName", moduleName);
            var moduleUrl = moduleUrlHelper.Action(menuItem.Action, menuItem.Controller, routeValues);
            moduleUrl = ModuleUrlHelper.RemoveApplicationPath(moduleUrl, moduleUrlHelper.RequestContext.HttpContext.Request.ApplicationPath);
            menuItem.Controller = scaffoldController;
            menuItem.Action = scaffoldAction;
            menuItem.RouteValues = scaffoldRouteValues != null ? new RouteValueDictionary(scaffoldRouteValues) : new RouteValueDictionary();
            menuItem.RouteValues.Merge("ModuleUrl", moduleUrl);
            menuItem.RouteValues.Merge("ModuleName", moduleName);

            if (menuItem.Items != null && menuItem.Items.Count > 0)
            {
                foreach (var item in menuItem.Items)
                {
                    InitModuleMenuItem(item, moduleUrlHelper, moduleName, scaffoldController, scaffoldAction, scaffoldRouteValues, siteName);
                }
            }

            var isCurrentModule = moduleUrlHelper.RequestContext.GetRequestValue("ModuleName").EqualsOrNullEmpty(moduleName, StringComparison.OrdinalIgnoreCase);
            menuItem.IsActive = menuItem.IsActive && isCurrentModule;
            menuItem.IsCurrent = isCurrentModule;
        }
        protected override bool GetIsActive(MenuItem item, System.Web.Mvc.ControllerContext controllerContext)
        {
            string parent = controllerContext.RequestContext.GetRequestValue("uuid");
            var fullName = item.RouteValues["uuid"] == null ? "" : item.RouteValues["uuid"].ToString();

            return (string.Compare(parent, fullName, true) == 0 || string.IsNullOrEmpty(fullName)) && controllerContext.RequestContext.GetRequestValue("controller").ToLower() == "page";
        }
Beispiel #4
0
        public override void Inject(Kooboo.Web.Mvc.Menu.MenuItem menu, System.Web.Mvc.ControllerContext controllerContext)
        {
            // 只有在未选中某个实例时才显示全局菜单
            if (CommerceInstance.Current != null)
            {
                return;
            }

            menu.Items.Add(new CommerceMenuItem
            {
                Name        = "Instances",
                Text        = "Instances",
                Controller  = "Instance",
                Action      = "Index",
                Initializer = new GlobalMenuItemInitializer()
            });

            menu.Items.Add(new CommerceMenuItem
            {
                Name        = "Add-ins",
                Text        = "Add-ins",
                Controller  = "AddInManagement",
                Action      = "Index",
                Initializer = new GlobalMenuItemInitializer()
            });
        }
Beispiel #5
0
        private MenuItem CreateMenuItemByTemplate(string areaName, MenuItemTemplate template, ControllerContext controllerContext)
        {
            MenuItem item = new MenuItem()
            {
                Action = template.Action,
                Area = string.IsNullOrEmpty(template.Area) ? areaName : template.Area,
                Controller = template.Controller,
                HtmlAttributes = new RouteValueDictionary(template.HtmlAttributes),
                Localizable = template.Localizable,
                Name = template.Name,
                ReadOnlyProperties = template.ReadOnlyProperties,
                RouteValues = new RouteValueDictionary(template.RouteValues),
                Text = template.Text,
                Visible = template.Visible,
                Initializer = template.Initializer
            };

            List<MenuItem> items = new List<MenuItem>();
            if (template.ItemContainers != null)
            {
                foreach (var itemContainer in template.ItemContainers)
                {
                    items.AddRange(itemContainer.GetItems(areaName, controllerContext));
                }
            }

            item.Items = items;

            return item;
        }
Beispiel #6
0
 private MenuItem GetModuleMenuItem(string moduleName, ControllerContext controllerContext, ControllerContext moduleControllerContext)
 {
     MenuItem moduleMenuItem = new MenuItem() { Text = moduleName, Action = "", Controller = "", HtmlAttributes = new System.Web.Routing.RouteValueDictionary(), RouteValues = new System.Web.Routing.RouteValueDictionary() };
     var moduleMenu = ModuleMenu.GetModuleMenu(moduleName, controllerContext, moduleControllerContext, new RouteValueDictionary(new { area = "Sites" }), Site.Current.FullName, "Module", "Scaffold");
     moduleMenuItem.Items = moduleMenu.Items;
     return moduleMenuItem;
 }
Beispiel #7
0
 protected override bool GetIsActive(MenuItem menuItem, ControllerContext controllerContext)
 {
     string siteName = controllerContext.RequestContext.GetRequestValue("siteName");
     //string page = controllerContext.RequestContext.GetRequestValue("name");
     return string.Compare(siteName, menuItem.RouteValues["siteName"].ToString(), true) == 0;
     //|| string.Compare(page, this.Page.Name) == 0;
 }
Beispiel #8
0
        private void Initialize(string moduleName, MenuItem item)
        {
            if (item.ReadOnlyProperties != null)
            {
                var roleName = item.ReadOnlyProperties["role"];
                if (!string.IsNullOrEmpty(roleName) && item.Visible)
                {
                    item.Visible = Kooboo.CMS.Sites.Services.ServiceFactory.UserManager.IsInRole(Site.Current
                        , HttpContext.Current.User.Identity.Name
                        , roleName);
                }
                string permissionGroup = item.ReadOnlyProperties["permissionGroup"];
                string permissionName = item.ReadOnlyProperties["permissionName"];
                if (!string.IsNullOrEmpty(permissionName))
                {
                    var permission = new Permission() { AreaName = moduleName, Group = permissionGroup, Name = permissionName };
                    item.Visible = Kooboo.CMS.Sites.Services.ServiceFactory.UserManager.Authorize(Site.Current
                      , HttpContext.Current.User.Identity.Name
                      , permission);
                }
            }

            if (item.Items != null)
            {
                foreach (var chd in item.Items)
                {
                    Initialize(moduleName, chd);
                }
            }
        }
Beispiel #9
0
 protected override bool GetIsVisible(MenuItem menuItem, System.Web.Mvc.ControllerContext controllerContext)
 {
     var visible = false;
     if (Repository.Current != null)
     {
         visible = Repository.Current.EnableWorkflow;
     }
     return visible;
 }
Beispiel #10
0
        private MenuItem GetModuleMenuItem(string moduleName, ControllerContext controllerContext)
        {
            MenuItem moduleMenuItem = new MenuItem() { Text = moduleName, Action = "", Controller = "", HtmlAttributes = new System.Web.Routing.RouteValueDictionary(), RouteValues = new System.Web.Routing.RouteValueDictionary() };
            var items = MenuFactory.BuildMenu(controllerContext, moduleName, false).Items;
            moduleMenuItem.Items = items;

            Initialize(moduleName, moduleMenuItem);

            return moduleMenuItem;
        }
        protected override bool GetIsVisible(MenuItem menuItem, System.Web.Mvc.ControllerContext controllerContext)
        {
            var visible = base.GetIsVisible(menuItem, controllerContext);
            if (visible)
            {
                visible = CommerceInstance.Current == null;
            }

            return visible;
        }
        protected override bool GetIsActive(MenuItem item, System.Web.Mvc.ControllerContext controllerContext)
        {
            string folderPath = (controllerContext.RequestContext.GetRequestValue("folderPath") ?? "").ToLower();

            string type = (controllerContext.RequestContext.GetRequestValue("type") ?? "").ToLower();

            string route_FolderPath = (item.RouteValues["folderPath"] ?? "").ToString().ToLower();
            string route_Type = item.RouteValues["type"].ToString().ToLower();
            return (route_FolderPath == folderPath)
                && route_Type == type;
        }
Beispiel #13
0
 public virtual bool IsActive(MenuItem item, ControllerContext controllerContext)
 {
     if (!string.IsNullOrEmpty(item.Area))
     {
         if (string.Compare(item.Area, AreaHelpers.GetAreaName(controllerContext.RouteData)) != 0)
         {
             return false;
         }
     }
     return string.Compare(controllerContext.RouteData.Values["controller"].ToString(), item.Controller, true) == 0;
 }
 protected override bool GetIsVisible(MenuItem menuItem, System.Web.Mvc.ControllerContext controllerContext)
 {
     var visible = false;
     if (Repository.Current != null)
     {
         visible = Repository.Current.EnableBroadcasting;
     }
     if (visible)
     {
         visible = base.GetIsVisible(menuItem, controllerContext);
     }
     return visible;
 }
        public override MenuItem Initialize(MenuItem menuItem, ControllerContext controllerContext)
        {
            if (menuItem.RouteValues == null)
            {
                menuItem.RouteValues = new System.Web.Routing.RouteValueDictionary();
            }
            var instanceName = GetCommerceInstanceName(controllerContext);
            if (!String.IsNullOrWhiteSpace(instanceName))
            {
                menuItem.RouteValues["instance"] = instanceName;
            }

            return base.Initialize(menuItem, controllerContext);
        }
        protected override bool GetIsActive(MenuItem menuItem, ControllerContext controllerContext)
        {
            string areaName = AreaHelpers.GetAreaName(controllerContext.RouteData);
            string controllerName = controllerContext.RouteData.Values.GetString("controller");
            string actionName = controllerContext.RouteData.Values.GetString("action");
            if(menuItem.Area.Equals(areaName, StringComparison.OrdinalIgnoreCase) &&
                menuItem.Controller.Equals(controllerName, StringComparison.OrdinalIgnoreCase) &&
                menuItem.Action.Equals(actionName, StringComparison.OrdinalIgnoreCase))
            {
                return true;
            }

            return false;
        }
        public virtual MenuItem Initialize(MenuItem menuItem, ControllerContext controllerContext)
        {
            var areaName = AreaHelpers.GetAreaName(controllerContext.RouteData);
            if (!string.IsNullOrEmpty(areaName) && menuItem.RouteValues != null)
            {
                menuItem.RouteValues["area"] = areaName;
            }
            if (!string.IsNullOrEmpty(menuItem.Area) && menuItem.RouteValues != null)
            {
                menuItem.RouteValues["area"] = menuItem.Area;
            }

            var isActive =
               GetIsActive(menuItem, controllerContext);
            menuItem.IsCurrent = isActive;

            foreach (var sub in menuItem.Items)
            {
                sub.Initialize(controllerContext);
                if (sub.IsActive)
                {
                    menuItem.IsCurrent = false;
                }
                isActive = isActive || sub.IsActive;
            }

            menuItem.IsActive = isActive;

            //if (!this.IsActive)
            //{
            //    this.IsActive = DefaultActive(controllerContext);
            //}

            if (menuItem.Visible != false)
            {
                var isVisible =
               GetIsVisible(menuItem, controllerContext);

                if (string.IsNullOrEmpty(menuItem.Action) && menuItem.Items.Where(it => it.Visible == true).Count() == 0)
                {
                    isVisible = false;
                }

                menuItem.Visible = isVisible;
            }

            menuItem.Initialized = true;

            return menuItem;
        }
 protected override bool GetIsVisible(MenuItem menuItem, System.Web.Mvc.ControllerContext controllerContext)
 {
     var visible = base.GetIsVisible(menuItem, controllerContext);
     if (menuItem.ReadOnlyProperties != null && !string.IsNullOrEmpty(menuItem.ReadOnlyProperties["permissionName"]))
     {
         var permission = new Kooboo.CMS.Account.Models.Permission()
         {
             AreaName = menuItem.ReadOnlyProperties["permissionArea"],
             Group = menuItem.ReadOnlyProperties["permissionGroup"],
             Name = menuItem.ReadOnlyProperties["permissionName"]
         };
         return controllerContext.RequestContext.Authorize(permission);
     }
     return visible;
 }
        public override void Inject(Kooboo.Web.Mvc.Menu.MenuItem menu, System.Web.Mvc.ControllerContext controllerContext)
        {
            if (CommerceInstance.Current == null)
            {
                return;
            }

            menu.Items.Add(Start());
            menu.Items.Add(Catalog());
            menu.Items.Add(Orders());
            menu.Items.Add(BusinessRules());
            menu.Items.Add(Shop());
            menu.Items.Add(Customers());
            menu.Items.Add(System());
        }
        protected override bool GetIsActive(MenuItem item, System.Web.Mvc.ControllerContext controllerContext)
        {
            if (controllerContext.RouteData.Values["controller"].ToString().ToLower() == "datarule")
            {
                if (controllerContext.RequestContext.GetRequestValue("from").ToLower() == item.Controller.ToLower())
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }

            return base.GetIsActive(item, controllerContext);
        }
        public static IEnumerable<MenuItem> GetMenuItems()
        {
            yield return new MenuItem
            {
                Text = "Overview",
                Name = "Overview",
                Controller = "Rule",
                Area = "Commerce",
                Action = "Index",
                ReadOnlyProperties = new System.Collections.Specialized.NameValueCollection
                {
                    { "activeByAction", "true" }
                }
            };

            var manager = EventSlotManager.Instance;

            foreach (var group in manager.GetGroups())
            {
                var groupItem = new MenuItem
                {
                    Text = group,
                    Name = group
                };

                var slots = manager.GetSlots(group).ToList();

                foreach (var each in slots)
                {
                    var eventItem = new MenuItem
                    {
                        Name = each.EventType.Name,
                        Text = each.ShortName ?? each.EventType.Name,
                        Controller = "Rule",
                        Action = "List",
                        Area = "Commerce",
                        RouteValues = new RouteValueDictionary(new { eventName = each.EventType.Name }),
                        Initializer = new BusinessRuleMenuItemInitializer()
                    };

                    groupItem.Items.Add(eventItem);
                }

                yield return groupItem;
            }
        }
        protected override bool GetIsActive(MenuItem menuItem, ControllerContext controllerContext)
        {
            var isActive = base.GetIsActive(menuItem, controllerContext);
            if (isActive)
            {
                var culture = menuItem.RouteValues["culture"] as string;
                if (!String.IsNullOrEmpty(culture) && culture.Equals(controllerContext.HttpContext.Request.QueryString["culture"], StringComparison.OrdinalIgnoreCase))
                {
                    isActive = true;
                }
                else
                {
                    isActive = false;
                }
            }

            return isActive;
        }
Beispiel #23
0
        private MenuItem GetModuleMenuItem(string moduleName, ControllerContext controllerContext)
        {
            MenuItem root;
            var items = MenuFactory.BuildMenu(controllerContext, moduleName, false).Items;
            if (items.Count == 1 && items.First().Name.ToLower() == "root")
            {
                root = items.First();
            }
            else
            {
                root = new MenuItem() { Text = moduleName, Action = "", Controller = "", HtmlAttributes = new System.Web.Routing.RouteValueDictionary(), RouteValues = new System.Web.Routing.RouteValueDictionary() };
                root.Items = items;
            }

            Initialize(moduleName, root);

            return root;
        }
        public override void Inject(Kooboo.Web.Mvc.Menu.MenuItem menu, System.Web.Mvc.ControllerContext controllerContext)
        {
            if (CommerceInstance.Current == null)
            {
                return;
            }

            var root = new MenuItem
            {
                Text = "Search"
            };

            menu.Items.Add(root);

            root.Items.Add(new SearchMenuItem
            {
                Text       = "Indexes",
                Controller = "Indexes"
            });
        }
Beispiel #25
0
 protected virtual bool GetIsActive(MenuItem menuItem, ControllerContext controllerContext)
 {
     if (!string.IsNullOrEmpty(menuItem.Area))
     {
         if (string.Compare(menuItem.Area, AreaHelpers.GetAreaName(controllerContext.RouteData)) != 0)
         {
             return false;
         }
     }
     var active = string.Compare(controllerContext.RouteData.Values["controller"].ToString(), menuItem.Controller, true) == 0;
     if (active && menuItem.ReadOnlyProperties != null)
     {
         var activeByAction = menuItem.ReadOnlyProperties["activeByAction"];
         if (!string.IsNullOrEmpty(activeByAction) && activeByAction.ToLower() == "true")
         {
             active = string.Compare(controllerContext.RouteData.Values["action"].ToString(), menuItem.Action, true) == 0;
         }
     }
     return active;
 }
Beispiel #26
0
        public override void Inject(Kooboo.Web.Mvc.Menu.MenuItem menu, System.Web.Mvc.ControllerContext controllerContext)
        {
            if (CommerceInstance.Current == null)
            {
                return;
            }

            var root = new MenuItem
            {
                Text = "Search"
            };

            menu.Items.Add(root);

            root.Items.Add(new SearchMenuItem
            {
                Text = "Indexes",
                Controller = "Indexes"
            });
        }
Beispiel #27
0
        public override void Inject(Kooboo.Web.Mvc.Menu.MenuItem menu, System.Web.Mvc.ControllerContext controllerContext)
        {
            if (CommerceInstance.Current == null)
            {
                return;
            }

            var recommendations = new RecommendationMenuItem
            {
                Text = "Recommendations"
            };

            menu.Items.Add(recommendations);

            recommendations.Items.Add(new RecommendationMenuItem
            {
                Text       = "Settings",
                Controller = "Config",
                Action     = "Behaviors"
            });
        }
        protected override bool GetIsVisible(MenuItem menuItem, System.Web.Mvc.ControllerContext controllerContext)
        {
            var visible = base.GetIsVisible(menuItem, controllerContext);

            if (menuItem.ReadOnlyProperties != null)
            {
                var requiredAdministrator = menuItem.ReadOnlyProperties["requiredAdministrator"];
                if (!string.IsNullOrEmpty(requiredAdministrator) && requiredAdministrator.ToLower() == "true")
                {
                    return Kooboo.CMS.Sites.Services.ServiceFactory.UserManager.IsAdministrator(controllerContext.HttpContext.User.Identity.Name);
                }
                if (!string.IsNullOrEmpty(menuItem.ReadOnlyProperties["permissionName"]))
                {
                    var permission = new Kooboo.CMS.Account.Models.Permission()
                    {
                        AreaName = menuItem.ReadOnlyProperties["permissionArea"],
                        Group = menuItem.ReadOnlyProperties["permissionGroup"],
                        Name = menuItem.ReadOnlyProperties["permissionName"]
                    };
                    return controllerContext.RequestContext.Authorize(permission);
                }
            }
            return visible;
        }
 public abstract void Inject(Kooboo.Web.Mvc.Menu.MenuItem menu, System.Web.Mvc.ControllerContext controllerContext);
Beispiel #30
0
 public virtual void Initialize(MenuItem menuItem, ControllerContext controllerContext)
 {
     Initializer.Initialize(menuItem, controllerContext);
 }
Beispiel #31
0
 protected override bool GetIsActive(MenuItem menuItem, ControllerContext controllerContext)
 {
     string category = controllerContext.RequestContext.GetRequestValue("category");
     return string.Compare(category, menuItem.RouteValues["category"].ToString(), true) == 0;
 }
Beispiel #32
0
 protected override bool GetIsActive(MenuItem menuItem, ControllerContext controllerContext)
 {
     var baseActive = base.GetIsActive(menuItem, controllerContext);
     if (baseActive)
     {
         string repositoryName = controllerContext.RequestContext.GetRequestValue("repositoryName");
         string folder = controllerContext.RequestContext.GetRequestValue("FolderName");
         return string.Compare(repositoryName, menuItem.RouteValues["repositoryName"].ToString(), true) == 0
             && string.Compare(folder, menuItem.RouteValues["FolderName"].ToString()) == 0;
     }
     else
     {
         return baseActive;
     }
 }
Beispiel #33
0
            protected override bool GetIsVisible(MenuItem menuItem, ControllerContext controllerContext)
            {
                var folderName = menuItem.RouteValues["FolderName"].ToString();

                if (string.Equals(menuItem.Controller, "MediaContent", StringComparison.OrdinalIgnoreCase))
                {
                    return base.GetIsVisible(menuItem, controllerContext);
                }
                var textFolder = new TextFolder(Repository.Current, folderName).AsActual();

                if (!textFolder.Visible)
                {
                    return false;
                }

                var allowedView = Kooboo.CMS.Content.Services.ServiceFactory.WorkflowManager
                    .AvailableViewContent(textFolder, controllerContext.HttpContext.User.Identity.Name);

                return allowedView &&
                    base.GetIsVisible(menuItem, controllerContext);
            }
Beispiel #34
0
            protected override bool GetIsActive(MenuItem menuItem, ControllerContext controllerContext)
            {
                string repositoryName = controllerContext.RequestContext.GetRequestValue("repositoryName");

                return string.Compare(repositoryName, menuItem.RouteValues["repositoryName"].ToString(), true) == 0;
            }
Beispiel #35
0
 protected override bool GetIsActive(MenuItem item, System.Web.Mvc.ControllerContext controllerContext)
 {
     string ns = controllerContext.RequestContext.GetRequestValue("ns");
     var nsItem = item.RouteValues["ns"] == null ? "" : item.RouteValues["ns"].ToString();
     if (controllerContext.RouteData.Values["controller"].ToString().ToLower() == "datarule")
     {
         if (controllerContext.RequestContext.GetRequestValue("from").ToLower() == item.Controller.ToLower()
             && string.Compare(ns, nsItem, true) == 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
     if (controllerContext.RouteData.Values["controller"].ToString().ToLower() == "view")
     {
         return string.Compare(ns, nsItem, true) == 0;
     }
     return false;
 }