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

using System;
using System.Collections;
using System.Data;

namespace CommunityServer.Components
{
	/// <summary>
	/// Summary description for IApplication.
	/// </summary>
	public abstract class CSApplicationData : IComparable
	{
		public abstract IList Groups();
		public abstract IList Sections();
		public abstract IList SectionsByGroup(int groupID);
		public abstract ApplicationType ApplicationType { get;}
		public abstract string Name { get;}

        public abstract string Home { get;}

        public abstract string SectionUrl(IContent ic);

		public virtual string SectionName
		{
			get
			{
				return ResourceManager.GetString("Application_Section");
			}
		}

		public virtual string PostName
		{
			get
			{
				return ResourceManager.GetString("Application_Post");
			}
		}

		public virtual string GroupName
		{
			get
			{
				return ResourceManager.GetString("Application_Group");
			}
		}

		public virtual string CategoryName
		{
			get
			{
				return ResourceManager.GetString("Application_Category");
			}
		}

		#region Favorite Text

		public virtual string AddFavoritePostText
		{
			get
			{
				return ResourceManager.GetString("Favorites_General_AddPost");
			}
		}

		public virtual string RemoveFavoritePostText
		{
			get
			{
				return ResourceManager.GetString("Favorites_General_RemovePost");
			}
		}

		public virtual string AddFavoriteSectionText
		{
			get
			{
				return ResourceManager.GetString("Favorites_General_AddSection");
			}
		}

		public virtual string RemoveFavoriteSectionText
		{
			get
			{
				return ResourceManager.GetString("Favorites_General_RemoveSection");
			}
		}

		#endregion

        public virtual Section GetSectionByID(int sectionID)
        {
            foreach(Section section in Sections())
            {
                if(section.SectionID == sectionID)
                    return section;
            }

            return null;
        }

        public virtual bool IsSearchable
        {
            get { return true;}
        }

		public virtual bool SupportsTags
		{
			get { return true; }
		}

        public abstract string Url(Post post);

		public abstract Post GetPost(int postID);

        public abstract Post InstantiatePost(IDataReader dr);

        public abstract bool Enabled{ get;}
		public abstract void SetEnabledStatus(bool enabled);

		#region IComparable Members

		public int CompareTo(object obj)
		{
			return this.Name.CompareTo(((CSApplicationData) obj).Name);
		}

		#endregion
	}

    public abstract class EmptyCSApplicationData : CSApplicationData
    {
        public override IList Groups()
        {
            return new ArrayList();
        }

        public override IList Sections()
        {
            return new ArrayList();
        }

        public override IList SectionsByGroup(int groupID)
        {
            return new ArrayList();
        }

        public override string Url(Post post)
        {
            return null;
        }

        public override Post InstantiatePost(IDataReader dr)
        {
           return null;
        }

		public override Post GetPost(int postID)
		{
			return null;
		}

        public override string Home
        {
            get { return string.Empty;}
        }

        public override string SectionUrl(IContent ic)
        {
            return string.Empty;
        }

        public override bool IsSearchable
        {
            get
            {
                return false;
            }
        }

    }
}
