protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) { var menu = new MenuItemCollection(); // Root actions if (id == "-1") { menu.Items.Add <ActionNew>(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias))) .ConvertLegacyMenuItem(null, Constants.Trees.Packages, queryStrings.GetValue <string>("application")); } else if (id == "created") { menu.Items.Add <ActionNew>(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias))) .ConvertLegacyMenuItem(null, Constants.Trees.Packages, queryStrings.GetValue <string>("application")); menu.Items.Add <RefreshNode, ActionRefresh>( Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true); } else { //it's a package node menu.Items.Add <ActionDelete>(ui.Text("actions", ActionDelete.Instance.Alias)); } return(menu); }
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { var nodes = new TreeNodeCollection(); if (id == Constants.System.Root.ToInvariantString()) { nodes.Add( CreateTreeNode(Constants.Conventions.MemberTypes.AllMembersListId, id, queryStrings, Services.TextService.Localize("member/allMembers"), "icon-users", true, queryStrings.GetValue <string>("application") + TreeAlias.EnsureStartsWith('/') + "/list/" + Constants.Conventions.MemberTypes.AllMembersListId)); if (_isUmbracoProvider) { nodes.AddRange(Services.MemberTypeService.GetAll() .Select(memberType => CreateTreeNode(memberType.Alias, id, queryStrings, memberType.Name, "icon-users", true, queryStrings.GetValue <string>("application") + TreeAlias.EnsureStartsWith('/') + "/list/" + memberType.Alias))); } } //There is no menu for any of these nodes nodes.ForEach(x => x.MenuUrl = null); //All nodes are containers nodes.ForEach(x => x.AdditionalData.Add("isContainer", true)); return(nodes); }
public HttpResponseMessage GetMembersExport(FormDataCollection queryStrings) { // Base Query data string memberType = queryStrings.HasKey("memberType") ? queryStrings.GetValue<string>("memberType") : ""; string orderBy = queryStrings.HasKey("orderBy") ? queryStrings.GetValue<string>("orderBy") : "email"; Direction orderDirection = queryStrings.HasKey("orderDirection") ? queryStrings.GetValue<Direction>("orderDirection") : Direction.Ascending; string filter = queryStrings.HasKey("filter") ? queryStrings.GetValue<string>("filter") : ""; int totalMembers = 0; var members = Mapper.Map<IEnumerable<MemberExportModel>>(MemberSearch.PerformMemberSearch(filter, queryStrings, out totalMembers, memberType, orderBy: orderBy, orderDirection: orderDirection)); var content = members.CreateCSV(); // see http://stackoverflow.com/questions/9541351/returning-binary-file-from-controller-in-asp-net-web-api // & http://stackoverflow.com/questions/12975886/how-to-download-a-file-using-web-api-in-asp-net-mvc-4-and-jquery // We really should use an async version - the above reference includes an example. HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new StringContent(content); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); result.Content.Headers.ContentDisposition.FileName = string.Format("Members_{0:yyyyMMdd}.csv", DateTime.Now); return result; }
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) { var menu = new MenuItemCollection(); // Root actions if (id == "-1") { menu.Items.Add <ActionNew>(Services.TextService, opensDialog: true) .ConvertLegacyMenuItem(null, Constants.Trees.Packages, queryStrings.GetValue <string>("application")); } else if (id == "created") { menu.Items.Add <ActionNew>(Services.TextService, opensDialog: true) .ConvertLegacyMenuItem(null, Constants.Trees.Packages, queryStrings.GetValue <string>("application")); menu.Items.Add(new RefreshNode(Services.TextService, true)); } else { //it's a package node menu.Items.Add <ActionDelete>(Services.TextService, opensDialog: true); } return(menu); }
public HttpResponseMessage GetMembersExport(FormDataCollection queryStrings) { // Base Query data string memberType = queryStrings.HasKey("memberType") ? queryStrings.GetValue <string>("memberType") : ""; string orderBy = queryStrings.HasKey("orderBy") ? queryStrings.GetValue <string>("orderBy") : "email"; Direction orderDirection = queryStrings.HasKey("orderDirection") ? queryStrings.GetValue <Direction>("orderDirection") : Direction.Ascending; string filter = queryStrings.HasKey("filter") ? queryStrings.GetValue <string>("filter") : ""; int totalMembers = 0; var members = Mapper.Map <IEnumerable <MemberExportModel> >(MemberSearch.PerformMemberSearch(filter, queryStrings, out totalMembers, memberType, orderBy: orderBy, orderDirection: orderDirection)); var content = members.CreateCSV(); // see http://stackoverflow.com/questions/9541351/returning-binary-file-from-controller-in-asp-net-web-api // & http://stackoverflow.com/questions/12975886/how-to-download-a-file-using-web-api-in-asp-net-mvc-4-and-jquery // We really should use an async version - the above reference includes an example. HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new StringContent(content); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); result.Content.Headers.ContentDisposition.FileName = string.Format("Members_{0:yyyyMMdd}.csv", DateTime.Now); return(result); }
private string GetEditorPath(ITemplate template, FormDataCollection queryStrings) { //TODO: Rebuild the language editor in angular, then we dont need to have this at all (which is just a path to the legacy editor) return(Services.FileService.DetermineTemplateRenderingEngine(template) == RenderingEngine.WebForms ? "/" + queryStrings.GetValue <string>("application") + "/framed/" + Uri.EscapeDataString("settings/editTemplate.aspx?templateID=" + template.Id) : "/" + queryStrings.GetValue <string>("application") + "/framed/" + Uri.EscapeDataString("settings/Views/EditView.aspx?treeType=" + Constants.Trees.Templates + "&templateID=" + template.Id)); }
/// <summary> /// Returns the menu structure for the node /// </summary> /// <param name="id"></param> /// <param name="queryStrings"></param> /// <returns></returns> protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) { var menu = new MenuItemCollection(); if (id == Constants.System.Root.ToInvariantString()) { //Create the normal create action menu.Items.Add <ActionNew>(ui.Text("actions", ActionNew.Instance.Alias)) //Since we haven't implemented anything for templates in angular, this needs to be converted to //use the legacy format .ConvertLegacyMenuItem(null, "inittemplates", queryStrings.GetValue <string>("application")); //refresh action menu.Items.Add <RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true); return(menu); } var template = Services.FileService.GetTemplate(int.Parse(id)); if (template == null) { return(new MenuItemCollection()); } var entity = FromTemplate(template); //Create the create action for creating sub layouts menu.Items.Add <ActionNew>(ui.Text("actions", ActionNew.Instance.Alias)) //Since we haven't implemented anything for templates in angular, this needs to be converted to //use the legacy format .ConvertLegacyMenuItem(entity, "templates", queryStrings.GetValue <string>("application")); //don't allow delete if it has child layouts if (template.IsMasterTemplate == false) { //add delete option if it doesn't have children menu.Items.Add <ActionDelete>(ui.Text("actions", ActionDelete.Instance.Alias), true) //Since we haven't implemented anything for languages in angular, this needs to be converted to //use the legacy format .ConvertLegacyMenuItem(entity, "templates", queryStrings.GetValue <string>("application")); } //add refresh menu.Items.Add <RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true); return(menu); }
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { var nodes = new TreeNodeCollection(); var settings = _settingsService.GetSettings(); var trashedNodes = _umbracoDbRepository.GetTrashedNodes(); if (id == PackageConstants.FirstNodeId && settings != null && !settings.HideLeftPanel) { foreach (var timage in _imageService.GetTopOptimizedImages()) { var treeNode = CreateTreeNode(timage.Id + string.Empty, id, queryStrings, timage.Name, PackageConstants.TreeIcon, false, queryStrings.GetValue <string>(PackageConstants.AppAlias) + PackageConstants.CustomTreeUrl + SolutionExtensions.Base64Encode(timage.Id)); if (trashedNodes.Count(idNode => timage.Id.Equals(idNode.ToString())) != 0) { treeNode.Name += " (trashed)"; } treeNode.MenuUrl = null; nodes.Add(treeNode); } } return(nodes); }
/// <summary> /// The method called to render the contents of the tree structure /// </summary> /// <param name="id"></param> /// <param name="queryStrings"> /// All of the query string parameters passed from jsTree /// </param> /// <remarks> /// We are allowing an arbitrary number of query strings to be pased in so that developers are able to persist custom data from the front-end /// to the back end to be used in the query for model data. /// </remarks> protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { var nodes = new TreeNodeCollection(); if (id == Constants.System.Root.ToInvariantString()) { var languages = Services.LocalizationService.GetAllLanguages(); foreach (var language in languages) { string displayName; try { displayName = language.CultureInfo.DisplayName; } catch (CultureNotFoundException ex) { Logger.Error <LanguageTreeController>(string.Format("Could not find the specified culture: '{0}'. Please make sure this culture is installed on your machine.", language.IsoCode), ex); displayName = "Unknown Locale (" + language.IsoCode + ")"; } nodes.Add(CreateTreeNode( language.Id.ToString(CultureInfo.InvariantCulture), "-1", queryStrings, displayName, "icon-flag-alt", false, //TODO: Rebuild the language editor in angular, then we dont need to have this at all (which is just a path to the legacy editor) "/" + queryStrings.GetValue <string>("application") + "/framed/" + Uri.EscapeDataString("settings/editLanguage.aspx?id=" + language.Id))); } } return(nodes); }
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) { var menu = new MenuItemCollection(); if (id == Constants.System.Root.ToInvariantString()) { //set the default to create menu.DefaultMenuAlias = ActionNew.Instance.Alias; // root actions menu.Items.Add <ActionNew>(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias))) .ConvertLegacyMenuItem(null, Constants.Trees.Macros, queryStrings.GetValue <string>("application")); menu.Items.Add <RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true); return(menu); } //TODO: This is all hacky ... don't have time to convert the tree, views and dialogs over properly so we'll keep using the legacy dialogs var menuItem = menu.Items.Add(ActionDelete.Instance, Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias))); var legacyConfirmView = LegacyTreeDataConverter.GetLegacyConfirmView(ActionDelete.Instance); if (legacyConfirmView == false) { throw new InvalidOperationException("Could not resolve the confirmation view for the legacy action " + ActionDelete.Instance.Alias); } menuItem.LaunchDialogView( legacyConfirmView.Result, Services.TextService.Localize(string.Format("general/{0}", ActionDelete.Instance.Alias))); return(menu); }
protected virtual TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings) { var nodes = new TreeNodeCollection(); var rootIdString = Constants.System.Root.ToString(CultureInfo.InvariantCulture); var hasAccessToRoot = UserStartNodes.Contains(Constants.System.Root); var startNodeId = queryStrings.HasKey(TreeQueryStringParameters.StartNodeId) ? queryStrings.GetValue <string>(TreeQueryStringParameters.StartNodeId) : string.Empty; if (string.IsNullOrEmpty(startNodeId) == false && startNodeId != "undefined" && startNodeId != rootIdString) { // request has been made to render from a specific, non-root, start node id = startNodeId; // ensure that the user has access to that node, otherwise return the empty tree nodes collection // TODO: in the future we could return a validation statement so we can have some UI to notify the user they don't have access if (HasPathAccess(id, queryStrings) == false) { Logger.Warn <ContentTreeControllerBase>("User {Username} does not have access to node with id {Id}", Security.CurrentUser.Username, id); return(nodes); } // if the tree is rendered... // - in a dialog: render only the children of the specific start node, nothing to do // - in a section: if the current user's start nodes do not contain the root node, we need // to include these start nodes in the tree too, to provide some context - i.e. change // start node back to root node, and then GetChildEntities method will take care of the rest. if (IsDialog(queryStrings) == false && hasAccessToRoot == false) { id = rootIdString; } } // get child entities - if id is root, but user's start nodes do not contain the // root node, this returns the start nodes instead of root's children var entities = GetChildEntities(id, queryStrings).ToList(); nodes.AddRange(entities.Select(x => GetSingleTreeNodeWithAccessCheck(x, id, queryStrings)).Where(x => x != null)); // if the user does not have access to the root node, what we have is the start nodes, // but to provide some context we also need to add their topmost nodes when they are not // topmost nodes themselves (level > 1). if (id == rootIdString && hasAccessToRoot == false) { var topNodeIds = entities.Where(x => x.Level > 1).Select(GetTopNodeId).Where(x => x != 0).Distinct().ToArray(); if (topNodeIds.Length > 0) { var topNodes = Services.EntityService.GetAll(UmbracoObjectType, topNodeIds.ToArray()); nodes.AddRange(topNodes.Select(x => GetSingleTreeNodeWithAccessCheck(x, id, queryStrings)).Where(x => x != null)); } } return(nodes); }
/// <summary> /// If the request should allows a user to choose nodes that they normally don't have access to /// </summary> /// <param name="queryStrings"></param> /// <returns></returns> internal bool IgnoreUserStartNodes(FormDataCollection queryStrings) { var dataTypeId = queryStrings.GetValue <Guid?>(TreeQueryStringParameters.DataTypeId); if (dataTypeId.HasValue) { return(Services.DataTypeService.IsDataTypeIgnoringUserStartNodes(dataTypeId.Value)); } return(false); }
public PagedResult <MemberListItem> GetMembers(FormDataCollection queryStrings) { // Base Query data int pageNumber = queryStrings.HasKey("pageNumber") ? queryStrings.GetValue <int>("pageNumber") : 1; int pageSize = queryStrings.HasKey("pageSize") ? queryStrings.GetValue <int>("pageSize") : 10; string orderBy = queryStrings.HasKey("orderBy") ? queryStrings.GetValue <string>("orderBy") : "email"; Direction orderDirection = queryStrings.HasKey("orderDirection") ? queryStrings.GetValue <Direction>("orderDirection") : Direction.Ascending; string memberType = queryStrings.HasKey("memberType") ? queryStrings.GetValue <string>("memberType") : ""; string filter = queryStrings.HasKey("filter") ? queryStrings.GetValue <string>("filter") : ""; int totalMembers = 0; var members = Mapper.Map <IEnumerable <MemberListItem> >(MemberSearch.PerformMemberSearch(filter, queryStrings, out totalMembers, memberType, pageNumber, pageSize, orderBy, orderDirection)); if (totalMembers == 0) { return(new PagedResult <MemberListItem>(0, 0, 0)); } var pagedResult = new PagedResult <MemberListItem>( totalMembers, pageNumber, pageSize); pagedResult.Items = members; return(pagedResult); }
public PagedResult<MemberListItem> GetMembers(FormDataCollection queryStrings) { // Base Query data int pageNumber = queryStrings.HasKey("pageNumber") ? queryStrings.GetValue<int>("pageNumber") : 1; int pageSize = queryStrings.HasKey("pageSize") ? queryStrings.GetValue<int>("pageSize") : 10; string orderBy = queryStrings.HasKey("orderBy") ? queryStrings.GetValue<string>("orderBy") : "email"; Direction orderDirection = queryStrings.HasKey("orderDirection") ? queryStrings.GetValue<Direction>("orderDirection") : Direction.Ascending; string memberType = queryStrings.HasKey("memberType") ? queryStrings.GetValue<string>("memberType") : ""; string filter = queryStrings.HasKey("filter") ? queryStrings.GetValue<string>("filter") : ""; int totalMembers = 0; var members = Mapper.Map<IEnumerable<MemberListItem>>(MemberSearch.PerformMemberSearch(filter, queryStrings, out totalMembers, memberType, pageNumber, pageSize, orderBy, orderDirection)); if (totalMembers == 0) return new PagedResult<MemberListItem>(0, 0, 0); var pagedResult = new PagedResult<MemberListItem>( totalMembers, pageNumber, pageSize); pagedResult.Items = members; return pagedResult; }
/// <summary> /// Ensures the recycle bin is appended when required (i.e. user has access to the root and it's not in dialog mode) /// </summary> /// <param name="id"></param> /// <param name="queryStrings"></param> /// <returns></returns> /// <remarks> /// This method is overwritten strictly to render the recycle bin, it should serve no other purpose /// </remarks> protected sealed override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { var ignoreUserStartNodes = queryStrings.GetValue <bool>(TreeQueryStringParameters.IgnoreUserStartNodes); //check if we're rendering the root if (id == Constants.System.RootString && UserStartNodes.Contains(Constants.System.Root) || ignoreUserStartNodes) { var altStartId = string.Empty; if (queryStrings.HasKey(TreeQueryStringParameters.StartNodeId)) { altStartId = queryStrings.GetValue <string>(TreeQueryStringParameters.StartNodeId); } //check if a request has been made to render from a specific start node if (string.IsNullOrEmpty(altStartId) == false && altStartId != "undefined" && altStartId != Constants.System.RootString) { id = altStartId; } var nodes = GetTreeNodesInternal(id, queryStrings); //only render the recycle bin if we are not in dialog and the start id id still the root if (IsDialog(queryStrings) == false && id == Constants.System.RootString) { nodes.Add(CreateTreeNode( RecycleBinId.ToInvariantString(), id, queryStrings, Services.TextService.Localize("general/recycleBin"), "icon-trash", RecycleBinSmells, queryStrings.GetRequiredValue <string>("application") + TreeAlias.EnsureStartsWith('/') + "/recyclebin")); } return(nodes); } return(GetTreeNodesInternal(id, queryStrings)); }
public PagedResult <MappedSearchResult> GetSearchResults(FormDataCollection queryStrings) { int pageNumber = queryStrings.HasKey("pageNumber") ? queryStrings.GetValue <int>("pageNumber") : 1; int pageSize = queryStrings.HasKey("pageSize") ? queryStrings.GetValue <int>("pageSize") : 0; string filter = queryStrings.HasKey("filter") ? queryStrings.GetValue <string>("filter") : string.Empty; if (string.IsNullOrEmpty(filter)) { return(new PagedResult <MappedSearchResult>(0, pageNumber, pageSize)); } // todo: consider caching search results in session for paging optimisation. var results = Umbraco.PerformContentSearch(filter); var count = results.Count(); var pagedResult = new PagedResult <MappedSearchResult>( count, pageNumber, pageSize); if (count > 0) { if (pageSize > 0) { int skipCount = (pageNumber > 0 && pageSize > 0) ? Convert.ToInt32((pageNumber - 1) * pageSize) : 0; if (count < skipCount) { skipCount = count / pageSize; } pagedResult.Items = results.Skip(skipCount).Take(pageSize); } else { pagedResult.Items = results; } } return(pagedResult); }
/// <summary> /// If the request should allows a user to choose nodes that they normally don't have access to /// </summary> /// <param name="queryStrings"></param> /// <returns></returns> internal bool IgnoreUserStartNodes(FormDataCollection queryStrings) { if (_ignoreUserStartNodes.HasValue) { return(_ignoreUserStartNodes.Value); } var dataTypeKey = queryStrings.GetValue <Guid?>(TreeQueryStringParameters.DataTypeKey); _ignoreUserStartNodes = dataTypeKey.HasValue && Services.DataTypeService.IsDataTypeIgnoringUserStartNodes(dataTypeKey.Value); return(_ignoreUserStartNodes.Value); }
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) { var menu = new MenuItemCollection(); if (id == Constants.System.Root.ToInvariantString()) { //Create the normal create action menu.Items.Add <ActionNew>(Services.TextService, opensDialog: true) //Since we haven't implemented anything for macros in angular, this needs to be converted to //use the legacy format .ConvertLegacyMenuItem(null, "initmacros", queryStrings.GetValue <string>("application")); //refresh action menu.Items.Add(new RefreshNode(Services.TextService, true)); return(menu); } var macro = Services.MacroService.GetById(int.Parse(id)); if (macro == null) { return(new MenuItemCollection()); } //add delete option for all macros menu.Items.Add <ActionDelete>(Services.TextService, opensDialog: true) //Since we haven't implemented anything for macros in angular, this needs to be converted to //use the legacy format .ConvertLegacyMenuItem(new EntitySlim { Id = macro.Id, Level = 1, ParentId = -1, Name = macro.Name }, "macros", queryStrings.GetValue <string>("application")); return(menu); }
/// <summary> /// Returns the menu structure for the node /// </summary> /// <param name="id"></param> /// <param name="queryStrings"></param> /// <returns></returns> protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) { var menu = new MenuItemCollection(); if (id == Constants.System.Root.ToInvariantString()) { //Create the normal create action menu.Items.Add <ActionNew>(ui.Text("actions", ActionNew.Instance.Alias)) //Since we haven't implemented anything for languages in angular, this needs to be converted to //use the legacy format .ConvertLegacyMenuItem(null, "initlanguages", queryStrings.GetValue <string>("application")); //refresh action menu.Items.Add <RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true); return(menu); } var lang = Services.LocalizationService.GetLanguageById(int.Parse(id)); if (lang == null) { return(new MenuItemCollection()); } //add delete option for all languages menu.Items.Add <ActionDelete>(ui.Text("actions", ActionDelete.Instance.Alias)) //Since we haven't implemented anything for languages in angular, this needs to be converted to //use the legacy format .ConvertLegacyMenuItem(new UmbracoEntity { Id = lang.Id, Level = 1, ParentId = -1, Name = lang.CultureInfo.DisplayName }, "language", queryStrings.GetValue <string>("application")); return(menu); }
protected override MenuItemCollection GetMenuForRootNode(FormDataCollection queryStrings) { var menu = new MenuItemCollection(); //set the default to create menu.DefaultMenuAlias = ActionNew.Instance.Alias; // root actions menu.Items.Add <ActionNew>(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias))) .ConvertLegacyMenuItem(null, Constants.Trees.Xslt, queryStrings.GetValue <string>("application")); menu.Items.Add <RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true); return(menu); }
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { var baseUrl = Constants.Applications.Developer + "/packages/"; var nodes = new TreeNodeCollection(); var createdPackages = CreatedPackage.GetAllCreatedPackages(); if (id == "created") { nodes.AddRange( createdPackages .OrderBy(entity => entity.Data.Name) .Select(dt => { var node = CreateTreeNode(dt.Data.Id.ToString(), id, queryStrings, dt.Data.Name, "icon-inbox", false, string.Format("/{0}/framed/{1}", queryStrings.GetValue <string>("application"), Uri.EscapeDataString("developer/Packages/EditPackage.aspx?id=" + dt.Data.Id))); return(node); })); } else { //must be root var node = CreateTreeNode( "created", id, queryStrings, Services.TextService.Localize("treeHeaders/createdPackages"), "icon-folder", createdPackages.Count > 0, string.Empty); //TODO: This isn't the best way to ensure a noop process for clicking a node but it works for now. node.AdditionalData["jsClickCallback"] = "javascript:void(0);"; nodes.Add(node); } return(nodes); }
/// <summary> /// Helper method to create a root model for a tree /// </summary> /// <returns></returns> protected virtual TreeNode CreateRootNode(FormDataCollection queryStrings) { var rootNodeAsString = Constants.System.Root.ToString(CultureInfo.InvariantCulture); var currApp = queryStrings.GetValue <string>(TreeQueryStringParameters.Application); var node = new TreeNode( rootNodeAsString, null, //this is a root node, there is no parent Url.GetTreeUrl(GetType(), rootNodeAsString, queryStrings), Url.GetMenuUrl(GetType(), rootNodeAsString, queryStrings)) { HasChildren = true, RoutePath = currApp, Name = RootNodeDisplayName }; return(node); }
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { var nodes = new TreeNodeCollection(); long totalUsers; nodes.AddRange( Services.UserService.GetAll(0, int.MaxValue, out totalUsers) .Where(x => x.Id != Constants.Security.SuperUserId && x.IsApproved) .Select(x => CreateTreeNode(x.Id.ToString(), id, queryStrings, x.Name, "icon-user", false, "/" + queryStrings.GetValue <string>("application") + "/framed/" + Uri.EscapeDataString("users/PermissionEditor.aspx?id=" + x.Id)))); return(nodes); }
/// <summary> /// Gets the tree nodes for the given id /// </summary> /// <param name="id"></param> /// <param name="queryStrings"></param> /// <returns></returns> protected virtual TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings) { var nodes = new TreeNodeCollection(); var altStartId = string.Empty; if (queryStrings.HasKey(TreeQueryStringParameters.StartNodeId)) { altStartId = queryStrings.GetValue <string>(TreeQueryStringParameters.StartNodeId); } //check if a request has been made to render from a specific start node if (string.IsNullOrEmpty(altStartId) == false && altStartId != "undefined" && altStartId != Constants.System.Root.ToString(CultureInfo.InvariantCulture)) { id = altStartId; //we need to verify that the user has access to view this node, otherwise we'll render an empty tree collection // TODO: in the future we could return a validation statement so we can have some UI to notify the user they don't have access if (HasPathAccess(id, queryStrings) == false) { LogHelper.Warn <ContentTreeControllerBase>("The user " + Security.CurrentUser.Username + " does not have access to the tree node " + id); return(new TreeNodeCollection()); } // So there's an alt id specified, it's not the root node and the user has access to it, great! But there's one thing we // need to consider: // If the tree is being rendered in a dialog view we want to render only the children of the specified id, but // when the tree is being rendered normally in a section and the current user's start node is not -1, then // we want to include their start node in the tree as well. // Therefore, in the latter case, we want to change the id to -1 since we want to render the current user's root node // and the GetChildEntities method will take care of rendering the correct root node. // If it is in dialog mode, then we don't need to change anything and the children will just render as per normal. if (IsDialog(queryStrings) == false && UserStartNode != Constants.System.Root) { id = Constants.System.Root.ToString(CultureInfo.InvariantCulture); } } var entities = GetChildEntities(id); nodes.AddRange(entities.Select(entity => GetSingleTreeNode(entity, id, queryStrings)).Where(node => node != null)); return(nodes); }
/// <summary> /// The method called to render the contents of the tree structure /// </summary> /// <param name="id"></param> /// <param name="queryStrings"> /// All of the query string parameters passed from jsTree /// </param> /// <remarks> /// We are allowing an arbitrary number of query strings to be pased in so that developers are able to persist custom data from the front-end /// to the back end to be used in the query for model data. /// </remarks> protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { var nodes = new TreeNodeCollection(); if (id == Constants.System.Root.ToInvariantString()) { var languages = Services.LocalizationService.GetAllLanguages(); foreach (var language in languages) { nodes.Add( CreateTreeNode( language.Id.ToString(CultureInfo.InvariantCulture), "-1", queryStrings, language.CultureInfo.DisplayName, "icon-flag-alt", false, //TODO: Rebuild the language editor in angular, then we dont need to have this at all (which is just a path to the legacy editor) "/" + queryStrings.GetValue <string>("application") + "/framed/" + Uri.EscapeDataString("settings/editLanguage.aspx?id=" + language.Id))); } } return(nodes); }
/// <summary> /// Returns the menu structure for the node /// </summary> /// <param name="id"></param> /// <param name="queryStrings"></param> /// <returns></returns> protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) { var menu = new MenuItemCollection(); //Create the normal create action var item = menu.Items.Add <ActionNew>(ui.Text("actions", ActionNew.Instance.Alias)); item.NavigateToRoute(string.Format("{0}/templates/edit/{1}?create=true", queryStrings.GetValue <string>("application"), id)); if (id == Constants.System.Root.ToInvariantString()) { //refresh action menu.Items.Add <RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true); return(menu); } var template = Services.FileService.GetTemplate(int.Parse(id)); if (template == null) { return(new MenuItemCollection()); } var entity = FromTemplate(template); //don't allow delete if it has child layouts if (template.IsMasterTemplate == false) { //add delete option if it doesn't have children menu.Items.Add <ActionDelete>(ui.Text("actions", ActionDelete.Instance.Alias), true); } //add refresh menu.Items.Add <RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true); return(menu); }
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { var nodes = new TreeNodeCollection(); if (id == Constants.System.Root.ToInvariantString()) { foreach (var macro in Services.MacroService.GetAll()) { nodes.Add(CreateTreeNode( macro.Id.ToString(), id, queryStrings, macro.Name, "icon-settings-alt", false, //TODO: Rebuild the macro editor in angular, then we dont need to have this at all (which is just a path to the legacy editor) "/" + queryStrings.GetValue <string>("application") + "/framed/" + Uri.EscapeDataString("/umbraco/developer/macros/editMacro.aspx?macroID=" + macro.Id))); } } return(nodes); }
/// <summary> /// Helper method to create a root model for a tree /// </summary> /// <returns></returns> protected virtual TreeNode CreateRootNode(FormDataCollection queryStrings) { var getChildNodesUrl = Url.GetTreeUrl(GetType(), RootNodeId, queryStrings); var isDialog = queryStrings.GetValue <bool>(TreeQueryStringParameters.DialogMode); //var node = new TreeNode(RootNodeId, BackOfficeRequestContext.RegisteredComponents.MenuItems, jsonUrl) var node = new TreeNode(RootNodeId, getChildNodesUrl) { HasChildren = true, //THIS IS TEMPORARY UNTIL WE FIGURE OUT HOW WE ARE LOADING STUFF (I.E. VIEW NAMES, ACTION NAMES, DUNNO) EditorUrl = queryStrings.HasKey(TreeQueryStringParameters.OnNodeClick) //has a node click handler? ? queryStrings.Get(TreeQueryStringParameters.OnNodeClick) //return node click handler : isDialog //is in dialog mode without a click handler ? ? "#" //return empty string, otherwise, return an editor URL: : "mydashboard", Title = RootNodeDisplayName }; //add the tree type to the root node.AdditionalData.Add("treeType", GetType().FullName); ////add the tree-root css class //node.Style.AddCustom("tree-root"); //node.AdditionalData.Add("id", node.HiveId.ToString()); //node.AdditionalData.Add("title", node.Title); AddQueryStringsToAdditionalData(node, queryStrings); //check if the tree is searchable and add that to the meta data as well if (this is ISearchableTree) { node.AdditionalData.Add("searchable", "true"); } return(node); }
/// <summary> /// This will automatically check if the recycle bin needs to be rendered (i.e. its the first level) /// and will automatically append it to the result of GetChildNodes. /// </summary> /// <param name="id"></param> /// <param name="queryStrings"></param> /// <returns></returns> protected sealed override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { //check if we're rendering the root if (id == Constants.System.Root.ToInvariantString() && UserStartNode == Constants.System.Root) { var nodes = new TreeNodeCollection(); var altStartId = string.Empty; if(queryStrings.HasKey(TreeQueryStringParameters.StartNodeId)) altStartId = queryStrings.GetValue<string>(TreeQueryStringParameters.StartNodeId); //check if a request has been made to render from a specific start node //TODO: This 'undefined' check should not be required whatseover - this parameter should not be sent up ever it if is null from the front-end. if (!string.IsNullOrEmpty(altStartId) && altStartId != "undefined" && altStartId != Constants.System.Root.ToString(CultureInfo.InvariantCulture)) { id = queryStrings.GetValue<string>(TreeQueryStringParameters.StartNodeId); //we need to verify that the user has access to view this node, otherwise we'll render an empty tree collection // TODO: in the future we could return a validation statement so we can have some UI to notify the user they don't have access if (HasPathAccess(id, queryStrings)) { nodes = GetTreeNodesInternal(id, queryStrings); } } else { //load normally nodes = GetTreeNodesInternal(id, queryStrings); } //only render the recycle bin if we are not in dialog and the start id id still the root if (IsDialog(queryStrings) == false && id == Constants.System.Root.ToInvariantString()) { nodes.Add(CreateTreeNode( RecycleBinId.ToInvariantString(), id, queryStrings, ui.GetText("general", "recycleBin"), "icon-trash", RecycleBinSmells, //TODO: This would be nice to enable so we can have a nice recyclebin view, see the NOTE: in the routes.js angular file // for the time being we'll just load the dashboard of the section. //queryStrings.GetValue<string>("application") + TreeAlias.EnsureStartsWith('/') + "/recyclebin")); queryStrings.GetValue<string>("application"))); } return nodes; } return GetTreeNodesInternal(id, queryStrings); }
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { if (id == global::Umbraco.Core.Constants.System.Root.ToString()) { //top level nodes - generate list of tag groups that this user has access to. var tree = new TreeNodeCollection(); foreach (var tagGroup in _tManagerController.GetTagGroups()) { var item = CreateTreeNode("tagGroup-" + tagGroup.Group, id, null, tagGroup.Group, "icon-bulleted-list", true, queryStrings.GetValue <string>("application")); tree.Add(item); } return(tree); } else { //List all tags under group //Get tag groupname var groupName = id.Substring(id.IndexOf('-') + 1); var tree = new TreeNodeCollection(); var cmsTags = _tManagerController.GetAllTagsInGroup(groupName); foreach (var tag in cmsTags) { var item = CreateTreeNode(tag.Id.ToString(), groupName, queryStrings, $"{tag.Tag} ({tag.NoTaggedNodes.ToString()})", "icon-bulleted-list", false); tree.Add(item); } return(tree); } }
/// <summary> /// Helper method to create a root model for a tree /// </summary> /// <returns></returns> protected virtual TreeNode CreateRootNode(FormDataCollection queryStrings) { var getChildNodesUrl = Url.GetTreeUrl(GetType(), RootNodeId, queryStrings); var isDialog = queryStrings.GetValue<bool>(TreeQueryStringParameters.DialogMode); //var node = new TreeNode(RootNodeId, BackOfficeRequestContext.RegisteredComponents.MenuItems, jsonUrl) var node = new TreeNode(RootNodeId, getChildNodesUrl) { HasChildren = true, //THIS IS TEMPORARY UNTIL WE FIGURE OUT HOW WE ARE LOADING STUFF (I.E. VIEW NAMES, ACTION NAMES, DUNNO) EditorUrl = queryStrings.HasKey(TreeQueryStringParameters.OnNodeClick) //has a node click handler? ? queryStrings.Get(TreeQueryStringParameters.OnNodeClick) //return node click handler : isDialog //is in dialog mode without a click handler ? ? "#" //return empty string, otherwise, return an editor URL: : "mydashboard", Title = RootNodeDisplayName }; //add the tree type to the root node.AdditionalData.Add("treeType", GetType().FullName); ////add the tree-root css class //node.Style.AddCustom("tree-root"); //node.AdditionalData.Add("id", node.HiveId.ToString()); //node.AdditionalData.Add("title", node.Title); AddQueryStringsToAdditionalData(node, queryStrings); //check if the tree is searchable and add that to the meta data as well if (this is ISearchableTree) { node.AdditionalData.Add("searchable", "true"); } return node; }
/// <summary> /// If the request should allows a user to choose nodes that they normally don't have access to /// </summary> /// <param name="queryStrings"></param> /// <returns></returns> protected bool IgnoreUserStartNodes(FormDataCollection queryStrings) { return(queryStrings.GetValue <bool>(TreeQueryStringParameters.IgnoreUserStartNodes)); }
/// <summary> /// Helper method to create a root model for a tree /// </summary> /// <returns></returns> protected virtual TreeNode CreateRootNode(FormDataCollection queryStrings) { var rootNodeAsString = Constants.System.Root.ToString(CultureInfo.InvariantCulture); var currApp = queryStrings.GetValue<string>(TreeQueryStringParameters.Application); var node = new TreeNode( rootNodeAsString, null, //this is a root node, there is no parent Url.GetTreeUrl(GetType(), rootNodeAsString, queryStrings), Url.GetMenuUrl(GetType(), rootNodeAsString, queryStrings)) { HasChildren = true, RoutePath = currApp, Name = RootNodeDisplayName }; return node; }
/// <summary> /// If the request is for a dialog mode tree /// </summary> /// <param name="queryStrings"></param> /// <returns></returns> protected bool IsDialog(FormDataCollection queryStrings) { return(queryStrings.GetValue <bool>(TreeQueryStringParameters.IsDialog)); }
/// <summary> /// If the request is for a dialog mode tree /// </summary> /// <param name="queryStrings"></param> /// <returns></returns> protected bool IsDialog(FormDataCollection queryStrings) { return queryStrings.GetValue<bool>(TreeQueryStringParameters.IsDialog); }
public static IEnumerable<SearchResult> PerformMemberSearch(string filter, FormDataCollection queryStrings, out int totalRecordCount, string memberType = "", int pageNumber = 0, int pageSize = 0, string orderBy = "", Direction orderDirection = Direction.Ascending) { var internalSearcher = ExamineManager.Instance.SearchProviderCollection[Constants.Examine.InternalMemberSearcher]; ISearchCriteria criteria = internalSearcher.CreateSearchCriteria().RawQuery(" +__IndexType:member"); //build a lucene query if (string.IsNullOrWhiteSpace(filter) && !queryStrings.Any(qs => qs.Key.StartsWith("f_") && !string.IsNullOrWhiteSpace(qs.Value))) { // Generic get everything... criteria.RawQuery("a* b* c* d* e* f* g* h* i* j* k* l* m* n* o* p* q* r* s* t* u* v* w* x* y* z*"); } else { // the __nodeName will be boosted 10x without wildcards // then __nodeName will be matched normally with wildcards // the rest will be normal without wildcards if (!string.IsNullOrWhiteSpace(filter)) { var sb = new StringBuilder(); sb.Append("+("); //node name exactly boost x 10 sb.AppendFormat("__nodeName:{0}^10.0 ", filter.ToLower()); //node name normally with wildcards sb.AppendFormat(" __nodeName:{0}* ", filter.ToLower()); var basicFields = new List<string>() { "id", "_searchEmail", "email", "loginName" }; var userFields = ExamineManager.Instance.IndexProviderCollection["InternalMemberIndexer"].IndexerData.UserFields.Select(x => x.Name); basicFields.AddRange(userFields); foreach (var field in basicFields.Distinct()) { //additional fields normally sb.AppendFormat("{0}:{1} ", field, filter); } sb.Append(")"); criteria.RawQuery(sb.ToString()); } // Now specific field searching. - these should be ANDed and grouped. foreach (var qs in queryStrings.Where(q => q.Key.StartsWith("f_") && !string.IsNullOrWhiteSpace(q.Value))) { // Got a filter. string alias = qs.Key.Substring(2); var values = queryStrings.GetValue<string>(qs.Key).Split(','); if (values.Length > 0) { criteria.GroupedOr(new[] { alias }, values); } } } //must match index type if (!string.IsNullOrWhiteSpace(memberType)) { criteria.NodeTypeAlias(memberType); } //// Order the results //// Examine Sorting seems too unreliable, particularly on nodeName //if (orderDirection == Direction.Ascending) { // criteria.OrderBy(orderBy.ToLower() == "name" ? "nodeName" : "email"); //} else { // criteria.OrderByDescending(orderBy.ToLower() == "name" ? "nodeName" : "email"); //} var result = internalSearcher.Search(criteria); totalRecordCount = result.TotalItemCount; // Order the results var orderedResults = orderDirection == Direction.Ascending ? result.OrderBy(o => orderBy.ToLower() == "name" ? o.Fields["nodeName"] : o.Fields["email"]) : result.OrderByDescending(o => orderBy.ToLower() == "name" ? o.Fields["nodeName"] : o.Fields["email"]); if (pageSize > 0) { int skipCount = (pageNumber > 0 && pageSize > 0) ? Convert.ToInt32((pageNumber - 1) * pageSize) : 0; if (result.TotalItemCount < skipCount) { skipCount = result.TotalItemCount / pageSize; } return orderedResults.Skip(skipCount).Take(pageSize); } return orderedResults; }
private IEnumerable <EntityBasic> GetResultForAncestors(int id, UmbracoEntityTypes entityType, FormDataCollection queryStrings = null, bool ignoreUserStartNodes = false) { var objectType = ConvertToObjectType(entityType); if (objectType.HasValue) { // TODO: Need to check for Object types that support hierarchic here, some might not. var ids = Services.EntityService.Get(id).Path.Split(',').Select(int.Parse).Distinct().ToArray(); if (ignoreUserStartNodes == false) { int[] aids = null; switch (entityType) { case UmbracoEntityTypes.Document: aids = Security.CurrentUser.CalculateContentStartNodeIds(Services.EntityService); break; case UmbracoEntityTypes.Media: aids = Security.CurrentUser.CalculateMediaStartNodeIds(Services.EntityService); break; } if (aids != null) { var lids = new List <int>(); var ok = false; foreach (var i in ids) { if (ok) { lids.Add(i); continue; } if (aids.Contains(i)) { lids.Add(i); ok = true; } } ids = lids.ToArray(); } } var culture = queryStrings?.GetValue <string>("culture"); return(ids.Length == 0 ? Enumerable.Empty <EntityBasic>() : Services.EntityService.GetAll(objectType.Value, ids) .WhereNotNull() .OrderBy(x => x.Level) .Select(MapEntities(culture))); } //now we need to convert the unknown ones switch (entityType) { case UmbracoEntityTypes.PropertyType: case UmbracoEntityTypes.PropertyGroup: case UmbracoEntityTypes.Domain: case UmbracoEntityTypes.Language: case UmbracoEntityTypes.User: case UmbracoEntityTypes.Macro: default: throw new NotSupportedException("The " + typeof(EntityController) + " does not currently support data for the type " + entityType); } }