using System; using CMS.CMSHelper; using CMS.Controls; using CMS.GlobalHelper; using CMS.DocumentEngine; using CMS.UIControls; public partial class CMSModules_Content_Controls_Attachments_DocumentAttachments_DocumentAttachments : CMSUserControl { #region "Variables" private string mPath = null; #endregion #region "Basic repeater properties" /// /// Gets the repeater control. /// public BasicRepeater Repeater { get { return ucRepeater; } } /// /// Gets or sets AlternatingItemTemplate property. /// public string AlternatingItemTransformationName { get { return ValidationHelper.GetString(GetValue("AlternatingItemTransformationName"), ""); } set { SetValue("AlternatingItemTransformationName", value); } } /// /// Gets or sets FooterTemplate property. /// public string FooterTransformationName { get { return ValidationHelper.GetString(GetValue("FooterTransformationName"), ""); } set { SetValue("FooterTransformationName", value); } } /// /// Gets or sets HeaderTemplate property. /// public string HeaderTransformationName { get { return ValidationHelper.GetString(GetValue("HeaderTransformationName"), ""); } set { SetValue("HeaderTransformationName", value); } } /// /// Gets or sets ItemTemplate property. /// public string TransformationName { get { return ValidationHelper.GetString(GetValue("TransformationName"), ""); } set { SetValue("TransformationName", value); } } /// /// Gets or sets SeparatorTemplate property. /// public string SeparatorTransformationName { get { return ValidationHelper.GetString(GetValue("SeparatorTransformationName"), ""); } set { SetValue("SeparatorTransformationName", value); } } /// /// Gets or sets HideControlForZeroRows property. /// public bool HideControlForZeroRows { get { return ucRepeater.HideControlForZeroRows; } set { ucRepeater.HideControlForZeroRows = value; } } /// /// Gets or sets ZeroRowsText property. /// public string ZeroRowsText { get { return ucRepeater.ZeroRowsText; } set { ucRepeater.ZeroRowsText = value; } } #endregion #region "UniPager properties" /// /// Gets or sets the value that indicates whether pager should be hidden for single page. /// public bool HidePagerForSinglePage { get { return ucPager.HidePagerForSinglePage; } set { ucPager.HidePagerForSinglePage = value; } } /// /// Gets or sets the number of records to display on a page. /// public int PageSize { get { return ucPager.PageSize; } set { ucPager.PageSize = value; } } /// /// Gets or sets the number of pages displayed for current page range. /// public int GroupSize { get { return ucPager.GroupSize; } set { ucPager.GroupSize = value; } } /// /// Gets or sets the pager mode. /// public UniPagerMode PagingMode { get { return ucPager.PagerMode; } set { ucPager.PagerMode = value; } } /// /// Gets or sets the querysting parameter. /// public string QueryStringKey { get { return ucPager.QueryStringKey; } set { ucPager.QueryStringKey = value; } } /// /// Gets or sets the value that indicates whether first and last item template are displayed dynamically based on current view. /// public bool DisplayFirstLastAutomatically { get { return ucPager.DisplayFirstLastAutomatically; } set { ucPager.DisplayFirstLastAutomatically = value; } } /// /// Gets or sets the value that indicates whether first and last item template are displayed dynamically based on current view. /// public bool DisplayPreviousNextAutomatically { get { return ucPager.DisplayPreviousNextAutomatically; } set { ucPager.DisplayPreviousNextAutomatically = value; } } #endregion #region "UniPager Template properties" /// /// Gets or sets the pages template. /// public string PagesTemplate { get { return ValidationHelper.GetString(GetValue("Pages"), ""); } set { SetValue("Pages", value); } } /// /// Gets or sets the current page template. /// public string CurrentPageTemplate { get { return ValidationHelper.GetString(GetValue("CurrentPage"), ""); } set { SetValue("CurrentPage", value); } } /// /// Gets or sets the separator template. /// public string SeparatorTemplate { get { return ValidationHelper.GetString(GetValue("PageSeparator"), ""); } set { SetValue("PageSeparator", value); } } /// /// Gets or sets the first page template. /// public string FirstPageTemplate { get { return ValidationHelper.GetString(GetValue("FirstPage"), ""); } set { SetValue("FirstPage", value); } } /// /// Gets or sets the last page template. /// public string LastPageTemplate { get { return ValidationHelper.GetString(GetValue("LastPage"), ""); } set { SetValue("LastPage", value); } } /// /// Gets or sets the previous page template. /// public string PreviousPageTemplate { get { return ValidationHelper.GetString(GetValue("PreviousPage"), ""); } set { SetValue("PreviousPage", value); } } /// /// Gets or sets the next page template. /// public string NextPageTemplate { get { return ValidationHelper.GetString(GetValue("NextPage"), ""); } set { SetValue("NextPage", value); } } /// /// Gets or sets the previous group template. /// public string PreviousGroupTemplate { get { return ValidationHelper.GetString(GetValue("PreviousGroup"), ""); } set { SetValue("PreviousGroup", value); } } /// /// Gets or sets the next group template. /// public string NextGroupTemplate { get { return ValidationHelper.GetString(GetValue("NextGroup"), ""); } set { SetValue("NextGroup", value); } } /// /// Gets or sets the layout template. /// public string LayoutTemplate { get { return ValidationHelper.GetString(GetValue("PagerLayout"), ""); } set { SetValue("PagerLayout", value); } } #endregion #region "Data source properties" /// /// Gets the datasource control. /// public AttachmentsDataSource DataSource { get { return ucDataSource; } } /// /// Gets or sets WHERE condition. /// public string WhereCondition { get { return ucDataSource.WhereCondition; } set { ucDataSource.WhereCondition = value; } } /// /// Gets or sets top N. /// public int TopN { get { return ucDataSource.TopN; } set { ucDataSource.TopN = value; } } /// /// Gets or sets site name. /// public string SiteName { get { return ucDataSource.SiteName; } set { ucDataSource.SiteName = value; } } /// /// Gets or sets ORDER BY condition. /// public string OrderBy { get { return ucDataSource.OrderBy; } set { ucDataSource.OrderBy = value; } } /// /// Gets or sets the source filter name. /// public string FilterName { get { return ucDataSource.SourceFilterName; } set { ucDataSource.SourceFilterName = value; } } /// /// Gets or sets the cache item name. /// public string CacheItemName { get { return ucDataSource.CacheItemName; } set { ucDataSource.CacheItemName = value; } } /// /// Cache dependencies, each cache dependency on a new line. /// public string CacheDependencies { get { return ucDataSource.CacheDependencies; } set { ucDataSource.CacheDependencies = value; } } /// /// Gets or sets the cache minutes. /// public int CacheMinutes { get { return ucDataSource.CacheMinutes; } set { ucDataSource.CacheMinutes = value; } } /// /// Gets or sets selected columns. /// public string SelectedColumns { get { return ucDataSource.SelectedColumns; } set { ucDataSource.SelectedColumns = value; } } /// /// Tree provider instance used to access data. If no TreeProvider is assigned, a new TreeProvider instance is created. /// public TreeProvider TreeProvider { get { return ucDataSource.TreeProvider; } set { ucDataSource.TreeProvider = value; } } /// /// Indicates whether select also binary content of the attachments. /// public bool GetBinary { get { return ucDataSource.GetBinary; } set { ucDataSource.GetBinary = value; } } /// /// Group GUID (document field GUID) of the grouped attachments. /// public Guid AttachmentGroupGUID { get { return ucDataSource.AttachmentGroupGUID; } set { ucDataSource.AttachmentGroupGUID = value; } } /// /// Form GUID of the temporary attachments. /// public Guid AttachmentFormGUID { get { return ucDataSource.AttachmentFormGUID; } set { ucDataSource.AttachmentFormGUID = value; } } /// /// ID of version history. /// public int DocumentVersionHistoryID { get { return ucDataSource.DocumentVersionHistoryID; } set { ucDataSource.DocumentVersionHistoryID = value; } } /// /// Culture code, such as en-us. /// public string CultureCode { get { return ucDataSource.CultureCode; } set { ucDataSource.CultureCode = value; } } /// /// Indicates if the document should be selected eventually from the default culture. /// public bool CombineWithDefaultCulture { get { return ucDataSource.CombineWithDefaultCulture; } set { ucDataSource.CombineWithDefaultCulture = value; } } /// /// Gets or sets the alias path. /// public string Path { get { return mPath; } set { mPath = value; ucDataSource.Path = CMSContext.ResolveCurrentPath(value); } } /// /// Allows you to specify whether to check permissions of the current user. If the value is 'false' (default value) no permissions are checked. Otherwise, only nodes for which the user has read permission are displayed. /// public bool CheckPermissions { get { return ucDataSource.CheckPermissions; } set { ucDataSource.CheckPermissions = value; } } /// /// Gets whethter datasource is empty or not. /// public bool HasData { get { return !DataHelper.DataSourceIsEmpty(ucRepeater.DataSource); } } #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; ucDataSource.StopProcessing = value; } } #endregion protected void Page_Load(object sender, EventArgs e) { ucRepeater.DataBindByDefault = false; ucPager.PageControl = ucRepeater.ID; // Reload data if (!StopProcessing) { ReloadData(); } } /// /// OnPrerender override (Set visibility). /// protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); Visible = ucRepeater.Visible; if (!HasData && HideControlForZeroRows) { Visible = false; } } /// /// Reloads the data. /// public void ReloadData() { ReloadData(false); } /// /// Reloads the data. /// /// Indicates if the rload should be forced public void ReloadData(bool forceReload) { #region "Repeater template properties" // Apply transformations if they exist ucRepeater.ItemTemplate = CMSDataProperties.LoadTransformation(this, TransformationName, false); if (!string.IsNullOrEmpty(AlternatingItemTransformationName)) { ucRepeater.AlternatingItemTemplate = CMSDataProperties.LoadTransformation(this, AlternatingItemTransformationName, false); } if (!string.IsNullOrEmpty(FooterTransformationName)) { ucRepeater.FooterTemplate = CMSDataProperties.LoadTransformation(this, FooterTransformationName, false); } if (!string.IsNullOrEmpty(HeaderTransformationName)) { ucRepeater.HeaderTemplate = CMSDataProperties.LoadTransformation(this, HeaderTransformationName, false); } if (!string.IsNullOrEmpty(SeparatorTransformationName)) { ucRepeater.SeparatorTemplate = CMSDataProperties.LoadTransformation(this, SeparatorTransformationName, false); } #endregion #region "UniPager template properties" // UniPager template properties if (!string.IsNullOrEmpty(PagesTemplate)) { ucPager.PageNumbersTemplate = CMSDataProperties.LoadTransformation(ucPager, PagesTemplate, false); } if (!string.IsNullOrEmpty(CurrentPageTemplate)) { ucPager.CurrentPageTemplate = CMSDataProperties.LoadTransformation(ucPager, CurrentPageTemplate, false); } if (!string.IsNullOrEmpty(SeparatorTemplate)) { ucPager.PageNumbersSeparatorTemplate = CMSDataProperties.LoadTransformation(ucPager, SeparatorTemplate, false); } if (!string.IsNullOrEmpty(FirstPageTemplate)) { ucPager.FirstPageTemplate = CMSDataProperties.LoadTransformation(ucPager, FirstPageTemplate, false); } if (!string.IsNullOrEmpty(LastPageTemplate)) { ucPager.LastPageTemplate = CMSDataProperties.LoadTransformation(ucPager, LastPageTemplate, false); } if (!string.IsNullOrEmpty(PreviousPageTemplate)) { ucPager.PreviousPageTemplate = CMSDataProperties.LoadTransformation(ucPager, PreviousPageTemplate, false); } if (!string.IsNullOrEmpty(NextPageTemplate)) { ucPager.NextPageTemplate = CMSDataProperties.LoadTransformation(ucPager, NextPageTemplate, false); } if (!string.IsNullOrEmpty(PreviousGroupTemplate)) { ucPager.PreviousGroupTemplate = CMSDataProperties.LoadTransformation(ucPager, PreviousGroupTemplate, false); } if (!string.IsNullOrEmpty(NextGroupTemplate)) { ucPager.NextGroupTemplate = CMSDataProperties.LoadTransformation(ucPager, NextGroupTemplate, false); } if (!string.IsNullOrEmpty(LayoutTemplate)) { ucPager.LayoutTemplate = CMSDataProperties.LoadTransformation(ucPager, LayoutTemplate, false); } #endregion if (forceReload) { ucDataSource.DataSource = null; } // Connects repeater with data source ucRepeater.DataSource = ucDataSource.DataSource; ucRepeater.RelatedData = ucDataSource.RelatedData; if (HasData) { ucRepeater.DataBind(); } } /// /// Clears control cache. /// public void ClearCache() { ucDataSource.ClearCache(); } }