CrLfTab
This commit is contained in:
@@ -1,118 +1,118 @@
|
||||
using System.Linq;
|
||||
using System.Net.Http.Formatting;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
using Umbraco.Web._Legacy.Actions;
|
||||
using Constants = Umbraco.Core.Constants;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Formatting;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
using Umbraco.Web._Legacy.Actions;
|
||||
using Constants = Umbraco.Core.Constants;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
/// <summary>
|
||||
/// The content blueprint tree controller
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This authorizes based on access to the content section even though it exists in the settings
|
||||
/// </remarks>
|
||||
[UmbracoApplicationAuthorize(Constants.Applications.Content)]
|
||||
[Tree(Constants.Applications.Settings, Constants.Trees.ContentBlueprints, null, sortOrder: 8)]
|
||||
[PluginController("UmbracoTrees")]
|
||||
[CoreTree]
|
||||
public class ContentBlueprintTreeController : TreeController
|
||||
{
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
/// <summary>
|
||||
/// The content blueprint tree controller
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This authorizes based on access to the content section even though it exists in the settings
|
||||
/// </remarks>
|
||||
[UmbracoApplicationAuthorize(Constants.Applications.Content)]
|
||||
[Tree(Constants.Applications.Settings, Constants.Trees.ContentBlueprints, null, sortOrder: 8)]
|
||||
[PluginController("UmbracoTrees")]
|
||||
[CoreTree]
|
||||
public class ContentBlueprintTreeController : TreeController
|
||||
{
|
||||
|
||||
protected override TreeNode CreateRootNode(FormDataCollection queryStrings)
|
||||
{
|
||||
var root = base.CreateRootNode(queryStrings);
|
||||
protected override TreeNode CreateRootNode(FormDataCollection queryStrings)
|
||||
{
|
||||
var root = base.CreateRootNode(queryStrings);
|
||||
|
||||
//this will load in a custom UI instead of the dashboard for the root node
|
||||
root.RoutePath = string.Format("{0}/{1}/{2}", Constants.Applications.Settings, Constants.Trees.ContentBlueprints, "intro");
|
||||
//this will load in a custom UI instead of the dashboard for the root node
|
||||
root.RoutePath = string.Format("{0}/{1}/{2}", Constants.Applications.Settings, Constants.Trees.ContentBlueprints, "intro");
|
||||
|
||||
return root;
|
||||
}
|
||||
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
var nodes = new TreeNodeCollection();
|
||||
return root;
|
||||
}
|
||||
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
var nodes = new TreeNodeCollection();
|
||||
|
||||
//get all blueprints
|
||||
var entities = Services.EntityService.GetChildren(Constants.System.Root, UmbracoObjectTypes.DocumentBlueprint).ToArray();
|
||||
//get all blueprints
|
||||
var entities = Services.EntityService.GetChildren(Constants.System.Root, UmbracoObjectTypes.DocumentBlueprint).ToArray();
|
||||
|
||||
//check if we're rendering the root in which case we'll render the content types that have blueprints
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
{
|
||||
//get all blueprint content types
|
||||
var contentTypeAliases = entities.Select(x => ((UmbracoEntity) x).ContentTypeAlias).Distinct();
|
||||
//get the ids
|
||||
var contentTypeIds = Services.ContentTypeService.GetAllContentTypeIds(contentTypeAliases.ToArray()).ToArray();
|
||||
//check if we're rendering the root in which case we'll render the content types that have blueprints
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
{
|
||||
//get all blueprint content types
|
||||
var contentTypeAliases = entities.Select(x => ((UmbracoEntity) x).ContentTypeAlias).Distinct();
|
||||
//get the ids
|
||||
var contentTypeIds = Services.ContentTypeService.GetAllContentTypeIds(contentTypeAliases.ToArray()).ToArray();
|
||||
|
||||
//now get the entities ... it's a bit round about but still smaller queries than getting all document types
|
||||
var docTypeEntities = contentTypeIds.Length == 0
|
||||
? new IUmbracoEntity[0]
|
||||
: Services.EntityService.GetAll(UmbracoObjectTypes.DocumentType, contentTypeIds).ToArray();
|
||||
//now get the entities ... it's a bit round about but still smaller queries than getting all document types
|
||||
var docTypeEntities = contentTypeIds.Length == 0
|
||||
? new IUmbracoEntity[0]
|
||||
: Services.EntityService.GetAll(UmbracoObjectTypes.DocumentType, contentTypeIds).ToArray();
|
||||
|
||||
nodes.AddRange(docTypeEntities
|
||||
.Select(entity =>
|
||||
{
|
||||
var treeNode = CreateTreeNode(entity, Constants.ObjectTypes.DocumentBlueprint, id, queryStrings, "icon-item-arrangement", true);
|
||||
treeNode.Path = string.Format("-1,{0}", entity.Id);
|
||||
treeNode.NodeType = "document-type-blueprints";
|
||||
//TODO: This isn't the best way to ensure a noop process for clicking a node but it works for now.
|
||||
treeNode.AdditionalData["jsClickCallback"] = "javascript:void(0);";
|
||||
return treeNode;
|
||||
}));
|
||||
nodes.AddRange(docTypeEntities
|
||||
.Select(entity =>
|
||||
{
|
||||
var treeNode = CreateTreeNode(entity, Constants.ObjectTypes.DocumentBlueprint, id, queryStrings, "icon-item-arrangement", true);
|
||||
treeNode.Path = string.Format("-1,{0}", entity.Id);
|
||||
treeNode.NodeType = "document-type-blueprints";
|
||||
//TODO: This isn't the best way to ensure a noop process for clicking a node but it works for now.
|
||||
treeNode.AdditionalData["jsClickCallback"] = "javascript:void(0);";
|
||||
return treeNode;
|
||||
}));
|
||||
|
||||
return nodes;
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
var intId = id.TryConvertTo<int>();
|
||||
//Get the content type
|
||||
var ct = Services.ContentTypeService.Get(intId.Result);
|
||||
if (ct == null) return nodes;
|
||||
var intId = id.TryConvertTo<int>();
|
||||
//Get the content type
|
||||
var ct = Services.ContentTypeService.Get(intId.Result);
|
||||
if (ct == null) return nodes;
|
||||
|
||||
var blueprintsForDocType = entities.Where(x => ct.Alias == ((UmbracoEntity) x).ContentTypeAlias);
|
||||
nodes.AddRange(blueprintsForDocType
|
||||
.Select(entity =>
|
||||
{
|
||||
var treeNode = CreateTreeNode(entity, Constants.ObjectTypes.DocumentBlueprint, id, queryStrings, "icon-blueprint", false);
|
||||
treeNode.Path = $"-1,{ct.Id},{entity.Id}";
|
||||
return treeNode;
|
||||
}));
|
||||
var blueprintsForDocType = entities.Where(x => ct.Alias == ((UmbracoEntity) x).ContentTypeAlias);
|
||||
nodes.AddRange(blueprintsForDocType
|
||||
.Select(entity =>
|
||||
{
|
||||
var treeNode = CreateTreeNode(entity, Constants.ObjectTypes.DocumentBlueprint, id, queryStrings, "icon-blueprint", false);
|
||||
treeNode.Path = $"-1,{ct.Id},{entity.Id}";
|
||||
return treeNode;
|
||||
}));
|
||||
|
||||
return nodes;
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
{
|
||||
// root actions
|
||||
menu.Items.Add<ActionNew>(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias)));
|
||||
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true);
|
||||
return menu;
|
||||
}
|
||||
var cte = Services.EntityService.Get(int.Parse(id), UmbracoObjectTypes.DocumentType);
|
||||
//only refresh & create if it's a content type
|
||||
if (cte != null)
|
||||
{
|
||||
var ct = Services.ContentTypeService.Get(cte.Id);
|
||||
var createItem = menu.Items.Add<ActionCreateBlueprintFromContent>(Services.TextService.Localize($"actions/{ActionCreateBlueprintFromContent.Instance.Alias}"));
|
||||
createItem.NavigateToRoute("/settings/contentBlueprints/edit/-1?create=true&doctype=" + ct.Alias);
|
||||
menu.Items.Add<ActionNew>(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias)));
|
||||
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true);
|
||||
return menu;
|
||||
}
|
||||
var cte = Services.EntityService.Get(int.Parse(id), UmbracoObjectTypes.DocumentType);
|
||||
//only refresh & create if it's a content type
|
||||
if (cte != null)
|
||||
{
|
||||
var ct = Services.ContentTypeService.Get(cte.Id);
|
||||
var createItem = menu.Items.Add<ActionCreateBlueprintFromContent>(Services.TextService.Localize($"actions/{ActionCreateBlueprintFromContent.Instance.Alias}"));
|
||||
createItem.NavigateToRoute("/settings/contentBlueprints/edit/-1?create=true&doctype=" + ct.Alias);
|
||||
|
||||
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize($"actions/{ActionRefresh.Instance.Alias}"), true);
|
||||
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize($"actions/{ActionRefresh.Instance.Alias}"), true);
|
||||
|
||||
return menu;
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
menu.Items.Add<ActionDelete>(Services.TextService.Localize($"actions/{ActionDelete.Instance.Alias}"));
|
||||
menu.Items.Add<ActionDelete>(Services.TextService.Localize($"actions/{ActionDelete.Instance.Alias}"));
|
||||
|
||||
return menu;
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Umbraco.Web.Trees
|
||||
public class ContentTreeController : ContentTreeControllerBase, ISearchableTree
|
||||
{
|
||||
private readonly UmbracoTreeSearcher _treeSearcher = new UmbracoTreeSearcher();
|
||||
|
||||
|
||||
protected override int RecycleBinId => Constants.System.RecycleBinContent;
|
||||
|
||||
protected override bool RecycleBinSmells => Services.ContentService.RecycleBinSmells();
|
||||
@@ -98,7 +98,7 @@ namespace Umbraco.Web.Trees
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
|
||||
// if the user's start node is not the root then the only menu item to display is refresh
|
||||
if (UserStartNodes.Contains(Constants.System.Root) == false)
|
||||
{
|
||||
@@ -246,7 +246,7 @@ namespace Umbraco.Web.Trees
|
||||
var menuItem = menu.Items.Add<TItem, TAction>(Services.TextService.Localize("actions", Current.Actions.GetAction<TAction>().Alias), hasSeparator);
|
||||
if (convert) menuItem.ConvertLegacyMenuItem(item, "content", "content");
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<SearchResultItem> Search(string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null)
|
||||
{
|
||||
return _treeSearcher.ExamineSearch(Umbraco, query, UmbracoEntityTypes.Document, pageSize, pageIndex, out totalFound, searchFrom);
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Umbraco.Web.Trees
|
||||
protected abstract TreeNode GetSingleTreeNode(IUmbracoEntity e, string parentId, FormDataCollection queryStrings);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="TreeNode"/> for the <see cref="IUmbracoEntity"/> and
|
||||
/// Returns a <see cref="TreeNode"/> for the <see cref="IUmbracoEntity"/> and
|
||||
/// attaches some meta data to the node if the user doesn't have start node access to it when in dialog mode
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
@@ -88,7 +88,7 @@ namespace Umbraco.Web.Trees
|
||||
if (entityIsAncestorOfStartNodes == false)
|
||||
return null;
|
||||
|
||||
var treeNode = GetSingleTreeNode(e, parentId, queryStrings);
|
||||
var treeNode = GetSingleTreeNode(e, parentId, queryStrings);
|
||||
if (hasPathAccess == false)
|
||||
{
|
||||
treeNode.AdditionalData["noAccess"] = true;
|
||||
@@ -110,7 +110,7 @@ namespace Umbraco.Web.Trees
|
||||
/// Returns the user's start node for this tree
|
||||
/// </summary>
|
||||
protected abstract int[] UserStartNodes { get; }
|
||||
|
||||
|
||||
protected virtual TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
var nodes = new TreeNodeCollection();
|
||||
@@ -167,7 +167,7 @@ namespace Umbraco.Web.Trees
|
||||
if (int.TryParse(pathParts[1], out siteNodeId) == false)
|
||||
continue;
|
||||
|
||||
//we'll look up this
|
||||
//we'll look up this
|
||||
siteNodeIds.Add(siteNodeId);
|
||||
}
|
||||
var siteNodes = Services.EntityService.GetAll(UmbracoObjectType, siteNodeIds.ToArray())
|
||||
@@ -176,13 +176,13 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
//add site nodes
|
||||
nodes.AddRange(siteNodes.Select(e => GetSingleTreeNodeWithAccessCheck(e, id, queryStrings)).Where(node => node != null));
|
||||
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
nodes.AddRange(entities.Select(e => GetSingleTreeNodeWithAccessCheck(e, id, queryStrings)).Where(node => node != null));
|
||||
return nodes;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract MenuItemCollection PerformGetMenuForNode(string id, FormDataCollection queryStrings);
|
||||
|
||||
@@ -353,7 +353,7 @@ namespace Umbraco.Web.Trees
|
||||
var permission = Services.UserService.GetPermissions(Security.CurrentUser, dd.Path);
|
||||
var actions = global::Umbraco.Web._Legacy.Actions.Action.FromEntityPermission(permission)
|
||||
.ToList();
|
||||
|
||||
|
||||
// A user is allowed to delete their own stuff
|
||||
if (dd.CreatorId == Security.GetUserId() && actions.Contains(ActionDelete.Instance) == false)
|
||||
actions.Add(ActionDelete.Instance);
|
||||
@@ -397,7 +397,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var guidUdi = idUdi as GuidUdi;
|
||||
if (guidUdi != null)
|
||||
return new Tuple<Guid?, int?>(guidUdi.Guid, null);
|
||||
return new Tuple<Guid?, int?>(guidUdi.Guid, null);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Umbraco.Web.Trees
|
||||
}
|
||||
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true);
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
@@ -23,4 +23,4 @@ namespace Umbraco.Web.Trees
|
||||
/// <returns></returns>
|
||||
IEnumerable<SearchResultItem> Search(string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
Current.Logger.Warn<LegacyTreeDataConverter>("Cannot render tree: " + appTree.Alias + ". Cannot render a " + typeof(TreeController) + " tree type with the legacy web services.");
|
||||
return null;
|
||||
|
||||
|
||||
//var legacyAtt = controllerAttempt.Result.GetCustomAttribute<LegacyBaseTreeAttribute>(false);
|
||||
//if (legacyAtt == null)
|
||||
//{
|
||||
@@ -228,7 +228,7 @@ namespace Umbraco.Web.Trees
|
||||
new LegacyUrlAction(
|
||||
"dialogs/sort.aspx?id=" + nodeId + "&nodeType=" + nodeType + "&app=" + currentSection + "&rnd=" + DateTime.UtcNow.Ticks,
|
||||
Current.Services.TextService.Localize("actions/sort")));
|
||||
|
||||
|
||||
case "UmbClientMgr.appActions().actionProtect()":
|
||||
return Attempt.Succeed(
|
||||
new LegacyUrlAction(
|
||||
@@ -274,7 +274,7 @@ namespace Umbraco.Web.Trees
|
||||
new LegacyUrlAction(
|
||||
"dialogs/sendToTranslation.aspx?id=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks,
|
||||
Current.Services.TextService.Localize("actions/sendToTranslate")));
|
||||
|
||||
|
||||
case "UmbClientMgr.appActions().actionImport()":
|
||||
return Attempt.Succeed(
|
||||
new LegacyUrlAction(
|
||||
@@ -290,7 +290,7 @@ namespace Umbraco.Web.Trees
|
||||
new LegacyUrlAction(
|
||||
"dialogs/viewAuditTrail.aspx?nodeId=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks,
|
||||
Current.Services.TextService.Localize("actions/auditTrail")));
|
||||
|
||||
|
||||
}
|
||||
return Attempt<LegacyUrlAction>.Fail();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Web.Trees
|
||||
public class MediaTreeController : ContentTreeControllerBase, ISearchableTree
|
||||
{
|
||||
private readonly UmbracoTreeSearcher _treeSearcher = new UmbracoTreeSearcher();
|
||||
|
||||
|
||||
protected override int RecycleBinId => Constants.System.RecycleBinMedia;
|
||||
|
||||
protected override bool RecycleBinSmells => Services.MediaService.RecycleBinSmells();
|
||||
|
||||
@@ -42,4 +42,4 @@ namespace Umbraco.Web.Trees
|
||||
return menu;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user