using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CMS.CMSHelper; using CMS.GlobalHelper; using CMS.PortalControls; public partial class CMSWebParts_Forums_Syndication_ForumPostsRSSFeed : CMSAbstractWebPart { #region "RSS Feed Properties" /// /// Querystring key which is used for RSS feed identification on a page with multiple RSS feeds. /// public string QueryStringKey { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("QueryStringKey"), null), rssFeed.QueryStringKey); } set { SetValue("QueryStringKey", value); rssFeed.QueryStringKey = value; } } /// /// Feed name to identify this feed on a page with multiple feeds. If the value is empty the GUID of the web part instance will be used by default. /// public string FeedName { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("FeedName"), null), GetIdentifier()); } set { string valueToSet = value; // If no feed name was specified if (string.IsNullOrEmpty(valueToSet)) { // Set default name valueToSet = GetIdentifier(); } SetValue("FeedName", valueToSet); rssFeed.FeedName = valueToSet; } } /// /// Text for the feed link. /// public string LinkText { get { return ValidationHelper.GetString(GetValue("LinkText"), string.Empty); } set { SetValue("LinkText", value); rssFeed.LinkText = value; } } /// /// Icon which will be displayed in the feed link. /// public string LinkIcon { get { return ValidationHelper.GetString(GetValue("LinkIcon"), string.Empty); } set { SetValue("LinkIcon", value); rssFeed.LinkIcon = value; } } /// /// Indicates if the RSS feed is automatically discovered by the browser. /// public bool EnableRSSAutodiscovery { get { return ValidationHelper.GetBoolean(GetValue("EnableRSSAutodiscovery"), true); } set { SetValue("EnableRSSAutodiscovery", value); rssFeed.EnableAutodiscovery = value; } } #endregion #region "RSS Repeater properties" /// /// URL title of the feed. /// public string FeedTitle { get { return ValidationHelper.GetString(GetValue("FeedTitle"), string.Empty); } set { SetValue("FeedTitle", value); rssFeed.FeedTitle = value; } } /// /// Description of the feed. /// public string FeedDescription { get { return ValidationHelper.GetString(GetValue("FeedDescription"), string.Empty); } set { SetValue("FeedDescription", value); rssFeed.FeedDescription = value; } } /// /// Language of the feed. If the value is empty the content culture will be used. /// public string FeedLanguage { get { string cultureCode = ValidationHelper.GetString(GetValue("FeedLanguage"), null); if (string.IsNullOrEmpty(cultureCode)) { cultureCode = CMSContext.PreferredCultureCode; } return cultureCode; } set { SetValue("FeedLanguage", value); rssFeed.FeedLanguage = value; } } /// /// Custom feed header XML which is generated before feed items. If the value is empty default header for RSS feed is generated. /// public string HeaderXML { get { return ValidationHelper.GetString(GetValue("HeaderXML"), null); } set { SetValue("HeaderXML", value); rssFeed.HeaderXML = value; } } /// /// Custom feed footer XML which is generated after feed items. If the value is empty default footer for RSS feed is generated. /// public string FooterXML { get { return ValidationHelper.GetString(GetValue("FooterXML"), null); } set { SetValue("FooterXML", value); rssFeed.FooterXML = value; } } #endregion #region "Transformation properties" /// /// Gets or sets ItemTemplate property. /// public string TransformationName { get { return ValidationHelper.GetString(GetValue("TransformationName"), string.Empty); } set { SetValue("TransformationName", value); rssFeed.TransformationName = value; } } #endregion #region "Datasource properties" /// /// Gets or sets the web service URL. /// public string SiteName { get { return DataHelper.GetNotEmpty(GetValue("SiteName"), CMSContext.CurrentSiteName); } set { SetValue("SiteName", value); srcElem.SiteName = value; } } /// /// Gets or sets forum name for which blog posts should be obtained. /// public string ForumName { get { return ValidationHelper.GetString(GetValue("ForumName"), ""); } set { SetValue("ForumName", value); srcElem.ForumName = value; } } /// /// Gets or sets Select only approved property. /// public bool SelectOnlyApproved { get { return ValidationHelper.GetBoolean(GetValue("SelectOnlyApproved"), true); } set { SetValue("SelectOnlyApproved", value); srcElem.SelectOnlyApproved = value; } } /// /// Gets or sets Check permissions property. /// public bool CheckPermissions { get { return ValidationHelper.GetBoolean(GetValue("CheckPermissions"), true); } set { SetValue("CheckPermissions", value); srcElem.CheckPermissions = value; } } /// /// Gets or sets the ORDER BY clause. /// public string OrderBy { get { return ValidationHelper.GetString(GetValue("OrderBy"), ""); } set { SetValue("OrderBy", value); srcElem.OrderBy = value; } } /// /// Gets or sets the WHERE condition. /// public string WhereCondition { get { return ValidationHelper.GetString(GetValue("WhereCondition"), ""); } set { SetValue("WhereCondition", value); srcElem.WhereCondition = value; } } /// /// Gets or sets the number which indicates how many documents should be displayed. /// public int SelectTopN { get { return ValidationHelper.GetInteger(GetValue("SelectTopN"), 0); } set { SetValue("SelectTopN", value); srcElem.TopN = value; } } /// /// Gets or sets the source filter name. /// public string FilterName { get { return ValidationHelper.GetString(GetValue("FilterName"), ""); } set { SetValue("FilterName", value); srcElem.SourceFilterName = value; } } /// /// Gest or sets selected columns. /// public string Columns { get { return ValidationHelper.GetString(GetValue("Columns"), ""); } set { SetValue("Columns", value); srcElem.SelectedColumns = value; } } /// /// Indicates if group posts should be included. /// public bool ShowGroupPosts { get { return ValidationHelper.GetBoolean(GetValue("ShowGroupPosts"), false); } set { SetValue("ShowGroupPosts", value); srcElem.ShowGroupPosts = value; } } #endregion #region "Cache properties" /// /// Gest or sets the cache item name. /// public override string CacheItemName { get { return base.CacheItemName; } set { base.CacheItemName = value; srcElem.CacheItemName = value; rssFeed.CacheItemName = value; } } /// /// Cache dependencies, each cache dependency on a new line. /// public override string CacheDependencies { get { return ValidationHelper.GetString(base.CacheDependencies, srcElem.CacheDependencies); } set { base.CacheDependencies = value; srcElem.CacheDependencies = value; rssFeed.CacheDependencies = value; } } /// /// Gets or sets the cache minutes. /// public override int CacheMinutes { get { return base.CacheMinutes; } set { base.CacheMinutes = value; srcElem.CacheMinutes = value; rssFeed.CacheMinutes = value; } } #endregion #region "Stop processing" /// /// Returns true if the control processing should be stopped. /// public override bool StopProcessing { get { return base.StopProcessing; } set { base.StopProcessing = value; rssFeed.StopProcessing = value; srcElem.StopProcessing = value; } } #endregion #region "Overidden methods" /// /// Content loaded event handler. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Reloads data. /// public override void ReloadData() { base.ReloadData(); SetupControl(); } #endregion #region "Setup control" /// /// Initializes the control properties. /// protected void SetupControl() { if (StopProcessing) { rssFeed.StopProcessing = true; srcElem.StopProcessing = true; } else { string feedCodeName = URLHelper.GetSafeUrlPart(FeedName, SiteName); // RSS feed properties rssFeed.FeedName = feedCodeName; rssFeed.FeedLink = URLHelper.GetAbsoluteUrl(URLHelper.AddParameterToUrl(URLHelper.CurrentURL, QueryStringKey, feedCodeName)); rssFeed.LinkText = LinkText; rssFeed.LinkIcon = LinkIcon; rssFeed.FeedTitle = FeedTitle; rssFeed.FeedDescription = FeedDescription; rssFeed.FeedLanguage = FeedLanguage; rssFeed.EnableAutodiscovery = EnableRSSAutodiscovery; rssFeed.QueryStringKey = QueryStringKey; rssFeed.HeaderXML = HeaderXML; rssFeed.FooterXML = FooterXML; // Datasource properties srcElem.FilterName = ValidationHelper.GetString(GetValue("WebPartControlID"), ClientID); srcElem.SiteName = SiteName; srcElem.ForumName = ForumName; srcElem.OrderBy = OrderBy; srcElem.WhereCondition = WhereCondition; srcElem.TopN = SelectTopN; srcElem.SourceFilterName = FilterName; srcElem.SelectOnlyApproved = SelectOnlyApproved; srcElem.CheckPermissions = CheckPermissions; srcElem.SelectedColumns = Columns; srcElem.ShowGroupPosts = ShowGroupPosts; // Cache properties rssFeed.CacheItemName = CacheItemName; rssFeed.CacheDependencies = CacheDependencies; rssFeed.CacheMinutes = CacheMinutes; srcElem.CacheItemName = CacheItemName; srcElem.CacheDependencies = CacheDependencies; srcElem.CacheMinutes = CacheMinutes; // Transformation properties rssFeed.TransformationName = TransformationName; // Set datasource rssFeed.DataSourceControl = srcElem; } } #endregion }