@@ -67,6 +67,15 @@ namespace umbraco.cms.businesslogic.web
|
||||
// (Alex N 20100212)
|
||||
dtd.AppendLine("<!DOCTYPE root [ ");
|
||||
|
||||
dtd.AppendLine(GenerateXmlDocumentType());
|
||||
dtd.AppendLine("]>");
|
||||
|
||||
return dtd.ToString();
|
||||
}
|
||||
|
||||
public static string GenerateXmlDocumentType()
|
||||
{
|
||||
StringBuilder dtd = new StringBuilder();
|
||||
if (UmbracoSettings.UseLegacyXmlSchema)
|
||||
{
|
||||
dtd.AppendLine("<!ELEMENT node ANY> <!ATTLIST node id ID #REQUIRED> <!ELEMENT data ANY>");
|
||||
@@ -101,9 +110,8 @@ namespace umbraco.cms.businesslogic.web
|
||||
}
|
||||
|
||||
}
|
||||
dtd.AppendLine("]>");
|
||||
|
||||
return dtd.ToString();
|
||||
|
||||
}
|
||||
|
||||
public new static DocumentType GetByAlias(string Alias)
|
||||
@@ -253,15 +261,17 @@ namespace umbraco.cms.businesslogic.web
|
||||
public void RemoveTemplate(int templateId)
|
||||
{
|
||||
// remove if default template
|
||||
if (this.DefaultTemplate == templateId) {
|
||||
if (this.DefaultTemplate == templateId)
|
||||
{
|
||||
RemoveDefaultTemplate();
|
||||
}
|
||||
|
||||
// remove from list of document type templates
|
||||
if (_templateIds.Contains(templateId)) {
|
||||
SqlHelper.ExecuteNonQuery("delete from cmsDocumentType where contentTypeNodeId = @id and templateNodeId = @templateId",
|
||||
SqlHelper.CreateParameter("@id", this.Id), SqlHelper.CreateParameter("@templateId", templateId)
|
||||
);
|
||||
if (_templateIds.Contains(templateId))
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery("delete from cmsDocumentType where contentTypeNodeId = @id and templateNodeId = @templateId",
|
||||
SqlHelper.CreateParameter("@id", this.Id), SqlHelper.CreateParameter("@templateId", templateId)
|
||||
);
|
||||
_templateIds.Remove(templateId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,35 @@ namespace umbraco
|
||||
get { return Application.SqlHelper; }
|
||||
}
|
||||
|
||||
|
||||
protected static void ReGenerateSchema(XmlDocument xmlDoc)
|
||||
{
|
||||
string dtd = DocumentType.GenerateXmlDocumentType();
|
||||
|
||||
// remove current doctype
|
||||
XmlNode n = xmlDoc.FirstChild;
|
||||
while (n.NodeType != XmlNodeType.DocumentType && n.NextSibling != null)
|
||||
{
|
||||
n = n.NextSibling;
|
||||
}
|
||||
if (n.NodeType == XmlNodeType.DocumentType)
|
||||
{
|
||||
xmlDoc.RemoveChild(n);
|
||||
}
|
||||
XmlDocumentType docType = xmlDoc.CreateDocumentType("root", null, null, dtd);
|
||||
xmlDoc.InsertAfter(docType, xmlDoc.FirstChild);
|
||||
|
||||
}
|
||||
|
||||
protected static void ValidateSchema(string docTypeAlias, XmlDocument xmlDoc)
|
||||
{
|
||||
// if doctype is not defined i)n schema, then regenerate it
|
||||
if (!xmlDoc.DocumentType.InternalSubset.Contains(String.Format("<!ATTLIST {0} id ID #REQUIRED>", docTypeAlias)))
|
||||
{
|
||||
// we need to re-load the content, else the dtd changes won't be picked up by the XmlDocument
|
||||
content.Instance.XmlContentInternal = content.Instance.LoadContentFromDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -276,7 +304,11 @@ namespace umbraco
|
||||
|
||||
public static void AppendDocumentXml(int id, int level, int parentId, XmlNode docXml, XmlDocument xmlContentCopy)
|
||||
{
|
||||
|
||||
// Validate schema (that a definition of the current document type exists in the DTD
|
||||
if (!UmbracoSettings.UseLegacyXmlSchema)
|
||||
{
|
||||
ValidateSchema(docXml.Name, xmlContentCopy);
|
||||
}
|
||||
|
||||
// Find the document in the xml cache
|
||||
XmlNode x = xmlContentCopy.GetElementById(id.ToString());
|
||||
|
||||
Reference in New Issue
Block a user