Removes .ChildNode calls for .SelectNodes() with correct element selection. Allows comments in configuration.

Also updates some Macro Properties to work with new schema.
This commit is contained in:
Casey Neehouse
2012-09-21 01:53:43 +04:00
parent 3a21d48dbc
commit 0225047a52
5 changed files with 17 additions and 19 deletions

View File

@@ -94,7 +94,7 @@ namespace Umbraco.Web.Routing
var customHandlers = new XmlDocument();
customHandlers.Load(Umbraco.Core.IO.IOHelper.MapPath(Umbraco.Core.IO.SystemFiles.NotFoundhandlersConfig));
foreach (XmlNode n in customHandlers.DocumentElement.ChildNodes)
foreach (XmlNode n in customHandlers.DocumentElement.SelectNodes("notFound"))
{
var assemblyName = n.Attributes.GetNamedItem("assembly").Value;

View File

@@ -2113,7 +2113,7 @@ namespace umbraco
{
string error404 = "";
XmlNode error404Node = UmbracoSettings.GetKeyAsNode("/settings/content/errors/error404");
if (error404Node.ChildNodes.Count > 0 && error404Node.ChildNodes[0].HasChildNodes)
if (error404Node.SelectNodes("errorPage").Count > 0 && error404Node.SelectNodes("errorPage")[0].HasChildNodes)
{
// try to get the 404 based on current culture (via domain)
XmlNode cultureErrorNode;

View File

@@ -958,7 +958,7 @@ namespace umbraco
currentNode = macroXML.ImportNode(umbracoXML.GetElementById(currentID.ToString()), true);
// remove all sub content nodes
foreach (XmlNode n in currentNode.SelectNodes("./node"))
foreach (XmlNode n in currentNode.SelectNodes("node|*[@isDoc]"))
currentNode.RemoveChild(n);
macroXmlNode.AppendChild(currentNode);
@@ -979,7 +979,7 @@ namespace umbraco
XmlNode source = umbracoXML.GetElementById(macroPropertyValue);
if (source != null)
{
XmlNodeList sourceList = source.SelectNodes("node");
XmlNodeList sourceList = source.SelectNodes("node|*[@isDoc]");
if (sourceList.Count > 0)
{
int rndNumber;
@@ -990,7 +990,7 @@ namespace umbraco
}
XmlNode node = macroXML.ImportNode(sourceList[rndNumber], true);
// remove all sub content nodes
foreach (XmlNode n in node.SelectNodes("./node"))
foreach (XmlNode n in node.SelectNodes("node|*[@isDoc]"))
node.RemoveChild(n);
macroXmlNode.AppendChild(node);

View File

@@ -286,21 +286,21 @@ namespace umbraco {
IOHelper.MapPath( SystemFiles.NotFoundhandlersConfig ) );
}
for (int i = 0; i < _customHandlers.DocumentElement.ChildNodes.Count; i++) {
foreach (XmlNode notFoundHandler in _customHandlers.DocumentElement.SelectNodes("notFound"))
{
// Load handler
string _chAssembly =
_customHandlers.DocumentElement.ChildNodes[i].Attributes.GetNamedItem("assembly").Value;
string _chType = _customHandlers.DocumentElement.ChildNodes[i].Attributes.GetNamedItem("type").Value;
string _chAssembly = notFoundHandler.Attributes.GetNamedItem("assembly").Value;
string _chType = notFoundHandler.Attributes.GetNamedItem("type").Value;
// check for namespace
string _chNameSpace = _chAssembly;
if (_customHandlers.DocumentElement.ChildNodes[i].Attributes.GetNamedItem("namespace") != null)
_chNameSpace =
_customHandlers.DocumentElement.ChildNodes[i].Attributes.GetNamedItem("namespace").Value;
if (notFoundHandler.Attributes.GetNamedItem("namespace") != null)
_chNameSpace = notFoundHandler.Attributes.GetNamedItem("namespace").Value;
try {
// Reflect to execute and check whether the type is umbraco.main.IFormhandler
HttpContext.Current.Trace.Write("notFoundHandler",
string.Format("Trying NotFoundHandler '{0}.{1}'...", _chAssembly,
_chType));
string.Format("Trying NotFoundHandler '{0}.{1}'...", _chAssembly, _chType));
Assembly assembly =
Assembly.LoadFrom(
IOHelper.MapPath( SystemDirectories.Bin + "/" + _chAssembly + ".dll"));
@@ -313,9 +313,8 @@ namespace umbraco {
int redirectID = typeInstance.redirectID;
currentPage = umbracoContent.GetElementById(redirectID.ToString());
HttpContext.Current.Trace.Write("notFoundHandler",
string.Format(
"NotFoundHandler '{0}.{1} found node matching {2} with id: {3}",
_chAssembly, _chType, url, redirectID));
string.Format("NotFoundHandler '{0}.{1} found node matching {2} with id: {3}",
_chAssembly, _chType, url, redirectID));
// check for caching
if (typeInstance.CacheUrl) {

View File

@@ -19,9 +19,8 @@ namespace umbraco.presentation.umbraco
HelpConfigPages = new List<HelpConfigPage>();
foreach (XmlNode linkNode in helpConfigNode.ChildNodes)
foreach (XmlNode linkNode in helpConfigNode.SelectNodes("link"))
{
if (linkNode.NodeType != XmlNodeType.Element) continue;
HelpConfigPages.Add(new HelpConfigPage
{