using System; using System.Data; using System.Collections; using System.Web; using System.Web.UI; using CMS.CMSHelper; using CMS.GlobalHelper; using CMS.PortalControls; public partial class CMSWebParts_Ecommerce_Products_ProductsDataSource : CMSAbstractWebPart { #region "Properties" /// /// Gets or sets WHERE condition. /// public string WhereCondition { get { return ValidationHelper.GetString(GetValue("WhereCondition"), ""); } set { SetValue("WhereCondition", value); srcProducts.WhereCondition = value; } } /// /// Gets or sets ORDER BY condition. /// public string OrderBy { get { return ValidationHelper.GetString(GetValue("OrderBy"), ""); } set { SetValue("OrderBy", value); srcProducts.OrderBy = value; } } /// /// Gets or sets top N selected documents. /// public int SelectTopN { get { return ValidationHelper.GetInteger(GetValue("SelectTopN"), 0); } set { SetValue("SelectTopN", value); srcProducts.TopN = value; } } /// /// Gets or sets the source filter name. /// public string FilterName { get { return ValidationHelper.GetString(GetValue("FilterName"), ""); } set { SetValue("FilterName", value); srcProducts.SourceFilterName = value; } } /// /// Gets or sets the cache item name. /// public override string CacheItemName { get { return base.CacheItemName; } set { base.CacheItemName = value; srcProducts.CacheItemName = value; } } /// /// Cache dependencies, each cache dependency on a new line. /// public override string CacheDependencies { get { return ValidationHelper.GetString(base.CacheDependencies, srcProducts.CacheDependencies); } set { base.CacheDependencies = value; srcProducts.CacheDependencies = value; } } /// /// Gets or sets the cache minutes. /// public override int CacheMinutes { get { return base.CacheMinutes; } set { base.CacheMinutes = value; srcProducts.CacheMinutes = value; } } /// /// Gets or sets selected columns. /// public string Columns { get { return ValidationHelper.GetString(GetValue("Columns"), ""); } set { SetValue("Columns", value); srcProducts.SelectedColumns = value; } } #endregion #region "Document filter properties" /// /// Indicates if the comments should be retrieved according to document filter settings. /// public bool UseDocumentFilter { get { return ValidationHelper.GetBoolean(GetValue("UseDocumentFilter"), false); } set { SetValue("UseDocumentFilter", value); srcProducts.UseDocumentFilter = value; } } /// /// Gets or sets the site name. /// public string SiteName { get { return DataHelper.GetNotEmpty(GetValue("SiteName"), ""); } set { SetValue("SiteName", value); srcProducts.SiteName = value; } } /// /// Gets or sets the where condition for blog posts. /// public string DocumentsWhereCondition { get { return ValidationHelper.GetString(GetValue("DocumentsWhereCondition"), ""); } set { SetValue("DocumentsWhereCondition", value); srcProducts.DocumentsWhereCondition = value; } } /// /// Gets or sets the value that indicates whether documents are combined with default culture version. /// public bool CombineWithDefaultCulture { get { return ValidationHelper.GetBoolean(GetValue("CombineWithDefaultCulture"), false); } set { SetValue("CombineWithDefaultCulture", value); srcProducts.CombineWithDefaultCulture = value; } } /// /// Gets or sets the culture code of the documents. /// public string CultureCode { get { return DataHelper.GetNotEmpty(GetValue("CultureCode"), CMSContext.PreferredCultureCode); } set { SetValue("CultureCode", value); srcProducts.CultureCode = value; } } /// /// Gets or sets the maximal relative level of the documents to be shown. /// public int MaxRelativeLevel { get { return ValidationHelper.GetInteger(GetValue("MaxRelativeLevel"), -1); } set { SetValue("MaxRelativeLevel", value); srcProducts.MaxRelativeLevel = value; } } /// /// Gets or sets the path of the documents. /// public string Path { get { return ValidationHelper.GetString(GetValue("Path"), srcProducts.Path); } set { SetValue("Path", value); srcProducts.Path = value; } } /// /// Gets or sets the value that indicates whether only published documents are selected. /// public bool SelectOnlyPublished { get { return ValidationHelper.GetBoolean(GetValue("SelectOnlyPublished"), false); } set { SetValue("SelectOnlyPublished", value); srcProducts.SelectOnlyPublished = value; } } #endregion /// /// Content loaded event handler. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Initializes the control properties. /// protected void SetupControl() { if (StopProcessing) { // Do nothing } else { // Properties srcProducts.WhereCondition = WhereCondition; srcProducts.OrderBy = OrderBy; srcProducts.TopN = SelectTopN; srcProducts.FilterName = ValidationHelper.GetString(GetValue("WebPartControlID"), ClientID); srcProducts.SourceFilterName = FilterName; srcProducts.CacheItemName = CacheItemName; srcProducts.CacheDependencies = CacheDependencies; srcProducts.CacheMinutes = CacheMinutes; srcProducts.SelectedColumns = Columns; // Prepare alias path string aliasPath = Path; if (String.IsNullOrEmpty(aliasPath)) { aliasPath = "/%"; } aliasPath = CMSContext.ResolveCurrentPath(aliasPath); // Prepare site name string siteName = SiteName; if (String.IsNullOrEmpty(siteName)) { siteName = CMSContext.CurrentSiteName; } // Prepare culture code string cultureCode = CultureCode; if (String.IsNullOrEmpty(cultureCode)) { cultureCode = CMSContext.PreferredCultureCode; } // Document filter properties srcProducts.SiteName = siteName; srcProducts.UseDocumentFilter = UseDocumentFilter; srcProducts.DocumentsWhereCondition = DocumentsWhereCondition; srcProducts.CombineWithDefaultCulture = CombineWithDefaultCulture; srcProducts.CultureCode = cultureCode; srcProducts.SelectOnlyPublished = SelectOnlyPublished; srcProducts.MaxRelativeLevel = MaxRelativeLevel; srcProducts.Path = aliasPath; } } /// /// Clears cache. /// public override void ClearCache() { srcProducts.ClearCache(); } }