2013-09-25 19:03:05 +10:00
using System ;
using System.Linq ;
2012-04-28 13:57:04 -01:00
using System.Xml.Linq ;
using System.Xml.XPath ;
using umbraco.cms.presentation.Trees ;
namespace umbraco.editorControls.MultiNodeTreePicker
{
2012-04-29 22:41:43 -01:00
/// <summary>
/// XmlTreeNode extensions for the MultiNodeTreePicker.
/// </summary>
2013-09-25 19:03:05 +10:00
[Obsolete("IDataType and all other references to the legacy property editors are no longer used this will be removed from the codebase in future versions")]
2012-04-28 13:57:04 -01:00
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" ) ;
2012-04-29 22:41:43 -01:00
}
2012-04-28 13:57:04 -01:00
}
}
catch ( XPathException )
{
2012-04-29 22:41:43 -01:00
node . Text = "umbraco.editorControls: MNTP: XPath Error!" ;
2012-04-28 13:57:04 -01:00
}
}
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" ) ;
2012-04-29 22:41:43 -01:00
}
2012-04-28 13:57:04 -01:00
}
}
}
}