using System; using System.Data; using System.Web; using System.Web.UI; using CMS.CMSHelper; using CMS.GlobalHelper; using CMS.PortalControls; using CMS.PortalEngine; using CMS.SettingsProvider; public partial class CMSWebParts_Viewers_Documents_attachments : CMSAbstractWebPart { #region "Repeater properties" /// /// Gets or sets the maximum nesting level. It specifies the number of sub-levels in the content tree /// that should be included in the displayed content. /// public int MaxRelativeLevel { get { return ValidationHelper.GetInteger(GetValue("MaxRelativeLevel"), -1); } set { SetValue("MaxRelativeLevel", value); repItems.MaxRelativeLevel = value; } } /// /// Gets or sets the ORDER BY part of the SELECT query. /// public string OrderBy { get { return ValidationHelper.GetString(GetValue("OrderBy"), "DocumentName"); } set { SetValue("OrderBy", value); repItems.OrderBy = value; } } /// /// Gets or sets the value that indicates whether control should be hidden if no data found. /// public bool HideControlForZeroRows { get { return ValidationHelper.GetBoolean(GetValue("HideControlForZeroRows"), repItems.HideControlForZeroRows); } set { SetValue("HideControlForZeroRows", value); repItems.HideControlForZeroRows = value; } } /// /// Gets or sets the text which is displayed when there is no data. /// public string ZeroRowsText { get { return ValidationHelper.GetString(GetValue("ZeroRowsText"), GetString("AttachmentsWebPart.NoDataFound")); } set { SetValue("ZeroRowsText", value); repItems.ZeroRowsText = value; } } /// /// Gets or sets the value that indicates whether to enable paging or not. /// public bool EnablePaging { get { return ValidationHelper.GetBoolean(GetValue("EnablePaging"), false); } set { SetValue("EnablePaging", value); repItems.EnablePaging = value; } } /// /// Gets or sets the name of the transforamtion which is used for displaying the results. /// public string TransformationName { get { return ValidationHelper.GetString(GetValue("TransformationName"), ""); } set { SetValue("TransformationName", value); repItems.TransformationName = value; } } /// /// Gets or sets the class names (document types) separated with semicolon, which should be displayed. /// public string ClassNames { get { return ValidationHelper.GetString(GetValue("ClassNames"), "CMS.File"); } set { SetValue("ClassNames", value); repItems.ClassNames = value; } } #endregion /// /// Gets or sets the value that indicates whether to enable button for adding new attachments in EDIT mode. /// public bool EnableAddButton { get { return ValidationHelper.GetBoolean(GetValue("EnableAddButton"), false); } set { SetValue("EnableAddButton", value); } } #region "Stop processing" /// /// Returns true if the control processing should be stopped. /// public override bool StopProcessing { get { return base.StopProcessing; } set { base.StopProcessing = value; repItems.StopProcessing = value; } } #endregion /// /// Content loaded event handler. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Initializes the control properties. /// protected void SetupControl() { if (StopProcessing) { repItems.StopProcessing = true; } else { repItems.ControlContext = ControlContext; repItems.MaxRelativeLevel = MaxRelativeLevel; repItems.ClassNames = ClassNames; if (TransformationName != "") { repItems.TransformationName = TransformationName; } repItems.CacheItemName = CacheItemName; repItems.CacheDependencies = CacheDependencies; repItems.CacheMinutes = CacheMinutes; repItems.OrderBy = OrderBy; repItems.ZeroRowsText = ZeroRowsText; repItems.HideControlForZeroRows = HideControlForZeroRows; repItems.EnablePaging = EnablePaging; if ((EnableAddButton) && (CMSContext.ViewMode == ViewModeEnum.Edit)) { DataClassInfo dci = DataClassInfoProvider.GetDataClass(ClassNames); if (dci != null) { ltrAddButton.Text = "" + GetString("AttachmentsWebPart.Add") + "
"; } } } } /// /// OnPrerender override (Set visibility). /// protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); Visible = repItems.Visible && !StopProcessing; if (DataHelper.DataSourceIsEmpty(repItems.DataSource) && (HideControlForZeroRows)) { Visible = false; } } /// /// Reloads the data. /// public override void ReloadData() { base.ReloadData(); SetupControl(); repItems.ReloadData(true); } /// /// Clear cache. /// public override void ClearCache() { repItems.ClearCache(); } }