Wire up the editors and controllers

This commit is contained in:
Niels Hartvig
2017-01-19 09:49:27 +01:00
parent 1fb05fcca7
commit 051af5c48e
12 changed files with 154 additions and 653 deletions

View File

@@ -562,13 +562,6 @@
<Compile Include="Umbraco\Settings\Stylesheet\Property\EditStyleSheetProperty.aspx.designer.cs">
<DependentUpon>EditStyleSheetProperty.aspx</DependentUpon>
</Compile>
<Compile Include="Umbraco\Settings\Views\EditView.aspx.cs">
<DependentUpon>EditView.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Umbraco\Settings\Views\EditView.aspx.designer.cs">
<DependentUpon>EditView.aspx</DependentUpon>
</Compile>
<Compile Include="Umbraco\TreeInit.aspx.cs">
<DependentUpon>treeInit.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -751,7 +744,6 @@
<Content Include="Umbraco\Images\thumbs_med.png" />
<Content Include="Umbraco\Images\thumbs_smll.png" />
<Content Include="Umbraco\Images\Umbraco\settingView.gif" />
<Content Include="Umbraco\Settings\Views\EditView.aspx" />
<Content Include="Umbraco_Client\Application\Extensions.js" />
<Content Include="Umbraco_Client\Application\JQuery\jquery.validate.min.js" />
<Content Include="Umbraco_Client\Application\JQuery\jquery.validate.unobtrusive.min.js" />

View File

@@ -9,10 +9,10 @@
<!--Settings-->
<add initialize="true" sortOrder="0" alias="documentTypes" application="settings" title="Document Types" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Web.Trees.ContentTypeTreeController, umbraco" />
<add application="settings" alias="templates" title="Templates" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Web.Trees.TemplatesTreeController, umbraco" initialize="true" sortOrder="1" />
<add application="settings" alias="partialViews" title="Partial Views" silent="false" initialize="true" iconClosed="icon-folder" iconOpen="icon-folder" type="Umbraco.Web.Trees.PartialViewsTree, umbraco" sortOrder="2" />
<add application="settings" alias="partialViews" title="Partial Views" silent="false" initialize="true" iconClosed="icon-folder" iconOpen="icon-folder" type="Umbraco.Web.Trees.PartialViewsTreeController, umbraco" sortOrder="2" />
<add application="settings" alias="stylesheets" title="Stylesheets" type="umbraco.loadStylesheets, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="3" />
<add application="settings" alias="stylesheetProperty" title="Stylesheet Property" type="umbraco.loadStylesheetProperty, umbraco" iconClosed="" iconOpen="" initialize="false" sortOrder="0" />
<add application="settings" alias="scripts" title="Scripts" type="umbraco.loadScripts, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="4" />
<add application="settings" alias="scripts" title="Scripts" type="Umbraco.Web.Trees.ScriptTreeController, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="4" />
<add application="settings" alias="languages" title="Languages" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Web.Trees.LanguageTreeController, umbraco" sortOrder="5" />
<add application="settings" alias="dictionary" title="Dictionary" type="umbraco.loadDictionary, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="6" />
<add initialize="true" sortOrder="7" alias="mediaTypes" application="settings" title="Media Types" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Web.Trees.MediaTypeTreeController, umbraco" />
@@ -22,7 +22,7 @@
<add application="developer" alias="macros" title="Macros" type="umbraco.loadMacros, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="2" />
<add application="developer" alias="relationTypes" title="Relation Types" type="umbraco.loadRelationTypes, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="4" />
<add application="developer" alias="xslt" title="XSLT Files" type="umbraco.loadXslt, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="5" />
<add application="developer" alias="partialViewMacros" type="Umbraco.Web.Trees.PartialViewMacrosTree, umbraco" silent="false" initialize="true" sortOrder="6" title="Partial View Macro Files" iconClosed="icon-folder" iconOpen="icon-folder" />
<add application="developer" alias="partialViewMacros" type="Umbraco.Web.Trees.PartialViewMacrosTreeController, umbraco" silent="false" initialize="true" sortOrder="6" title="Partial View Macro Files" iconClosed="icon-folder" iconOpen="icon-folder" />
<!--Users-->
<add application="users" alias="users" title="Users" type="umbraco.loadUsers, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="0" />
<add application="users" alias="userTypes" title="User Types" type="umbraco.cms.presentation.Trees.UserTypes, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="1" />
@@ -41,5 +41,4 @@
<add initialize="true" sortOrder="0" alias="form" application="forms" title="Forms" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Forms.Web.Trees.FormTreeController, Umbraco.Forms.Web" />
<add initialize="true" sortOrder="3" alias="prevaluesource" application="forms" title="Prevalue sources" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Forms.Web.Trees.PreValueSourceTreeController, Umbraco.Forms.Web" />
<add initialize="true" sortOrder="3" alias="formsecurity" application="users" title="Forms Security" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Forms.Web.Trees.FormSecurityTreeController, Umbraco.Forms.Web" />
</trees>

View File

@@ -1,88 +0,0 @@
<%@ Page Language="C#" MasterPageFile="../../masterpages/umbracoPage.Master" AutoEventWireup="True"
CodeBehind="EditView.aspx.cs" Inherits="Umbraco.Web.UI.Umbraco.Settings.Views.EditView"
ValidateRequest="False" %>
<%@ OutputCache Location="None" %>
<%@ Import Namespace="Umbraco.Core" %>
<%@ Import Namespace="Umbraco.Core.IO" %>
<%@ Import Namespace="Umbraco.Web" %>
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
<asp:Content ID="DocTypeContent" ContentPlaceHolderID="DocType" runat="server">
<!DOCTYPE html>
</asp:Content>
<asp:Content ContentPlaceHolderID="head" runat="server">
<umb:JsInclude ID="JsInclude1" runat="server" FilePath="Editors/EditView.js" PathNameAlias="UmbracoClient" />
<script type="text/javascript">
//we need to have this as a global object since we reference this object with callbacks.
var editViewEditor;
(function ($) {
$(document).ready(function () {
//create and assign a new EditView object
editViewEditor = new Umbraco.Editors.EditView({
treeSyncPath: "<%=TemplateTreeSyncPath%>",
currentTreeType: "<%=CurrentTreeType%>",
editorType: "<%= EditorType.ToString() %>",
originalFileName: "<%=OriginalFileName %>",
restServiceLocation: "<%= Url.GetSaveFileServicePath() %>",
masterPageDropDown: $("#<%= MasterTemplate.ClientID %>"),
nameTxtBox: $("#<%= NameTxt.ClientID %>"),
aliasTxtBox: $("#<%= AliasTxt.ClientID %>"),
saveButton: $("#<%= ((Control)SaveButton).ClientID %>"),
templateId: '<%= Request.CleanForXss("templateID") %>',
codeEditorElementId: '<%= editorSource.ClientID %>',
modalUrl: "<%= IOHelper.ResolveUrl(SystemDirectories.Umbraco) %>/dialogs/editMacro.aspx"
});
//initialize it.
editViewEditor.init();
//bind save shortcut
UmbClientMgr.appActions().bindSaveShortCut();
});
})(jQuery);
</script>
</asp:Content>
<asp:Content ContentPlaceHolderID="body" runat="server">
<cc1:TabView ID="Panel1" runat="server" hasMenu="true">
<cc1:Pane ID="Pane8" runat="server" >
<cc1:PropertyPanel ID="pp_source" runat="server">
<cc1:CodeArea ID="editorSource" runat="server" CodeBase="Razor" ClientSaveMethod="doSubmit" AutoResize="false" />
</cc1:PropertyPanel>
</cc1:Pane>
<cc1:Pane ID="Pane7" runat="server" >
<cc1:PropertyPanel ID="pp_name" runat="server">
<asp:Literal runat="server" ID="PathPrefix"></asp:Literal>
<asp:TextBox ID="NameTxt" runat="server"></asp:TextBox>
</cc1:PropertyPanel>
<cc1:PropertyPanel ID="pp_alias" runat="server">
<asp:TextBox ID="AliasTxt" runat="server"></asp:TextBox>
</cc1:PropertyPanel>
<cc1:PropertyPanel ID="pp_masterTemplate" runat="server">
<asp:DropDownList ID="MasterTemplate" runat="server" />
</cc1:PropertyPanel>
</cc1:Pane>
</cc1:TabView>
</asp:Content>

View File

@@ -1,280 +0,0 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Web.Trees;
using Umbraco.Web.UI.Controls;
using umbraco;
using umbraco.BasePages;
using umbraco.cms.businesslogic.template;
using umbraco.cms.helpers;
using umbraco.cms.presentation.Trees;
using Umbraco.Core;
using umbraco.uicontrols;
namespace Umbraco.Web.UI.Umbraco.Settings.Views
{
public partial class EditView : global::umbraco.BasePages.UmbracoEnsuredPage
{
private Template _template;
public MenuButton SaveButton;
public EditView()
{
CurrentApp = global::umbraco.BusinessLogic.DefaultApps.settings.ToString();
}
/// <summary>
/// The type of MVC/Umbraco view the editor is editing
/// </summary>
public enum ViewEditorType
{
Template,
PartialView,
PartialViewMacro
}
/// <summary>
/// Returns the type of view being edited
/// </summary>
protected ViewEditorType EditorType
{
get
{
if (_template != null) return ViewEditorType.Template;
if (Request.QueryString["treeType"].IsNullOrWhiteSpace() == false && Request.QueryString["treeType"].InvariantEquals("partialViewMacros")) return ViewEditorType.PartialViewMacro;
return ViewEditorType.PartialView;
}
}
protected string TemplateTreeSyncPath { get; private set; }
/// <summary>
/// This view is shared between different trees so we'll look for the query string
/// </summary>
protected string CurrentTreeType
{
get
{
if (Request.QueryString["treeType"].IsNullOrWhiteSpace())
{
return TreeDefinitionCollection.Instance.FindTree<PartialViewsTree>().Tree.Alias;
}
return Request.CleanForXss("treeType");
}
}
/// <summary>
/// Returns the original file name that the editor was loaded with
/// </summary>
/// <remarks>
/// this is used for editing a partial view
/// </remarks>
protected string OriginalFileName { get; private set; }
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!IsPostBack)
{
//configure screen for editing a template
if (_template != null)
{
MasterTemplate.Items.Add(new ListItem(ui.Text("none"), "0"));
var selectedTemplate = string.Empty;
foreach (var t in Template.GetAllAsList())
{
if (t.Id == _template.Id) continue;
var li = new ListItem(t.Text, t.Id.ToString(CultureInfo.InvariantCulture));
li.Attributes.Add("id", t.Alias.Replace(" ", "") + ".cshtml");
MasterTemplate.Items.Add(li);
}
try
{
if (_template.MasterTemplate > 0)
MasterTemplate.SelectedValue = _template.MasterTemplate.ToString(CultureInfo.InvariantCulture);
}
catch (Exception ex)
{
LogHelper.Error<EditView>("An error occurred setting a master template id", ex);
}
MasterTemplate.SelectedValue = selectedTemplate;
NameTxt.Text = _template.GetRawText();
AliasTxt.Text = _template.Alias;
editorSource.Text = _template.Design;
PathPrefix.Visible = false;
}
else
{
//configure editor for editing a file....
NameTxt.Text = OriginalFileName;
var svce = ApplicationContext.Current.Services.FileService;
var file = EditorType == ViewEditorType.PartialView
? svce.GetPartialView(OriginalFileName)
: svce.GetPartialViewMacro(OriginalFileName);
editorSource.Text = file.Content;
const string prefixFormat = "<span style=\"display: inline-block; height: 20px; line-height: 20px; margin-bottom: 0px; padding: 4px 6px;\">{0}</span>";
PathPrefix.Text = string.Format(prefixFormat, EditorType == ViewEditorType.PartialView
? "Partials/"
: "MacroPartials/");
}
}
ClientTools
.SetActiveTreeType(CurrentTreeType)
.SyncTree(TemplateTreeSyncPath, false);
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
//check if a templateId is assigned, meaning we are editing a template
if (!Request.QueryString["templateID"].IsNullOrWhiteSpace())
{
_template = new Template(int.Parse(Request.QueryString["templateID"]));
TemplateTreeSyncPath = "-1,init," + _template.Path.Replace("-1,", "");
}
else if (!Request.QueryString["file"].IsNullOrWhiteSpace())
{
//we are editing a view (i.e. partial view)
OriginalFileName = HttpUtility.UrlDecode(Request.QueryString["file"]);
//TemplateTreeSyncPath = "-1,init," + Path.GetFileName(OriginalFileName);
TemplateTreeSyncPath = DeepLink.GetTreePathFromFilePath(OriginalFileName.TrimStart("MacroPartials/").TrimStart("Partials/"));
}
else
{
throw new InvalidOperationException("Cannot render the editor without a supplied templateId or a file");
}
Panel1.hasMenu = true;
var editor = Panel1.NewTabPage(ui.Text("template"));
editor.Controls.Add(Pane8);
var props = Panel1.NewTabPage(ui.Text("properties"));
props.Controls.Add(Pane7);
SaveButton = Panel1.Menu.NewButton();
SaveButton.Text = ui.Text("save");
SaveButton.ButtonType = MenuButtonType.Primary;
SaveButton.ID = "save";
SaveButton.CssClass = "client-side";
Panel1.Text = ui.Text("edittemplate");
pp_name.Text = ui.Text("name", base.getUser());
pp_alias.Text = ui.Text("alias", base.getUser());
pp_masterTemplate.Text = ui.Text("mastertemplate", base.getUser());
// Editing buttons
MenuIconI umbField = editorSource.Menu.NewIcon();
umbField.ImageURL = UmbracoPath + "/images/editor/insField.gif";
umbField.OnClickCommand =
ClientTools.Scripts.OpenModalWindow(
IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/dialogs/umbracoField.aspx?objectId=" +
editorSource.ClientID + "&tagName=UMBRACOGETDATA&mvcView=true", ui.Text("template", "insertPageField"), 640, 550);
umbField.AltText = ui.Text("template", "insertPageField");
// TODO: Update icon
MenuIconI umbDictionary = editorSource.Menu.NewIcon();
umbDictionary.ImageURL = GlobalSettings.Path + "/images/editor/dictionaryItem.gif";
umbDictionary.OnClickCommand =
ClientTools.Scripts.OpenModalWindow(
IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/dialogs/umbracoField.aspx?objectId=" +
editorSource.ClientID + "&tagName=UMBRACOGETDICTIONARY&mvcView=true", ui.Text("template", "insertDictionaryItem"),
640, 550);
umbDictionary.AltText = "Insert umbraco dictionary item";
var macroSplitButton = new InsertMacroSplitButton
{
ClientCallbackInsertMacroMarkup = "function(alias) {editViewEditor.insertMacroMarkup(alias);}",
ClientCallbackOpenMacroModel = "function(alias) {editViewEditor.openMacroModal(alias);}"
};
editorSource.Menu.InsertNewControl(macroSplitButton, 40);
MenuIconI umbTemplateQueryBuilder = editorSource.Menu.NewIcon();
umbTemplateQueryBuilder.ImageURL = UmbracoPath + "/images/editor/inshtml.gif";
umbTemplateQueryBuilder.OnClickCommand = "editViewEditor.openQueryModal()";
umbTemplateQueryBuilder.AltText = "Open query builder";
if (_template == null)
{
InitializeEditorForPartialView();
}
else
{
InitializeEditorForTemplate();
}
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/codeEditorSave.asmx"));
ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/legacyAjaxCalls.asmx"));
}
/// <summary>
/// Configure the editor for partial view editing
/// </summary>
private void InitializeEditorForPartialView()
{
pp_masterTemplate.Visible = false;
pp_alias.Visible = false;
pp_name.Text = "Filename";
}
/// <summary>
/// Configure the editor for editing a template
/// </summary>
private void InitializeEditorForTemplate()
{
//TODO: implement content placeholders, etc... just like we had in v5
editorSource.Menu.InsertSplitter();
MenuIconI umbRenderBody = editorSource.Menu.NewIcon();
umbRenderBody.ImageURL = UmbracoPath + "/images/editor/renderbody.gif";
//umbContainer.AltText = ui.Text("template", "insertContentAreaPlaceHolder");
umbRenderBody.AltText = "Insert @RenderBody()";
umbRenderBody.OnClickCommand = "editViewEditor.insertRenderBody()";
MenuIconI umbSection = editorSource.Menu.NewIcon();
umbSection.ImageURL = UmbracoPath + "/images/editor/masterpagePlaceHolder.gif";
//umbContainer.AltText = ui.Text("template", "insertContentAreaPlaceHolder");
umbSection.AltText = "Insert Section";
umbSection.OnClickCommand = "editViewEditor.openSnippetModal('section')";
MenuIconI umbRenderSection = editorSource.Menu.NewIcon();
umbRenderSection.ImageURL = UmbracoPath + "/images/editor/masterpageContent.gif";
//umbContainer.AltText = ui.Text("template", "insertContentAreaPlaceHolder");
umbRenderSection.AltText = "Insert @RenderSection";
umbRenderSection.OnClickCommand = "editViewEditor.openSnippetModal('rendersection')";
}
}
}

View File

@@ -1,132 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Umbraco.Web.UI.Umbraco.Settings.Views {
public partial class EditView {
/// <summary>
/// JsInclude1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::ClientDependency.Core.Controls.JsInclude JsInclude1;
/// <summary>
/// Panel1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.TabView Panel1;
/// <summary>
/// Pane8 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.Pane Pane8;
/// <summary>
/// pp_source control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.PropertyPanel pp_source;
/// <summary>
/// editorSource control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.CodeArea editorSource;
/// <summary>
/// Pane7 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.Pane Pane7;
/// <summary>
/// pp_name control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.PropertyPanel pp_name;
/// <summary>
/// PathPrefix control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal PathPrefix;
/// <summary>
/// NameTxt control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox NameTxt;
/// <summary>
/// pp_alias control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.PropertyPanel pp_alias;
/// <summary>
/// AliasTxt control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox AliasTxt;
/// <summary>
/// pp_masterTemplate control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.PropertyPanel pp_masterTemplate;
/// <summary>
/// MasterTemplate control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.DropDownList MasterTemplate;
}
}

View File

@@ -194,12 +194,13 @@ namespace Umbraco.Web.Editors
if (viewMacro != null)
{
viewMacro.Content = display.Content;
viewMacro.Path = display.Name;
var result = Services.FileService.SavePartialViewMacro(viewMacro, Security.CurrentUser.Id);
if (result.Success == false)
{
display.AddErrorNotification(
Services.TextService.Localize("speechBubbles/partialViewErrorHeader"),
Services.TextService.Localize("speechBubbles/partialViewErrorText"));
Services.TextService.Localize("speechBubbles/macroPartialViewErrorHeader"),
Services.TextService.Localize("speechBubbles/macroPartialViewErrorText"));
}
}
else
@@ -213,6 +214,7 @@ namespace Umbraco.Web.Editors
if (script != null)
{
script.Content = display.Content;
script.Path = display.Name;
Services.FileService.SaveScript(script, Security.CurrentUser.Id);
}

View File

@@ -1,49 +0,0 @@
using System.Text;
using Umbraco.Core.IO;
using umbraco.businesslogic;
using umbraco.cms.presentation.Trees;
using Umbraco.Core;
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 PartialViewMacrosTree : PartialViewsTree
{
public PartialViewMacrosTree(string application) : base(application)
{
}
protected override string FilePath
{
get { return SystemDirectories.MvcViews + "/MacroPartials/"; }
}
public override void RenderJS(ref StringBuilder javascript)
{
javascript.Append(
@"
function openMacroPartialView(id) {
UmbClientMgr.contentFrame('Settings/Views/EditView.aspx?treeType=partialViewMacros&file=' + id);
}
");
}/// <summary>
/// Ensures that no folders can be added
/// </summary>
/// <param name="xNode"></param>
protected override void OnRenderFolderNode(ref XmlTreeNode xNode)
{
base.OnRenderFolderNode(ref xNode);
xNode.NodeType = "partialViewMacrosFolder";
}
protected override void ChangeNodeAction(XmlTreeNode xNode)
{
xNode.Action = xNode.Action.Replace("openFile", "openMacroPartialView");
}
}
}

View File

@@ -0,0 +1,49 @@
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"; }
}
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
{
var menu = new MenuItemCollection();
if (id == Constants.System.Root.ToInvariantString())
{
//refresh action
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true);
return menu;
}
// 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);
}
}
}

View File

@@ -1,88 +0,0 @@
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(Constants.Applications.Settings, "partialViews", "Partial Views", sortOrder: 2)]
public class PartialViewsTree : FileSystemTree
{
public PartialViewsTree(string application) : base(application) { }
public override void RenderJS(ref StringBuilder javascript)
{
javascript.Append(
@"
function openPartialView(id) {
UmbClientMgr.contentFrame('Settings/Views/EditView.aspx?treeType=partialViews&file=' + 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)
{
// 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[]
{
ActionNew.Instance,
ContextMenuSeperator.Instance,
ActionDelete.Instance,
ContextMenuSeperator.Instance,
ActionRefresh.Instance
});
}
protected virtual void ChangeNodeAction(XmlTreeNode xNode)
{
xNode.Action = xNode.Action.Replace("openFile", "openPartialView");
}
protected override void OnRenderFileNode(ref XmlTreeNode xNode)
{
ChangeNodeAction(xNode);
xNode.Icon = "icon-article";
xNode.OpenIcon = "icon-article";
xNode.Text = xNode.Text.StripFileExtension();
}
}
}

View File

@@ -0,0 +1,49 @@
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 views in the settings app
/// </summary>
[Tree(Constants.Applications.Settings, "partialViews", "Partial Views", sortOrder: 2)]
public class PartialViewsTreeController : FileSystemTreeController
{
protected override string FilePath
{
get { return SystemDirectories.PartialViews; }
}
protected override string FileSearchPattern
{
get { return "*.cshtml"; }
}
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
{
var menu = new MenuItemCollection();
if (id == Constants.System.Root.ToInvariantString())
{
//refresh action
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true);
return menu;
}
// 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);
}
}
}

View File

@@ -0,0 +1,46 @@
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
{
[Tree(Constants.Applications.Settings, "scripts", "Scripts", sortOrder: 4)]
public class ScriptTreeController : FileSystemTreeController
{
protected override string FilePath
{
get { return SystemDirectories.Scripts; }
}
protected override string FileSearchPattern
{
get { return "*.js"; }
}
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
{
var menu = new MenuItemCollection();
if (id == Constants.System.Root.ToInvariantString())
{
//refresh action
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true);
return menu;
}
// 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);
}
}
}

View File

@@ -394,6 +394,7 @@
<Compile Include="Trees\MemberTypeTreeController.cs" />
<Compile Include="Security\OwinExtensions.cs" />
<Compile Include="Security\WebAuthExtensions.cs" />
<Compile Include="Trees\ScriptTreeController.cs" />
<Compile Include="UmbracoDefaultOwinStartup.cs" />
<Compile Include="IUmbracoContextAccessor.cs" />
<Compile Include="Models\ContentEditing\Relation.cs" />
@@ -1048,8 +1049,8 @@
<Compile Include="Strategies\ServerRegistrationEventHandler.cs" />
<Compile Include="Templates\TemplateRenderer.cs" />
<Compile Include="Templates\TemplateUtilities.cs" />
<Compile Include="Trees\PartialViewMacrosTree.cs" />
<Compile Include="Trees\PartialViewsTree.cs" />
<Compile Include="Trees\PartialViewMacrosTreeController.cs" />
<Compile Include="Trees\PartialViewsTreeController.cs" />
<Compile Include="UI\Controls\InsertMacroSplitButton.cs" />
<Compile Include="UI\IAssignedApp.cs" />
<Compile Include="UI\LegacyDialogHandler.cs" />