Files
Umbraco-CMS/src/Umbraco.Web/Trees/PartialViewsTree.cs
Shannon Deminick e88dce59fe Added create dialog to partial view macros files, now need to update that dialog to support creating
macros at the same time like with xslt, etc... but at least you can create/edit/delete them now.
2013-01-01 01:00:33 +03:00

78 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using umbraco.BusinessLogic.Actions;
using umbraco.businesslogic;
using umbraco.cms.businesslogic.template;
using umbraco.cms.presentation.Trees;
using umbraco.interfaces;
namespace Umbraco.Web.Trees
{
/// <summary>
/// Tree for displaying partial views in the settings app
/// </summary>
[Tree("settings", "partialViews", "Partial Views", sortOrder: 2)]
public class PartialViewsTree : FileSystemTree
{
public PartialViewsTree(string application) : base(application) { }
public override void RenderJS(ref StringBuilder javascript)
{
//NOTE: Notice the Partials%2f string below, this is a URLEncoded string of "Partials/" so that the editor knows
// to load the file from the correct location
javascript.Append(
@"
function openPartialView(id) {
UmbClientMgr.contentFrame('Settings/Views/EditView.aspx?file=Partials%2f' + id);
}
");
}
protected override void CreateRootNode(ref XmlTreeNode rootNode)
{
rootNode.NodeType = TreeAlias;
rootNode.NodeID = "init";
}
protected override string FilePath
{
get { return SystemDirectories.MvcViews + "/Partials/"; }
}
protected override string FileSearchPattern
{
get { return "*.cshtml"; }
}
/// <summary>
/// Ensures that no folders can be added
/// </summary>
/// <param name="xNode"></param>
protected override void OnRenderFolderNode(ref XmlTreeNode xNode)
{
xNode = null;
}
protected virtual void ChangeNodeAction(XmlTreeNode xNode)
{
xNode.Action = xNode.Action.Replace("openFile", "openPartialView");
}
protected override void OnRenderFileNode(ref XmlTreeNode xNode)
{
ChangeNodeAction(xNode);
xNode.Icon = "settingView.gif";
xNode.OpenIcon = "settingView.gif";
}
}
}