<%	string rootNamespaceToUse = _executingGenerator.RootNamespaceToUse;
%>using System;
using System.Web;
using <%=rootNamespaceToUse%>.ExtendedClasses;

/// <summary>
/// Individual level of a BreadCrumb list
/// </summary>
[Serializable]
public class PageCrumb
{
	#region Class Member Declarations

	private int _level;
	private string _url;
	private string _title;
	private Bucket _bucket;

	private readonly string defaultTitle = Resources.Global.Crumb_DefaultTitle;
	#endregion

	public PageCrumb()
	{
		_level = 1;
		_url = DefaultUrl;
		_title = defaultTitle;
		_bucket = null;
	}

	public PageCrumb(PageCrumb previousPageCrumb)
	{
		_level = previousPageCrumb.Level;
		_url = previousPageCrumb.Url;
		_title = previousPageCrumb.Title;
		_bucket = previousPageCrumb.Bucket;
	}

	//We are setting all the properties at the time of construction
	public PageCrumb(int level, string url, string title)
	{
		_level = level;
		_url = url;
		_title = title;
		_bucket = null;
	}

	//We are setting all the properties at the time of construction
	public PageCrumb(int level, string url, string title, Bucket bucket)
	{
		_level = level;
		_url = url;
		_title = title;
		_bucket = bucket;
	}

	public bool IsValid()
	{
		return ((_level > 0) && (!string.IsNullOrEmpty(_url)) && (!string.IsNullOrEmpty(_title)));
	}

	#region Class Property Declarations

	/// <summary>
	/// Hierarchy level of the PageCrumb
	/// </summary>
	public int Level
	{
		get { return _level; }
		set
		{
			_level = value > 0 
					? value 
					: 1;
		}
	}

	/// <summary>
	/// URL associated to the PageCrumb
	/// </summary>
	public string Url
	{
		get { return _url; }
		set	{ _url = value ?? DefaultUrl; }
	}

	/// <summary>
	/// Label shown of the PageCrumb
	/// </summary>
	public string Title
	{
		get { return _title; }
		set
		{
			_title = string.IsNullOrEmpty(value)
				? defaultTitle 
				: value;
		}
	}

	/// <summary>
	/// Postback bucket stored in the PageCrumb
	/// </summary>
	public Bucket Bucket
	{
		get { return _bucket; }
		set { _bucket = value; }
	}

	/// <summary>
	/// True if the Bucket is a RelationPredicateBucket
	/// False if it is a List &lt;SpTypedViewPredicate&gt;
	/// </summary>
	public bool IsStandardBucket
	{
		get { return (_bucket == null) || _bucket.IsRelationPredicateBucket; }
	}

	protected string DefaultUrl
	{
		get
		{
			/*
			IGeneraProfile profile = (IGeneraProfile)HttpContext.Current.User;
			string url = (profile.IsInRole("User") || profile.IsInRole("Anonymous"))
				? "~/AnonymousLogin.aspx"
				: "~/Default.aspx";
			*/
			return VirtualPathUtility.ToAbsolute("~/Default.aspx");
		}
	}
	#endregion
}
