uComponents: Added MNTP to the core!

This commit is contained in:
leekelleher
2012-04-28 13:57:04 -01:00
parent a0d9e668bd
commit c2c4bb7413
23 changed files with 3791 additions and 3 deletions

View File

@@ -0,0 +1,78 @@
using System.Linq;
using System.Xml.Linq;
using System.Xml.XPath;
using umbraco.cms.presentation.Trees;
namespace umbraco.editorControls.MultiNodeTreePicker
{
/// <summary>
/// XmlTreeNode extensions for the MultiNodeTreePicker.
/// </summary>
public static class XmlTreeNodeExtensions
{
//public static void DetermineSelected(this XmlTreeNode node)
//{
//}
/// <summary>
/// Determines if the node should be clickable based on the xpath given
/// </summary>
/// <param name="node">The node.</param>
/// <param name="xpath">The xpath.</param>
/// <param name="type">The type.</param>
/// <param name="xml">The XML.</param>
public static void DetermineClickable(this XmlTreeNode node, string xpath, XPathFilterType type, XElement xml)
{
if (!string.IsNullOrEmpty(xpath))
{
try
{
var matched = xml.XPathSelectElements(xpath);
if (matched.Count() > 0)
{
if (type == XPathFilterType.Disable)
{
//add the non-clickable color to the node
node.Style.AddCustom("uc-treenode-noclick");
}
else
{
//add the non-clickable color to the node
node.Style.AddCustom("uc-treenode-click");
}
}
else
{
if (type == XPathFilterType.Disable)
{
//ensure the individual node is the correct color
node.Style.AddCustom("uc-treenode-click");
}
else
{
//ensure the individual node is the correct color
node.Style.AddCustom("uc-treenode-noclick");
}
}
}
catch (XPathException)
{
node.Text = "uComponents: XPath Error!";
}
}
else
{
if (type == XPathFilterType.Disable)
{
//ensure the individual node is the correct color
node.Style.AddCustom("uc-treenode-click");
}
else
{
//ensure the individual node is the correct color
node.Style.AddCustom("uc-treenode-noclick");
}
}
}
}
}