Work items: 30148

This commit is contained in:
hartvig
2011-09-12 11:19:37 -02:00
parent c1fa3bfb23
commit 4c2ffb00f9
17 changed files with 157 additions and 36 deletions

View File

@@ -57,5 +57,9 @@ namespace umbraco.cms.businesslogic {
public int ParentId { get; internal set; }
}
public class ContentCacheLoadNodeEventArgs : System.ComponentModel.CancelEventArgs
{
public bool CancelChildren { get; set; }
}
}

View File

@@ -10,6 +10,7 @@ using System.Xml.XPath;
using umbraco.BusinessLogic;
using umbraco.BusinessLogic.Actions;
using umbraco.cms.businesslogic;
using umbraco.cms.businesslogic.cache;
using umbraco.cms.businesslogic.web;
using umbraco.DataLayer;
@@ -743,6 +744,88 @@ namespace umbraco
}
/// <summary>
/// Occurs when [after loading the xml string from the database and creating the xml node].
/// </summary>
public delegate void ContentCacheLoadNodeEventHandler(XmlNode xmlNode, cms.businesslogic.ContentCacheLoadNodeEventArgs e);
/// <summary>
/// Occurs when [after loading the xml string from the database].
/// </summary>
public delegate void ContentCacheDatabaseLoadXmlStringEventHandler(ref string xml, cms.businesslogic.ContentCacheLoadNodeEventArgs e);
/// <summary>
/// Occurs when [after loading the xml string from the database].
/// </summary>
public static event ContentCacheDatabaseLoadXmlStringEventHandler AfterContentCacheDatabaseLoadXmlString;
/// <summary>
/// Fires the before when creating the document cache from database
/// </summary>
/// <param name="node">The sender.</param>
/// <param name="e">The <see cref="umbraco.cms.businesslogic.ContentCacheLoadNodeEventArgs"/> instance containing the event data.</param>
internal static void FireAfterContentCacheDatabaseLoadXmlString(ref string xml, cms.businesslogic.ContentCacheLoadNodeEventArgs e)
{
if (AfterContentCacheDatabaseLoadXmlString != null)
{
AfterContentCacheDatabaseLoadXmlString(ref xml, e);
}
}
/// <summary>
/// Occurs when [before when creating the document cache from database].
/// </summary>
public static event ContentCacheLoadNodeEventHandler BeforeContentCacheLoadNode;
/// <summary>
/// Fires the before when creating the document cache from database
/// </summary>
/// <param name="node">The sender.</param>
/// <param name="e">The <see cref="umbraco.cms.businesslogic.ContentCacheLoadNodeEventArgs"/> instance containing the event data.</param>
internal static void FireBeforeContentCacheLoadNode(XmlNode node, cms.businesslogic.ContentCacheLoadNodeEventArgs e)
{
if (BeforeContentCacheLoadNode != null)
{
BeforeContentCacheLoadNode(node, e);
}
}
/// <summary>
/// Occurs when [after loading document cache xml node from database].
/// </summary>
public static event ContentCacheLoadNodeEventHandler AfterContentCacheLoadNodeFromDatabase;
/// <summary>
/// Fires the after loading document cache xml node from database
/// </summary>
/// <param name="node">The sender.</param>
/// <param name="e">The <see cref="umbraco.cms.businesslogic.ContentCacheLoadNodeEventArgs"/> instance containing the event data.</param>
internal static void FireAfterContentCacheLoadNodeFromDatabase(XmlNode node, cms.businesslogic.ContentCacheLoadNodeEventArgs e)
{
if (AfterContentCacheLoadNodeFromDatabase != null)
{
AfterContentCacheLoadNodeFromDatabase(node, e);
}
}
/// <summary>
/// Occurs when [before a publish action updates the content cache].
/// </summary>
public static event ContentCacheLoadNodeEventHandler BeforePublishNodeToContentCache;
/// <summary>
/// Fires the before a publish action updates the content cache
/// </summary>
/// <param name="node">The sender.</param>
/// <param name="e">The <see cref="umbraco.cms.businesslogic.ContentCacheLoadNodeEventArgs"/> instance containing the event data.</param>
public static void FireBeforePublishNodeToContentCache(XmlNode node, cms.businesslogic.ContentCacheLoadNodeEventArgs e)
{
if (BeforePublishNodeToContentCache != null)
{
BeforePublishNodeToContentCache(node, e);
}
}
#endregion
@@ -904,21 +987,40 @@ order by umbracoNode.level, umbracoNode.sortOrder";
{
int currentId = dr.GetInt("id");
int parentId = dr.GetInt("parentId");
var xml = dr.GetString("xml");
// Retrieve the xml content from the database
// and parse it into a DOM node
xmlDoc.LoadXml(dr.GetString("xml"));
nodeIndex.Add(currentId, xmlDoc.FirstChild);
// Build the content hierarchy
List<int> children;
if (!hierarchy.TryGetValue(parentId, out children))
// Call the eventhandler to allow modification of the string
var e1 = new ContentCacheLoadNodeEventArgs();
FireAfterContentCacheDatabaseLoadXmlString(ref xml, e1);
// check if a listener has canceled the event
if (!e1.Cancel)
{
// No children for this parent, so add one
children = new List<int>();
hierarchy.Add(parentId, children);
// and parse it into a DOM node
xmlDoc.LoadXml(xml);
var node = xmlDoc.FirstChild;
// same event handler loader form the xml node
var e2 = new ContentCacheLoadNodeEventArgs();
FireAfterContentCacheLoadNodeFromDatabase(node, e2);
// and checking if it was canceled again
if (!e1.Cancel)
{
nodeIndex.Add(currentId, node);
// verify if either of the handlers canceled the children to load
if (!e1.CancelChildren && !e2.CancelChildren)
{
// Build the content hierarchy
List<int> children;
if (!hierarchy.TryGetValue(parentId, out children))
{
// No children for this parent, so add one
children = new List<int>();
hierarchy.Add(parentId, children);
}
children.Add(currentId);
}
}
}
children.Add(currentId);
}
}
}

View File

@@ -42,6 +42,9 @@ namespace umbraco
private static Hashtable _macroAlias = new Hashtable();
public IList<Exception> Exceptions = new List<Exception>();
private readonly Dictionary<string, macro> macroObjectCache = new Dictionary<string, macro>();
/// <summary>Cache for <see cref="GetPredefinedXsltExtensions"/>.</summary>
private static Dictionary<string, object> m_PredefinedExtensions;
@@ -148,9 +151,9 @@ namespace umbraco
{
macroID = id;
if (macroCache[macroCacheIdentifier + id] != null)
if (macroObjectCache.ContainsKey(macroCacheIdentifier + id))
{
var tempMacro = (macro)macroCache[macroCacheIdentifier + id];
var tempMacro = macroObjectCache[macroCacheIdentifier + id];
Name = tempMacro.Name;
Alias = tempMacro.Alias;
ScriptType = tempMacro.ScriptType;
@@ -226,7 +229,8 @@ namespace umbraco
}
}
// add current macro-object to cache
macroCache.Insert(macroCacheIdentifier + id, this);
if (!macroObjectCache.ContainsKey(macroCacheIdentifier + id))
macroObjectCache.Add(macroCacheIdentifier + id, this);
}
macroType = (int)Macro.FindMacroType(XsltFile, ScriptFile, ScriptType, ScriptAssembly);
@@ -313,16 +317,16 @@ namespace umbraco
ClearAliasCache();
if (macroID > 0)
{
if (macroCache[macroCacheIdentifier + macroID] != null)
if (macroObjectCache.ContainsKey(macroCacheIdentifier + macroID))
{
macroCache.Remove(macroCacheIdentifier + macroID);
macroObjectCache.Remove(macroCacheIdentifier + macroID);
return true;
}
else
return false;
}
else
return false;
}
return false;
}
private string getCacheGuid(MacroModel model, Hashtable pageElements, int pageId)
@@ -416,6 +420,7 @@ namespace umbraco
}
catch (Exception e)
{
Exceptions.Add(e);
HttpContext.Current.Trace.Warn("umbracoMacro",
"Error loading userControl (" + scriptType + ")", e);
macroControl = new LiteralControl("Error loading userControl '" + scriptType + "'");
@@ -431,6 +436,7 @@ namespace umbraco
}
catch (Exception e)
{
Exceptions.Add(e);
HttpContext.Current.Trace.Warn("umbracoMacro",
"Error loading customControl (Assembly: " + scriptAssembly +
", Type: '" + scriptType + "'", e);
@@ -453,6 +459,7 @@ namespace umbraco
}
catch (Exception e)
{
Exceptions.Add(e);
HttpContext.Current.Trace.Warn("umbracoMacro",
"Error loading MacroEngine script (file: " + ScriptFile +
", Type: '" + scriptType + "'", e);
@@ -673,6 +680,8 @@ namespace umbraco
}
catch (Exception e)
{
Exceptions.Add(e);
// inner exception code by Daniel Lindström from SBBS.se
Exception ie = e;
while (ie != null)
@@ -685,6 +694,7 @@ namespace umbraco
}
catch (Exception e)
{
Exceptions.Add(e);
HttpContext.Current.Trace.Warn("umbracoMacro", "Error loading XSLT " + xsltFile, e);
return new LiteralControl("Error reading XSLT file: \\xslt\\" + XsltFile);
}
@@ -804,7 +814,7 @@ namespace umbraco
return umbraco.cms.businesslogic.cache.Cache.GetCacheItem(
_xsltExtensionsCacheKey, _xsltExtensionsSyncLock,
CacheItemPriority.Normal, // normal priority
CacheItemPriority.NotRemovable, // NH 4.7.1, Changing to NotRemovable
null, // no refresh action
new CacheDependency(_xsltExtensionsConfig), // depends on the .config file
TimeSpan.FromDays(1), // expires in 1 day (?)

View File

@@ -2,7 +2,7 @@
<script type="text/javascript" src="/umbraco/dashboard/scripts/swfobject.js"></script>
<div class="dashboardWrapper">
<h2>Desktop Media Uploader</h2>
<img src="/umbraco/dashboard/images/dmu.png" alt="Umbraco" class="dashboardIcon" />
<img src="./images/dmu.png" alt="Umbraco" class="dashboardIcon" />
<p><strong>Desktop Media Uploader</strong> is a small desktop application that you can install on your computer which allows you to easily upload media items directly to the media section.</p>
<p>The badge below will auto configure itself based upon whether you already have <strong>Desktop Media Uploader</strong> installed or not.</p>
<p>Just click the <strong>Install Now / Upgrade Now / Launch Now</strong> link to perform that action.</p>

View File

@@ -4,7 +4,7 @@
<div class="dashboardWrapper">
<h2>
Start here</h2>
<img src="/umbraco/dashboard/images/logo32x32.png" alt="Umbraco" class="dashboardIcon" />
<img src="./images/logo32x32.png" alt="Umbraco" class="dashboardIcon" />
<h3>
This section contains the tools to add advanced features to your Umbraco site</h3>
<p>

View File

@@ -107,7 +107,7 @@
<div class="dashboardWrapper">
<h2>Watch and learn</h2>
<img src="/umbraco/dashboard/images/tv.png" alt="Videos" class="dashboardIcon" />
<img src="./images/tv.png" alt="Videos" class="dashboardIcon" />
<h3>Hours of Umbraco training videos are only a click away</h3>
<p>
Want to master Umbraco Macros and more? Spend a couple of minutes learning some best practices

View File

@@ -4,7 +4,7 @@
<div class="dashboardWrapper">
<h2>
Start here</h2>
<img src="/umbraco/dashboard/images/logo32x32.png" alt="Umbraco" class="dashboardIcon" />
<img src="./images/logo32x32.png" alt="Umbraco" class="dashboardIcon" />
<h3>
Get started with Media right now</h3>
<p>

View File

@@ -106,7 +106,7 @@
</script>
<div class="dashboardWrapper">
<h2>Watch and learn</h2>
<img src="/umbraco/dashboard/images/tv.png" alt="Videos" class="dashboardIcon" />
<img src="./images/tv.png" alt="Videos" class="dashboardIcon" />
<h3>Hours of Umbraco training videos are only a click away</h3>
<p>
Want to master Umbraco? Spend a couple of minutes learning some best practices

View File

@@ -4,7 +4,7 @@
<div class="dashboardWrapper">
<h2>
Start here</h2>
<img src="/umbraco/dashboard/images/logo32x32.png" alt="Umbraco" class="dashboardIcon" />
<img src="./images/logo32x32.png" alt="Umbraco" class="dashboardIcon" />
<h3>
Get started with Members right now</h3>
<p>

View File

@@ -106,7 +106,7 @@
</script>
<div class="dashboardWrapper">
<h2>Watch and learn</h2>
<img src="/umbraco/dashboard/images/tv.png" alt="Videos" class="dashboardIcon" />
<img src="./images/tv.png" alt="Videos" class="dashboardIcon" />
<h3>Hours of Umbraco training videos are only a click away</h3>
<p>
Want to master Umbraco Members? Spend a couple of minutes learning some best practices

View File

@@ -4,7 +4,7 @@
<div class="dashboardWrapper">
<h2>
Start here</h2>
<img src="/umbraco/dashboard/images/logo32x32.png" alt="Umbraco" class="dashboardIcon" />
<img src="./images/logo32x32.png" alt="Umbraco" class="dashboardIcon" />
<h3>
This section contains the building blocks for your Umbraco site</h3>
<p>

View File

@@ -106,7 +106,7 @@
</script>
<div class="dashboardWrapper">
<h2>Watch and learn</h2>
<img src="/umbraco/dashboard/images/tv.png" alt="Videos" class="dashboardIcon" />
<img src="./images/tv.png" alt="Videos" class="dashboardIcon" />
<h3>Hours of Umbraco training videos are only a click away</h3>
<p>
Want to master Umbraco? Spend a couple of minutes learning some best practices

View File

@@ -3,7 +3,7 @@
<link href="/umbraco_client/propertypane/style.css" rel="stylesheet" />
<div class="dashboardWrapper">
<h2>Start Here</h2>
<img src="/umbraco/dashboard/images/logo32x32.png" alt="Umbraco" class="dashboardIcon" />
<img src="./dashboard/images/logo32x32.png" alt="Umbraco" class="dashboardIcon" />
<h3>Thank you for choosing Umbraco!</h3>
<p>
We think this could be the beginning of something beautiful. You have made a great

View File

@@ -3,7 +3,7 @@
<link href="/umbraco_client/propertypane/style.css" rel="stylesheet" />
<div class="dashboardWrapper">
<h2>Make it look great</h2>
<img src="/umbraco/dashboard/images/starterkit32x32.png" alt="Umbraco Starter Kits Rock!" class="dashboardIcon" />
<img src="./images/starterkit32x32.png" alt="Umbraco Starter Kits Rock!" class="dashboardIcon" />
<h3>Install a Starter Site and Skin</h3>
<p>
If you haven't already installed one of our Starter Kits, we think you should do that now. This is one of the best ways to start working with Umbraco.

View File

@@ -106,7 +106,7 @@
</script>
<div class="dashboardWrapper">
<h2>Watch and learn</h2>
<img src="/umbraco/dashboard/images/tv.png" alt="Videos" class="dashboardIcon" />
<img src="./images/tv.png" alt="Videos" class="dashboardIcon" />
<h3>Hours of Umbraco training videos are only a click away</h3>
<p>
Want to master Umbraco? Spend a couple of minutes learning some best practices

View File

@@ -2,7 +2,7 @@
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
<div class="dashboardWrapper">
<h2>Member Search</h2>
<img src="/umbraco/dashboard/images/membersearch.png" alt="Videos" class="dashboardIcon" />
<img src="./images/membersearch.png" alt="Videos" class="dashboardIcon" />
<p class="guiDialogNormal">
<asp:TextBox id="searchQuery" runat="server"></asp:TextBox>
<asp:Button id="ButtonSearch" runat="server" Text="Button" onclick="ButtonSearch_Click"></asp:Button></p>

View File

@@ -78,7 +78,6 @@ namespace umbraco.presentation.templateControls
ViewState["FileLocation"] = value.ToLower();
}
}
[Bindable(true)]
[Category("Umbraco")]
[DefaultValue(RenderEvents.Init)]
@@ -106,6 +105,8 @@ namespace umbraco.presentation.templateControls
Render
}
public IList<Exception> Exceptions = new List<Exception>();
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Init"/> event.
/// </summary>
@@ -162,7 +163,11 @@ namespace umbraco.presentation.templateControls
}
var c = tempMacro.renderMacro(model, (Hashtable)Context.Items["pageElements"], pageId);
if (c != null)
{
Exceptions = tempMacro.Exceptions;
Controls.Add(c);
}
else
System.Web.HttpContext.Current.Trace.Warn("Template", "Result of inline macro scripting is null");