Got the media tree converted to new tree structure.

This commit is contained in:
Shannon
2013-08-05 19:22:00 +10:00
parent 603e698621
commit ab594db5fc
7 changed files with 115 additions and 44 deletions

View File

@@ -17,20 +17,6 @@ using umbraco.interfaces;
namespace Umbraco.Web.Trees
{
//[Tree(Constants.Applications.Content, Constants.Trees.Content, "Content")]
//public class MediaTreeController : ContentTreeControllerBase
//{
// protected override TreeNodeCollection GetTreeData(string id, FormDataCollection queryStrings)
// {
// throw new NotImplementedException();
// }
// protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
// {
// throw new NotImplementedException();
// }
//}
[Tree(Constants.Applications.Content, Constants.Trees.Content, "Content")]
public class ContentTreeController : ContentTreeControllerBase
{
@@ -74,26 +60,10 @@ namespace Umbraco.Web.Trees
protected override TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings)
{
int iid;
if (int.TryParse(id, out iid) == false)
{
throw new InvalidCastException("The id for the content tree must be an integer");
}
var entities = GetChildEntities(id);
var nodes = new TreeNodeCollection();
IEnumerable<IUmbracoEntity> entities;
//if a request is made for the root node data but the user's start node is not the default, then
// we need to return their start node data
if (iid == Constants.System.Root && UmbracoUser.StartNodeId != Constants.System.Root)
{
entities = Services.EntityService.GetChildren(UmbracoUser.StartNodeId, UmbracoObjectTypes.Document).ToArray();
}
else
{
entities = Services.EntityService.GetChildren(iid, UmbracoObjectTypes.Document).ToArray();
}
foreach (var entity in entities)
{
var e = (UmbracoEntity)entity;
@@ -124,8 +94,11 @@ namespace Umbraco.Web.Trees
UmbracoUser.GetPermissions(Constants.System.Root.ToInvariantString()))
.Select(x => new MenuItem(x));
//these two are the standard items
menu.AddMenuItem<ActionNew>();
menu.AddMenuItem<ActionSort>();
//filter the standard items
var allowedMenu = GetUserAllowedMenuItems(menu, nodeActions);
if (allowedMenu.Any())
@@ -133,9 +106,9 @@ namespace Umbraco.Web.Trees
allowedMenu.Last().SeperatorBefore = true;
}
// default actions for all users
// add default actions for *all* users
allowedMenu.AddMenuItem<ActionRePublish>();
menu.AddMenuItem<RefreshNodeMenuItem, ActionRefresh>(true);
allowedMenu.AddMenuItem<RefreshNodeMenuItem, ActionRefresh>(true);
return allowedMenu;
}
@@ -156,6 +129,11 @@ namespace Umbraco.Web.Trees
GetUserMenuItemsForNode(item));
}
protected override UmbracoObjectTypes UmbracoObjectType
{
get { return UmbracoObjectTypes.Document; }
}
protected IEnumerable<MenuItem> CreateAllowedActions()
{
var menu = new MenuItemCollection();