Beispiel #1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!IsPostBack)
            {
                FileList.Visible     = IsFileManagerVisibleInMenu();
                NewsListUnit.Visible = !PageReference.IsNullOrEmpty((PageReference)CurrentPage["NewsRoot"]) &&
                                       DataFactory.Instance.GetPage((PageReference)CurrentPage["NewsRoot"]).VisibleInMenu;
                CalendarList.Visible = !PageReference.IsNullOrEmpty((PageReference)CurrentPage["CalendarContainer"]) &&
                                       DataFactory.Instance.GetPage((PageReference)CurrentPage["CalendarContainer"]).VisibleInMenu;
                FileList.DataBind();
            }

            if (NewsListUnit.Visible)
            {
                NewsListUnit.DataSource = GetNewsListPages();
                NewsListUnit.DataBind();
            }

            if (CalendarList.Visible)
            {
                CalendarList.DataBind();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Hides the edit and delete buttons if the current user hasn't got at least Modify membership.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (!IsPostBack)
            {
                DeleteButton.OnClientClick = string.Format("if(!confirm('{0}'))return false;", Translate("/common/messages/confirmdelete"));
                DeleteNewsSectionLinkButton.OnClientClick = string.Format("if(!confirm('{0}'))return false;", Translate("/common/messages/confirmdelete"));
                NewsListUnit.DataBind();
            }

            UpdateDisplayTexts(NewsListUnit.SelectedPageId);
            SetDisplayMode();
        }
Beispiel #3
0
        /// <summary>
        /// Handles the Click event of the CreateNewsItem button.
        /// Creates a page of the type "[AlloyTech] News item" and places it below the current page.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Save_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                PageData page;
                switch (CurrentDisplayMode)
                {
                case DisplayMode.Add:
                    page = DataFactory.Instance.GetDefaultPageData(CurrentPageLink, NewsItemPageTypeName);
                    page.StartPublish = DateTime.Now.AddMinutes(-1);
                    break;

                case DisplayMode.Edit:
                    page = GetSelectedNewsItem(NewsListUnit.SelectedPageId).CreateWritableClone();
                    break;

                default:
                    Page.Validators.Add(new StaticValidator("Unsupported display mode"));
                    return;
                }
                try
                {
                    page.PageName    = EditPageName.Text.ToSafeString();
                    page["MainBody"] = EditMainBody.Text.ToSafeString();

                    NewsListUnit.SelectedPageId = DataFactory.Instance.Save(page, SaveAction.Publish);
                }
                catch (Exception ex)
                {
                    Page.Validators.Add(new StaticValidator(ex.Message));
                    return;
                }

                CurrentDisplayMode = DisplayMode.View;
                NewsListUnit.DataBind();
            }
        }