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.DocumentEngine; public partial class CMSWebParts_Viewers_Documents_relateddocuments : CMSAbstractWebPart { #region "Public properties" /// /// Gets or sets the where condition. /// public string WhereCondition { get { return ValidationHelper.GetString(GetValue("WhereCondition"), ""); } set { SetValue("WhereCondition", value); } } /// /// Gets or sets the order by clause. /// public string OrderBy { get { return ValidationHelper.GetString(GetValue("OrderBy"), ""); } set { SetValue("OrderBy", value); } } /// /// Gets or sets the value that indicates whether the current document is on the left side of the relationship. /// public bool CurrentDocumentIsOnTheLeftSide { get { return ValidationHelper.GetBoolean(GetValue("CurrentDocumentIsOnTheLeftSide"), true); } set { SetValue("CurrentDocumentIsOnTheLeftSide", value); } } /// /// Gets or sets the name of the relationship between documents. /// public string RelationshipName { get { return ValidationHelper.GetString(GetValue("RelationshipName"), ""); } set { SetValue("RelationshipName", 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); } } /// /// Gets or sets the value that indicates whether to hide the control when no data found. /// public bool HideControlForZeroRows { get { return ValidationHelper.GetBoolean(GetValue("HideControlForZeroRows"), repElem.HideControlForZeroRows); } set { SetValue("HideControlForZeroRows", value); repElem.HideControlForZeroRows = value; } } /// /// Gets or sets the text which should be displayed when no data found. /// public string ZeroRowsText { get { return ValidationHelper.GetString(GetValue("ZeroRowsText"), repElem.ZeroRowsText); } set { SetValue("ZeroRowsText", value); repElem.ZeroRowsText = value; } } /// /// Gets or sets the value that indicates whether to show only published documents. /// public bool SelectOnlyPublished { get { return ValidationHelper.GetBoolean(GetValue("SelectOnlyPublished"), repElem.SelectOnlyPublished); } set { SetValue("SelectOnlyPublished", value); repElem.SelectOnlyPublished = value; } } /// /// Gets or sets the number which indicates how many documents should be displayed. /// public int SelectTopN { get { return ValidationHelper.GetInteger(GetValue("SelectTopN"), repElem.SelectTopN); } set { SetValue("SelectTopN", value); repElem.SelectTopN = value; } } /// /// Gets or sets the columns to get. /// public string Columns { get { return DataHelper.GetNotEmpty(GetValue("Columns"), repElem.Columns); } set { SetValue("Columns", value); repElem.Columns = 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; repElem.StopProcessing = value; } } #endregion /// /// Content loaded event handler. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Reloads data. /// public override void ReloadData() { base.ReloadData(); SetupControl(); } /// /// Initializes the control properties. /// protected void SetupControl() { if (StopProcessing) { repElem.StopProcessing = true; } else { SetContext(); // Setup the control PageInfo currentPage = CMSContext.CurrentPageInfo; if (currentPage != null) { repElem.ControlContext = ControlContext; // Get documents DataSet ds = TreeHelper.GetDocuments(CMSContext.CurrentSiteName, "/%", currentPage.DocumentCulture, true, "", WhereCondition, OrderBy, -1, SelectOnlyPublished, currentPage.NodeGUID, RelationshipName, CurrentDocumentIsOnTheLeftSide, SelectTopN, Columns); repElem.DataSource = ds; repElem.Path = "/%"; repElem.MaxRelativeLevel = -1; repElem.ClassNames = "CMS.Root"; repElem.SelectOnlyPublished = SelectOnlyPublished; if (TransformationName != string.Empty) { repElem.TransformationName = TransformationName; } repElem.HideControlForZeroRows = HideControlForZeroRows; repElem.ZeroRowsText = ZeroRowsText; repElem.EnablePaging = false; if (!DataHelper.DataSourceIsEmpty(ds)) { repElem.DataBind(); } } ReleaseContext(); } } /// /// OnPrerender override (Set visibility). /// protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); Visible = repElem.Visible && !StopProcessing; if (DataHelper.DataSourceIsEmpty(repElem.DataSource) && HideControlForZeroRows) { Visible = false; } } /// /// Clears cache. /// public override void ClearCache() { repElem.ClearCache(); } }