From c0214ac4ec75d1c8d6d0d8ce53a5523298ddfd87 Mon Sep 17 00:00:00 2001 From: neehouse Date: Tue, 10 Sep 2013 09:34:19 -0400 Subject: [PATCH] Modified the MacroRendering event as requested. Removed the unnecessary check for the file path from the Partial View Macro as it would not be hit anyhow since the macro engine is determined using the same rule. U4-2644 & U4-2643 --- src/Umbraco.Web/Macros/PartialViewMacroEngine.cs | 6 ------ src/Umbraco.Web/umbraco.presentation/macro.cs | 16 ++++++++-------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs b/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs index 3e819a737d..507b9fbb6e 100644 --- a/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs +++ b/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs @@ -104,12 +104,6 @@ namespace Umbraco.Web.Macros if (currentPage == null) throw new ArgumentNullException("currentPage"); if (macro.ScriptName.IsNullOrWhiteSpace()) throw new ArgumentException("The ScriptName property of the macro object cannot be null or empty"); - //if (!macro.ScriptName.StartsWith(SystemDirectories.MvcViews + "/MacroPartials/") - // && (!Regex.IsMatch(macro.ScriptName, "~/App_Plugins/.+?/Views/MacroPartials", RegexOptions.Compiled))) - //{ - // throw new InvalidOperationException("Cannot render the Partial View Macro with file: " + macro.ScriptName + ". All Partial View Macros must exist in the " + SystemDirectories.MvcViews + "/MacroPartials/ folder"); - //} - var http = _getHttpContext(); var umbCtx = _getUmbracoContext(); var routeVals = new RouteData(); diff --git a/src/Umbraco.Web/umbraco.presentation/macro.cs b/src/Umbraco.Web/umbraco.presentation/macro.cs index 180d69a015..d2ad5fe292 100644 --- a/src/Umbraco.Web/umbraco.presentation/macro.cs +++ b/src/Umbraco.Web/umbraco.presentation/macro.cs @@ -231,20 +231,20 @@ namespace umbraco return renderMacro(pageElements, pageId); } - public delegate void RenderEventHandler(MacroModel sender, RenderEventArgs e); - public new static event RenderEventHandler BeforeRender; - protected virtual void FireBeforeRender(RenderEventArgs e) + public delegate void OnMacroRenderingEventHandler(macro sender, EventArgs e); + public static event OnMacroRenderingEventHandler OnMacroRendering; + protected void FireOnMacroRendering(EventArgs e) { - if (BeforeRender != null) - BeforeRender(Model, e); + if (OnMacroRendering != null) + OnMacroRendering(this, e); } public Control renderMacro(Hashtable pageElements, int pageId) { // Event to allow manipulation of Macro Model - var rea = new RenderEventArgs(); - FireBeforeRender(rea); + var rea = new EventArgs(); + FireOnMacroRendering(rea); var macroInfo = (Model.MacroType == MacroTypes.Script && Model.Name.IsNullOrWhiteSpace()) @@ -1966,6 +1966,6 @@ namespace umbraco #endregion } - public class RenderEventArgs : System.ComponentModel.CancelEventArgs { } + public class MacroRenderingEventArgs : System.EventArgs { } } \ No newline at end of file