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

using System.Xml;
using CommunityServer.Components;

namespace CommunityServer.Galleries.Components
{
	/// <summary>
	/// Summary description for GalleryFormattingModule.
	/// </summary>
	public class GalleryFormattingModule : ICSModule
	{
		public GalleryFormattingModule()
		{

		}

	    public void Init(CSApplication csa, XmlNode node)
	    {
	        csa.PreSectionUpdate +=new CSSectionEventHandler(csa_PreSectionUpdate);
        }

        private void csa_PreSectionUpdate(Section section, CSEventArgs e)
        {
            if(e.ApplicationType == ApplicationType.Gallery && (e.State == ObjectState.Create || e.State == ObjectState.Update))
            {
                Gallery g = section as Gallery;
                g.Description = HtmlScrubber.Clean(g.Description,true,true);
                g.Name = HtmlScrubber.Clean(g.Name,true,true);
                //g.News = HtmlScrubber.Clean(g.News,true,true);
                g.AboutTitle = HtmlScrubber.Clean(g.AboutTitle,true,true);
                g.AboutDescription = HtmlScrubber.Clean(g.AboutDescription,true,true);

				// These values are inserted into a HTML tag attrib, so we cannot allow HTML
				g.MetaTagDescription = Transforms.StripHtmlXmlTags(g.MetaTagDescription);
				g.MetaTagKeywords = Transforms.StripHtmlXmlTags(g.MetaTagKeywords);
				
            }
        }
    }

}
