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

using System;
using System.Collections;
using System.Data;
using CommunityServer.Components;

namespace CommunityServer.Files.Components
{
	public class FileGalleryApplication : CSApplicationData
	{
		public FileGalleryApplication()
		{
			//
			// TODO: Add constructor logic here
			//
		}

        public override string Home
        {
            get{ return FileGalleryUrls.Instance().Home;}
        }

        public override string SectionUrl(IContent ic)
        {
            if(ic != null)
            {
                IndexPost ip = ic as IndexPost;
				if(ip != null)
					return FileGalleryUrls.Instance().ViewFolder(ip.ApplicationKey);

                Entry e = ic as Entry;
                if(e != null)
                    return FileGalleryUrls.Instance().ViewFolder(e.Section.ApplicationKey);
            }

            return string.Empty;
        }

		public override string PostName
		{
			get
			{
				return ResourceManager.GetString("FileGalleryApplication_Post");
			}
		}

		public override string SectionName
		{
			get
			{
				return ResourceManager.GetString("FileGalleryApplication_Section");
			}
		}

		public override string GroupName
		{
			get
			{
				return ResourceManager.GetString("FileGalleryApplication_Group");
			}
		}

		public override string CategoryName
		{
			get
			{
				return ResourceManager.GetString("FileGalleryApplication_Category");
			}
		}

		#region Favorite Text

		public override string AddFavoritePostText
		{
			get
			{
				return ResourceManager.GetString("Favorites_FileGallery_AddPost");
			}
		}

		public override string RemoveFavoritePostText
		{
			get
			{
				return ResourceManager.GetString("Favorites_FileGallery_RemovePost");
			}
		}

		public override string AddFavoriteSectionText
		{
			get
			{
				return ResourceManager.GetString("Favorites_FileGallery_AddSection");
			}
		}

		public override string RemoveFavoriteSectionText
		{
			get
			{
				return ResourceManager.GetString("Favorites_FileGallery_RemoveSection");
			}
		}

		#endregion

		public override IList Groups()
		{
			return Folders.GetFolderGroups(true, false, false);
		}

		public override IList Sections()
		{
			return Folders.GetFolders(true, false);
		}

		public override IList SectionsByGroup(int groupID)
		{
			return Folders.GetFoldersByGroupID(groupID, false, true, false);
		}

		public override ApplicationType ApplicationType
		{
			get { return ApplicationType.FileGallery; }
		}

		public override string Name
		{
			get { return ResourceManager.GetString("files");}
		}

		public override string Url(Post post)
		{
			return FileGalleryUrls.Instance().ViewEntry(post.Section.ApplicationKey,post.PostID);
		}

		public override Post InstantiatePost(IDataReader dr)
		{
			return FileGalleryDataProvider.PopulateEntryFromIDataReader(dr, false, false, false, false);
		}

		public override Post GetPost(int postID)
		{
			return Entries.GetEntry(postID);
		}

        public override bool Enabled
        {
            get { return FileGalleryConfiguration.GetConfig().Enabled;}
        }

        public override void SetEnabledStatus(bool enabled)
        {
            FileGalleryConfiguration config = FileGalleryConfiguration.GetConfig(false);
            config.Enabled = enabled;
            config.Save();

        }

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

	}
}

