From ce889a698d394dc609f46c7cc387145f96b8fd37 Mon Sep 17 00:00:00 2001 From: hartvig Date: Thu, 18 Feb 2010 23:44:54 +0000 Subject: [PATCH] WORK IN PROGRESS, GET STABLE SOURCE FROM DOWNLOAD TAB Fixes 26258: Issues with insert macro dialog in tiny [TFS Changeset #64073] --- umbraco/presentation/UmbracoContext.cs | 5 +++-- umbraco/presentation/macro.cs | 2 +- umbraco/presentation/umbraco/dialogs/Preview.aspx.cs | 2 +- umbraco/presentation/umbraco/editContent.aspx.cs | 7 +++++++ umbraco/presentation/umbraco/nodeFactory/Page.cs | 4 ++-- .../umbraco/plugins/tinymce3/insertMacro.aspx.cs | 2 +- umbraco/presentation/umbraco/preview/Preview.cs | 10 ++++++++++ 7 files changed, 25 insertions(+), 7 deletions(-) diff --git a/umbraco/presentation/UmbracoContext.cs b/umbraco/presentation/UmbracoContext.cs index 087d09cce1..a99d09facb 100644 --- a/umbraco/presentation/UmbracoContext.cs +++ b/umbraco/presentation/UmbracoContext.cs @@ -81,14 +81,15 @@ namespace umbraco.presentation } /// - /// Determines whether the current user is in a preview mode + /// Determines whether the current user is in a preview mode and browsing the site (ie. not in the admin UI) /// public virtual bool InPreviewMode { get { + string currentUrl = Request.Url.AbsolutePath; return !String.IsNullOrEmpty(StateHelper.GetCookieValue("PreviewSet")) && - UmbracoUser != null; + UmbracoUser != null && !currentUrl.StartsWith(IO.IOHelper.ResolveUrl(IO.SystemDirectories.Umbraco)); } } diff --git a/umbraco/presentation/macro.cs b/umbraco/presentation/macro.cs index bec6a4abc3..8892674a77 100644 --- a/umbraco/presentation/macro.cs +++ b/umbraco/presentation/macro.cs @@ -1398,7 +1398,7 @@ namespace umbraco // Create a new 'HttpWebRequest' Object to the mentioned URL. string retVal = string.Empty; string url = "http://" + HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + ":" + - HttpContext.Current.Request.ServerVariables["SERVER_PORT"] + SystemDirectories.Umbraco + + HttpContext.Current.Request.ServerVariables["SERVER_PORT"] + IOHelper.ResolveUrl( SystemDirectories.Umbraco ) + "/macroResultWrapper.aspx?" + querystring; diff --git a/umbraco/presentation/umbraco/dialogs/Preview.aspx.cs b/umbraco/presentation/umbraco/dialogs/Preview.aspx.cs index bc04182cbf..520e02309a 100644 --- a/umbraco/presentation/umbraco/dialogs/Preview.aspx.cs +++ b/umbraco/presentation/umbraco/dialogs/Preview.aspx.cs @@ -27,7 +27,7 @@ namespace umbraco.presentation.dialogs pc.SavePreviewSet(); docLit.Text = d.Text; changeSetUrl.Text = pc.PreviewsetPath; - StateHelper.SetCookieValue("PreviewSet", pc.PreviewSet.ToString()); + pc.ActivatePreviewCookie(); Response.Redirect("../../" + d.Id.ToString() + ".aspx", true); } } diff --git a/umbraco/presentation/umbraco/editContent.aspx.cs b/umbraco/presentation/umbraco/editContent.aspx.cs index 6efc8e8658..61895d17ad 100644 --- a/umbraco/presentation/umbraco/editContent.aspx.cs +++ b/umbraco/presentation/umbraco/editContent.aspx.cs @@ -14,6 +14,8 @@ using umbraco.BusinessLogic.Actions; using umbraco.cms.helpers; using umbraco.IO; using umbraco.uicontrols.DatePicker; +using umbraco.BusinessLogic; +using umbraco.presentation.preview; namespace umbraco.cms.presentation @@ -62,6 +64,11 @@ namespace umbraco.cms.presentation //if (helper.Request("frontEdit") != "") // syncScript.Visible = false; + // clear preview cookie + if (!String.IsNullOrEmpty(StateHelper.GetCookieValue(PreviewContent.PREVIEW_COOKIE_KEY))) { + PreviewContent.ClearPreviewCookie(); + } + if (!IsPostBack) { //SyncPath.Text = _document.Path; diff --git a/umbraco/presentation/umbraco/nodeFactory/Page.cs b/umbraco/presentation/umbraco/nodeFactory/Page.cs index d9bdff2b7c..fb1078d809 100644 --- a/umbraco/presentation/umbraco/nodeFactory/Page.cs +++ b/umbraco/presentation/umbraco/nodeFactory/Page.cs @@ -488,8 +488,8 @@ namespace umbraco.presentation.nodeFactory ); } } - else - throw new ArgumentNullException("Node xml source is null"); +// else +// throw new ArgumentNullException("Node xml source is null"); } public static Node GetCurrent() diff --git a/umbraco/presentation/umbraco/plugins/tinymce3/insertMacro.aspx.cs b/umbraco/presentation/umbraco/plugins/tinymce3/insertMacro.aspx.cs index ee5f507f07..489b0a8176 100644 --- a/umbraco/presentation/umbraco/plugins/tinymce3/insertMacro.aspx.cs +++ b/umbraco/presentation/umbraco/plugins/tinymce3/insertMacro.aspx.cs @@ -34,7 +34,7 @@ namespace umbraco.presentation.tinymce3 pane_insert.Text = ui.Text("insertMacro"); Page.Title = ui.Text("insertMacro"); - if (reqMacroID != "" || reqMacroAlias != "") + if (!String.IsNullOrEmpty(reqMacroID) || !String.IsNullOrEmpty(reqMacroAlias)) { pane_edit.Visible = true; diff --git a/umbraco/presentation/umbraco/preview/Preview.cs b/umbraco/presentation/umbraco/preview/Preview.cs index c7d5777cbd..8c5f1e1dcc 100644 --- a/umbraco/presentation/umbraco/preview/Preview.cs +++ b/umbraco/presentation/umbraco/preview/Preview.cs @@ -19,6 +19,7 @@ namespace umbraco.presentation.preview { public class PreviewContent { + public const string PREVIEW_COOKIE_KEY = "PreviewSet"; public XmlDocument XmlContent { get; set; } public Guid PreviewSet { get; set; } public string PreviewsetPath { get; set; } @@ -83,5 +84,14 @@ namespace umbraco.presentation.preview XmlContent.Save(PreviewsetPath); } + + public void ActivatePreviewCookie() { + StateHelper.SetCookieValue(PREVIEW_COOKIE_KEY, PreviewSet.ToString()); + } + + public static void ClearPreviewCookie() { + StateHelper.ClearCookie(PREVIEW_COOKIE_KEY); + } + } }