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

using System;
using System.Collections;
using CommunityServer.Components;
using CommunityServer.Configuration;

namespace CommunityServer.Discussions.Components
{
	/// <summary>
	/// Summary description for ForumRssWriter.
	/// </summary>
    public class ForumRssWriter : BaseForumsRssWriter
    {
        protected int ForumID;
		

        public ForumRssWriter(ArrayList posts, Section s, string baseUrl):base(posts,s,baseUrl)
        {
		        ForumID = s.SectionID;
        }

        /// <summary>
        /// Output the header contents of the channel element.
        /// </summary>
        protected override void WriteChannel()
        {
            BuildChannel(ForumUrls.Instance().Forum(ForumID),CurrentSection.Description, CurrentSection.DefaultLanguage );
        }

        protected override bool AllowComments
        {
            get
            {
                return false;
            }
        }

		protected override void PostComments(Post p)
		{
			base.PostComments (p);
			this.WriteElementString("comments", FormatUrl(SiteUrls.Instance().Post(p.PostID)));

			string url = FormatUrl(ForumUrls.Instance().CommentRss(p.SectionID, p.PostID));
			CSContext cntx = CSContext.Current;
			if (!cntx.IsUserTokenRequest)
				this.WriteElementString("wfw:commentRss", url);
			else
				this.WriteElementString("wfw:commentRss", SiteUrls.FormatUrlWithUserNameToken(url, cntx.User, true));
		}


    }
}
