using System; using CMS.CMSHelper; using CMS.Controls; using CMS.GlobalHelper; using CMS.PortalControls; using CMS.PortalEngine; public partial class CMSWebParts_Syndication_Basic_AtomRepeater : CMSAbstractWebPart { #region "Variables" private CMSBaseDataSource mDataSourceControl = null; private Guid mFeedGUID = Guid.Empty; #endregion #region "Atom Repeater properties" /// /// 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); atomRepeater.FeedName = valueToSet; } } /// /// URL title of the feed. /// public string FeedTitle { get { return ValidationHelper.GetString(GetValue("FeedTitle"), string.Empty); } set { SetValue("FeedTitle", value); atomRepeater.FeedTitle = value; } } /// /// Description/Subtitle of the feed. /// public string FeedSubtitle { get { return ValidationHelper.GetString(GetValue("FeedSubtitle"), string.Empty); } set { SetValue("FeedSubtitle", value); atomRepeater.FeedSubtitle = 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); atomRepeater.FeedLanguage = value; } } /// /// The unique identifier of the feed. If the value is empty, Guid.Empty will be used. /// public Guid FeedGUID { get { if (mFeedGUID == Guid.Empty) { return InstanceGUID; } else { return mFeedGUID; } } set { Guid valueToSet = value; // If no feed GUID was specified if (valueToSet == Guid.Empty) { // Set default GUID valueToSet = InstanceGUID; } mFeedGUID = valueToSet; atomRepeater.FeedGUID = valueToSet; } } /// /// Last significant modification date of the feed. /// public DateTime FeedUpdated { get { return ValidationHelper.GetDateTimeSystem(GetValue("FeedUpdated"), DateTimeHelper.ZERO_TIME); } set { SetValue("FeedUpdated", value); atomRepeater.FeedUpdated = value; } } /// /// Author name of the feed. /// public string FeedAuthorName { get { return ValidationHelper.GetString(GetValue("FeedAuthorName"), string.Empty); } set { SetValue("FeedAuthorName", value); atomRepeater.FeedAuthorName = value; } } /// /// Custom feed header XML which is generated before feed items. If the value is empty default header for Atom feed is generated. /// public string HeaderXML { get { return ValidationHelper.GetString(GetValue("HeaderXML"), null); } set { SetValue("HeaderXML", value); atomRepeater.HeaderXML = value; } } /// /// Custom feed footer XML which is generated after feed items. If the value is empty default footer for Atom feed is generated. /// public string FooterXML { get { return ValidationHelper.GetString(GetValue("FooterXML"), null); } set { SetValue("FooterXML", value); atomRepeater.FooterXML = value; } } #endregion #region "Datasource properties" /// /// Gets or sets name of source. /// public string DataSourceName { get { return ValidationHelper.GetString(GetValue("DataSourceName"), string.Empty); } set { SetValue("DataSourceName", value); atomRepeater.DataSourceName = value; } } /// /// Control with data source. /// public CMSBaseDataSource DataSourceControl { get { return mDataSourceControl; } set { mDataSourceControl = value; atomRepeater.DataSourceControl = value; } } #endregion #region "Cache properties" /// /// Gets or sets the cache item name. /// public override string CacheItemName { get { return ValidationHelper.GetString(base.CacheItemName, atomRepeater.CacheItemName); } set { base.CacheItemName = value; atomRepeater.CacheItemName = value; } } /// /// Cache dependencies, each cache dependency on a new line. /// public override string CacheDependencies { get { return ValidationHelper.GetString(base.CacheDependencies, atomRepeater.CacheDependencies); } set { base.CacheDependencies = value; atomRepeater.CacheDependencies = value; } } /// /// Gets or sets the cache minutes. /// public override int CacheMinutes { get { return base.CacheMinutes; } set { base.CacheMinutes = value; atomRepeater.CacheMinutes = 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); atomRepeater.TransformationName = 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; atomRepeater.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 || (CMSContext.ViewMode == ViewModeEnum.Design) || (CMSContext.ViewMode == ViewModeEnum.Edit) || (CMSContext.ViewMode == ViewModeEnum.EditDisabled)) { atomRepeater.StopProcessing = true; } else { // Atom feed properties atomRepeater.FeedName = FeedName; atomRepeater.FeedLink = URLHelper.GetAbsoluteUrl(URLHelper.CurrentURL); atomRepeater.FeedTitle = FeedTitle; atomRepeater.FeedSubtitle = FeedSubtitle; atomRepeater.FeedLanguage = FeedLanguage; atomRepeater.FeedAuthorName = FeedAuthorName; atomRepeater.FeedGUID = FeedGUID; atomRepeater.FeedUpdated = FeedUpdated; atomRepeater.HeaderXML = HeaderXML; atomRepeater.FooterXML = FooterXML; // Cache properties atomRepeater.CacheItemName = CacheItemName; atomRepeater.CacheDependencies = CacheDependencies; atomRepeater.CacheMinutes = CacheMinutes; // Transformation properties atomRepeater.TransformationName = TransformationName; // Datasource properties atomRepeater.DataSourceName = DataSourceName; } } #endregion }