2017-01-19 09:49:27 +01:00
|
|
|
|
using Umbraco.Core;
|
|
|
|
|
|
using Umbraco.Core.IO;
|
|
|
|
|
|
using umbraco.BusinessLogic.Actions;
|
|
|
|
|
|
using Umbraco.Web.Models.Trees;
|
|
|
|
|
|
using System.Net.Http.Formatting;
|
|
|
|
|
|
using Umbraco.Core.Services;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Trees
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Tree for displaying partial view macros in the developer app
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Tree(Constants.Applications.Developer, "partialViewMacros", "Partial View Macro Files", sortOrder: 6)]
|
|
|
|
|
|
public class PartialViewMacrosTreeController : FileSystemTreeController
|
|
|
|
|
|
{
|
|
|
|
|
|
protected override string FilePath
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return SystemDirectories.MacroPartials; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override string FileSearchPattern
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return "*.cshtml"; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-01-19 10:41:08 +01:00
|
|
|
|
protected override string FileIcon
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return "icon-article"; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-01-19 09:49:27 +01:00
|
|
|
|
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
|
|
|
|
|
|
{
|
|
|
|
|
|
var menu = new MenuItemCollection();
|
|
|
|
|
|
|
|
|
|
|
|
if (id == Constants.System.Root.ToInvariantString())
|
|
|
|
|
|
{
|
2017-01-31 10:10:05 +01:00
|
|
|
|
//set the default to create
|
|
|
|
|
|
menu.DefaultMenuAlias = ActionNew.Instance.Alias;
|
|
|
|
|
|
//create action
|
|
|
|
|
|
menu.Items.Add<ActionNew>(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias)));
|
2017-01-19 09:49:27 +01:00
|
|
|
|
//refresh action
|
|
|
|
|
|
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true);
|
|
|
|
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-02-02 09:20:42 +01:00
|
|
|
|
if (id.EndsWith(FileSearchPattern.TrimStart("*")) == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
//set the default to create
|
|
|
|
|
|
menu.DefaultMenuAlias = ActionNew.Instance.Alias;
|
|
|
|
|
|
//create action
|
|
|
|
|
|
menu.Items.Add<ActionNew>(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias)));
|
|
|
|
|
|
//refresh action
|
|
|
|
|
|
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-01-19 09:49:27 +01:00
|
|
|
|
// TODO: Wire up new delete dialog
|
|
|
|
|
|
menu.Items.Add<ActionDelete>(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)));
|
|
|
|
|
|
return menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnRenderFileNode(ref TreeNode treeNode)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnRenderFileNode(ref treeNode);
|
|
|
|
|
|
}
|
2017-01-26 11:32:13 +00:00
|
|
|
|
|
|
|
|
|
|
protected override void OnRenderFolderNode(ref TreeNode treeNode)
|
|
|
|
|
|
{
|
|
|
|
|
|
//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);";
|
|
|
|
|
|
}
|
2017-01-19 09:49:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|