From 4d03d05f9cc454c8b6ab59178052e9068197a893 Mon Sep 17 00:00:00 2001 From: hartvig Date: Fri, 23 Apr 2010 11:54:12 +0000 Subject: [PATCH] Fixes 26838 and 26857. Issues with urls and publish status when using the new schema [TFS Changeset #65723] --- umbraco/cms/businesslogic/web/Document.cs | 7 ++++++- umbraco/presentation/requestHandler.cs | 21 ++++++++++++------- .../presentation/umbraco/editContent.aspx.cs | 7 +++++-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/umbraco/cms/businesslogic/web/Document.cs b/umbraco/cms/businesslogic/web/Document.cs index e9889d12c4..0a26987618 100644 --- a/umbraco/cms/businesslogic/web/Document.cs +++ b/umbraco/cms/businesslogic/web/Document.cs @@ -609,7 +609,12 @@ namespace umbraco.cms.businesslogic.web _updated = dr.GetDateTime("updateDate"); } dr.Close(); - _published = (SqlHelper.ExecuteScalar("select Count(published) as tmp from cmsDocument where published = 1 And nodeId =" + Id) > 0); + _published = HasPublishedVersion(); + } + + public bool HasPublishedVersion() + { + return (SqlHelper.ExecuteScalar("select Count(published) as tmp from cmsDocument where published = 1 And nodeId =" + Id) > 0); } protected void InitializeDocument(User InitUser, User InitWriter, string InitText, int InitTemplate, diff --git a/umbraco/presentation/requestHandler.cs b/umbraco/presentation/requestHandler.cs index a9ccb3dfb7..2369a90f15 100644 --- a/umbraco/presentation/requestHandler.cs +++ b/umbraco/presentation/requestHandler.cs @@ -85,15 +85,14 @@ namespace umbraco { } public static string CreateXPathQuery(string url, bool checkDomain) { - string childContainerName = UmbracoSettings.TEMP_FRIENDLY_XML_CHILD_CONTAINER_NODENAME; string _tempQuery = ""; if (GlobalSettings.HideTopLevelNodeFromPath && checkDomain) { - _tempQuery = "/root/" + childContainerName + "/*"; + _tempQuery = "/root" + getChildContainerName() + "/*"; } else if (checkDomain) - _tempQuery = "/root/" + childContainerName; + _tempQuery = "/root" + getChildContainerName(); string[] requestRawUrl = url.Split("/".ToCharArray()); @@ -131,8 +130,8 @@ namespace umbraco { { HttpContext.Current.Trace.Write("umbracoRequestHandler", "xpath: '" + _tempQuery + "'"); if (_tempQuery == "") - _tempQuery = "/root/" + childContainerName + "/*"; - _tempQuery = "/root/" + childContainerName + "/* [" + _urlName + + _tempQuery = "/root" + getChildContainerName() + "/*"; + _tempQuery = "/root" + getChildContainerName() + "/* [" + _urlName + " = \"" + requestRawUrl[0].Replace(".aspx", "").ToLower() + "\"] | " + _tempQuery; HttpContext.Current.Trace.Write("umbracoRequestHandler", "xpath: '" + _tempQuery + "'"); rootAdded = true; @@ -142,13 +141,13 @@ namespace umbraco { for (int i = 0; i <= requestRawUrl.GetUpperBound(0); i++) { if (requestRawUrl[i] != "") - _tempQuery += "/" + childContainerName + "/* [" + _urlName + " = \"" + requestRawUrl[i].Replace(".aspx", "").ToLower() + + _tempQuery += getChildContainerName() + "/* [" + _urlName + " = \"" + requestRawUrl[i].Replace(".aspx", "").ToLower() + "\"]"; } if (GlobalSettings.HideTopLevelNodeFromPath && requestRawUrl.Length == 2) { - _tempQuery += " | " + pageXPathQueryStart + "/" + childContainerName + "/* [" + _urlName + " = \"" + + _tempQuery += " | " + pageXPathQueryStart + getChildContainerName() + "/* [" + _urlName + " = \"" + requestRawUrl[1].Replace(".aspx", "").ToLower() + "\"]"; } HttpContext.Current.Trace.Write("umbracoRequestHandler", "xpath: '" + _tempQuery + "'"); @@ -163,6 +162,14 @@ namespace umbraco { return _tempQuery; } + private static string getChildContainerName() + { + if (!String.IsNullOrEmpty(UmbracoSettings.TEMP_FRIENDLY_XML_CHILD_CONTAINER_NODENAME)) + return "/" + UmbracoSettings.TEMP_FRIENDLY_XML_CHILD_CONTAINER_NODENAME; + else + return ""; + } + public requestHandler(XmlDocument umbracoContent, String url) { HttpContext.Current.Trace.Write("request handler", "current url '" + url + "'"); bool getByID = false; diff --git a/umbraco/presentation/umbraco/editContent.aspx.cs b/umbraco/presentation/umbraco/editContent.aspx.cs index c5f16bd291..8649361c98 100644 --- a/umbraco/presentation/umbraco/editContent.aspx.cs +++ b/umbraco/presentation/umbraco/editContent.aspx.cs @@ -26,6 +26,7 @@ namespace umbraco.cms.presentation protected uicontrols.TabView TabView1; protected System.Web.UI.WebControls.TextBox documentName; private cms.businesslogic.web.Document _document; + private bool _documentHasPublishedVersion = false; protected System.Web.UI.WebControls.Literal jsIds; private LiteralControl dp = new LiteralControl(); private DateTimePicker dpRelease = new DateTimePicker(); @@ -66,6 +67,8 @@ namespace umbraco.cms.presentation //_document = new cms.businesslogic.web.Document(int.Parse(Request.QueryString["id"])); _document = new Document(true, id); + // we need to check if there's a published version of this document + _documentHasPublishedVersion = _document.HasPublishedVersion(); // Check publishing permissions if (!base.getUser().GetPermissions(_document.Path).Contains(ActionPublish.Instance.Letter.ToString())) @@ -88,7 +91,7 @@ namespace umbraco.cms.presentation System.Web.UI.WebControls.PlaceHolder publishStatus = new PlaceHolder(); - if (_document.Published) + if (_documentHasPublishedVersion) { littPublishStatus.Text = ui.Text("content", "lastPublished", base.getUser()) + ": " + _document.VersionDate.ToShortDateString() + "   "; @@ -324,7 +327,7 @@ namespace umbraco.cms.presentation private void updateLinks() { - if (_document.Published) + if (_documentHasPublishedVersion) { l.Text = "" + library.NiceUrl(_document.Id) + "";