From e200e2fc4848eb61ac5f22ca536406faf5123387 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Thu, 24 Jul 2014 16:17:40 +0200 Subject: [PATCH 1/2] Removes obsolete cachebrowser --- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 1 - src/Umbraco.Web.UI/umbraco/cacheBrowser.aspx | 16 ------- src/Umbraco.Web/Umbraco.Web.csproj | 3 -- .../umbraco/cacheBrowser.aspx.cs | 42 ------------------- 4 files changed, 62 deletions(-) delete mode 100644 src/Umbraco.Web.UI/umbraco/cacheBrowser.aspx delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/cacheBrowser.aspx.cs diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index bdc4b99c2e..c625eb0d98 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -2103,7 +2103,6 @@ UserControl - Designer diff --git a/src/Umbraco.Web.UI/umbraco/cacheBrowser.aspx b/src/Umbraco.Web.UI/umbraco/cacheBrowser.aspx deleted file mode 100644 index 7aa26dda00..0000000000 --- a/src/Umbraco.Web.UI/umbraco/cacheBrowser.aspx +++ /dev/null @@ -1,16 +0,0 @@ -<%@ Page language="c#" Codebehind="cacheBrowser.aspx.cs" AutoEventWireup="True" Inherits="umbraco.cms.presentation.cacheBrowser" trace="true" %> - - - - cacheBrowser - - - - - - -
- -
- - diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 9012a9564e..71033887a7 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -591,9 +591,6 @@ - - ASPXCodeBehind - ASPXCodeBehind diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/cacheBrowser.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/cacheBrowser.aspx.cs deleted file mode 100644 index 0e923ffc03..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/cacheBrowser.aspx.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Collections; -using umbraco.BasePages; - -namespace umbraco.cms.presentation -{ - /// - /// Summary description for cacheBrowser. - /// - public partial class cacheBrowser : UmbracoEnsuredPage - { - public cacheBrowser() - { - CurrentApp = BusinessLogic.DefaultApps.developer.ToString(); - - } - protected void Page_Load(object sender, System.EventArgs e) - { - // Cache removal checks - if (Request.QueryString["clearByType"] != null) - ApplicationContext.ApplicationCache.ClearCacheObjectTypes(Request.QueryString["clearByType"]); - else if (Request.QueryString["clearByKey"] != null) - ApplicationContext.ApplicationCache.ClearCacheItem(Request.QueryString["clearByKey"]); - - // Put user code to initialize the page here - Hashtable ht = cms.businesslogic.cache.Cache.ReturnCacheItemsOrdred(); - foreach (string key in ht.Keys) - { - Response.Write("" + key + ": " + ((ArrayList)ht[key]).Count.ToString() + " (Delete)
"); - if (Request.QueryString["key"] == key) - for (int i = 0; i < ((ArrayList)ht[key]).Count; i++) - Response.Write(" - " + ((ArrayList)ht[key])[i] + " (Delete)
"); - } - } - protected void Button1_Click(object sender, System.EventArgs e) - { - ApplicationContext.ApplicationCache.ClearAllCache(); - } - - protected System.Web.UI.HtmlControls.HtmlForm Form1; - protected System.Web.UI.WebControls.Button Button1; - } -} From ff94eba3a7eef6360372e0105d4dc2626e3b8ccd Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 24 Jul 2014 09:39:05 -0700 Subject: [PATCH 2/2] Fixes: U4-5273 6.2: Umbraco.Field no longer rendering macro container --- .../MacroContainerValueConverter.cs | 69 +++++++++++++++++++ .../RteMacroRenderingValueConverter.cs | 2 +- src/Umbraco.Web/Umbraco.Web.csproj | 1 + 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs new file mode 100644 index 0000000000..f08610350e --- /dev/null +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs @@ -0,0 +1,69 @@ +using System; +using System.Text; +using System.Web; +using Umbraco.Core; +using Umbraco.Core.Macros; +using Umbraco.Core.Models.PublishedContent; +using Umbraco.Core.PropertyEditors; + +namespace Umbraco.Web.PropertyEditors.ValueConverters +{ + /// + /// Ensures macro syntax is parsed for the macro container which will work when getting the field + /// values in any way (i.e. dynamically, using Field(), or IPublishedContent) + /// + [PropertyValueType(typeof (IHtmlString))] + [PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Request)] + public class MacroContainerValueConverter : PropertyValueConverterBase + { + public override bool IsConverter(PublishedPropertyType propertyType) + { + return Guid.Parse(Constants.PropertyEditors.MacroContainer).Equals(propertyType.PropertyEditorGuid); + } + + // NOT thread-safe over a request because it modifies the + // global UmbracoContext.Current.InPreviewMode status. So it + // should never execute in // over the same UmbracoContext with + // different preview modes. + static string RenderMacros(string source, bool preview) + { + // save and set for macro rendering + var inPreviewMode = UmbracoContext.Current.InPreviewMode; + UmbracoContext.Current.InPreviewMode = preview; + + var sb = new StringBuilder(); + + try + { + var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); + MacroTagParser.ParseMacros( + source, + //callback for when text block is found + textBlock => sb.Append(textBlock), + //callback for when macro syntax is found + (macroAlias, macroAttributes) => sb.Append(umbracoHelper.RenderMacro( + macroAlias, + //needs to be explicitly casted to Dictionary + macroAttributes.ConvertTo(x => (string)x, x => x)).ToString())); + } + finally + { + // restore + UmbracoContext.Current.InPreviewMode = inPreviewMode; + } + + return sb.ToString(); + } + + public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview) + { + if (source == null) return null; + var sourceString = source.ToString(); + + // ensure string is parsed for macros and macros are executed correctly + sourceString = RenderMacros(sourceString, preview); + + return sourceString; + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs index 3fb4516e3a..ee33ea40ec 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs @@ -11,7 +11,7 @@ using Umbraco.Web.Templates; namespace Umbraco.Web.PropertyEditors.ValueConverters { - /// + /// /// A value converter for TinyMCE that will ensure any macro content is rendered properly even when /// used dynamically. /// diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 9012a9564e..651adfbbe7 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -298,6 +298,7 @@ +