Fixes bugs in 4.7 preview engine. Work items: 30208, 30288

This commit is contained in:
hartvig
2011-09-09 09:46:04 -02:00
parent 6bd344834c
commit b083cb8837
2 changed files with 44 additions and 13 deletions

View File

@@ -90,11 +90,11 @@ namespace umbraco.presentation
get
{
string currentUrl = Request.Url.AbsolutePath;
// zb-00004 #29956 : refactor cookies names & handling
return
StateHelper.Cookies.Preview.HasValue // has preview cookie
&& UmbracoUser != null // has user
&& !currentUrl.StartsWith(IO.IOHelper.ResolveUrl(IO.SystemDirectories.Umbraco)); // is not in admin UI
// zb-00004 #29956 : refactor cookies names & handling
return
StateHelper.Cookies.Preview.HasValue // has preview cookie
&& UmbracoUser != null // has user
&& !currentUrl.StartsWith(IO.IOHelper.ResolveUrl(IO.SystemDirectories.Umbraco)); // is not in admin UI
}
}
@@ -105,14 +105,14 @@ namespace umbraco.presentation
if (_previewContent == null)
{
_previewContent = new PreviewContent(new Guid(StateHelper.Cookies.Preview.GetValue()));
_previewContent.LoadPreviewset();
if (_previewContent.ValidPreviewSet)
_previewContent.LoadPreviewset();
}
return _previewContent.XmlContent;
}
else
{
return content.Instance.XmlContent;
if (_previewContent.ValidPreviewSet)
return _previewContent.XmlContent;
}
return content.Instance.XmlContent;
}
/// <summary>

View File

@@ -24,6 +24,9 @@ namespace umbraco.presentation.preview
public XmlDocument XmlContent { get; set; }
public Guid PreviewSet { get; set; }
public string PreviewsetPath { get; set; }
public bool ValidPreviewSet { get; set; }
private int m_userId = 0;
public PreviewContent(User user)
@@ -54,16 +57,44 @@ namespace umbraco.presentation.preview
public PreviewContent(Guid previewSet)
{
updatePreviewPaths(previewSet);
ValidPreviewSet = updatePreviewPaths(previewSet);
}
private void updatePreviewPaths(Guid previewSet)
private bool updatePreviewPaths(Guid previewSet)
{
PreviewSet = previewSet;
PreviewsetPath = IO.IOHelper.MapPath(
Path.Combine(IO.SystemDirectories.Preview, m_userId.ToString() + "_" + PreviewSet + ".config"));
if (!ValidatePreviewPath())
{
// preview cookie failed so we'll log the error and clear the cookie
Log.Add(LogTypes.Error, User.GetUser(m_userId), -1, string.Format("Preview failed for preview set {0}", previewSet));
PreviewSet = Guid.Empty;
PreviewsetPath = String.Empty;
ClearPreviewCookie();
return false;
}
return true;
}
/// <summary>
/// Checks a preview file exist based on preview cookie
/// </summary>
/// <returns></returns>
public bool ValidatePreviewPath()
{
if (!File.Exists(PreviewsetPath))
return false;
return true;
}
public void LoadPreviewset()
{
XmlContent = new XmlDocument();