Lots or removal & tidy up - still WIP & may break build
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using NUnit.Framework;
|
||||
using umbraco.cms.presentation.create.controls;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using Umbraco.Tests.Testing;
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@ namespace Umbraco.Tests.UI
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase(typeof(macroTasks), Constants.Applications.Settings)]
|
||||
public void Check_Assigned_Apps_For_Tasks(Type taskType, string app)
|
||||
{
|
||||
var task = (LegacyDialogTask)Activator.CreateInstance(taskType);
|
||||
Assert.AreEqual(task.AssignedApp, app);
|
||||
}
|
||||
//[TestCase(typeof(macroTasks), Constants.Applications.Settings)]
|
||||
//public void Check_Assigned_Apps_For_Tasks(Type taskType, string app)
|
||||
//{
|
||||
// var task = (LegacyDialogTask)Activator.CreateInstance(taskType);
|
||||
// Assert.AreEqual(task.AssignedApp, app);
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
<Folder Include="Umbraco\Translation\" />
|
||||
<Folder Include="Views\MacroPartials\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -134,7 +133,6 @@
|
||||
</Compile>
|
||||
<Compile Include="Config\splashes\NoNodes.aspx.designer.cs">
|
||||
<DependentUpon>noNodes.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
@@ -142,39 +140,6 @@
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Create.aspx.cs">
|
||||
<DependentUpon>create.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Create.aspx.designer.cs">
|
||||
<DependentUpon>create.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Developer\Macros\EditMacro.aspx.cs">
|
||||
<DependentUpon>editMacro.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Developer\Macros\EditMacro.aspx.designer.cs">
|
||||
<DependentUpon>editMacro.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Masterpages\Default.Master.cs">
|
||||
<DependentUpon>default.Master</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Masterpages\Default.Master.designer.cs">
|
||||
<DependentUpon>default.Master</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Masterpages\UmbracoDialog.master.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Masterpages\UmbracoDialog.master.designer.cs">
|
||||
<DependentUpon>umbracoDialog.Master</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Masterpages\UmbracoPage.master.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Masterpages\UmbracoPage.master.designer.cs">
|
||||
<DependentUpon>umbracoPage.Master</DependentUpon>
|
||||
</Compile>
|
||||
<Content Include="App_Plugins\ModelsBuilder\modelsbuilder.controller.js" />
|
||||
<Content Include="App_Plugins\ModelsBuilder\modelsbuilder.htm" />
|
||||
<Content Include="App_Plugins\ModelsBuilder\modelsbuilder.resource.js" />
|
||||
@@ -197,12 +162,11 @@
|
||||
<Content Include="Config\Lang\ru-RU.user.xml" />
|
||||
<Content Include="Config\Lang\sv-SE.user.xml" />
|
||||
<Content Include="Config\Lang\zh-CN.user.xml" />
|
||||
<Content Include="Config\splashes\booting.aspx" />
|
||||
<Content Include="Config\splashes\noNodes.aspx" />
|
||||
<Content Include="Umbraco\Config\Lang\cs.xml" />
|
||||
<Content Include="Umbraco\Config\Lang\tr.xml" />
|
||||
<Content Include="Umbraco\Config\Lang\zh_tw.xml" />
|
||||
<Content Include="Umbraco\create.aspx" />
|
||||
<Content Include="Config\Splashes\booting.aspx" />
|
||||
<Content Include="Config\Splashes\noNodes.aspx" />
|
||||
<Content Include="Umbraco\Install\Views\Web.config" />
|
||||
<Content Include="App_Plugins\ModelsBuilder\package.manifest" />
|
||||
<None Include="Config\404handlers.Release.config">
|
||||
@@ -261,10 +225,6 @@
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</Content>
|
||||
<None Include="Umbraco\Config\Create\UI.Release.xml">
|
||||
<DependentUpon>UI.xml</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<Content Include="Global.asax" />
|
||||
<Content Include="Umbraco\Config\Lang\en_us.xml">
|
||||
<SubType>Designer</SubType>
|
||||
@@ -277,7 +237,6 @@
|
||||
<Content Include="Umbraco\Config\Lang\zh.xml" />
|
||||
<Content Include="Umbraco\Config\Lang\ko.xml" />
|
||||
<Content Include="Umbraco\Dashboard\FeedProxy.aspx" />
|
||||
<Content Include="default.aspx" />
|
||||
<Content Include="Umbraco\Config\Lang\da.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
@@ -288,7 +247,6 @@
|
||||
<Content Include="Umbraco\Config\Lang\nl.xml" />
|
||||
<Content Include="Umbraco\Config\Lang\nb.xml" />
|
||||
<Content Include="Umbraco\Config\Lang\sv.xml" />
|
||||
<Content Include="Umbraco\Config\Create\UI.xml" />
|
||||
<Content Include="Umbraco\Config\Lang\en.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
@@ -348,15 +306,10 @@
|
||||
<DependentUpon>Web.Template.config</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<Content Include="Umbraco\Masterpages\umbracoPage.Master" />
|
||||
<Content Include="Umbraco\Masterpages\umbracoDialog.Master" />
|
||||
<Content Include="Umbraco\Create\simple.ascx" />
|
||||
<Content Include="Umbraco\Developer\Macros\editMacro.aspx" />
|
||||
<Content Include="Umbraco\Js\dualSelectBox.js" />
|
||||
<Content Include="Umbraco\Js\guiFunctions.js" />
|
||||
<Content Include="Umbraco\Js\umbracoCheckKeys.js" />
|
||||
<!--<Content Include="Umbraco\users\PermissionEditor.aspx" />-->
|
||||
<Content Include="Umbraco\Masterpages\default.Master" />
|
||||
<None Include="web.Template.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using Umbraco.Web._Legacy.UI;
|
||||
|
||||
namespace Umbraco.Web.UI.Umbraco
|
||||
{
|
||||
public partial class CreateDialog : global::umbraco.cms.presentation.Create
|
||||
{
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
if (SecurityCheck(Request.QueryString["nodeType"]))
|
||||
{
|
||||
//if we're allowed, then continue
|
||||
base.OnLoad(e);
|
||||
}
|
||||
else
|
||||
{
|
||||
//otherwise show an error
|
||||
UI.Visible = false;
|
||||
AccessError.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool SecurityCheck(string nodeTypeAlias)
|
||||
{
|
||||
return LegacyDialogHandler.UserHasCreateAccess(
|
||||
new HttpContextWrapper(Context),
|
||||
Security.CurrentUser,
|
||||
nodeTypeAlias);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
25
src/Umbraco.Web.UI/Umbraco/Create.aspx.designer.cs
generated
25
src/Umbraco.Web.UI/Umbraco/Create.aspx.designer.cs
generated
@@ -1,25 +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 {
|
||||
|
||||
|
||||
public partial class CreateDialog
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// AccessError 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.PlaceHolder AccessError;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<createUI>
|
||||
<nodeType alias="initmacros">
|
||||
<header>Macro</header>
|
||||
<usercontrol>/create/simple.ascx</usercontrol>
|
||||
<tasks>
|
||||
<create assembly="Umbraco.Web" type="macroTasks" />
|
||||
</tasks>
|
||||
</nodeType>
|
||||
<nodeType alias="macros">
|
||||
<header>Macro</header>
|
||||
<usercontrol>/create/simple.ascx</usercontrol>
|
||||
<tasks>
|
||||
<create assembly="Umbraco.Web" type="macroTasks" />
|
||||
<delete assembly="Umbraco.Web" type="macroTasks" />
|
||||
</tasks>
|
||||
</nodeType>
|
||||
</createUI>
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<createUI>
|
||||
<nodeType alias="initmacros">
|
||||
<header>Macro</header>
|
||||
<usercontrol>/create/simple.ascx</usercontrol>
|
||||
<tasks>
|
||||
<create assembly="Umbraco.Web" type="macroTasks" />
|
||||
</tasks>
|
||||
</nodeType>
|
||||
<nodeType alias="macros">
|
||||
<header>Macro</header>
|
||||
<usercontrol>/create/simple.ascx</usercontrol>
|
||||
<tasks>
|
||||
<create assembly="Umbraco.Web" type="macroTasks" />
|
||||
<delete assembly="Umbraco.Web" type="macroTasks" />
|
||||
</tasks>
|
||||
</nodeType>
|
||||
</createUI>
|
||||
@@ -1,43 +0,0 @@
|
||||
<%@ Page Language="c#" MasterPageFile="masterpages/umbracoDialog.Master" Codebehind="CreateDialog.aspx.cs" AutoEventWireup="True" Inherits="Umbraco.Web.UI.Umbraco.CreateDialog" %>
|
||||
<%@ Register Namespace="umbraco" TagPrefix="umb" Assembly="Umbraco.Web" %>
|
||||
|
||||
|
||||
<asp:Content ContentPlaceHolderID="head" runat="server">
|
||||
<script type="text/javascript">
|
||||
var preExecute;
|
||||
function doSubmit() { document.forms[0].submit(); }
|
||||
|
||||
var functionsFrame = this;
|
||||
var tabFrame = this;
|
||||
var isDialog = true;
|
||||
var submitOnEnter = true;
|
||||
</script>
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content runat="server" ContentPlaceHolderID="body">
|
||||
<asp:PlaceHolder ID="UI" runat="server"></asp:PlaceHolder>
|
||||
<asp:PlaceHolder runat="server" Visible="False" ID="AccessError">
|
||||
<div class="error">
|
||||
<p>
|
||||
The current user does not have access to create this type of object
|
||||
</p>
|
||||
</div>
|
||||
</asp:PlaceHolder>
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content runat="server" ContentPlaceHolderID="footer">
|
||||
<script type="text/javascript">
|
||||
function setFocusOnText() {
|
||||
for (var i = 0; i < document.forms[0].length; i++) {
|
||||
if (document.forms[0][i].type == 'text') {
|
||||
document.forms[0][i].focus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<%if (!IsPostBack) { %>
|
||||
setTimeout("setFocusOnText()", 100);
|
||||
<%} %>
|
||||
</script>
|
||||
</asp:Content>
|
||||
@@ -1,22 +0,0 @@
|
||||
<%@ Control Language="c#" AutoEventWireup="True" Inherits="umbraco.cms.presentation.create.controls.simple" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
|
||||
<%@ Register TagPrefix="cc1" Namespace="Umbraco.Web._Legacy.Controls" Assembly="Umbraco.Web" %>
|
||||
|
||||
|
||||
<cc1:Pane runat="server">
|
||||
<cc1:PropertyPanel runat="server" Text="Name">
|
||||
<asp:TextBox id="rename" CssClass="bigInput input-large-type input-block-level" Runat="server"></asp:TextBox><asp:RequiredFieldValidator id="RequiredFieldValidator1" ErrorMessage="*" ControlToValidate="rename" runat="server">*</asp:RequiredFieldValidator>
|
||||
</cc1:PropertyPanel>
|
||||
</cc1:Pane>
|
||||
|
||||
<cc1:Pane runat="server" CssClass="btn-toolbar umb-btn-toolbar">
|
||||
<a href="#" class="btn btn-link" onclick="UmbClientMgr.closeModalWindow()"><%=Services.TextService.Localize("cancel")%></a>
|
||||
<asp:Button id="sbmt" Runat="server" CssClass="btn btn-primary" onclick="sbmt_Click"></asp:Button>
|
||||
</cc1:Pane>
|
||||
|
||||
|
||||
|
||||
<!-- added to support missing postback on enter in IE -->
|
||||
<asp:TextBox runat="server" style="visibility:hidden;display:none;" ID="Textbox1"/>
|
||||
<asp:CustomValidator runat="server" ID="CustomValidation" ForeColor="red" style="display:block;"></asp:CustomValidator>
|
||||
<input type="hidden" name="nodeType">
|
||||
|
||||
@@ -1,363 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.IO;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using System.Linq;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web._Legacy.Controls;
|
||||
|
||||
namespace Umbraco.Web.UI.Umbraco.Developer.Macros
|
||||
{
|
||||
public partial class EditMacro : UmbracoEnsuredPage
|
||||
{
|
||||
public EditMacro()
|
||||
{
|
||||
CurrentApp = Constants.Applications.Packages.ToString();
|
||||
}
|
||||
|
||||
protected PlaceHolder Buttons;
|
||||
protected Table MacroElements;
|
||||
|
||||
public TabPage InfoTabPage;
|
||||
public TabPage Parameters;
|
||||
|
||||
private IMacro _macro;
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
_macro = Services.MacroService.GetById(Convert.ToInt32(Request.QueryString["macroID"]));
|
||||
|
||||
if (IsPostBack == false)
|
||||
{
|
||||
ClientTools
|
||||
.SyncTree("-1," + _macro.Id, false);
|
||||
|
||||
PopulateFieldsOnLoad(_macro);
|
||||
|
||||
// Load elements from macro
|
||||
MacroPropertyBind();
|
||||
|
||||
PopulatePartialViewFiles();
|
||||
|
||||
// Load usercontrols
|
||||
PopulateUserControls(IOHelper.MapPath(SystemDirectories.UserControls));
|
||||
userControlList.Items.Insert(0, new ListItem("Browse usercontrols on server...", string.Empty));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Populates the control (textbox) values on page load
|
||||
/// </summary>
|
||||
/// <param name="macro"></param>
|
||||
protected void PopulateFieldsOnLoad(IMacro macro)
|
||||
{
|
||||
macroName.Text = macro.Name;
|
||||
macroAlias.Text = macro.Alias;
|
||||
macroKey.Text = macro.Key.ToString();
|
||||
cachePeriod.Text = macro.CacheDuration.ToInvariantString();
|
||||
macroRenderContent.Checked = macro.DontRender == false;
|
||||
macroEditor.Checked = macro.UseInEditor;
|
||||
cacheByPage.Checked = macro.CacheByPage;
|
||||
cachePersonalized.Checked = macro.CacheByMember;
|
||||
macroUserControl.Text = macro.MacroType == MacroTypes.UserControl ? macro.MacroSource : null;
|
||||
SelectedPartialView.Text = macro.MacroType == MacroTypes.PartialView ? macro.MacroSource : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the values on the Macro object from the values posted back before saving the macro
|
||||
/// </summary>
|
||||
protected void SetMacroValuesFromPostBack(IMacro macro, int macroCachePeriod, string userControlValue, string partialViewValue)
|
||||
{
|
||||
macro.UseInEditor = macroEditor.Checked;
|
||||
macro.DontRender = macroRenderContent.Checked == false;
|
||||
macro.CacheByPage = cacheByPage.Checked;
|
||||
macro.CacheByMember = cachePersonalized.Checked;
|
||||
macro.CacheDuration = macroCachePeriod;
|
||||
macro.Alias = macroAlias.Text;
|
||||
macro.Name = macroName.Text;
|
||||
macro.MacroSource = !userControlValue.IsNullOrWhiteSpace() ? userControlValue : partialViewValue;
|
||||
macro.MacroType = !userControlValue.IsNullOrWhiteSpace() ? MacroTypes.UserControl : !partialViewValue.IsNullOrWhiteSpace() ? MacroTypes.PartialView : MacroTypes.Unknown;
|
||||
}
|
||||
|
||||
public void DeleteMacroProperty(object sender, EventArgs e)
|
||||
{
|
||||
var macroPropertyId = (HtmlInputHidden)((Control)sender).Parent.FindControl("macroPropertyID");
|
||||
|
||||
var property = _macro.Properties.Values.Single(x => x.Id == int.Parse(macroPropertyId.Value));
|
||||
_macro.Properties.Remove(property);
|
||||
|
||||
Services.MacroService.Save(_macro);
|
||||
|
||||
MacroPropertyBind();
|
||||
}
|
||||
|
||||
public void MacroPropertyBind()
|
||||
{
|
||||
macroProperties.DataSource = _macro.Properties.Values.OrderBy(x => x.SortOrder);
|
||||
macroProperties.DataBind();
|
||||
}
|
||||
|
||||
public object CheckNull(object test)
|
||||
{
|
||||
return Convert.IsDBNull(test) ? 0 : test;
|
||||
}
|
||||
|
||||
protected IEnumerable<IDataEditor> GetMacroParameterEditors()
|
||||
{
|
||||
return Current.ParameterEditors;
|
||||
}
|
||||
|
||||
public void macroPropertyCreate(object sender, EventArgs e)
|
||||
{
|
||||
//enable add validators
|
||||
var val1 = (RequiredFieldValidator)((Control)sender).Parent.FindControl("RequiredFieldValidator1");
|
||||
var val2 = (RequiredFieldValidator)((Control)sender).Parent.FindControl("RequiredFieldValidator4");
|
||||
var val3 = (RequiredFieldValidator)((Control)sender).Parent.FindControl("RequiredFieldValidator5");
|
||||
val1.Enabled = true;
|
||||
val2.Enabled = true;
|
||||
val3.Enabled = true;
|
||||
|
||||
Page.Validate();
|
||||
|
||||
if (Page.IsValid == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var macroPropertyAliasNew = (TextBox)((Control)sender).Parent.FindControl("macroPropertyAliasNew");
|
||||
var macroPropertyNameNew = (TextBox)((Control)sender).Parent.FindControl("macroPropertyNameNew");
|
||||
var macroPropertyTypeNew = (DropDownList)((Control)sender).Parent.FindControl("macroPropertyTypeNew");
|
||||
|
||||
if (macroPropertyAliasNew.Text != Services.TextService.Localize("general/new") + " " + Services.TextService.Localize("general/alias"))
|
||||
{
|
||||
if (_macro.Properties.ContainsKey(macroPropertyAliasNew.Text.Trim()))
|
||||
{
|
||||
//don't continue
|
||||
return;
|
||||
}
|
||||
|
||||
_macro.Properties.Add(new MacroProperty(
|
||||
macroPropertyAliasNew.Text.Trim(),
|
||||
macroPropertyNameNew.Text.Trim(),
|
||||
_macro.Properties.Values.Any() ? _macro.Properties.Values.Max(x => x.SortOrder) + 1 : 0,
|
||||
macroPropertyTypeNew.SelectedValue));
|
||||
|
||||
Services.MacroService.Save(_macro);
|
||||
|
||||
MacroPropertyBind();
|
||||
}
|
||||
}
|
||||
|
||||
public bool macroIsVisible(object isChecked)
|
||||
{
|
||||
return Convert.ToBoolean(isChecked);
|
||||
}
|
||||
|
||||
public void AddChooseList(object sender, EventArgs e)
|
||||
{
|
||||
if (IsPostBack == false)
|
||||
{
|
||||
var dropDown = (DropDownList)sender;
|
||||
dropDown.Items.Insert(0, new ListItem("Choose...", string.Empty));
|
||||
}
|
||||
}
|
||||
|
||||
private void PopulateUserControls(string path)
|
||||
{
|
||||
var directoryInfo = new DirectoryInfo(path);
|
||||
if (directoryInfo.Exists == false) return;
|
||||
|
||||
var rootDir = IOHelper.MapPath(SystemDirectories.UserControls);
|
||||
|
||||
foreach (var uc in directoryInfo.GetFiles("*.ascx"))
|
||||
{
|
||||
userControlList.Items.Add(
|
||||
new ListItem(SystemDirectories.UserControls +
|
||||
uc.FullName.Substring(rootDir.Length).Replace(IOHelper.DirSepChar, '/')));
|
||||
|
||||
}
|
||||
foreach (var dir in directoryInfo.GetDirectories())
|
||||
PopulateUserControls(dir.FullName);
|
||||
}
|
||||
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
base.OnInit(e);
|
||||
EnsureChildControls();
|
||||
}
|
||||
|
||||
protected override void CreateChildControls()
|
||||
{
|
||||
base.CreateChildControls();
|
||||
|
||||
// Tab setup
|
||||
InfoTabPage = TabView1.NewTabPage("Macro Properties");
|
||||
InfoTabPage.Controls.Add(Pane1);
|
||||
InfoTabPage.Controls.Add(Pane1_2);
|
||||
InfoTabPage.Controls.Add(Pane1_3);
|
||||
InfoTabPage.Controls.Add(Pane1_4);
|
||||
|
||||
Parameters = TabView1.NewTabPage("Parameters");
|
||||
Parameters.Controls.Add(Panel2);
|
||||
|
||||
//var save = TabView1.Menu.NewButton();
|
||||
//save.ButtonType = MenuButtonType.Primary;
|
||||
//save.Text = Services.TextService.Localize("save");
|
||||
//save.ID = "save";
|
||||
//save.Click += Save_Click;
|
||||
}
|
||||
|
||||
void Save_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
Page.Validate();
|
||||
|
||||
ClientTools
|
||||
.SyncTree("-1," + _macro.Id.ToInvariantString(), true); //true forces the reload
|
||||
|
||||
|
||||
var tempCachePeriod = cachePeriod.Text;
|
||||
if (tempCachePeriod == string.Empty)
|
||||
tempCachePeriod = "0";
|
||||
|
||||
SetMacroValuesFromPostBack(_macro, Convert.ToInt32(tempCachePeriod), macroUserControl.Text, SelectedPartialView.Text);
|
||||
|
||||
// save elements
|
||||
// this is oh so completely broken
|
||||
var aliases = new Dictionary<string, string>();
|
||||
foreach (RepeaterItem item in macroProperties.Items)
|
||||
{
|
||||
var macroPropertyId = (HtmlInputHidden)item.FindControl("macroPropertyID");
|
||||
var macroElementName = (TextBox)item.FindControl("macroPropertyName");
|
||||
var macroElementAlias = (TextBox)item.FindControl("macroPropertyAlias");
|
||||
var macroElementSortOrder = (TextBox)item.FindControl("macroPropertySortOrder");
|
||||
var macroElementType = (DropDownList)item.FindControl("macroPropertyType");
|
||||
|
||||
var prop = _macro.Properties.Values.Single(x => x.Id == int.Parse(macroPropertyId.Value));
|
||||
var sortOrder = 0;
|
||||
int.TryParse(macroElementSortOrder.Text, out sortOrder);
|
||||
|
||||
var alias = macroElementAlias.Text.Trim();
|
||||
if (prop.Alias != alias) // changing the alias
|
||||
{
|
||||
// use a temp alias to avoid collision if eg swapping aliases
|
||||
var tempAlias = Guid.NewGuid().ToString("N").Substring(0, 8);
|
||||
aliases[tempAlias] = alias;
|
||||
alias = tempAlias;
|
||||
}
|
||||
|
||||
_macro.Properties.UpdateProperty(
|
||||
prop.Alias,
|
||||
macroElementName.Text.Trim(),
|
||||
sortOrder,
|
||||
macroElementType.SelectedValue,
|
||||
alias);
|
||||
}
|
||||
|
||||
// now apply the real aliases, should not collide
|
||||
foreach (var kvp in aliases)
|
||||
_macro.Properties.UpdateProperty(kvp.Key, newAlias: kvp.Value);
|
||||
|
||||
Services.MacroService.Save(_macro);
|
||||
|
||||
ClientTools.ShowSpeechBubble(SpeechBubbleIcon.Save, "Macro saved", "");
|
||||
|
||||
MacroPropertyBind();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Populate the drop down list for partial view files
|
||||
/// </summary>
|
||||
private void PopulatePartialViewFiles()
|
||||
{
|
||||
var partialsDir = IOHelper.MapPath(SystemDirectories.MvcViews + "/MacroPartials");
|
||||
//get all the partials in the normal /MacroPartials folder
|
||||
var foundMacroPartials = GetPartialViewFiles(partialsDir, partialsDir, SystemDirectories.MvcViews + "/MacroPartials");
|
||||
//now try to find all of them int he App_Plugins/[PackageName]/Views/MacroPartials folder
|
||||
var appPluginsFolder = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.AppPlugins));
|
||||
if (appPluginsFolder.Exists)
|
||||
{
|
||||
foreach (var d in appPluginsFolder.GetDirectories())
|
||||
{
|
||||
var viewsFolder = d.GetDirectories("Views");
|
||||
if (viewsFolder.Any())
|
||||
{
|
||||
var macroPartials = viewsFolder.First().GetDirectories("MacroPartials");
|
||||
if (macroPartials.Any())
|
||||
{
|
||||
foundMacroPartials = foundMacroPartials.Concat(
|
||||
GetPartialViewFiles(macroPartials.First().FullName, macroPartials.First().FullName, SystemDirectories.AppPlugins + "/" + d.Name + "/Views/MacroPartials"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PartialViewList.DataSource = foundMacroPartials;
|
||||
PartialViewList.DataBind();
|
||||
PartialViewList.Items.Insert(0, new ListItem("Browse partial view files on server...", string.Empty));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the list of partial view files in the ~/Views/MacroPartials folder and in all
|
||||
/// folders of ~/App_Plugins/[PackageName]/Views/MacroPartials
|
||||
/// </summary>
|
||||
/// <param name="orgPath"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="prefixVirtualPath"> </param>
|
||||
/// <returns></returns>
|
||||
private IEnumerable<string> GetPartialViewFiles(string orgPath, string path, string prefixVirtualPath)
|
||||
{
|
||||
var files = new List<string>();
|
||||
var dirInfo = new DirectoryInfo(path);
|
||||
|
||||
// Populate subdirectories
|
||||
var dirInfos = dirInfo.GetDirectories();
|
||||
foreach (var dir in dirInfos)
|
||||
{
|
||||
files.AddRange(GetPartialViewFiles(orgPath, path + "/" + dir.Name, prefixVirtualPath));
|
||||
}
|
||||
|
||||
var fileInfo = dirInfo.GetFiles("*.*");
|
||||
|
||||
files.AddRange(
|
||||
fileInfo.Select(file =>
|
||||
prefixVirtualPath.TrimEnd('/') + "/" + (path.Replace(orgPath, string.Empty).Trim('/') + "/" + file.Name).Trim('/')));
|
||||
return files;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Binds the drop down list but ensures that the macro param type exists if it doesn't the drop down will be left blank
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void MacroPropertiesOnItemDataBound(object sender, RepeaterItemEventArgs e)
|
||||
{
|
||||
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
|
||||
{
|
||||
var propertyTypes = (DropDownList)e.Item.FindControl("macroPropertyType");
|
||||
|
||||
var editors = GetMacroParameterEditors();
|
||||
propertyTypes.DataSource = editors;
|
||||
propertyTypes.DataBind();
|
||||
var macroProp = (IMacroProperty)e.Item.DataItem;
|
||||
if (editors.Any(x => x.Alias == macroProp.EditorAlias))
|
||||
{
|
||||
propertyTypes.SelectedValue = macroProp.EditorAlias;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,222 +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.Developer.Macros {
|
||||
|
||||
|
||||
public partial class EditMacro {
|
||||
|
||||
/// <summary>
|
||||
/// CssInclude1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::ClientDependency.Core.Controls.CssInclude CssInclude1;
|
||||
|
||||
/// <summary>
|
||||
/// SelectedPartialView 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 SelectedPartialView;
|
||||
|
||||
/// <summary>
|
||||
/// PartialViewList 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 PartialViewList;
|
||||
|
||||
/// <summary>
|
||||
/// TabView1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.TabView TabView1;
|
||||
|
||||
/// <summary>
|
||||
/// Pane1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.Pane Pane1;
|
||||
|
||||
/// <summary>
|
||||
/// macroPane control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlTable macroPane;
|
||||
|
||||
/// <summary>
|
||||
/// macroName 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 macroName;
|
||||
|
||||
/// <summary>
|
||||
/// macroAlias 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 macroAlias;
|
||||
|
||||
/// <summary>
|
||||
/// macroAlias 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.Label macroKey;
|
||||
|
||||
/// <summary>
|
||||
/// Pane1_2 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.Pane Pane1_2;
|
||||
|
||||
/// <summary>
|
||||
/// macroUserControl 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 macroUserControl;
|
||||
|
||||
/// <summary>
|
||||
/// userControlList 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 userControlList;
|
||||
|
||||
/// <summary>
|
||||
/// Pane1_3 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.Pane Pane1_3;
|
||||
|
||||
/// <summary>
|
||||
/// Table1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlTable Table1;
|
||||
|
||||
/// <summary>
|
||||
/// macroEditor 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.CheckBox macroEditor;
|
||||
|
||||
/// <summary>
|
||||
/// macroRenderContent 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.CheckBox macroRenderContent;
|
||||
|
||||
/// <summary>
|
||||
/// Pane1_4 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.Pane Pane1_4;
|
||||
|
||||
/// <summary>
|
||||
/// Table3 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlTable Table3;
|
||||
|
||||
/// <summary>
|
||||
/// cachePeriod 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 cachePeriod;
|
||||
|
||||
/// <summary>
|
||||
/// cacheByPage 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.CheckBox cacheByPage;
|
||||
|
||||
/// <summary>
|
||||
/// cachePersonalized 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.CheckBox cachePersonalized;
|
||||
|
||||
/// <summary>
|
||||
/// Panel2 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.Pane Panel2;
|
||||
|
||||
/// <summary>
|
||||
/// macroProperties 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.Repeater macroProperties;
|
||||
}
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
<%@ Page Language="c#" MasterPageFile="../../masterpages/umbracoPage.Master" Title="Edit macro"
|
||||
CodeBehind="EditMacro.aspx.cs" AutoEventWireup="True" Inherits="Umbraco.Web.UI.Umbraco.Developer.Macros.EditMacro" %>
|
||||
|
||||
<%@ Register TagPrefix="cc1" Namespace="Umbraco.Web._Legacy.Controls" Assembly="Umbraco.Web" %>
|
||||
<%@ Register TagPrefix="CD" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="head" runat="server">
|
||||
|
||||
<CD:CssInclude ID="CssInclude1" runat="server" FilePath="Editors/EditMacro.css" PathNameAlias="UmbracoClient" />
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
//handles the change selection of the drop downs to populate the text box
|
||||
(function($) {
|
||||
$(document).ready(function () {
|
||||
|
||||
//on drop down change, update the text box and clear other text boxes
|
||||
$(".fileChooser select").change(function () {
|
||||
//update the txt box
|
||||
var txt = $(this).prev("input[type='text']");
|
||||
txt.val($(this).val());
|
||||
//clear other text boxes
|
||||
$(".fileChooser input[type='text']").not(txt).val("");
|
||||
//reset other drop downs
|
||||
$(".fileChooser select").not($(this)).val("");
|
||||
});
|
||||
|
||||
UmbClientMgr.appActions().bindSaveShortCut();
|
||||
|
||||
// U4-667: Make the "Render content in editor" checkbox dependent on the "Use in editor checkbox"
|
||||
var useInEditorCheckBox = $("#<%= macroEditor.ClientID %>");
|
||||
var renderInEditorCheckBox = $("#<%= macroRenderContent.ClientID %>");
|
||||
|
||||
function toggle() {
|
||||
var disabled = useInEditorCheckBox.is(":checked") == false;
|
||||
renderInEditorCheckBox.prop("disabled", disabled);
|
||||
}
|
||||
|
||||
toggle();
|
||||
|
||||
useInEditorCheckBox.on("change", function () {
|
||||
toggle();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ContentPlaceHolderID="body" runat="server">
|
||||
<cc1:TabView ID="TabView1" runat="server"></cc1:TabView>
|
||||
|
||||
<cc1:Pane ID="Pane1" runat="server">
|
||||
<cc1:PropertyPanel runat="server" Text="Name">
|
||||
<asp:TextBox ID="macroName" runat="server" CssClass="guiInputText"></asp:TextBox>
|
||||
</cc1:PropertyPanel>
|
||||
<cc1:PropertyPanel runat="server" Text="Alias">
|
||||
<asp:TextBox ID="macroAlias" runat="server" CssClass="guiInputText"></asp:TextBox>
|
||||
</cc1:PropertyPanel>
|
||||
<cc1:PropertyPanel runat="server" Text="Key">
|
||||
<asp:Label ID="macroKey" runat="server" CssClass="guiLabel"></asp:Label>
|
||||
</cc1:PropertyPanel>
|
||||
</cc1:Pane>
|
||||
|
||||
|
||||
<cc1:Pane ID="Pane1_2" runat="server" title="Choose a file to render" CssClass="fileChooser">
|
||||
|
||||
<cc1:PropertyPanel runat="server" Text="MVC Partial view">
|
||||
<asp:TextBox ID="SelectedPartialView" runat="server" CssClass="guiInputText"></asp:TextBox>
|
||||
<asp:DropDownList ID="PartialViewList" runat="server" >
|
||||
</asp:DropDownList>
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
<cc1:PropertyPanel runat="server" Text="usercontrol">
|
||||
<asp:TextBox ID="macroUserControl" runat="server" CssClass="guiInputText"></asp:TextBox>
|
||||
<asp:DropDownList ID="userControlList" runat="server">
|
||||
</asp:DropDownList>
|
||||
</cc1:PropertyPanel>
|
||||
</cc1:Pane>
|
||||
|
||||
<cc1:Pane ID="Pane1_3" runat="server" Title="Editor settings">
|
||||
|
||||
<cc1:PropertyPanel runat="server" Text="Use in rich text editor and the grid">
|
||||
<asp:CheckBox ID="macroEditor" runat="server" Text="Yes"></asp:CheckBox>
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
<cc1:PropertyPanel runat="server" Text="Render in rich text editor and the grid">
|
||||
<asp:CheckBox ID="macroRenderContent" runat="server" Text="Yes"></asp:CheckBox>
|
||||
</cc1:PropertyPanel>
|
||||
</cc1:Pane>
|
||||
<cc1:Pane ID="Pane1_4" runat="server" Title="Cache settings">
|
||||
|
||||
<cc1:PropertyPanel runat="server" Text="Cache period">
|
||||
<asp:TextBox ID="cachePeriod" runat="server" CssClass="guiInputText input-small" type="number" min="0"></asp:TextBox> Seconds
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
<cc1:PropertyPanel runat="server" Text="Cache by page">
|
||||
<asp:CheckBox ID="cacheByPage" runat="server" Text="Yes"></asp:CheckBox>
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
<cc1:PropertyPanel runat="server" Text="Cache personalized">
|
||||
<asp:CheckBox ID="cachePersonalized" runat="server" Text="Yes"></asp:CheckBox>
|
||||
</cc1:PropertyPanel>
|
||||
</cc1:Pane>
|
||||
|
||||
<cc1:Pane ID="Panel2" runat="server">
|
||||
<asp:Repeater ID="macroProperties" runat="server" OnItemDataBound="MacroPropertiesOnItemDataBound">
|
||||
<HeaderTemplate>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<%=Services.TextService.Localize("general/alias")%>
|
||||
</th>
|
||||
<th>
|
||||
<%=Services.TextService.Localize("general/name")%>
|
||||
</th>
|
||||
<th>
|
||||
<%=Services.TextService.Localize("general/type")%>
|
||||
</th>
|
||||
<th>
|
||||
<%=Services.TextService.Localize("general/sort")%>
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</HeaderTemplate>
|
||||
<ItemTemplate>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="hidden" id="macroPropertyID" runat="server" value='<%#Eval("Id")%>'
|
||||
name="macroPropertyID" />
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="macroPropertyAlias" Display="Dynamic" ForeColor="#b94a48">Required<br/></asp:RequiredFieldValidator>
|
||||
<asp:TextBox runat="server" ID="macroPropertyAlias" CLASS="-full-width-input" Text='<%#Eval("Alias")%>' />
|
||||
</td>
|
||||
<td>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="macroPropertyName" Display="Dynamic" ForeColor="#b94a48">Required<br/></asp:RequiredFieldValidator>
|
||||
<asp:TextBox runat="server" ID="macroPropertyName" CssClass="-full-width-input" Text='<%#Eval("Name")%>' />
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="macroPropertyType" Display="Dynamic" ForeColor="#b94a48">Required<br/></asp:RequiredFieldValidator>
|
||||
<asp:DropDownList OnPreRender="AddChooseList" runat="server" ID="macroPropertyType"
|
||||
DataTextFormatString="" DataTextField='Name' DataValueField="Alias">
|
||||
</asp:DropDownList>
|
||||
</td>
|
||||
<td>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="macroPropertySortOrder" Display="Dynamic" ForeColor="#b94a48">Required<br/></asp:RequiredFieldValidator>
|
||||
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="macroPropertySortOrder" Display="Dynamic" ForeColor="#b94a48" ValidationExpression="^\d+$">Numbers only<br/></asp:RegularExpressionValidator>
|
||||
<asp:TextBox runat="server" ID="macroPropertySortOrder" CssClass="-full-width-input" Text='<%#Eval("SortOrder")%>' type="number" />
|
||||
</td>
|
||||
<td>
|
||||
<asp:Button OnClick="DeleteMacroProperty" ID="delete" Text="Delete" runat="server" CssClass="btn btn-default btn-danger delete-button" />
|
||||
</td>
|
||||
</tr>
|
||||
</ItemTemplate>
|
||||
<FooterTemplate>
|
||||
<tr>
|
||||
<td>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" EnableViewState="false" Enabled="false" EnableClientScript="false" runat="server" ControlToValidate="macroPropertyAliasNew" Display="Dynamic" ForeColor="#b94a48">Required<br/></asp:RequiredFieldValidator>
|
||||
<asp:TextBox runat="server" ID="macroPropertyAliasNew" CssClass="-full-width-input" PlaceHolder='New Alias' />
|
||||
</td>
|
||||
<td>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" EnableViewState="false" Enabled="false" EnableClientScript="false" runat="server" ControlToValidate="macroPropertyNameNew" Display="Dynamic" ForeColor="#b94a48">Required<br/></asp:RequiredFieldValidator>
|
||||
<asp:TextBox runat="server" ID="macroPropertyNameNew" CssClass="-full-width-input" PlaceHolder='New Name' />
|
||||
</td>
|
||||
<td>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" EnableViewState="false" Enabled="false" EnableClientScript="false" runat="server" ControlToValidate="macroPropertyTypeNew" Display="Dynamic" ForeColor="#b94a48">Required<br/></asp:RequiredFieldValidator>
|
||||
<asp:DropDownList OnPreRender="AddChooseList" runat="server" ID="macroPropertyTypeNew"
|
||||
DataTextField="Name"
|
||||
DataValueField="Alias"
|
||||
DataSource='<%# GetMacroParameterEditors()%>'>
|
||||
</asp:DropDownList>
|
||||
</td>
|
||||
<td>
|
||||
<%-- The macro parameter will automatically get sort order when created. --%>
|
||||
</td>
|
||||
<td>
|
||||
<asp:Button ID="createNew" Text="Add" runat="server" CssClass="btn btn-default btn-info add-button" OnClick="macroPropertyCreate" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</FooterTemplate>
|
||||
</asp:Repeater>
|
||||
</cc1:Pane>
|
||||
|
||||
</asp:Content>
|
||||
@@ -1,3 +0,0 @@
|
||||
<%@ Master Language="C#" AutoEventWireup="True" CodeBehind="Default.master.cs" Inherits="Umbraco.Web.UI.Umbraco.Masterpages.Default" %>
|
||||
<asp:ContentPlaceHolder ID="ContentPlaceHolderDefault" runat="server">
|
||||
</asp:ContentPlaceHolder>
|
||||
@@ -1,2 +0,0 @@
|
||||
<%@ Page language="c#" AutoEventWireup="True" Inherits="umbraco.UmbracoDefault" trace="true" validateRequest="false" %>
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.CodeAnnotations;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
//TODO: Add this back in when we support this functionality again
|
||||
///// <summary>
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.CodeAnnotations;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.CodeAnnotations;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.CodeAnnotations;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.CodeAnnotations;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.CodeAnnotations;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.CodeAnnotations;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.CodeAnnotations;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.CodeAnnotations;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.CodeAnnotations;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace Umbraco.Web.Cache
|
||||
|
||||
ClearAllIsolatedCacheByEntityType<IMacro>();
|
||||
|
||||
//TODO: WB Was I too aggresive with cleanup?
|
||||
AppCaches.RuntimeCache.ClearOfType<MacroCacheContent>();
|
||||
|
||||
base.RefreshAll();
|
||||
@@ -112,6 +113,7 @@ namespace Umbraco.Web.Cache
|
||||
|
||||
public static void ClearMacroContentCache(AppCaches appCaches)
|
||||
{
|
||||
//TODO: WB Was I too aggresive with cleanup?
|
||||
appCaches.RuntimeCache.ClearOfType<MacroCacheContent>();
|
||||
}
|
||||
|
||||
|
||||
@@ -347,10 +347,6 @@ namespace Umbraco.Web.Mvc
|
||||
// to Mvc since Mvc can't do much
|
||||
return new PublishedContentNotFoundHandler("In addition, no template exists to render the custom 404.");
|
||||
|
||||
// so we have a template, so we should have a rendering engine
|
||||
if (request.RenderingEngine == RenderingEngine.WebForms) // back to webforms ?
|
||||
return GetWebFormsHandler();
|
||||
|
||||
if (request.RenderingEngine != RenderingEngine.Mvc) // else ?
|
||||
return new PublishedContentNotFoundHandler("In addition, no rendering engine exists to render the custom 404.");
|
||||
|
||||
@@ -376,13 +372,6 @@ namespace Umbraco.Web.Mvc
|
||||
return HandlePostedValues(requestContext, postedInfo);
|
||||
}
|
||||
|
||||
//Now we can check if we are supposed to render WebForms when the route has not been hijacked
|
||||
if (request.RenderingEngine == RenderingEngine.WebForms
|
||||
&& request.HasTemplate
|
||||
&& routeDef.HasHijackedRoute == false)
|
||||
{
|
||||
return GetWebFormsHandler();
|
||||
}
|
||||
|
||||
//Here we need to check if there is no hijacked route and no template assigned,
|
||||
//if this is the case we want to return a blank page, but we'll leave that up to the NoTemplateHandler.
|
||||
@@ -434,16 +423,7 @@ namespace Umbraco.Web.Mvc
|
||||
|
||||
return new UmbracoMvcHandler(requestContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the handler for webforms requests
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal static IHttpHandler GetWebFormsHandler()
|
||||
{
|
||||
return (umbraco.UmbracoDefault) BuildManager.CreateInstanceFromVirtualPath("~/default.aspx", typeof(umbraco.UmbracoDefault));
|
||||
}
|
||||
|
||||
|
||||
private SessionStateBehavior GetSessionStateBehavior(RequestContext requestContext, string controllerName)
|
||||
{
|
||||
return _controllerFactory.GetControllerSessionBehavior(requestContext, controllerName);
|
||||
|
||||
@@ -30,15 +30,7 @@ namespace Umbraco.Web.Mvc
|
||||
|
||||
var routeDef = (RouteDefinition)context.RouteData.DataTokens[Umbraco.Core.Constants.Web.UmbracoRouteDefinitionDataToken];
|
||||
|
||||
//Special case, if it is webforms but we're posting to an MVC surface controller, then we
|
||||
// need to return the webforms result instead
|
||||
if (routeDef.PublishedRequest.RenderingEngine == RenderingEngine.WebForms)
|
||||
{
|
||||
EnsureViewContextForWebForms(context);
|
||||
var webFormsHandler = RenderRouteHandler.GetWebFormsHandler();
|
||||
webFormsHandler.ProcessRequest(HttpContext.Current);
|
||||
}
|
||||
else
|
||||
if (routeDef.PublishedRequest.RenderingEngine == RenderingEngine.Mvc)
|
||||
{
|
||||
var factory = ControllerBuilder.Current.GetControllerFactory();
|
||||
context.RouteData.Values["action"] = routeDef.ActionName;
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace Umbraco.Web.Mvc
|
||||
/// <param name="url">The url to validate</param>
|
||||
/// <param name="callerUrl">The url of the current local domain (to ensure we can validate if the requested url is local without dependency on the request)</param>
|
||||
/// <returns>True if it's an allowed url</returns>
|
||||
[Obsolete("This looks OLD & unused", true)]
|
||||
public static bool ValidateProxyUrl(this UrlHelper urlHelper, string url, string callerUrl)
|
||||
{
|
||||
if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute) == false)
|
||||
@@ -60,14 +61,6 @@ namespace Umbraco.Web.Mvc
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check for valid proxy urls
|
||||
var feedProxyXml = XmlHelper.OpenAsXmlDocument(IOHelper.MapPath(SystemFiles.FeedProxyConfig));
|
||||
if (feedProxyXml != null &&
|
||||
feedProxyXml.SelectSingleNode(string.Concat("//allow[@host = '", requestUri.Host, "']")) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -158,12 +158,7 @@ namespace Umbraco.Web.Templates
|
||||
break;
|
||||
case RenderingEngine.WebForms:
|
||||
default:
|
||||
var webFormshandler = (UmbracoDefault) BuildManager
|
||||
.CreateInstanceFromVirtualPath("~/default.aspx", typeof(UmbracoDefault));
|
||||
//the 'true' parameter will ensure that the current query strings are carried through, we don't have
|
||||
// to build up the url again, it will just work.
|
||||
_umbracoContext.HttpContext.Server.Execute(webFormshandler, sw, true);
|
||||
break;
|
||||
throw new Exception("We no longer support WebForms in Umbraco");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Security;
|
||||
using System.Web.UI;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Composing;
|
||||
|
||||
namespace Umbraco.Web.UI.Pages
|
||||
{
|
||||
/// <summary>
|
||||
/// umbraco.BasePages.BasePage is the default page type for the umbraco backend.
|
||||
/// The basepage keeps track of the current user and the page context. But does not
|
||||
/// Restrict access to the page itself.
|
||||
/// The keep the page secure, the umbracoEnsuredPage class should be used instead
|
||||
/// </summary>
|
||||
public class BasePage : Page
|
||||
{
|
||||
private UrlHelper _url;
|
||||
private HtmlHelper _html;
|
||||
private ClientTools _clientTools;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the logger.
|
||||
/// </summary>
|
||||
public ILogger Logger => Current.Logger;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the profiling helper.
|
||||
/// </summary>
|
||||
public IProfilingLogger ProfilingLogger => Current.ProfilingLogger;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Url helper.
|
||||
/// </summary>
|
||||
/// <remarks>This URL helper is created without any route data and an empty request context.</remarks>
|
||||
public UrlHelper Url => _url ?? (_url = new UrlHelper(Context.Request.RequestContext));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Html helper.
|
||||
/// </summary>
|
||||
/// <remarks>This html helper is created with an empty context and page so it may not have all of the functionality expected.</remarks>
|
||||
public HtmlHelper Html => _html ?? (_html = new HtmlHelper(new ViewContext(), new ViewPage()));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Umbraco context.
|
||||
/// </summary>
|
||||
public UmbracoContext UmbracoContext => Current.UmbracoContext;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the web security helper.
|
||||
/// </summary>
|
||||
public WebSecurity Security => UmbracoContext.Security;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the services context.
|
||||
/// </summary>
|
||||
public ServiceContext Services => Current.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an instance of ClientTools for access to the pages client API.
|
||||
/// </summary>
|
||||
public ClientTools ClientTools => _clientTools ?? (_clientTools = new ClientTools(this));
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Web.UI.Control.Load"></see> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="T:System.EventArgs"></see> object that contains the event data.</param>
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
if (Request.IsSecureConnection || Current.Configs.Global().UseHttps == false) return;
|
||||
|
||||
var serverName = HttpUtility.UrlEncode(Request.ServerVariables["SERVER_NAME"]);
|
||||
Response.Redirect($"https://{serverName}{Request.FilePath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,347 +0,0 @@
|
||||
using Umbraco.Core.IO;
|
||||
using System.Web.UI;
|
||||
using Umbraco.Core;
|
||||
|
||||
namespace Umbraco.Web.UI.Pages
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Renders the client side code necessary to interact with the Umbraco client side API.
|
||||
/// Each method returns an instance of this class so you can chain calls together.
|
||||
/// </summary>
|
||||
public sealed class ClientTools
|
||||
{
|
||||
|
||||
public ClientTools(Page page)
|
||||
{
|
||||
_page = page;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string markup for the JavaScript that is rendered.
|
||||
/// If referencing JavaScript scripts in the backend, this class should be used
|
||||
/// in case future changes to the client code is change, this will remain intact.
|
||||
/// </summary>
|
||||
public static class Scripts
|
||||
{
|
||||
internal const string ClientMgrScript = "UmbClientMgr";
|
||||
public static string GetAppActions { get { return string.Format("{0}.appActions()", ClientMgrScript); } }
|
||||
public static string GetMainWindow { get { return string.Format("{0}.mainWindow()", ClientMgrScript); } }
|
||||
public static string GetMainTree { get { return string.Format("{0}.mainTree()", ClientMgrScript); } }
|
||||
public static string GetContentFrame() { return string.Format("{0}.contentFrame()", ClientMgrScript); }
|
||||
public static string ShiftApp(string appAlias)
|
||||
{
|
||||
return string.Format(ClientMgrScript + ".historyManager().addHistory('{0}')", appAlias);
|
||||
}
|
||||
public static string OpenDashboard(string app)
|
||||
{
|
||||
return string.Format(GetAppActions + ".openDashboard('{0}');", app);
|
||||
}
|
||||
public static string RefreshAdmin { get { return "setTimeout('" + GetMainWindow + ".location.reload()', {0});"; } }
|
||||
public static string ShowSpeechBubble { get { return GetMainWindow + ".UmbSpeechBubble.ShowMessage('{0}','{1}', '{2}');"; } }
|
||||
public static string ChangeContentFrameUrl(string url) {
|
||||
return string.Format(ClientMgrScript + ".contentFrame('{0}');", url);
|
||||
}
|
||||
public static string ReloadContentFrameUrlIfPathLoaded(string url)
|
||||
{
|
||||
return string.Format(ClientMgrScript + ".reloadContentFrameUrlIfPathLoaded('{0}');", url);
|
||||
}
|
||||
public static string ReloadLocation { get { return ClientMgrScript + ".reloadLocation();"; } }
|
||||
public static string ReloadLocationIfMatched { get { return ClientMgrScript + ".reloadLocation('{0}');"; } }
|
||||
public static string ChildNodeCreated = GetMainTree + ".childNodeCreated();";
|
||||
public static string SyncTree { get { return GetMainTree + ".syncTree('{0}', {1});"; } }
|
||||
public static string ClearTreeCache { get { return GetMainTree + ".clearTreeCache();"; } }
|
||||
public static string CopyNode { get { return GetMainTree + ".copyNode('{0}', '{1}');"; } }
|
||||
public static string MoveNode { get { return GetMainTree + ".moveNode('{0}', '{1}');"; } }
|
||||
public static string ReloadActionNode { get { return GetMainTree + ".reloadActionNode({0}, {1}, null);"; } }
|
||||
public static string RefreshTree { get { return GetMainTree + ".refreshTree();"; } }
|
||||
public static string RefreshTreeType { get { return GetMainTree + ".refreshTree('{0}');"; } }
|
||||
public static string CloseModalWindow()
|
||||
{
|
||||
return string.Format("{0}.closeModalWindow();", ClientMgrScript);
|
||||
}
|
||||
public static string CloseModalWindow(string rVal)
|
||||
{
|
||||
return string.Format("{0}.closeModalWindow('{1}');", ClientMgrScript, rVal);
|
||||
}
|
||||
public static string OpenModalWindow(string url, string name, int width, int height)
|
||||
{
|
||||
return OpenModalWindow(url, name, true, width, height, 0, 0, "", "");
|
||||
}
|
||||
public static string OpenModalWindow(string url, string name, bool showHeader, int width, int height, int top, int leftOffset, string closeTriggers, string onCloseCallback)
|
||||
{
|
||||
return string.Format("{0}.openModalWindow('{1}', '{2}', {3}, {4}, {5}, {6}, {7}, '{8}', '{9}');",
|
||||
new object[] { ClientMgrScript, url, name, showHeader.ToString().ToLower(), width, height, top, leftOffset, closeTriggers, onCloseCallback });
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Page _page;
|
||||
|
||||
/// <summary>
|
||||
/// This removes all tree JSON data cached in the client browser.
|
||||
/// Useful when you want to ensure that the tree is reloaded from live data.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ClientTools ClearClientTreeCache()
|
||||
{
|
||||
RegisterClientScript(Scripts.ClearTreeCache);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change applications
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ClientTools ShiftApp(string appAlias)
|
||||
{
|
||||
RegisterClientScript(Scripts.ShiftApp(appAlias));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh the entire administration console after a specified amount of time.
|
||||
/// </summary>
|
||||
/// <param name="seconds"></param>
|
||||
/// <returns></returns>
|
||||
public ClientTools RefreshAdmin(int seconds)
|
||||
{
|
||||
RegisterClientScript(string.Format(Scripts.RefreshAdmin, seconds * 1000));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the entire current tree
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ClientTools RefreshTree()
|
||||
{
|
||||
RegisterClientScript(Scripts.RefreshTree);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClientTools RefreshTree(string treeType)
|
||||
{
|
||||
RegisterClientScript(string.Format(Scripts.RefreshTreeType, treeType));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A reference to the umbraco UI component "speechbubble". The speechbubble appears in the lower right corner of the screen, notifying users of events
|
||||
/// </summary>
|
||||
/// <param name="i">The speechbubble icon.</param>
|
||||
/// <param name="header">The speechbubble header.</param>
|
||||
/// <param name="body">The body text</param>
|
||||
public ClientTools ShowSpeechBubble(SpeechBubbleIcon i, string header, string body)
|
||||
{
|
||||
RegisterClientScript(string.Format(Scripts.ShowSpeechBubble, i.ToString(), header.Replace("'", "\\'"), body.Replace("'", "\\'")));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the content in the content frame to the specified URL
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
public ClientTools ChangeContentFrameUrl(string url)
|
||||
{
|
||||
//don't load if there is no url
|
||||
if (string.IsNullOrEmpty(url)) return this;
|
||||
|
||||
url = EnsureUmbracoUrl(url);
|
||||
|
||||
RegisterClientScript(Scripts.ChangeContentFrameUrl(url));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the content in the content frame if the specified URL is currently loaded
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
public ClientTools ReloadContentFrameUrlIfPathLoaded(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) return this;
|
||||
|
||||
url = EnsureUmbracoUrl(url);
|
||||
|
||||
RegisterClientScript(Scripts.ReloadContentFrameUrlIfPathLoaded(url));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClientTools ReloadLocationIfMatched(string routePath)
|
||||
{
|
||||
RegisterClientScript(string.Format(Scripts.ReloadLocationIfMatched, routePath));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClientTools ReloadLocation()
|
||||
{
|
||||
RegisterClientScript(Scripts.ReloadLocation);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
private string EnsureUmbracoUrl(string url)
|
||||
{
|
||||
if (url.StartsWith("/") && url.StartsWith(IOHelper.ResolveUrl(SystemDirectories.Umbraco)) == false)
|
||||
{
|
||||
url = IOHelper.ResolveUrl(SystemDirectories.Umbraco).EnsureEndsWith('/') + url;
|
||||
}
|
||||
|
||||
if (url.Trim().StartsWith("~"))
|
||||
url = IOHelper.ResolveUrl(url);
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the dashboard for the given application
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <returns></returns>
|
||||
public ClientTools ShowDashboard(string app)
|
||||
{
|
||||
return ChangeContentFrameUrl(SystemDirectories.Umbraco + string.Format("/dashboard.aspx?app={0}", app));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the children of the current action node and selects the node that didn't exist there before.
|
||||
/// If the client side system cannot determine which node is new, then no node is selected.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is used by many create dialogs, however the sync method should be used based on the full path of the
|
||||
/// node but because the current Umbraco implementation of ITask only returns a url to load, there's no way
|
||||
/// to determine what the full path of the new child is.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
public ClientTools ChildNodeCreated()
|
||||
{
|
||||
RegisterClientScript(Scripts.ChildNodeCreated);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronizes the tree to the path specified.
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="forceReload">
|
||||
/// If set to true, will ensure that the node to be synced has it's data
|
||||
/// reloaded from the server. Otherwise, if the node already exists, the tree will simply sync to the node
|
||||
/// that is already there.
|
||||
/// </param>
|
||||
/// <remarks>
|
||||
/// This will work for any tree, however you would need to know the path of the node. Currently, media and content
|
||||
/// are the only trees that store a path, however, if you were working in the template tree for example, a path to a
|
||||
/// node could be "init,1090" and this method would still work.
|
||||
///
|
||||
/// Sync tree will works by syncing the active tree type. This can be specified explicitly by calling SetActiveTreeType.
|
||||
/// This will allow developers to sync many trees in one application at one time if needed.
|
||||
/// </remarks>
|
||||
/// <example>
|
||||
/// <![CDATA[
|
||||
/// //if you had both the media and content trees in the same app, you could sync both at the same
|
||||
/// //time by doing:
|
||||
/// BasePage.Current.ClientTools
|
||||
/// .SetActiveTreeType("content")
|
||||
/// .SyncTree("-1,100,200")
|
||||
/// .SetActiveTreeType("media")
|
||||
/// .SyncTree("-1,323,355");
|
||||
/// ]]>
|
||||
/// </example>
|
||||
public ClientTools SyncTree(string path, bool forceReload)
|
||||
{
|
||||
RegisterClientScript(string.Format(Scripts.SyncTree, path, forceReload.ToString().ToLower()));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClientTools CopyNode(string currNodeId, string newParentPath)
|
||||
{
|
||||
RegisterClientScript(string.Format(Scripts.CopyNode, currNodeId, newParentPath));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClientTools MoveNode(string currNodeId, string newParentPath)
|
||||
{
|
||||
RegisterClientScript(string.Format(Scripts.MoveNode, currNodeId, newParentPath));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reloads only the last node that the user interacted with via the context menu. To reload a specify node, use SyncTree.
|
||||
/// </summary>
|
||||
/// <param name="reselect"></param>
|
||||
/// <param name="reloadChildren"></param>
|
||||
/// <remarks>
|
||||
/// If for whatever reason the client side system cannot just refresh the one node, the system will use jsTree's built in
|
||||
/// refresh tool, this however won't allow for reselect or reloadChildren. Most trees will work with the single node
|
||||
/// refresh but 3rd party tools may have poorly built tree data models.
|
||||
/// </remarks>
|
||||
public ClientTools ReloadActionNode(bool reselect, bool reloadChildren)
|
||||
{
|
||||
RegisterClientScript(string.Format(Scripts.ReloadActionNode, (!reselect).ToString().ToLower(), (!reloadChildren).ToString().ToLower()));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the Umbraco dialog window if it is open
|
||||
/// </summary>
|
||||
/// <param name="returnVal">specify a value to return to add to the onCloseCallback method if one was specified in the OpenModalWindow method</param>
|
||||
/// <returns></returns>
|
||||
public ClientTools CloseModalWindow(string returnVal)
|
||||
{
|
||||
RegisterClientScript(Scripts.CloseModalWindow(returnVal));
|
||||
return this;
|
||||
}
|
||||
/// <summary>
|
||||
/// Closes the umbraco dialog window if it is open
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ClientTools CloseModalWindow()
|
||||
{
|
||||
return CloseModalWindow("");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Opens a modal window
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="height"></param>
|
||||
/// <param name="showHeader"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <param name="top"></param>
|
||||
/// <param name="leftOffset"></param>
|
||||
/// <param name="closeTriggers"></param>
|
||||
/// <param name="onCloseCallback"></param>
|
||||
/// <returns></returns>
|
||||
public ClientTools OpenModalWindow(string url, string name, bool showHeader, int width, int height, int top, int leftOffset, string closeTriggers, string onCloseCallback)
|
||||
{
|
||||
RegisterClientScript(Scripts.OpenModalWindow(url, name, showHeader, width, height, top, leftOffset, closeTriggers, onCloseCallback));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will use the ScriptManager to register the script if one is available, otherwise will default to the ClientScript
|
||||
/// class of the page.
|
||||
/// </summary>
|
||||
/// <param name="script"></param>
|
||||
private void RegisterClientScript(string script)
|
||||
{
|
||||
//use the hash code of the script to generate the key, this way, the exact same script won't be
|
||||
//inserted more than once.
|
||||
if (ScriptManager.GetCurrent(_page) != null)
|
||||
{
|
||||
ScriptManager.RegisterStartupScript(_page, _page.GetType(), script.GetHashCode().ToString(), script, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_page.ClientScript.RegisterStartupScript(_page.GetType(), script.GetHashCode().ToString(), script, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Security;
|
||||
using System.Web;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Web.Actions;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Security;
|
||||
|
||||
|
||||
namespace Umbraco.Web.UI.Pages
|
||||
{
|
||||
/// <summary>
|
||||
/// UmbracoEnsuredPage is the standard protected page in the umbraco backend, and forces authentication.
|
||||
/// </summary>
|
||||
public class UmbracoEnsuredPage : BasePage
|
||||
{
|
||||
public UmbracoEnsuredPage()
|
||||
{
|
||||
//Assign security automatically if the attribute is found
|
||||
var treeAuth = this.GetType().GetCustomAttribute<WebformsPageTreeAuthorizeAttribute>(true);
|
||||
if (treeAuth != null)
|
||||
{
|
||||
var treeByAlias = Current.TreeService
|
||||
.GetByAlias(treeAuth.TreeAlias);
|
||||
if (treeByAlias != null)
|
||||
{
|
||||
CurrentApp = treeByAlias.ApplicationAlias;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs an authorization check for the user against the requested entity/path and permission set, this is only relevant to content and media
|
||||
/// </summary>
|
||||
/// <param name="entityId"></param>
|
||||
/// <param name="objectType"></param>
|
||||
/// <param name="actionToCheck"></param>
|
||||
protected void CheckPathAndPermissions(int entityId, UmbracoObjectTypes objectType, IAction actionToCheck)
|
||||
{
|
||||
if (objectType != UmbracoObjectTypes.Document && objectType != UmbracoObjectTypes.Media)
|
||||
return;
|
||||
|
||||
//check path access
|
||||
|
||||
var entity = entityId == Constants.System.Root
|
||||
? EntitySlim.Root
|
||||
: Services.EntityService.Get(entityId, objectType);
|
||||
var hasAccess = objectType == UmbracoObjectTypes.Document
|
||||
? Security.CurrentUser.HasContentPathAccess(entity, Services.EntityService)
|
||||
: Security.CurrentUser.HasMediaPathAccess(entity, Services.EntityService);
|
||||
if (hasAccess == false)
|
||||
throw new AuthorizationException($"The current user doesn't have access to the path '{entity.Path}'");
|
||||
|
||||
//only documents have action permissions
|
||||
if (objectType == UmbracoObjectTypes.Document)
|
||||
{
|
||||
var allActions = Current.Actions;
|
||||
var perms = Security.CurrentUser.GetPermissions(entity.Path, Services.UserService);
|
||||
var actions = perms
|
||||
.Select(x => allActions.FirstOrDefault(y => y.Letter.ToString(CultureInfo.InvariantCulture) == x))
|
||||
.WhereNotNull();
|
||||
if (actions.Contains(actionToCheck) == false)
|
||||
throw new AuthorizationException($"The current user doesn't have permission to {actionToCheck.Alias} on the path '{entity.Path}'");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _hasValidated = false;
|
||||
|
||||
/// <summary>
|
||||
/// Authorizes the user
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <remarks>
|
||||
/// Checks if the page exists outside of the /umbraco route, in which case the request will not have been authenticated for the back office
|
||||
/// so we'll force authentication.
|
||||
/// </remarks>
|
||||
protected override void OnPreInit(EventArgs e)
|
||||
{
|
||||
base.OnPreInit(e);
|
||||
|
||||
//If this is not a back office request, then the module won't have authenticated it, in this case we
|
||||
// need to do the auth manually and since this is an UmbracoEnsuredPage, this is the anticipated behavior
|
||||
// TODO: When we implement Identity, this process might not work anymore, will be an interesting challenge
|
||||
if (Context.Request.Url.IsBackOfficeRequest(HttpRuntime.AppDomainAppVirtualPath, Current.Configs.Global()) == false)
|
||||
{
|
||||
var http = new HttpContextWrapper(Context);
|
||||
var ticket = http.GetUmbracoAuthTicket();
|
||||
http.AuthenticateCurrentRequest(ticket, true);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Security.ValidateCurrentUser(true);
|
||||
_hasValidated = true;
|
||||
|
||||
if (!Security.ValidateUserApp(CurrentApp))
|
||||
{
|
||||
var ex = new SecurityException(String.Format("The current user doesn't have access to the section/app '{0}'", CurrentApp));
|
||||
Current.Logger.Error<UmbracoEnsuredPage>(ex, "Tried to access '{CurrentApp}'", CurrentApp);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Clear content as .NET transfers rendered content.
|
||||
Response.Clear();
|
||||
|
||||
// Ensure the person is definitely logged out
|
||||
UmbracoContext.Current.Security.ClearCurrentLogin();
|
||||
|
||||
// Redirect to the login page
|
||||
Response.Redirect(SystemDirectories.Umbraco + "#/login", true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets the app that this page is assigned to
|
||||
/// </summary>
|
||||
protected string CurrentApp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true then umbraco will force any window/frame to reload umbraco in the main window
|
||||
/// </summary>
|
||||
protected bool RedirectToUmbraco { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to assign a webforms page's security to a specific tree which will in turn check to see
|
||||
/// if the current user has access to the specified tree's registered section
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public sealed class WebformsPageTreeAuthorizeAttribute : Attribute
|
||||
{
|
||||
public string TreeAlias { get; private set; }
|
||||
|
||||
public WebformsPageTreeAuthorizeAttribute(string treeAlias)
|
||||
{
|
||||
TreeAlias = treeAlias;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,6 +247,7 @@
|
||||
<Compile Include="Trees\TreeCollection.cs" />
|
||||
<Compile Include="UI\JavaScript\ClientDependencyConfiguration.cs" />
|
||||
<Compile Include="Editors\Binders\BlueprintItemBinder.cs" />
|
||||
<Compile Include="umbraco.presentation\MacroCacheContent.cs" />
|
||||
<Compile Include="UmbracoApplicationBase.cs" />
|
||||
<Compile Include="WebApi\HttpActionContextExtensions.cs" />
|
||||
<Compile Include="Models\ContentEditing\IContentSave.cs" />
|
||||
@@ -894,9 +895,6 @@
|
||||
<Compile Include="UI\JavaScript\AssetInitialization.cs" />
|
||||
<Compile Include="UI\JavaScript\CssInitialization.cs" />
|
||||
<Compile Include="UI\JavaScript\DependencyPathRenderer.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\create.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UmbracoComponentRenderer.cs" />
|
||||
<Compile Include="Web References\org.umbraco.our\Reference.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
@@ -1049,9 +1047,6 @@
|
||||
<Compile Include="UI\Bundles\JsUmbracoApplicationUI.cs" />
|
||||
<Compile Include="UI\Bundles\JsUmbracoTree.cs" />
|
||||
<Compile Include="UI\CdfLogger.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\create\simple.ascx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controllers\UmbLoginController.cs" />
|
||||
<Compile Include="UrlHelperExtensions.cs" />
|
||||
<Compile Include="Editors\MediaController.cs" />
|
||||
@@ -1149,35 +1144,13 @@
|
||||
<Compile Include="_Legacy\Controls\PropertyPanel.cs" />
|
||||
<Compile Include="_Legacy\Controls\TabPage.cs" />
|
||||
<Compile Include="_Legacy\Controls\TabView.cs" />
|
||||
<Compile Include="_Legacy\PackageActions\addProxyFeedHost.cs" />
|
||||
<Compile Include="_Legacy\PackageActions\allowDoctype.cs" />
|
||||
<Compile Include="_Legacy\PackageActions\publishRootDocument.cs" />
|
||||
<Compile Include="_Legacy\UI\ITask.cs" />
|
||||
<Compile Include="_Legacy\UI\ITaskReturnUrl.cs" />
|
||||
<Compile Include="_Legacy\UI\LegacyDialogHandler.cs" />
|
||||
<Compile Include="_Legacy\UI\LegacyDialogTask.cs" />
|
||||
<Compile Include="UI\Pages\BasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\Pages\ClientTools.cs" />
|
||||
<Compile Include="UI\Pages\UmbracoEnsuredPage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\SpeechBubbleIcon.cs" />
|
||||
<Compile Include="umbraco.presentation\AttributeCollectionAdapter.cs" />
|
||||
<Compile Include="umbraco.presentation\Default.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\MacroCacheContent.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\masterpages\default.Master.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\masterpages\umbracoPage.master.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\masterpages\umbracoDialog.master.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UmbracoHelper.cs" />
|
||||
<Compile Include="Mvc\ViewContextExtensions.cs" />
|
||||
<Compile Include="Mvc\ViewDataContainerExtensions.cs" />
|
||||
@@ -1213,9 +1186,6 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\item.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\page.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -1224,10 +1194,6 @@
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbracoPageHolder.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\create\macroTasks.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\dashboard\FeedProxy.aspx.cs">
|
||||
<DependentUpon>FeedProxy.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -1235,11 +1201,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\dashboard\FeedProxy.aspx.designer.cs">
|
||||
<DependentUpon>FeedProxy.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\templateControls\DisableEventValidation.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\templateControls\Item.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\templateControls\ItemRenderer.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\templateControls\Macro.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\templateControls\ContentType.cs" />
|
||||
<Compile Include="UmbracoApplication.cs" />
|
||||
<Compile Include="UmbracoContext.cs" />
|
||||
<Compile Include="UmbracoInjectedModule.cs" />
|
||||
|
||||
@@ -1,312 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace umbraco
|
||||
{
|
||||
/// <summary>
|
||||
/// Class that adapts an <see cref="AttributeCollection"/> to the <see cref="IDictionary"/> interface.
|
||||
/// </summary>
|
||||
public class AttributeCollectionAdapter : IDictionary
|
||||
{
|
||||
private readonly AttributeCollection _collection;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AttributeCollectionAdapter"/> class.
|
||||
/// </summary>
|
||||
/// <param name="collection">The collection.</param>
|
||||
public AttributeCollectionAdapter(AttributeCollection collection)
|
||||
{
|
||||
_collection = collection;
|
||||
}
|
||||
|
||||
#region IDictionary Members
|
||||
|
||||
/// <summary>
|
||||
/// Adds an element with the provided key and value to the <see cref="T:System.Collections.IDictionary"/> object.
|
||||
/// </summary>
|
||||
/// <param name="key">The <see cref="T:System.Object"/> to use as the key of the element to add.</param>
|
||||
/// <param name="value">The <see cref="T:System.Object"/> to use as the value of the element to add.</param>
|
||||
public void Add(object key, object value)
|
||||
{
|
||||
_collection.Add(key.ToString(), value.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all elements from the <see cref="T:System.Collections.IDictionary"/> object.
|
||||
/// </summary>
|
||||
/// <exception cref="T:System.NotSupportedException">
|
||||
/// The <see cref="T:System.Collections.IDictionary"/> object is read-only.
|
||||
/// </exception>
|
||||
public void Clear()
|
||||
{
|
||||
_collection.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the <see cref="T:System.Collections.IDictionary"/> object contains an element with the specified key.
|
||||
/// </summary>
|
||||
/// <param name="key">The key to locate in the <see cref="T:System.Collections.IDictionary"/> object.</param>
|
||||
/// <returns>
|
||||
/// true if the <see cref="T:System.Collections.IDictionary"/> contains an element with the key; otherwise, false.
|
||||
/// </returns>
|
||||
public bool Contains(object key)
|
||||
{
|
||||
return _collection[key.ToString()] != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an <see cref="T:System.Collections.IDictionaryEnumerator"/> object for the <see cref="T:System.Collections.IDictionary"/> object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// An <see cref="T:System.Collections.IDictionaryEnumerator"/> object for the <see cref="T:System.Collections.IDictionary"/> object.
|
||||
/// </returns>
|
||||
public IDictionaryEnumerator GetEnumerator()
|
||||
{
|
||||
return new AttributeCollectionAdapterEnumerator(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the <see cref="T:System.Collections.IDictionary"/> object has a fixed size.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <returns>true if the <see cref="T:System.Collections.IDictionary"/> object has a fixed size; otherwise, false.
|
||||
/// </returns>
|
||||
public bool IsFixedSize
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the <see cref="T:System.Collections.IDictionary"/> object is read-only.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <returns>true if the <see cref="T:System.Collections.IDictionary"/> object is read-only; otherwise, false.
|
||||
/// </returns>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="T:System.Collections.ICollection"/> object containing the keys of the <see cref="T:System.Collections.IDictionary"/> object.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <returns>
|
||||
/// An <see cref="T:System.Collections.ICollection"/> object containing the keys of the <see cref="T:System.Collections.IDictionary"/> object.
|
||||
/// </returns>
|
||||
public ICollection Keys
|
||||
{
|
||||
get { return _collection.Keys; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the element with the specified key from the <see cref="T:System.Collections.IDictionary"/> object.
|
||||
/// </summary>
|
||||
/// <param name="key">The key of the element to remove.</param>
|
||||
public void Remove(object key)
|
||||
{
|
||||
_collection.Remove(key.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="T:System.Collections.ICollection"/> object containing the values in the <see cref="T:System.Collections.IDictionary"/> object.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <returns>
|
||||
/// An <see cref="T:System.Collections.ICollection"/> object containing the values in the <see cref="T:System.Collections.IDictionary"/> object.
|
||||
/// </returns>
|
||||
public ICollection Values
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="System.Object"/> with the specified key.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public object this[object key]
|
||||
{
|
||||
get { return _collection[key.ToString()]; }
|
||||
set { _collection[key.ToString()] = value.ToString(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
|
||||
/// <summary>Not implemented.</summary>
|
||||
/// <param name="array">The one-dimensional <see cref="T:System.Array"/> that is the destination of the elements copied from <see cref="T:System.Collections.ICollection"/>. The <see cref="T:System.Array"/> must have zero-based indexing.</param>
|
||||
/// <param name="index">The zero-based index in <paramref name="array"/> at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of elements contained in the <see cref="T:System.Collections.ICollection"/>.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <returns>
|
||||
/// The number of elements contained in the <see cref="T:System.Collections.ICollection"/>.
|
||||
/// </returns>
|
||||
public int Count
|
||||
{
|
||||
get { return _collection.Count; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether access to the <see cref="T:System.Collections.ICollection"/> is synchronized (thread safe).
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <returns>true if access to the <see cref="T:System.Collections.ICollection"/> is synchronized (thread safe); otherwise, false.
|
||||
/// </returns>
|
||||
public bool IsSynchronized
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection"/>.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <returns>
|
||||
/// An object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection"/>.
|
||||
/// </returns>
|
||||
public object SyncRoot
|
||||
{
|
||||
get { return _collection; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that iterates through a collection.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// An <see cref="T:System.Collections.IEnumerator"/> object that can be used to iterate through the collection.
|
||||
/// </returns>
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
foreach (object key in _collection.Keys)
|
||||
yield return _collection[(string)key];
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="IDictionaryEnumerator"/> for the <see cref="AttributeCollectionAdapter"/> class.
|
||||
/// </summary>
|
||||
private class AttributeCollectionAdapterEnumerator : IDictionaryEnumerator
|
||||
{
|
||||
private readonly AttributeCollectionAdapter _adapter;
|
||||
private readonly IEnumerator _enumerator;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AttributeCollectionAdapterEnumerator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="adapter">The adapter.</param>
|
||||
public AttributeCollectionAdapterEnumerator(AttributeCollectionAdapter adapter)
|
||||
{
|
||||
_adapter = adapter;
|
||||
_enumerator = ((IEnumerable)adapter).GetEnumerator();
|
||||
}
|
||||
|
||||
#region IDictionaryEnumerator Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets both the key and the value of the current dictionary entry.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <returns>
|
||||
/// A <see cref="T:System.Collections.DictionaryEntry"/> containing both the key and the value of the current dictionary entry.
|
||||
/// </returns>
|
||||
/// <exception cref="T:System.InvalidOperationException">
|
||||
/// The <see cref="T:System.Collections.IDictionaryEnumerator"/> is positioned before the first entry of the dictionary or after the last entry.
|
||||
/// </exception>
|
||||
public DictionaryEntry Entry
|
||||
{
|
||||
get { return new DictionaryEntry(Key, Value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the key of the current dictionary entry.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <returns>
|
||||
/// The key of the current element of the enumeration.
|
||||
/// </returns>
|
||||
/// <exception cref="T:System.InvalidOperationException">
|
||||
/// The <see cref="T:System.Collections.IDictionaryEnumerator"/> is positioned before the first entry of the dictionary or after the last entry.
|
||||
/// </exception>
|
||||
public object Key
|
||||
{
|
||||
get { return _enumerator.Current; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the current dictionary entry.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <returns>
|
||||
/// The value of the current element of the enumeration.
|
||||
/// </returns>
|
||||
/// <exception cref="T:System.InvalidOperationException">
|
||||
/// The <see cref="T:System.Collections.IDictionaryEnumerator"/> is positioned before the first entry of the dictionary or after the last entry.
|
||||
/// </exception>
|
||||
public object Value
|
||||
{
|
||||
get { return _adapter[_enumerator.Current]; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEnumerator Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current element in the collection.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <returns>
|
||||
/// The current element in the collection.
|
||||
/// </returns>
|
||||
/// <exception cref="T:System.InvalidOperationException">
|
||||
/// The enumerator is positioned before the first element of the collection or after the last element.
|
||||
/// </exception>
|
||||
public object Current
|
||||
{
|
||||
get { return _enumerator.Current; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next element of the collection.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
|
||||
/// </returns>
|
||||
/// <exception cref="T:System.InvalidOperationException">
|
||||
/// The collection was modified after the enumerator was created.
|
||||
/// </exception>
|
||||
public bool MoveNext()
|
||||
{
|
||||
return _enumerator.MoveNext();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the enumerator to its initial position, which is before the first element in the collection.
|
||||
/// </summary>
|
||||
/// <exception cref="T:System.InvalidOperationException">
|
||||
/// The collection was modified after the enumerator was created.
|
||||
/// </exception>
|
||||
public void Reset()
|
||||
{
|
||||
_enumerator.Reset();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Web.UI;
|
||||
using System;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace umbraco
|
||||
{
|
||||
@@ -7,6 +8,7 @@ namespace umbraco
|
||||
private readonly Control _control;
|
||||
private readonly string _id;
|
||||
|
||||
[Obsolete("TODO: WB This seems legacy as we reference WebForms Control type", false)]
|
||||
public MacroCacheContent(Control control, string ID)
|
||||
{
|
||||
_control = control;
|
||||
|
||||
@@ -1,183 +0,0 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Web.UI;
|
||||
using System.IO;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Web.Templates;
|
||||
using Umbraco.Web.Composing;
|
||||
|
||||
namespace umbraco
|
||||
{
|
||||
/// <summary>
|
||||
/// The codebehind class for the main default.aspx page that does the webforms rendering in Umbraco
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// We would move this to the UI project but there is a public API property and some protected properties which people may be using so
|
||||
/// we cannot move it.
|
||||
/// </remarks>
|
||||
public class UmbracoDefault : Page
|
||||
{
|
||||
/// <summary>
|
||||
/// Simply used to clear temp data
|
||||
/// </summary>
|
||||
private class TempDataController : Controller
|
||||
{
|
||||
}
|
||||
|
||||
private page _upage;
|
||||
private PublishedRequest _frequest;
|
||||
|
||||
/// <summary>
|
||||
/// To turn off request validation set this to false before the PageLoad event. This equivalent to the validateRequest page directive
|
||||
/// and has nothing to do with "normal" validation controls. Default value is true.
|
||||
/// </summary>
|
||||
public bool ValidateRequest { get; set; } = true;
|
||||
|
||||
protected override void OnPreInit(EventArgs e)
|
||||
{
|
||||
base.OnPreInit(e);
|
||||
using (Current.ProfilingLogger.DebugDuration<UmbracoDefault>("PreInit"))
|
||||
{
|
||||
// handle the infamous umbDebugShowTrace, etc
|
||||
Page.Trace.IsEnabled &= GlobalSettings.DebugMode && string.IsNullOrWhiteSpace(Request["umbDebugShowTrace"]) == false;
|
||||
|
||||
// get the document request and the page
|
||||
_frequest = UmbracoContext.Current.PublishedRequest;
|
||||
_upage = _frequest.UmbracoPage;
|
||||
|
||||
var args = new RequestInitEventArgs()
|
||||
{
|
||||
Page = _upage,
|
||||
PageId = _upage.PageID,
|
||||
Context = Context
|
||||
};
|
||||
FireBeforeRequestInit(args);
|
||||
|
||||
//if we are cancelling then return and don't proceed
|
||||
if (args.Cancel) return;
|
||||
|
||||
// reset the friendly path so it's used by forms, etc.
|
||||
Context.RewritePath(UmbracoContext.Current.OriginalRequestUrl.PathAndQuery);
|
||||
|
||||
//fire the init finished event
|
||||
FireAfterRequestInit(args);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
using (Current.ProfilingLogger.DebugDuration<UmbracoDefault>("Init"))
|
||||
{
|
||||
base.OnInit(e);
|
||||
|
||||
//This is a special case for webforms since in some cases we may be POSTing to an MVC controller, adding TempData there and then redirecting
|
||||
// to a webforms handler. In that case we need to manually clear out the tempdata ourselves since this is normally the function of the base
|
||||
// MVC controller instance and since that is not executing, we'll deal with that here.
|
||||
//Unfortunately for us though, we can never know which TempDataProvider was used for the previous controller, by default it is the sessionstateprovider
|
||||
// but since the tempdataprovider is not a global mvc thing, it is only a per-controller thing, we can only just assume it will be the sessionstateprovider
|
||||
var provider = new SessionStateTempDataProvider();
|
||||
//We create a custom controller context, the only thing that is referenced from this controller context in the sessionstateprovider is the HttpContext.Session
|
||||
// so we just need to ensure that is set
|
||||
var ctx = new ControllerContext(new HttpContextWrapper(Context), new RouteData(), new TempDataController());
|
||||
provider.LoadTempData(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
using (Current.ProfilingLogger.DebugDuration<UmbracoDefault>("Load"))
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
if (ValidateRequest)
|
||||
Request.ValidateInput();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Render(HtmlTextWriter writer)
|
||||
{
|
||||
using (Current.ProfilingLogger.DebugDuration<UmbracoDefault>("Render"))
|
||||
{
|
||||
|
||||
// do the original rendering
|
||||
TextWriter sw = new StringWriter();
|
||||
base.Render(new HtmlTextWriter(sw));
|
||||
string text = sw.ToString();
|
||||
|
||||
// filter / parse internal links - although this should be done elsewhere!
|
||||
text = TemplateUtilities.ParseInternalLinks(text, UmbracoContext.Current.UrlProvider);
|
||||
|
||||
// filter / add preview banner
|
||||
if (UmbracoContext.Current.InPreviewMode)
|
||||
{
|
||||
Current.Logger.Debug<UmbracoDefault>("Umbraco is running in preview mode.");
|
||||
|
||||
if (Response.ContentType.InvariantEquals("text/html")) // ASP.NET default value
|
||||
{
|
||||
int pos = text.ToLower().IndexOf("</body>");
|
||||
if (pos > -1)
|
||||
{
|
||||
string htmlBadge =
|
||||
string.Format(Current.Configs.Settings().Content.PreviewBadge,
|
||||
IOHelper.ResolveUrl(SystemDirectories.Umbraco),
|
||||
Server.UrlEncode(UmbracoContext.Current.HttpContext.Request.Path));
|
||||
|
||||
text = text.Substring(0, pos) + htmlBadge + text.Substring(pos, text.Length - pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// render
|
||||
writer.Write(text);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The preinit event handler
|
||||
/// </summary>
|
||||
public delegate void RequestInitEventHandler(object sender, RequestInitEventArgs e);
|
||||
/// <summary>
|
||||
/// occurs before the umbraco page is initialized for rendering.
|
||||
/// </summary>
|
||||
public static event RequestInitEventHandler BeforeRequestInit;
|
||||
/// <summary>
|
||||
/// Raises the <see cref="BeforeRequestInit"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected internal virtual void FireBeforeRequestInit(RequestInitEventArgs e)
|
||||
{
|
||||
if (BeforeRequestInit != null)
|
||||
BeforeRequestInit(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [after save].
|
||||
/// </summary>
|
||||
public static event RequestInitEventHandler AfterRequestInit;
|
||||
/// <summary>
|
||||
/// Raises the <see cref="AfterRequestInit"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void FireAfterRequestInit(RequestInitEventArgs e)
|
||||
{
|
||||
if (AfterRequestInit != null)
|
||||
AfterRequestInit(this, e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class RequestInitEventArgs : System.ComponentModel.CancelEventArgs
|
||||
{
|
||||
public page Page { get; internal set; }
|
||||
public HttpContext Context { get; internal set; }
|
||||
public string Url { get; internal set; }
|
||||
public int PageId { get; internal set; }
|
||||
}
|
||||
}
|
||||
@@ -1,237 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Web;
|
||||
using System.Xml;
|
||||
using StackExchange.Profiling;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Core.Profiling;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Macros;
|
||||
|
||||
namespace umbraco
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class item
|
||||
{
|
||||
private string _fieldContent = "";
|
||||
private readonly string _fieldName;
|
||||
|
||||
public string FieldContent
|
||||
{
|
||||
get { return _fieldContent; }
|
||||
}
|
||||
|
||||
public item(string itemValue, IDictionary attributes)
|
||||
{
|
||||
_fieldContent = itemValue;
|
||||
ParseItem(attributes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Legacy item
|
||||
/// </summary>
|
||||
/// <param name="elements"></param>
|
||||
/// <param name="attributes"></param>
|
||||
public item(IDictionary elements, IDictionary attributes)
|
||||
: this(null, elements, attributes)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an Item with a publishedContent item in order to properly recurse and return the value.
|
||||
/// </summary>
|
||||
/// <param name="publishedContent"></param>
|
||||
/// <param name="elements"></param>
|
||||
/// <param name="attributes"></param>
|
||||
/// <remarks>
|
||||
/// THIS ENTIRE CLASS WILL BECOME LEGACY, THE FIELD RENDERING NEEDS TO BE REPLACES SO THAT IS WHY THIS
|
||||
/// CTOR IS INTERNAL.
|
||||
/// </remarks>
|
||||
internal item(IPublishedContent publishedContent, IDictionary elements, IDictionary attributes)
|
||||
{
|
||||
_fieldName = FindAttribute(attributes, "field");
|
||||
|
||||
if (_fieldName.StartsWith("#"))
|
||||
{
|
||||
var umbHelper = new UmbracoHelper(Current.UmbracoContext, Current.Services);
|
||||
|
||||
_fieldContent = umbHelper.GetDictionaryValue(_fieldName.Substring(1, _fieldName.Length - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Loop through XML children we need to find the fields recursive
|
||||
var recursive = FindAttribute(attributes, "recursive") == "true";
|
||||
|
||||
if (publishedContent == null)
|
||||
{
|
||||
if (recursive)
|
||||
{
|
||||
var recursiveVal = GetRecursiveValueLegacy(elements);
|
||||
_fieldContent = recursiveVal.IsNullOrWhiteSpace() ? _fieldContent : recursiveVal;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//check for published content and get its value using that
|
||||
if (publishedContent != null && (publishedContent.HasProperty(_fieldName) || recursive))
|
||||
{
|
||||
var pval = publishedContent.Value(_fieldName, fallback: Fallback.ToAncestors);
|
||||
var rval = pval == null ? string.Empty : pval.ToString();
|
||||
_fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval;
|
||||
}
|
||||
else
|
||||
{
|
||||
//get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent)
|
||||
var elt = elements[_fieldName];
|
||||
if (elt != null && string.IsNullOrEmpty(elt.ToString()) == false)
|
||||
_fieldContent = elt.ToString().Trim();
|
||||
}
|
||||
|
||||
//now we check if the value is still empty and if so we'll check useIfEmpty
|
||||
if (string.IsNullOrEmpty(_fieldContent))
|
||||
{
|
||||
var altFieldName = FindAttribute(attributes, "useIfEmpty");
|
||||
if (string.IsNullOrEmpty(altFieldName) == false)
|
||||
{
|
||||
if (publishedContent != null && (publishedContent.HasProperty(altFieldName) || recursive))
|
||||
{
|
||||
var pval = publishedContent.Value(altFieldName, fallback: Fallback.ToAncestors);
|
||||
var rval = pval == null ? string.Empty : pval.ToString();
|
||||
_fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval;
|
||||
}
|
||||
else
|
||||
{
|
||||
//get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent)
|
||||
var elt = elements[altFieldName];
|
||||
if (elt != null && string.IsNullOrEmpty(elt.ToString()) == false)
|
||||
_fieldContent = elt.ToString().Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ParseItem(attributes);
|
||||
}
|
||||
|
||||
static string FindAttribute(IDictionary attributes, string key)
|
||||
{
|
||||
key = key.ToLowerInvariant();
|
||||
var attributeValue = attributes.Contains(key) ? attributes[key].ToString() : string.Empty;
|
||||
return MacroRenderer.ParseAttribute(null, attributeValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the recursive value using a legacy strategy of looking at the xml cache and the splitPath in the elements collection
|
||||
/// </summary>
|
||||
/// <param name="elements"></param>
|
||||
/// <returns></returns>
|
||||
private string GetRecursiveValueLegacy(IDictionary elements)
|
||||
{
|
||||
using (Current.ProfilingLogger.DebugDuration<item>("Checking recusively"))
|
||||
{
|
||||
var content = "";
|
||||
|
||||
var umbracoContext = UmbracoContext.Current;
|
||||
var cache = umbracoContext.ContentCache as Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache;
|
||||
if (cache == null)
|
||||
throw new InvalidOperationException("Unsupported IPublishedContentCache, only the Xml one is supported.");
|
||||
var umbracoXml = cache.GetXml(umbracoContext.InPreviewMode);
|
||||
|
||||
var splitpath = (string[])elements["splitpath"];
|
||||
for (int i = 0; i < splitpath.Length - 1; i++)
|
||||
{
|
||||
XmlNode element = umbracoXml.GetElementById(splitpath[splitpath.Length - i - 1]);
|
||||
|
||||
if (element == null)
|
||||
continue;
|
||||
|
||||
var xpath = "./{0}";
|
||||
var currentNode = element.SelectSingleNode(string.Format(xpath, _fieldName));
|
||||
|
||||
//continue if all is null
|
||||
if (currentNode == null || currentNode.FirstChild == null || string.IsNullOrEmpty(currentNode.FirstChild.Value) || string.IsNullOrEmpty(currentNode.FirstChild.Value.Trim()))
|
||||
continue;
|
||||
|
||||
HttpContext.Current.Trace.Write("item.recursive", "Item loaded from " + splitpath[splitpath.Length - i - 1]);
|
||||
content = currentNode.FirstChild.Value;
|
||||
break;
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
private void ParseItem(IDictionary attributes)
|
||||
{
|
||||
using (Current.ProfilingLogger.DebugDuration<item>("Start parsing " + _fieldName))
|
||||
{
|
||||
HttpContext.Current.Trace.Write("item", "Start parsing '" + _fieldName + "'");
|
||||
if (FindAttribute(attributes, "textIfEmpty") != "" && _fieldContent == "")
|
||||
_fieldContent = FindAttribute(attributes, "textIfEmpty");
|
||||
|
||||
_fieldContent = _fieldContent.Trim();
|
||||
|
||||
// DATE FORMATTING FUNCTIONS
|
||||
if (FindAttribute(attributes, "formatAsDateWithTime") == "true")
|
||||
{
|
||||
if (_fieldContent == "")
|
||||
_fieldContent = DateTime.Now.ToString();
|
||||
_fieldContent = Convert.ToDateTime(_fieldContent).ToLongDateString() +
|
||||
FindAttribute(attributes, "formatAsDateWithTimeSeparator") +
|
||||
Convert.ToDateTime(_fieldContent).ToShortTimeString();
|
||||
}
|
||||
else if (FindAttribute(attributes, "formatAsDate") == "true")
|
||||
{
|
||||
if (_fieldContent == "")
|
||||
_fieldContent = DateTime.Now.ToString();
|
||||
_fieldContent = Convert.ToDateTime(_fieldContent).ToLongDateString();
|
||||
}
|
||||
|
||||
|
||||
// TODO: Needs revision to check if parameter-tags has attributes
|
||||
if (FindAttribute(attributes, "stripParagraph") == "true" && _fieldContent.Length > 5)
|
||||
{
|
||||
_fieldContent = _fieldContent.Trim();
|
||||
string fieldContentLower = _fieldContent.ToLower();
|
||||
|
||||
// the field starts with an opening p tag
|
||||
if (fieldContentLower.Substring(0, 3) == "<p>"
|
||||
// it ends with a closing p tag
|
||||
&& fieldContentLower.Substring(_fieldContent.Length - 4, 4) == "</p>"
|
||||
// it doesn't contain multiple p-tags
|
||||
&& fieldContentLower.IndexOf("<p>", 1) < 0)
|
||||
{
|
||||
_fieldContent = _fieldContent.Substring(3, _fieldContent.Length - 7);
|
||||
}
|
||||
}
|
||||
|
||||
// CASING
|
||||
if (FindAttribute(attributes, "case") == "lower")
|
||||
_fieldContent = _fieldContent.ToLower();
|
||||
else if (FindAttribute(attributes, "case") == "upper")
|
||||
_fieldContent = _fieldContent.ToUpper();
|
||||
else if (FindAttribute(attributes, "case") == "title")
|
||||
_fieldContent = _fieldContent.ToCleanString(CleanStringType.Ascii | CleanStringType.Alias | CleanStringType.PascalCase);
|
||||
|
||||
// OTHER FORMATTING FUNCTIONS
|
||||
|
||||
if (FindAttribute(attributes, "urlEncode") == "true")
|
||||
_fieldContent = HttpUtility.UrlEncode(_fieldContent);
|
||||
if (FindAttribute(attributes, "htmlEncode") == "true")
|
||||
_fieldContent = HttpUtility.HtmlEncode(_fieldContent);
|
||||
if (FindAttribute(attributes, "convertLineBreaks") == "true")
|
||||
_fieldContent = _fieldContent.Replace("\n", "<br/>\n");
|
||||
|
||||
HttpContext.Current.Trace.Write("item", "Done parsing '" + _fieldName + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ namespace umbraco
|
||||
/// <summary>
|
||||
/// Summary description for page.
|
||||
/// </summary>
|
||||
[Obsolete("TODO: WB This seems legacy", false)]
|
||||
public class page
|
||||
{
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
using System.Xml;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
namespace umbraco.cms.presentation
|
||||
{
|
||||
public class Create : UmbracoEnsuredPage
|
||||
{
|
||||
protected Label helpText;
|
||||
protected TextBox rename;
|
||||
protected Label Label1;
|
||||
protected ListBox nodeType;
|
||||
protected PlaceHolder UI;
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
// Load create definitions
|
||||
var nodeType = Request.QueryString["nodeType"];
|
||||
|
||||
var createDef = new XmlDocument();
|
||||
var defReader = new XmlTextReader(IOHelper.MapPath(SystemFiles.CreateUiXml));
|
||||
createDef.Load(defReader);
|
||||
defReader.Close();
|
||||
|
||||
// Find definition for current nodeType
|
||||
var def = createDef.SelectSingleNode("//nodeType [@alias = '" + nodeType + "']");
|
||||
if (def == null)
|
||||
{
|
||||
throw new ArgumentException("The create dialog for \"" + nodeType + "\" does not match anything defined in the \"" + SystemFiles.CreateUiXml + "\". This could mean an incorrectly installed package or a corrupt UI file");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var virtualPath = SystemDirectories.Umbraco + def.SelectSingleNode("./usercontrol").FirstChild.Value;
|
||||
var mainControl = LoadControl(virtualPath);
|
||||
UI.Controls.Add(mainControl);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ArgumentException("ERROR CREATING CONTROL FOR NODETYPE: " + nodeType, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web._Legacy.UI;
|
||||
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
public class macroTasks : LegacyDialogTask
|
||||
{
|
||||
public override bool PerformSave()
|
||||
{
|
||||
var macro = Current.Services.MacroService.GetByAlias(Alias);
|
||||
if (macro == null)
|
||||
{
|
||||
macro = new Macro(Alias, Alias, string.Empty, MacroTypes.Unknown);
|
||||
Current.Services.MacroService.Save(macro);
|
||||
}
|
||||
_returnUrl = $"developer/Macros/editMacro.aspx?macroID={macro.Id}";
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool PerformDelete()
|
||||
{
|
||||
var macro = Current.Services.MacroService.GetById(ParentID);
|
||||
if (macro != null)
|
||||
Current.Services.MacroService.Delete(macro);
|
||||
return true;
|
||||
}
|
||||
|
||||
private string _returnUrl = "";
|
||||
|
||||
public override string ReturnUrl => _returnUrl;
|
||||
|
||||
public override string AssignedApp => Constants.Applications.Settings;
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
using Umbraco.Core.Services;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI.WebControls;
|
||||
using ClientDependency.Core;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.UI;
|
||||
using Umbraco.Web._Legacy.UI;
|
||||
using UmbracoUserControl = Umbraco.Web.UI.Controls.UmbracoUserControl;
|
||||
|
||||
namespace umbraco.cms.presentation.create.controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for simple.
|
||||
/// </summary>
|
||||
public partial class simple : UmbracoUserControl
|
||||
{
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
sbmt.Text = Services.TextService.Localize("create");
|
||||
rename.Attributes["placeholder"] = Services.TextService.Localize("name");
|
||||
|
||||
// Put user code to initialize the page here
|
||||
}
|
||||
|
||||
protected void sbmt_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Page.IsValid)
|
||||
{
|
||||
int nodeId;
|
||||
if (int.TryParse(Request.QueryString["nodeId"], out nodeId) == false)
|
||||
nodeId = -1;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
var returnUrl = LegacyDialogHandler.Create(
|
||||
new HttpContextWrapper(Context),
|
||||
Security.CurrentUser,
|
||||
Request.GetItemAsString("nodeType"),
|
||||
nodeId,
|
||||
rename.Text.Trim(),
|
||||
Request.QueryString.AsEnumerable().ToDictionary(x => x.Key, x => (object)x.Value));
|
||||
|
||||
ClientTools
|
||||
.ChangeContentFrameUrl(returnUrl)
|
||||
.ReloadActionNode(false, true)
|
||||
.CloseModalWindow();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CustomValidation.ErrorMessage = "* " + ex.Message;
|
||||
CustomValidation.IsValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected CustomValidator CustomValidation;
|
||||
|
||||
/// <summary>
|
||||
/// RequiredFieldValidator1 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.RequiredFieldValidator RequiredFieldValidator1;
|
||||
|
||||
/// <summary>
|
||||
/// rename 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 rename;
|
||||
|
||||
/// <summary>
|
||||
/// Textbox1 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 Textbox1;
|
||||
|
||||
/// <summary>
|
||||
/// sbmt 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.Button sbmt;
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
using System;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
|
||||
namespace umbraco.layoutControls
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for umbracoPageHolder.
|
||||
/// </summary>
|
||||
[DefaultProperty("Text"),
|
||||
ToolboxData("<{0}:umbracoPageHolder runat=server></{0}:umbracoPageHolder>")]
|
||||
public class umbracoPageHolder : System.Web.UI.WebControls.PlaceHolder
|
||||
{
|
||||
#region private properties
|
||||
|
||||
private String _pageName;
|
||||
private String _writerName;
|
||||
private DateTime _createDate;
|
||||
private DateTime _updateDate;
|
||||
private int _pageID;
|
||||
private int _pageVersion;
|
||||
private int _templateID;
|
||||
private Hashtable _elements = new Hashtable();
|
||||
private StringBuilder _pageContent = new StringBuilder();
|
||||
|
||||
#endregion
|
||||
|
||||
[Bindable(true), Category("umbraco"), DefaultValue("")]
|
||||
public string PageName
|
||||
{
|
||||
get {return _pageName;}
|
||||
set {_pageName = value;}
|
||||
}
|
||||
|
||||
[Bindable(true), Category("umbraco"), DefaultValue("")]
|
||||
public string WriterName
|
||||
{
|
||||
get {return _writerName;}
|
||||
set {_writerName = value;}
|
||||
}
|
||||
[Bindable(true), Category("umbraco"), DefaultValue("")]
|
||||
public DateTime CreateDate
|
||||
{
|
||||
get {return _createDate;}
|
||||
set {_createDate = value;}
|
||||
}
|
||||
[Bindable(true), Category("umbraco"), DefaultValue("")]
|
||||
public DateTime updateDate
|
||||
{
|
||||
get {return _updateDate;}
|
||||
set {_updateDate = value;}
|
||||
}
|
||||
[Bindable(true), Category("umbraco"), DefaultValue("")]
|
||||
public int pageID
|
||||
{
|
||||
get {return _pageID;}
|
||||
set {_pageID = value;}
|
||||
}
|
||||
[Bindable(true), Category("umbraco"), DefaultValue("")]
|
||||
public int pageVersion
|
||||
{
|
||||
get {return _pageVersion;}
|
||||
set {_pageVersion = value;}
|
||||
}
|
||||
[Bindable(true), Category("umbraco"), DefaultValue("")]
|
||||
public int templateID
|
||||
{
|
||||
get {return _templateID;}
|
||||
set {_templateID = value;}
|
||||
}
|
||||
[Bindable(true), Category("umbraco"), DefaultValue("")]
|
||||
public Hashtable Elements
|
||||
{
|
||||
get {return _elements;}
|
||||
set {_elements = value;}
|
||||
}
|
||||
[Bindable(true), Category("umbraco"), DefaultValue("")]
|
||||
public StringBuilder PageContent
|
||||
{
|
||||
get {return _pageContent;}
|
||||
set {_pageContent = value;}
|
||||
}
|
||||
|
||||
public void Populate(page Page) {
|
||||
if (Page != null)
|
||||
{
|
||||
_pageID = Page.PageID;
|
||||
_templateID = Page.Template;
|
||||
|
||||
_createDate = Page.CreateDate;
|
||||
_updateDate = Page.UpdateDate;
|
||||
|
||||
_writerName = Page.WriterName;
|
||||
_pageName = Page.PageName;
|
||||
_elements = Page.Elements;
|
||||
|
||||
_pageContent.Append(Page.PageContent);
|
||||
this.Controls.Add(Page.PageContentControl);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Render this control to the output parameter specified.
|
||||
/// </summary>
|
||||
/// <param name="output"> The HTML writer to write out to </param>
|
||||
protected override void Render(HtmlTextWriter output)
|
||||
{
|
||||
base.Render(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user