2013-09-03 12:27:48 +10:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Net;
|
2013-08-12 15:06:12 +02:00
|
|
|
|
using System.Net.Http.Formatting;
|
2013-09-03 12:27:48 +10:00
|
|
|
|
using System.Web.Http;
|
2013-08-12 15:06:12 +02:00
|
|
|
|
using Umbraco.Core;
|
|
|
|
|
|
using Umbraco.Core.Models;
|
|
|
|
|
|
using Umbraco.Core.Services;
|
2013-08-16 17:25:52 +10:00
|
|
|
|
using Umbraco.Web.Mvc;
|
2013-08-12 15:06:12 +02:00
|
|
|
|
using Umbraco.Web.Trees.Menu;
|
|
|
|
|
|
using umbraco.BusinessLogic.Actions;
|
2013-08-16 17:25:52 +10:00
|
|
|
|
using Constants = Umbraco.Core.Constants;
|
2013-08-12 15:06:12 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Trees
|
|
|
|
|
|
{
|
|
|
|
|
|
[Tree(Constants.Applications.Media, Constants.Trees.Media, "Media")]
|
2013-08-16 17:25:52 +10:00
|
|
|
|
[PluginController("UmbracoTrees")]
|
2013-08-12 15:06:12 +02:00
|
|
|
|
public class MediaTreeController : ContentTreeControllerBase
|
|
|
|
|
|
{
|
|
|
|
|
|
protected override int RecycleBinId
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return Constants.System.RecycleBinContent; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override bool RecycleBinSmells
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return Services.MediaService.RecycleBinSmells(); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings)
|
|
|
|
|
|
{
|
|
|
|
|
|
var entities = GetChildEntities(id);
|
|
|
|
|
|
|
|
|
|
|
|
var nodes = new TreeNodeCollection();
|
|
|
|
|
|
|
|
|
|
|
|
nodes.AddRange(
|
|
|
|
|
|
entities.Cast<UmbracoEntity>()
|
|
|
|
|
|
.Select(e => CreateTreeNode(e.Id.ToInvariantString(), queryStrings, e.Name, e.ContentTypeIcon, e.HasChildren)));
|
|
|
|
|
|
|
|
|
|
|
|
return nodes;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override MenuItemCollection PerformGetMenuForNode(string id, FormDataCollection queryStrings)
|
|
|
|
|
|
{
|
|
|
|
|
|
var menu = new MenuItemCollection();
|
|
|
|
|
|
|
|
|
|
|
|
if (id == Constants.System.Root.ToInvariantString())
|
|
|
|
|
|
{
|
2013-08-13 18:19:56 +10:00
|
|
|
|
// root actions
|
2013-08-12 15:06:12 +02:00
|
|
|
|
menu.AddMenuItem<ActionNew>();
|
|
|
|
|
|
menu.AddMenuItem<ActionSort>(true);
|
2013-08-20 17:25:17 +10:00
|
|
|
|
menu.AddMenuItem<RefreshNode, ActionRefresh>(true);
|
2013-08-12 15:06:12 +02:00
|
|
|
|
return menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-09-03 12:27:48 +10:00
|
|
|
|
int iid;
|
|
|
|
|
|
if (int.TryParse(id, out iid) == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new HttpResponseException(HttpStatusCode.NotFound);
|
|
|
|
|
|
}
|
|
|
|
|
|
var item = Services.EntityService.Get(iid, UmbracoObjectTypes.Media);
|
|
|
|
|
|
if (item == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new HttpResponseException(HttpStatusCode.NotFound);
|
|
|
|
|
|
}
|
2013-08-12 15:06:12 +02:00
|
|
|
|
//return a normal node menu:
|
|
|
|
|
|
menu.AddMenuItem<ActionNew>();
|
2013-09-03 12:27:48 +10:00
|
|
|
|
menu.AddMenuItem<ActionMove>().ConvertLegacyMenuItem(item, "media", "media");
|
2013-08-12 15:06:12 +02:00
|
|
|
|
menu.AddMenuItem<ActionDelete>();
|
|
|
|
|
|
menu.AddMenuItem<ActionSort>();
|
|
|
|
|
|
menu.AddMenuItem<ActionRefresh>(true);
|
|
|
|
|
|
return menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override UmbracoObjectTypes UmbracoObjectType
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return UmbracoObjectTypes.Media; }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2013-08-05 19:22:00 +10:00
|
|
|
|
}
|