2020-11-19 19:23:41 +11:00
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2020-06-08 13:14:23 +02:00
|
|
|
using Microsoft.AspNetCore.Http;
|
2021-01-13 11:02:29 +01:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core;
|
2021-02-23 16:09:36 +01:00
|
|
|
using Umbraco.Cms.Core.Events;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Services;
|
|
|
|
|
using Umbraco.Cms.Core.Trees;
|
|
|
|
|
using Umbraco.Cms.Web.Common.Attributes;
|
|
|
|
|
using Umbraco.Cms.Web.Common.Authorization;
|
|
|
|
|
using Constants = Umbraco.Cms.Core.Constants;
|
2014-11-20 16:28:50 +11:00
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
namespace Umbraco.Cms.Web.BackOffice.Trees
|
2014-11-20 16:28:50 +11:00
|
|
|
{
|
2020-11-19 19:23:41 +11:00
|
|
|
[Authorize(Policy = AuthorizationPolicies.TreeAccessLanguages)]
|
2019-01-22 09:31:47 +01:00
|
|
|
[Tree(Constants.Applications.Settings, Constants.Trees.Languages, SortOrder = 11, TreeGroup = Constants.Trees.Groups.Settings)]
|
2020-09-23 08:55:25 +02:00
|
|
|
[PluginController(Constants.Web.Mvc.BackOfficeTreeArea)]
|
2019-01-22 09:31:47 +01:00
|
|
|
[CoreTree]
|
2014-11-20 16:28:50 +11:00
|
|
|
public class LanguageTreeController : TreeController
|
|
|
|
|
{
|
2020-06-08 13:14:23 +02:00
|
|
|
|
|
|
|
|
public LanguageTreeController(
|
|
|
|
|
ILocalizedTextService textService,
|
2021-02-23 16:09:36 +01:00
|
|
|
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
|
|
|
|
|
IEventAggregator eventAggregator)
|
|
|
|
|
: base(textService, umbracoApiControllerTypeCollection, eventAggregator)
|
2020-06-08 13:14:23 +02:00
|
|
|
{
|
|
|
|
|
}
|
2021-01-14 19:41:32 +01:00
|
|
|
protected override ActionResult<TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings)
|
2014-11-20 16:28:50 +11:00
|
|
|
{
|
2018-03-21 11:42:09 +00:00
|
|
|
//We don't have any child nodes & only use the root node to load a custom UI
|
|
|
|
|
return new TreeNodeCollection();
|
|
|
|
|
}
|
2014-11-20 17:54:30 +11:00
|
|
|
|
2021-01-13 11:02:29 +01:00
|
|
|
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
|
2018-03-21 11:42:09 +00:00
|
|
|
{
|
|
|
|
|
//We don't have any menu item options (such as create/delete/reload) & only use the root node to load a custom UI
|
|
|
|
|
return null;
|
2014-11-20 16:28:50 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-03-21 11:42:09 +00:00
|
|
|
/// Helper method to create a root model for a tree
|
2014-11-20 16:28:50 +11:00
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2021-01-14 19:41:32 +01:00
|
|
|
protected override ActionResult<TreeNode> CreateRootNode(FormCollection queryStrings)
|
2014-11-20 16:28:50 +11:00
|
|
|
{
|
2021-01-14 19:41:32 +01:00
|
|
|
var rootResult = base.CreateRootNode(queryStrings);
|
|
|
|
|
if (!(rootResult.Result is null))
|
|
|
|
|
{
|
|
|
|
|
return rootResult;
|
|
|
|
|
}
|
|
|
|
|
var root = rootResult.Value;
|
2014-11-20 17:54:30 +11:00
|
|
|
|
2018-03-21 11:42:09 +00:00
|
|
|
//this will load in a custom UI instead of the dashboard for the root node
|
2019-11-05 13:45:42 +01:00
|
|
|
root.RoutePath = $"{Constants.Applications.Settings}/{Constants.Trees.Languages}/overview";
|
2018-04-03 11:25:59 +02:00
|
|
|
root.Icon = "icon-globe";
|
2018-03-21 15:53:09 +00:00
|
|
|
root.HasChildren = false;
|
|
|
|
|
root.MenuUrl = null;
|
2014-11-20 16:28:50 +11:00
|
|
|
|
2018-03-21 11:42:09 +00:00
|
|
|
return root;
|
2014-11-20 16:28:50 +11:00
|
|
|
}
|
2020-06-08 13:14:23 +02:00
|
|
|
|
|
|
|
|
|
2014-11-20 16:28:50 +11:00
|
|
|
}
|
2015-10-29 16:26:06 +01:00
|
|
|
}
|