private static void AddEnableRelations(MenuRenderingEventArgs eventArgs, UmbracoObjectTypes objectType, UrlHelper urlHelper)
 {
     if (objectType == UmbracoObjectTypes.DocumentType || objectType == UmbracoObjectTypes.MediaType)
     {
         var menuItem = eventArgs.Menu.Items.Add<EnableRelationsAction>("Enable relations");
         menuItem.LaunchDialogView(urlHelper.Content("~/App_Plugins/RelationEditor/enablerelations.html"), "Enable relations");
     }
 }
        private static void OnMenuRendering(TreeControllerBase instance, MenuRenderingEventArgs e)
        {
            var handler = MenuRendering;

            if (handler != null)
            {
                handler(instance, e);
            }
        }
        void TreeControllerBaseMenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
        {
            if (sender.TreeAlias == "content" && sender.Security.CurrentUser.UserType.Alias == "admin")
            {
                var menu = new MenuItem("moriyamaDeploy", "Deploy this");
                menu.Icon = "umb-content";

                e.Menu.Items.Add(menu);
            }
        }
Ejemplo n.º 4
0
        void TreeControllerBaseMenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
        {
            bool isContentTree = sender.TreeAlias == "content";
            bool userIsAdmin = sender.Security.CurrentUser.UserType.Alias == "admin";

            // Add custom menu item
            if (isContentTree && userIsAdmin && IsContentNode(e))
            {
                AddMenuItem(e);
            }
        }
Ejemplo n.º 5
0
        public void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
        {
            //if (sender.TreeAlias == "content")
            //{
                //var i = new MenuItem("editCanvas", "Edit in Canvas");
                //i.Icon = "edit";
                //i.LaunchDialogUrl("/umbraco/canvas?pageId=" + e.NodeId,"Edit in Canvas");

                //e.Menu.Items.Insert(3,i);
            //}
        }
Ejemplo n.º 6
0
 private void AddMenuItem(MenuRenderingEventArgs e)
 {
     var menuItem = new MenuItem("xmlEdit", "XmlEdit")
     {
         Icon = "code",
         SeperatorBefore = true,
         AdditionalData = {}
     };
     menuItem.AdditionalData.Add("actionView", "/App_Plugins/UmbracoXmlEdit/BackOffice/content/edit.html");
     e.Menu.Items.Add(menuItem);
 }
Ejemplo n.º 7
0
        private bool IsContentNode(MenuRenderingEventArgs e)
        {
            bool isRootNode = e.NodeId == "-1";
            bool isRecycleBin = e.NodeId == "-20";

            if (isRootNode || isRecycleBin)
            {
                return false;
            }

            return true;
        }
Ejemplo n.º 8
0
 void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
 {
     if (sender.TreeAlias == "content"
         && sender.Security.CurrentUser.UserType.Alias == "admin"
         && e.NodeId != "-1" && e.NodeId != "-20")
     {
         var mi = new MenuItem("pageNotFound", "404 page");
         mi.Icon = "document";
         mi.LaunchDialogView("/App_Plugins/PageNotFoundManager/Backoffice/Dialogs/dialog.html", "404 Page");
         mi.SeperatorBefore = true;
         e.Menu.Items.Insert(e.Menu.Items.Count - 1, mi);
     }
 }
        private void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
        {
            int nodeId;
            if (!int.TryParse(e.NodeId, out nodeId)) return;

            var selectedMedia = ApplicationContext.Current.Services.MediaService.GetById(nodeId);
            var mediaType = selectedMedia != null ? selectedMedia.ContentType.Alias : string.Empty;

            if (sender.TreeAlias == "media" && (mediaType.Equals("Folder") || nodeId == Constants.System.Root))
            {
                var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
                var menuItemTitle = umbracoHelper.GetDictionaryValue("ZippyMedia.Labels.UploadZipFile");

                if (string.IsNullOrWhiteSpace(menuItemTitle)) menuItemTitle = "Upload and Unpack ZIP";
                var menuItem = new MenuItem("uploadZipFile", menuItemTitle)
                {
                    Icon = "compress",
                    SeperatorBefore = true
                };
                menuItem.LaunchDialogView("/App_Plugins/zippyMedia/Views/Upload-Zip.html", menuItemTitle);

                e.Menu.Items.Add(menuItem);
            }



            //Upload from server AKA ftp upload comming soon 
            //if (sender.TreeAlias == "media" && mediaType.Equals("Folder") && sender.Security.CurrentUser.UserType.Alias.Equals("admin"))
            //{
            //    var menuItem = new MenuItem("unpackZipFileFromServer", "Unpack ZIP from server");
            //    menuItem.Icon = "server";
            //    menuItem.SeperatorBefore = false;
            //    menuItem.LaunchDialogView("/App_Plugins/zippyMedia/Views/Unpack-Zip.html", "Unpack ZIP archive from server");

            //    e.Menu.Items.Add(menuItem);
            //}

            //if (sender.TreeAlias == "media" && Convert.ToInt32(e.NodeId) == Constants.System.Root && sender.Security.CurrentUser.UserType.Alias.Equals("admin"))
            //{
            //    var menuItem = new MenuItem("unpackZipFileFromServer", "Unpack ZIP from server");
            //    menuItem.Icon = "server";
            //    menuItem.SeperatorBefore = false;
            //    menuItem.LaunchDialogView("/App_Plugins/zippyMedia/Views/Unpack-Zip.html", "Unpack ZIP archive from server");

            //    e.Menu.Items.Add(menuItem);

            //}

        }
        private void TreeControllerBaseOnMenuRendering(TreeControllerBase sender, MenuRenderingEventArgs eventArgs)
        {
            var context = new HttpContextWrapper(HttpContext.Current);
            var urlHelper = new UrlHelper(new RequestContext(context, new RouteData()));
            var treeNodeType = new TreeNodeType(sender.TreeAlias ?? eventArgs.QueryStrings.Get("section"), eventArgs.QueryStrings.Get("treeType"));
            var objectType = Mappings.TreeNodeObjectTypes.ContainsKey(treeNodeType) ?
                Mappings.TreeNodeObjectTypes[treeNodeType] :
                UmbracoObjectTypes.Unknown;
            if (objectType != UmbracoObjectTypes.Unknown && Convert.ToInt32(eventArgs.NodeId) > 0)
            {
                var type = Mappings.TreeNodeObjectTypes[treeNodeType];
                var id = Convert.ToInt32(eventArgs.NodeId);
                var alias = EntityHelper.FindAlias(type, id);

                AddEditRelations(eventArgs, type, alias, urlHelper);
                AddEnableRelations(eventArgs, objectType, urlHelper);
            }
        }
Ejemplo n.º 11
0
        private static void AddPreviewMenuItem(TreeControllerBase sender, MenuRenderingEventArgs e)
        {
            var section = e.QueryStrings.Get("section");
            var treeType = e.QueryStrings.Get("treeType");
            var isDocumentType = section == "settings" && (treeType == "nodeTypes" || treeType == "mediaTypes");
            if (!isDocumentType || e.NodeId == "-1")
                return;

            var insertAfter = e.Menu.Items.FirstOrDefault(extItem => extItem.Alias == "exportDocumentType");

              //creates a menu action that will open /umbraco/currentSection/itemAlias.html
            var i = new MenuItem("previewModelClass", "Preview CodeGen class");
            i.AdditionalData.Add("actionRoute", "settings/codegen/codegen.preview/" + e.NodeId);
            i.Icon = "brackets";

            if (insertAfter != null)
                e.Menu.Items.Insert(e.Menu.Items.IndexOf(insertAfter) + 1, i);
            else
                e.Menu.Items.Add(i);
        }
 void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
 {
     var user = sender.Security.CurrentUser;
     var path = "/App_Plugins/UserGroupPermissions/Views/ApplyUserGroupPermissions.html";
     var title = "Apply User Group Permissions";
     var treeType = e.QueryStrings.Get("treeType");
     var section = e.QueryStrings.Get("section");
     var validTree = "users".InvariantEquals(treeType) && "users".InvariantEquals(section);
     var strUserId = e.NodeId ?? "";
     var userId = default(int);
     var validUserId = int.TryParse(strUserId, out userId) ? userId > 0 : false;
     var validUser = user.IsAdmin();
     if (validTree && validUserId && validUser)
     {
         var menuItem = new MenuItem("ApplyUserGroupPermissions", "Apply Group Permissions")
         {
             Icon = "vcard"
         };
         menuItem.LaunchDialogView(path, title);
         e.Menu.Items.Add(menuItem);
     }
 }
Ejemplo n.º 13
0
        private void AddPurgeCacheForContentMenu(TreeControllerBase sender, MenuRenderingEventArgs args)
        {
            if(sender.TreeAlias != "content")
            {
                //We aren't dealing with the content menu
                return;
            }

            MenuItem menuItem = new MenuItem("purgeCache", "Purge Cloudflare Cache");

            menuItem.Icon = "umbracoflare-tiny";

            menuItem.LaunchDialogView("/App_Plugins/UmbracoFlare/backoffice/treeViews/PurgeCacheDialog.html", "Purge Cloudflare Cache");

            args.Menu.Items.Insert(args.Menu.Items.Count - 1, menuItem);
        }
Ejemplo n.º 14
0
 private static void OnMenuRendering(TreeControllerBase instance, MenuRenderingEventArgs e)
 {
     var handler = MenuRendering;
     if (handler != null) handler(instance, e);
 }
Ejemplo n.º 15
0
        private static void OnMenuRendering(TreeControllerBase instance, MenuRenderingEventArgs e)
        {
            var handler = MenuRendering;

            handler?.Invoke(instance, e);
        }
        private void ContentTreeController_MenuRendering(Umbraco.Web.Trees.TreeControllerBase sender, Umbraco.Web.Trees.MenuRenderingEventArgs e)
        {
            switch (sender.TreeAlias)
            {
            case "content":

                //creates a menu action that will open /umbraco/currentSection/itemAlias.html;
                var i = new Umbraco.Web.Models.Trees.MenuItem("duplicateNode", "Duplicate");

                //optional, if you dont want to follow conventions, but do want to use a angular view
                i.AdditionalData.Add("actionView", "/App_Plugins/DuplicateNode/DuplicateNodeView.html");

                //sets the icon to icon-wine-glass
                i.Icon = "user-females-alt";

                //insert at index 5
                if (e.Menu.Items.Count > 5)
                {
                    e.Menu.Items.Insert(5, i);
                }

                break;
            }
        }
        // A context menu is rendering.
        void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
        {

            // Variables.
            var path = "/App_Plugins/UserGroupPermissions/Views/SetUserGroupPermissions.html";
            var title = "User Group Permissions";

            // Initial check (in content tree and on a node).
            IUser currentUser = sender.Security.CurrentUser;
            var showMenuItem = sender.TreeAlias == "content";
            var strNodeId = e.NodeId;
            var nodeId = default(int);
            if (showMenuItem && int.TryParse(strNodeId, out nodeId))
            {
                showMenuItem = nodeId >= 0;
            }
            else
            {
                showMenuItem = false;
            }

            // Check permissions for non-admin users.
            if (showMenuItem && !currentUser.IsAdmin())
            {
                showMenuItem = false;
                var userService = ApplicationContext.Current.Services.UserService;
                var permissions = userService.GetPermissions(currentUser, nodeId);
                var letter = MenuActions.UserGroupPermissions.Instance.Letter.ToString();
                if(permissions.Any(x => x.AssignedPermissions.InvariantContains(letter)))
                {
                    showMenuItem = true;
                }
            }

            // Add a custom menu item in the content tree.
            if (showMenuItem)
            {

                var menuItem = new MenuItem("UserGroupPermissions", "User Group Permissions")
                {
                    Icon = "vcard"
                };

                menuItem.LaunchDialogView(path, title);

                var permissionsIndex = e.Menu.Items.FindIndex(x =>
                    "Permissions".InvariantEquals(x.Name) ||
                    "Permissions".InvariantEquals(x.Alias));

                // Attempt to insert after the existing "Permissions" menu item.
                if (permissionsIndex >= 0)
                {
                    e.Menu.Items.Insert(permissionsIndex + 1, menuItem);
                }
                else
                {
                    e.Menu.Items.Add(menuItem);
                }

            }

        }
        private static void AddEditRelations(MenuRenderingEventArgs eventArgs, UmbracoObjectTypes type, string alias, UrlHelper urlHelper)
        {
            var typeConfig = Configuration.Get(type, alias);
            if (!typeConfig.Enabled || !typeConfig.EnabledRelations.Any())
                return;

            var menuItem = eventArgs.Menu.Items.Add<EditRelationsAction>("Edit relations");
            menuItem.LaunchDialogView(
                urlHelper.Content("~/App_Plugins/RelationEditor/editrelations.html"),
                "Edit relations"
                );
        }