//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web.UI.WebControls;
using CommunityServer.ControlPanel.UI;
using CommunityServer.Controls;
using CommunityServer.Components;
using ResourceLinkButton = CommunityServer.ControlPanel.Controls.ResourceLinkButton;
using ResourceControl = CommunityServer.ControlPanel.Controls.ResourceControl;
using ResourceManager = CommunityServer.ControlPanel.Components.ResourceManager;

namespace CommunityServer.ControlPanel.Controls
{
	/// <summary>
	/// Summary description for DescriptiveOptionsPage.
	/// </summary>
	public class DescriptiveOptionsPage : BaseGalleryPage
	{

		#region Child Controls

        protected TextBox Title;
        protected TextBox Description;
        protected TextBox News;
		protected TextBox MetaTagDescription;
		protected TextBox MetaTagKeywords;
		protected ResourceLinkButton SaveButton;
		protected StatusMessage Status;

		#endregion
	
		private void Page_Load(object sender, EventArgs e)
		{
			if(!IsPostBack)
			{
			    Title.Text = this.CurrentGallery.Name;
                Description.Text = this.CurrentGallery.Description;
				MetaTagDescription.Text = this.CurrentGallery.MetaTagDescription;
				MetaTagKeywords.Text = this.CurrentGallery.MetaTagKeywords;
			}
		}

		override protected void OnInit(EventArgs e)
		{
			this.Load += new System.EventHandler(this.Page_Load);
			base.OnInit(e);
			this.SaveButton.Click += new EventHandler(SaveButton_Click);
		}

        private void SaveButton_Click(object sender, EventArgs e)
        {
            if(Page.IsValid)
            {
                CurrentGallery.Name = Title.Text;
                CurrentGallery.Description = Description.Text;
				CurrentGallery.MetaTagDescription = Transforms.StripHtmlXmlTags(MetaTagDescription.Text);
				CurrentGallery.MetaTagKeywords = Transforms.StripHtmlXmlTags(MetaTagKeywords.Text);

            	CommunityServer.Galleries.Galleries.Update(CurrentGallery);

            }
        }
	}
}
