using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using CMS.IO;
using System.Globalization;
using CMS.PortalControls;
using CMS.GlobalHelper;
using CMS.Controls;
using CMS.PortalEngine;
using CMS.CMSHelper;
public partial class CMSWebParts_Navigation_xmlsitemap : CMSAbstractWebPart
{
#region "Sitemap properties"
///
/// Indicates whether sitemap index transformations should be used
///
public bool IsSiteMapIndex
{
get
{
return ValidationHelper.GetBoolean(GetValue("IsSiteMapIndex"), ucSiteMap.IsSiteMapIndex);
}
set
{
SetValue("IsSiteMapIndex", value);
ucSiteMap.IsSiteMapIndex = value;
}
}
///
/// Indicates whether exclude from search option should be ignored for sitemap
///
public bool IgnoreExcludeFromSearch
{
get
{
return ValidationHelper.GetBoolean(GetValue("IgnoreExcludeFromSearch"), ucSiteMap.IgnoreExcludeFromSearch);
}
set
{
SetValue("IgnoreExcludeFromSearch", value);
ucSiteMap.IgnoreExcludeFromSearch = value;
}
}
///
/// Gets or sets the value that indicates whether children should be hidden if parent is not accessible. False by default.
///
public bool HideChildrenForHiddenParent
{
get
{
return ValidationHelper.GetBoolean(GetValue("HideChildrenForHiddenParent"), ucSiteMap.HideChildrenForHiddenParent);
}
set
{
SetValue("HideChildrenForHiddenParent", value);
ucSiteMap.HideChildrenForHiddenParent = value;
}
}
///
/// Property to set and get name of transformation for displaying results. If none is set, default transformation is used.
///
public string TransformationName
{
get
{
return ValidationHelper.GetString(GetValue("TransformationName"), String.Empty);
}
set
{
SetValue("TransformationName", value);
ucSiteMap.TransformationName = value;
}
}
#endregion
#region "Document properties"
///
/// Gets or sets the cache minutes.
///
public override int CacheMinutes
{
get
{
return base.CacheMinutes;
}
set
{
base.CacheMinutes = value;
ucSiteMap.CacheMinutes = value;
}
}
///
/// Gets or sets the cache item dependencies.
///
public override string CacheDependencies
{
get
{
return base.CacheDependencies;
}
set
{
base.CacheDependencies = value;
ucSiteMap.CacheDependencies = value;
}
}
///
/// Gets or sets the name of the cache item. If not explicitly specified, the name is automatically
/// created based on the control unique ID
///
public override string CacheItemName
{
get
{
return base.CacheItemName;
}
set
{
base.CacheItemName = value;
ucSiteMap.CacheItemName = value;
}
}
///
/// Gets or sets the value that indicates whether permissions are checked.
///
public bool CheckPermissions
{
get
{
return ValidationHelper.GetBoolean(GetValue("CheckPermissions"), ucSiteMap.CheckPermissions);
}
set
{
SetValue("CheckPermissions", value);
ucSiteMap.CheckPermissions = value;
}
}
///
/// Gets or sets the class names.
///
public string ClassNames
{
get
{
return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("Classnames"), ucSiteMap.ClassNames), ucSiteMap.ClassNames);
}
set
{
SetValue("ClassNames", value);
ucSiteMap.ClassNames = value;
}
}
///
/// Gets or sets the value that indicates whether selected documents are combined with default culture.
///
public bool CombineWithDefaultCulture
{
get
{
return ValidationHelper.GetBoolean(GetValue("CombineWithDefaultCulture"), ucSiteMap.CombineWithDefaultCulture);
}
set
{
SetValue("CombineWithDefaultCulture", value);
ucSiteMap.CombineWithDefaultCulture = value;
}
}
///
/// Gets or sets the culture code.
///
public string CultureCode
{
get
{
return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("CultureCode"), ucSiteMap.CultureCode), ucSiteMap.CultureCode);
}
set
{
SetValue("CultureCode", value);
ucSiteMap.CultureCode = value;
}
}
///
/// Gets or sets the maximal relative level.
///
public int MaxRelativeLevel
{
get
{
return ValidationHelper.GetInteger(GetValue("MaxRelativeLevel"), ucSiteMap.MaxRelativeLevel);
}
set
{
SetValue("MaxRelativeLevel", value);
ucSiteMap.MaxRelativeLevel = value;
}
}
///
/// Gets or sets the order by clause.
///
public string OrderBy
{
get
{
return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("OrderBy"), ucSiteMap.OrderBy), ucSiteMap.OrderBy);
}
set
{
SetValue("OrderBy", value);
ucSiteMap.OrderBy = value;
}
}
///
/// Gets or sets the nodes path.
///
public string Path
{
get
{
return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("Path"), ucSiteMap.Path), ucSiteMap.Path);
}
set
{
SetValue("Path", value);
ucSiteMap.Path = value;
}
}
///
/// Gets or sets the value that indicates whether selected documents must be published.
///
public bool SelectOnlyPublished
{
get
{
return ValidationHelper.GetBoolean(GetValue("SelectOnlyPublished"), ucSiteMap.SelectOnlyPublished);
}
set
{
SetValue("SelctOnlyPublished", value);
ucSiteMap.SelectOnlyPublished = value;
}
}
///
/// Gets or sets the site name.
///
public string SiteName
{
get
{
return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("SiteName"), ucSiteMap.SiteName), ucSiteMap.SiteName);
}
set
{
SetValue("SiteName", value);
ucSiteMap.SiteName = value;
}
}
///
/// Gets or sets the where condition.
///
public string WhereCondition
{
get
{
return DataHelper.GetNotEmpty(GetValue("WhereCondition"), ucSiteMap.WhereCondition);
}
set
{
SetValue("WhereCondition", value);
ucSiteMap.WhereCondition = value;
}
}
#endregion
#region "Methods"
///
/// Content loaded event handler.
///
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
}
///
/// Initializes the control properties.
///
protected void SetupControl()
{
if (StopProcessing)
{
// Do nothing
ucSiteMap.StopProcessing = true;
}
else
{
// Switch by view mode
switch (CMSContext.ViewMode)
{
case ViewModeEnum.LiveSite:
// Set properties
ucSiteMap.IgnoreExcludeFromSearch = IgnoreExcludeFromSearch;
ucSiteMap.HideChildrenForHiddenParent = HideChildrenForHiddenParent;
ucSiteMap.IsSiteMapIndex = IsSiteMapIndex;
ucSiteMap.TransformationName = TransformationName;
ucSiteMap.CacheMinutes = CacheMinutes;
ucSiteMap.CacheDependencies = CacheDependencies;
ucSiteMap.CacheItemName = CacheItemName;
ucSiteMap.CheckPermissions = CheckPermissions;
ucSiteMap.ClassNames = ClassNames;
ucSiteMap.CombineWithDefaultCulture = CombineWithDefaultCulture;
ucSiteMap.CultureCode = CultureCode;
ucSiteMap.MaxRelativeLevel = MaxRelativeLevel;
ucSiteMap.OrderBy = OrderBy;
ucSiteMap.Path = Path;
ucSiteMap.SelectOnlyPublished = SelectOnlyPublished;
ucSiteMap.SiteName = SiteName;
ucSiteMap.WhereCondition = WhereCondition;
// Reload data
ucSiteMap.ReloadData(true);
// Keep current response
HttpResponse response = Context.Response;
// Render XML
response.Clear();
response.ClearContent();
response.ContentType = "text/xml";
response.ContentEncoding = Encoding.UTF8;
// Render control
StringBuilder stringBuilder = new StringBuilder();
using (StringWriter textWriter = new StringWriter(stringBuilder, CultureInfo.InvariantCulture))
{
using (HtmlTextWriter writer = new HtmlTextWriter(textWriter))
{
RenderChildren(writer);
}
}
// Add to the response an end response
response.Write(stringBuilder.ToString());
RequestHelper.EndResponse();
break;
// For other view modes do nothing and display message
default:
ucSiteMap.StopProcessing = true;
lbSiteMap.Visible = true;
lbSiteMap.Text = GetString("xmlsitemap.nodisplay");
break;
}
}
}
///
/// Reloads the control data
///
public override void ReloadData()
{
base.ReloadData();
SetupControl();
}
#endregion
}