using System; using System.Data; using System.Collections; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using CMS.GlobalHelper; using CMS.PortalControls; using CMS.UIControls; public partial class CMSWebParts_UserContributions_ContributionList : CMSAbstractWebPart { #region "Document properties" /// /// Gets or sets the class names (document types) separated with semicolon, which should be displayed. /// public string ClassNames { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("Classnames"), list.ClassNames), list.ClassNames); } set { SetValue("ClassNames", value); list.ClassNames = value; } } /// /// Gets or sets the value that indicates whether the default language version of the document /// should be displayed if the document is not translated to the current language. /// public bool CombineWithDefaultCulture { get { return ValidationHelper.GetBoolean(GetValue("CombineWithDefaultCulture"), list.CombineWithDefaultCulture); } set { SetValue("CombineWithDefaultCulture", value); list.CombineWithDefaultCulture = value; } } /// /// Gets or sets the culture version of the displayed content. /// public string CultureCode { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("CultureCode"), list.CultureCode), list.CultureCode); } set { SetValue("CultureCode", value); list.CultureCode = value; } } /// /// 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"), list.MaxRelativeLevel); } set { SetValue("MaxRelativeLevel", value); list.MaxRelativeLevel = value; } } /// /// Gets or sets the ORDER BY part of the SELECT query. /// public string OrderBy { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("OrderBy"), list.OrderBy), list.OrderBy); } set { SetValue("OrderBy", value); list.OrderBy = value; } } /// /// Gets or sets the path to the document. /// public string Path { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("Path"), null), null); } set { SetValue("Path", value); list.Path = value; } } /// /// Gets or sets the value that indicates whether to show only published documents. /// public bool SelectOnlyPublished { get { return ValidationHelper.GetBoolean(GetValue("SelectOnlyPublished"), list.SelectOnlyPublished); } set { SetValue("SelectOnlyPublished", value); list.SelectOnlyPublished = value; } } /// /// Gets or sets the codename of the site from which you want to display the content. /// public string SiteName { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("SiteName"), list.SiteName), list.SiteName); } set { SetValue("SiteName", value); list.SiteName = value; } } /// /// Gets or sets the WHERE part of the SELECT query. /// public string WhereCondition { get { return DataHelper.GetNotEmpty(GetValue("WhereCondition"), list.WhereCondition); } set { SetValue("WhereCondition", value); list.WhereCondition = value; } } /// /// Gets or sets the columns to retrieve. /// public string Columns { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("Columns"), list.Columns), list.Columns); } set { SetValue("Columns", value); list.Columns = value; } } #endregion #region "Public properties" /// /// Gets or sets the value that indicates whether the list of documents should be displayed. /// public bool DisplayList { get { return ValidationHelper.GetBoolean(GetValue("DisplayList"), list.DisplayList); } set { SetValue("DisplayList", value); list.DisplayList = value; } } /// /// Gets or sets the path for new created documents. /// public string NewDocumentPath { get { return ValidationHelper.GetString(GetValue("NewDocumentPath"), list.NewDocumentPath); } set { SetValue("NewDocumentPath", value); list.NewDocumentPath = value; } } /// /// Gets or sets the value that indicates whether inserting new document is allowed. /// public bool AllowInsert { get { return ValidationHelper.GetBoolean(GetValue("AllowInsert"), list.AllowInsert); } set { SetValue("AllowInsert", value); list.AllowInsert = value; } } /// /// Gets or sets the value that indicates whether editing document is allowed. /// public bool AllowEdit { get { return ValidationHelper.GetBoolean(GetValue("AllowEdit"), list.AllowEdit); } set { SetValue("AllowEdit", value); list.AllowEdit = value; } } /// /// Gets or sets the value that indicates whether deleting document is allowed. /// public bool AllowDelete { get { return ValidationHelper.GetBoolean(GetValue("AllowDelete"), list.AllowDelete); } set { SetValue("AllowDelete", value); list.AllowDelete = value; } } /// /// Gets or sets the group of users which can work with the documents. /// public UserContributionAllowUserEnum AllowUsers { get { object value = GetValue("AllowUsers"); if (value == null) { return UserContributionAllowUserEnum.DocumentOwner; } else if (ValidationHelper.IsInteger(value)) { return (UserContributionAllowUserEnum)(ValidationHelper.GetInteger(value, 2)); } else { return (UserContributionAllowUserEnum)(value); } } set { SetValue("AllowUsers", value); list.AllowUsers = value; } } /// /// Gets or sets the page template the new items are assigned to. /// public string NewItemPageTemplate { get { return ValidationHelper.GetString(GetValue("NewItemPageTemplate"), list.NewItemPageTemplate); } set { SetValue("NewItemPageTemplate", value); list.NewItemPageTemplate = value; } } /// /// Gets or sets the type of the child documents that are allowed to be created. /// public string AllowedChildClasses { get { return ValidationHelper.GetString(GetValue("AllowedChildClasses"), list.AllowedChildClasses); } set { SetValue("AllowedChildClasses", value); list.AllowedChildClasses = value; } } /// /// Gets or sets alternative form name. /// public string AlternativeFormName { get { return ValidationHelper.GetString(GetValue("AlternativeFormName"), list.AlternativeFormName); } set { SetValue("AlternativeFormName", value); list.AlternativeFormName = value; } } /// /// Gets or sets the message which is displayed after validation failed. /// public string ValidationErrorMessage { get { return ValidationHelper.GetString(GetValue("ValidationErrorMessage"), list.ValidationErrorMessage); } set { SetValue("ValidationErrorMessage", value); list.ValidationErrorMessage = value; } } /// /// Gets or sets the value that indicates whether the permissions are checked. /// public bool CheckPermissions { get { return ValidationHelper.GetBoolean(GetValue("CheckPermissions"), list.CheckPermissions); } set { SetValue("CheckPermissions", value); list.CheckPermissions = value; } } /// /// Gets or sets the value that indicates if document type permissions are required to create new document. /// public bool CheckDocPermissionsForInsert { get { return ValidationHelper.GetBoolean(GetValue("CheckDocPermissionsForInsert"), list.CheckDocPermissionsForInsert); } set { SetValue("CheckDocPermissionsForInsert", value); list.CheckDocPermissionsForInsert = value; } } /// /// Gets or sets new item button label. /// public string NewItemButtonText { get { return DataHelper.GetNotEmpty(GetValue("NewItemButtonText"), list.NewItemButtonText); } set { SetValue("NewItemButtonText", value); list.NewItemButtonText = value; } } /// /// Gets or sets List button label. /// public string ListButtonText { get { return DataHelper.GetNotEmpty(GetValue("ListButtonText"), list.ListButtonText); } set { SetValue("ListButtonText", value); list.ListButtonText = value; } } /// /// Indicates whether activity is logged. /// public bool LogActivity { get { return ValidationHelper.GetBoolean(GetValue("LogActivity"), false); } set { SetValue("LogActivity", value); list.LogActivity = value; } } #endregion /// /// Content loaded event handler. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); AttachEvents(); } /// /// Reloads data for partial caching. /// public override void ReloadData() { base.ReloadData(); SetupControl(); AttachEvents(); } /// /// Event registration. /// protected void AttachEvents() { list.EditForm.OnAfterApprove += EditForm_OnAfterChange; list.EditForm.OnAfterReject += EditForm_OnAfterChange; list.EditForm.OnAfterDelete += EditForm_OnAfterChange; list.EditForm.CMSForm.OnAfterSave += CMSForm_OnAfterSave; list.OnAfterDelete += EditForm_OnAfterChange; } /// /// EditForm after change event handler. /// private void EditForm_OnAfterChange(object sender, EventArgs e) { CMSForm_OnAfterSave(sender, e); } /// /// CMSForm after save event handler. /// private void CMSForm_OnAfterSave(object sender, EventArgs e) { if (!StandAlone) { // Reload data after saving the document PagePlaceholder.ClearCache(); PagePlaceholder.ReloadData(); } } /// /// Initializes the control properties. /// protected void SetupControl() { if (StopProcessing) { list.StopProcessing = true; // Do nothing } else { list.ControlContext = ControlContext; list.AllowEdit = AllowEdit; list.AllowInsert = AllowInsert; list.AllowDelete = AllowDelete; list.CheckPermissions = CheckPermissions; list.CheckDocPermissionsForInsert = CheckDocPermissionsForInsert; list.AllowedChildClasses = AllowedChildClasses; list.NewItemPageTemplate = NewItemPageTemplate; list.AllowUsers = AllowUsers; list.WhereCondition = WhereCondition; list.SiteName = SiteName; list.SelectOnlyPublished = SelectOnlyPublished; list.Path = Path; list.OrderBy = OrderBy; list.MaxRelativeLevel = MaxRelativeLevel; list.CultureCode = CultureCode; list.CombineWithDefaultCulture = CombineWithDefaultCulture; list.ClassNames = ClassNames; list.DisplayList = DisplayList; list.NewDocumentPath = NewDocumentPath; list.AlternativeFormName = AlternativeFormName; list.ValidationErrorMessage = ValidationErrorMessage; list.NewItemButtonText = NewItemButtonText; list.ListButtonText = ListButtonText; list.Columns = Columns; list.LogActivity = LogActivity; list.ComponentName = WebPartID; } } protected override void OnPreRender(EventArgs e) { if (list.StopProcessing) { // Hide control if stop processing is set list.Visible = false; } base.OnPreRender(e); } }