2012-12-30 00:59:25 +03:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
2012-12-31 02:51:30 +03:00
|
|
|
|
using System.Web;
|
2012-12-30 00:59:25 +03:00
|
|
|
|
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
|
|
|
|
|
|
{
|
2012-12-31 02:51:30 +03:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Tree for displaying partial views in the settings app
|
|
|
|
|
|
/// </summary>
|
2013-03-22 13:13:05 +00:00
|
|
|
|
[Tree(Constants.Applications.Settings, "partialViews", "Partial Views", sortOrder: 2)]
|
2012-12-30 00:59:25 +03:00
|
|
|
|
public class PartialViewsTree : FileSystemTree
|
|
|
|
|
|
{
|
|
|
|
|
|
public PartialViewsTree(string application) : base(application) { }
|
|
|
|
|
|
|
|
|
|
|
|
public override void RenderJS(ref StringBuilder javascript)
|
|
|
|
|
|
{
|
2012-12-31 02:51:30 +03:00
|
|
|
|
//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
|
2012-12-30 00:59:25 +03:00
|
|
|
|
javascript.Append(
|
2013-05-08 14:18:18 -10:00
|
|
|
|
@"
|
2012-12-30 00:59:25 +03:00
|
|
|
|
function openPartialView(id) {
|
2013-05-08 14:18:18 -10:00
|
|
|
|
UmbClientMgr.contentFrame('Settings/Views/EditView.aspx?treeType=partialViews&file=Partials%2f' + id);
|
2012-12-30 00:59:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void CreateRootNode(ref XmlTreeNode rootNode)
|
|
|
|
|
|
{
|
2012-12-31 02:51:30 +03:00
|
|
|
|
rootNode.NodeType = TreeAlias;
|
2012-12-30 00:59:25 +03:00
|
|
|
|
rootNode.NodeID = "init";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override string FilePath
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return SystemDirectories.MvcViews + "/Partials/"; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override string FileSearchPattern
|
|
|
|
|
|
{
|
2012-12-31 02:51:30 +03:00
|
|
|
|
get { return "*.cshtml"; }
|
2012-12-30 00:59:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-12-31 02:51:30 +03:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Ensures that no folders can be added
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="xNode"></param>
|
|
|
|
|
|
protected override void OnRenderFolderNode(ref XmlTreeNode xNode)
|
|
|
|
|
|
{
|
2014-09-04 10:17:54 -04:00
|
|
|
|
// We should allow folder hierarchy for organization in large sites.
|
|
|
|
|
|
xNode.Action = "javascript:void(0);";
|
|
|
|
|
|
xNode.NodeType = "partialViewsFolder";
|
|
|
|
|
|
xNode.Menu = new List<IAction>(new IAction[] { ActionDelete.Instance, ContextMenuSeperator.Instance, ActionNew.Instance, ContextMenuSeperator.Instance, ActionRefresh.Instance });
|
|
|
|
|
|
|
2012-12-31 02:51:30 +03:00
|
|
|
|
}
|
2012-12-30 00:59:25 +03:00
|
|
|
|
|
2012-12-31 02:51:30 +03:00
|
|
|
|
protected virtual void ChangeNodeAction(XmlTreeNode xNode)
|
2012-12-30 00:59:25 +03:00
|
|
|
|
{
|
|
|
|
|
|
xNode.Action = xNode.Action.Replace("openFile", "openPartialView");
|
2012-12-31 02:51:30 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnRenderFileNode(ref XmlTreeNode xNode)
|
|
|
|
|
|
{
|
|
|
|
|
|
ChangeNodeAction(xNode);
|
2013-01-01 01:00:33 +03:00
|
|
|
|
xNode.Icon = "settingView.gif";
|
|
|
|
|
|
xNode.OpenIcon = "settingView.gif";
|
2014-06-18 17:11:47 +10:00
|
|
|
|
|
|
|
|
|
|
xNode.Text = xNode.Text.StripFileExtension();
|
2012-12-30 00:59:25 +03:00
|
|
|
|
}
|
2012-12-04 03:29:02 +05:00
|
|
|
|
|
2012-12-30 00:59:25 +03:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|