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

using System;
using System.Web.UI.WebControls;
using CommunityServer.Reader.Components;

namespace CommunityServer.Reader.Controls
{
	/// <summary>
	/// Summary description for FolderListing.
	/// </summary>
	public class FeedProperties : FeedReaderTemplatedWebControl
	{

		#region Private Members

		private Literal lTitle;
		private Literal lUrl;
		private Literal lLink;
		private Literal lLanguage;
		private Literal lGenerator;
		private Literal lSubscribeDate;
		private Literal lLastUpdateDate;
		private Literal lState;
		private Literal lSubscribeCount;
		private Literal lPostCount;
		private Literal lStateDescription;
		private Literal lUrlUrl;
		private Literal lLinkUrl;

		#endregion

		#region Constructor(s)

		public FeedProperties()
		{
			
		}

		#endregion

		#region Class Methods

		protected override void AttachChildControls()
		{

			lTitle			= (Literal) FindControl("lTitle");
			lUrl			= (Literal) FindControl("lUrl");
			lLink			= (Literal) FindControl("lLink");
			lLanguage		= (Literal) FindControl("lLanguage");
			lGenerator		= (Literal) FindControl("lGenerator");
			lSubscribeDate	= (Literal) FindControl("lSubscribeDate");
			lLastUpdateDate	= (Literal) FindControl("lLastUpdateDate");
			lState			= (Literal) FindControl("lState");
			lSubscribeCount = (Literal) FindControl("lSubscribeCount");
			lPostCount		= (Literal) FindControl("lPostCount");
			lStateDescription = (Literal) FindControl("lStateDescription");
			lUrlUrl			= (Literal) FindControl("lUrlUrl");
			lLinkUrl		= (Literal) FindControl("lLinkUrl");
			
		}

		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad (e);
			DataBind();
		}


		public override void DataBind()
		{
			base.DataBind ();

			CommunityServer.Controls.Head.AddTitle(FeedReaderResourceManager.GetString("reader_feed_props_label"), this.Context);
			
			string[] feedInputs = Page.Request.QueryString["ID"].Split('-');
			int feedId = 0;


			if (feedInputs.Length > 1)
			{
				feedId = Convert.ToInt32(feedInputs[1]);
			}	
		

			if (feedId != 0)
			{
				Feed feed = FeedReaderDataProvider.Instance().GetFeedProperties(feedId);


				lTitle.Text				= feed.Title;
				lUrl.Text				= feed.Url;
				lUrlUrl.Text			= feed.Url;
				lLinkUrl.Text			= feed.Link;
				lLink.Text				= feed.Link;
				lLanguage.Text			= feed.Language;
				lGenerator.Text			= feed.Generator;
				lSubscribeDate.Text		= feed.SubscribeDate.ToString();
				lLastUpdateDate.Text	= feed.LastUpdateDate.ToString();
				lState.Text				= feed.StateName;
				lStateDescription.Text	= feed.StateDescription;
				lSubscribeCount.Text	= feed.SubscribeCount.ToString();
				lPostCount.Text			= feed.PostCount.ToString();

			}
		}

		#endregion

		#region Callbacks


		#endregion


	}
}
