diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs
index fbc96c803b..56f0af8490 100644
--- a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs
@@ -794,6 +794,34 @@ namespace Umbraco.Core.Persistence.Repositories
}
+ ///
+ /// Returns the persisted content's preview XML structure
+ ///
+ ///
+ ///
+ public XElement GetContentXml(int contentId)
+ {
+ var sql = new Sql().Select("*").From(SqlSyntax).Where(SqlSyntax, d => d.NodeId == contentId);
+ var dto = Database.SingleOrDefault(sql);
+ if (dto == null) return null;
+ return XElement.Parse(dto.Xml);
+ }
+
+ ///
+ /// Returns the persisted content's preview XML structure
+ ///
+ ///
+ ///
+ ///
+ public XElement GetContentPreviewXml(int contentId, Guid version)
+ {
+ var sql = new Sql().Select("*").From(SqlSyntax)
+ .Where(SqlSyntax, d => d.NodeId == contentId && d.VersionId == version);
+ var dto = Database.SingleOrDefault(sql);
+ if (dto == null) return null;
+ return XElement.Parse(dto.Xml);
+ }
+
#endregion
#region IRecycleBinRepository members
diff --git a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentRepository.cs
index 9d3fcbb40b..32961ccf7c 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentRepository.cs
@@ -88,5 +88,20 @@ namespace Umbraco.Core.Persistence.Repositories
/// An Enumerable list of objects
IEnumerable GetPagedResultsByQuery(IQuery query, long pageIndex, int pageSize, out long totalRecords,
string orderBy, Direction orderDirection, string filter = "");
+
+ ///
+ /// Returns the persisted content's preview XML structure
+ ///
+ ///
+ ///
+ XElement GetContentXml(int contentId);
+
+ ///
+ /// Returns the persisted content's preview XML structure
+ ///
+ ///
+ ///
+ ///
+ XElement GetContentPreviewXml(int contentId, Guid version);
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs
index 8195fb9432..6a9d447938 100644
--- a/src/Umbraco.Core/Services/ContentService.cs
+++ b/src/Umbraco.Core/Services/ContentService.cs
@@ -1662,6 +1662,35 @@ namespace Umbraco.Core.Services
return true;
}
+ ///
+ /// Returns the persisted content's XML structure
+ ///
+ ///
+ ///
+ public XElement GetContentXml(int contentId)
+ {
+ var uow = UowProvider.GetUnitOfWork();
+ using (var repository = RepositoryFactory.CreateContentRepository(uow))
+ {
+ return repository.GetContentXml(contentId);
+ }
+ }
+
+ ///
+ /// Returns the persisted content's preview XML structure
+ ///
+ ///
+ ///
+ ///
+ public XElement GetContentPreviewXml(int contentId, Guid version)
+ {
+ var uow = UowProvider.GetUnitOfWork();
+ using (var repository = RepositoryFactory.CreateContentRepository(uow))
+ {
+ return repository.GetContentPreviewXml(contentId, version);
+ }
+ }
+
///
/// Rebuilds all xml content in the cmsContentXml table for all documents
///
diff --git a/src/Umbraco.Core/Services/IContentService.cs b/src/Umbraco.Core/Services/IContentService.cs
index c686cf4891..fd46bf1008 100644
--- a/src/Umbraco.Core/Services/IContentService.cs
+++ b/src/Umbraco.Core/Services/IContentService.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Xml.Linq;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
@@ -93,6 +94,21 @@ namespace Umbraco.Core.Services
///
public interface IContentService : IService
{
+ ///
+ /// Returns the persisted content's XML structure
+ ///
+ ///
+ ///
+ XElement GetContentXml(int contentId);
+
+ ///
+ /// Returns the persisted content's preview XML structure
+ ///
+ ///
+ ///
+ ///
+ XElement GetContentPreviewXml(int contentId, Guid version);
+
///
/// Rebuilds all xml content in the cmsContentXml table for all documents
///
diff --git a/src/Umbraco.Core/Services/PackagingService.cs b/src/Umbraco.Core/Services/PackagingService.cs
index 12dc794498..7d1c4891d5 100644
--- a/src/Umbraco.Core/Services/PackagingService.cs
+++ b/src/Umbraco.Core/Services/PackagingService.cs
@@ -165,11 +165,8 @@ namespace Umbraco.Core.Services
{
var contents = new List();
foreach (var root in roots)
- {
- bool isLegacySchema = root.Name.LocalName.ToLowerInvariant().Equals("node");
- string contentTypeAlias = isLegacySchema
- ? root.Attribute("nodeTypeAlias").Value
- : root.Name.LocalName;
+ {
+ var contentTypeAlias = root.Name.LocalName;
if (_importedContentTypes.ContainsKey(contentTypeAlias) == false)
{
@@ -177,26 +174,24 @@ namespace Umbraco.Core.Services
_importedContentTypes.Add(contentTypeAlias, contentType);
}
- var content = CreateContentFromXml(root, _importedContentTypes[contentTypeAlias], null, parentId, isLegacySchema);
+ var content = CreateContentFromXml(root, _importedContentTypes[contentTypeAlias], null, parentId);
contents.Add(content);
var children = from child in root.Elements()
where (string)child.Attribute("isDoc") == ""
select child;
if (children.Any())
- contents.AddRange(CreateContentFromXml(children, content, isLegacySchema));
+ contents.AddRange(CreateContentFromXml(children, content));
}
return contents;
}
- private IEnumerable CreateContentFromXml(IEnumerable children, IContent parent, bool isLegacySchema)
+ private IEnumerable CreateContentFromXml(IEnumerable children, IContent parent)
{
var list = new List();
foreach (var child in children)
{
- string contentTypeAlias = isLegacySchema
- ? child.Attribute("nodeTypeAlias").Value
- : child.Name.LocalName;
+ string contentTypeAlias = child.Name.LocalName;
if (_importedContentTypes.ContainsKey(contentTypeAlias) == false)
{
@@ -205,7 +200,7 @@ namespace Umbraco.Core.Services
}
//Create and add the child to the list
- var content = CreateContentFromXml(child, _importedContentTypes[contentTypeAlias], parent, default(int), isLegacySchema);
+ var content = CreateContentFromXml(child, _importedContentTypes[contentTypeAlias], parent, default(int));
list.Add(content);
//Recursive call
@@ -215,19 +210,20 @@ namespace Umbraco.Core.Services
select grand;
if (grandChildren.Any())
- list.AddRange(CreateContentFromXml(grandChildren, content, isLegacySchema));
+ list.AddRange(CreateContentFromXml(grandChildren, content));
}
return list;
}
- private IContent CreateContentFromXml(XElement element, IContentType contentType, IContent parent, int parentId, bool isLegacySchema)
+ private IContent CreateContentFromXml(XElement element, IContentType contentType, IContent parent, int parentId)
{
var id = element.Attribute("id").Value;
var level = element.Attribute("level").Value;
var sortOrder = element.Attribute("sortOrder").Value;
var nodeName = element.Attribute("nodeName").Value;
var path = element.Attribute("path").Value;
+ //TODO: Shouldn't we be using this value???
var template = element.Attribute("template").Value;
var properties = from property in element.Elements()
@@ -248,7 +244,7 @@ namespace Umbraco.Core.Services
foreach (var property in properties)
{
- string propertyTypeAlias = isLegacySchema ? property.Attribute("alias").Value : property.Name.LocalName;
+ string propertyTypeAlias = property.Name.LocalName;
if (content.HasProperty(propertyTypeAlias))
{
var propertyValue = property.Value;
diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs
index d3b9ebee6a..220338b635 100644
--- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs
+++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs
@@ -348,7 +348,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
var parent = _xmlNode == null ? null : _xmlNode.ParentNode;
if (parent == null) return;
- if (parent.Name == "node" || (parent.Attributes != null && parent.Attributes.GetNamedItem("isDoc") != null))
+ if (parent.Attributes != null && parent.Attributes.GetNamedItem("isDoc") != null)
_parent = (new XmlPublishedContent(parent, _isPreviewing, true)).CreateModel();
}
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 300fec620e..1c11870613 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -1836,9 +1836,6 @@
Form
-
- Designer
-
ASPXCodeBehind
@@ -1892,22 +1889,6 @@
Resources.Designer.cs
Designer
-
-
-
-
-
- package.xsd
-
-
- umbraco.xsd
-
-
- umbraco.xsd
-
-
- umbraco.xsd
-
diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs
index c9074ff12b..6c3c841f97 100644
--- a/src/Umbraco.Web/WebBootManager.cs
+++ b/src/Umbraco.Web/WebBootManager.cs
@@ -322,6 +322,8 @@ namespace Umbraco.Web
container.EnablePerWebRequestScope();
+ //no need to declare as per request, it's lifetime is already managed as a singleton
+ container.Register(factory => new HttpContextWrapper(HttpContext.Current));
container.RegisterSingleton();
container.RegisterSingleton();
container.RegisterSingleton(factory => new PublishedContentCache());
diff --git a/src/Umbraco.Web/umbraco.presentation/content.cs b/src/Umbraco.Web/umbraco.presentation/content.cs
index a29f61c984..bffc5050e4 100644
--- a/src/Umbraco.Web/umbraco.presentation/content.cs
+++ b/src/Umbraco.Web/umbraco.presentation/content.cs
@@ -18,6 +18,8 @@ using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Profiling;
+using Umbraco.Core.Services;
+using Umbraco.Core.Strings;
using Umbraco.Web;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
using Umbraco.Web.Scheduling;
@@ -204,13 +206,21 @@ namespace umbraco
private static XmlNode GetPreviewOrPublishedNode(Document d, XmlDocument xmlContentCopy, bool isPreview)
{
+ var contentItem = d.ContentEntity;
+ var serializer = new EntityXmlSerializer();
+ var services = ApplicationContext.Current.Services;
+
if (isPreview)
{
- return d.ToPreviewXml(xmlContentCopy);
+ var xml = services.ContentService.GetContentPreviewXml(contentItem.Id, contentItem.Version);
+ return xml.GetXmlNode(xmlContentCopy);
+ //return d.ToPreviewXml(xmlContentCopy);
}
else
{
- return d.ToXml(xmlContentCopy, false);
+ var xml = services.ContentService.GetContentXml(contentItem.Id);
+ return xml.GetXmlNode(xmlContentCopy);
+ //return d.ToXml(xmlContentCopy, false);
}
}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/package.xsd b/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/package.xsd
deleted file mode 100644
index 95a257395a..0000000000
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/package.xsd
+++ /dev/null
@@ -1,389 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Decides how umbraco should import documents
-
-
-
-
-
-
-
-
-
-
-
- Decides how umbraco should handle if the package or any items with identical aliases/guids
- have been imported before
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/package.xsx b/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/package.xsx
deleted file mode 100644
index ff71343be3..0000000000
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/package.xsx
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/umbraco.xsc b/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/umbraco.xsc
deleted file mode 100644
index 5f282702bb..0000000000
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/umbraco.xsc
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/umbraco.xsd b/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/umbraco.xsd
deleted file mode 100644
index 9bb22b548d..0000000000
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/umbraco.xsd
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/umbraco.xss b/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/umbraco.xss
deleted file mode 100644
index 5f282702bb..0000000000
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/umbraco.xss
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/umbraco.xsx b/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/umbraco.xsx
deleted file mode 100644
index f09e598dcb..0000000000
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/schemas/umbraco.xsx
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/umbraco.cms/businesslogic/CMSNode.cs b/src/umbraco.cms/businesslogic/CMSNode.cs
index 132afdbb14..d4e6028a7f 100644
--- a/src/umbraco.cms/businesslogic/CMSNode.cs
+++ b/src/umbraco.cms/businesslogic/CMSNode.cs
@@ -473,6 +473,8 @@ namespace umbraco.cms.businesslogic
/// The CMSNode Xmlrepresentation
public virtual XmlNode ToXml(XmlDocument xd, bool Deep)
{
+ throw new NotSupportedException("DO NOT USE THIS METHOD, THIS NEEDS TO BE REMOVED FROM THE CODEBASE, REFACTOR ANYTHING THAT IS USING THIS IF YOU GET THIS EXCEPTION");
+
XmlNode x = xd.CreateNode(XmlNodeType.Element, "node", "");
XmlPopulate(xd, x, Deep);
return x;