<%@ Page language="c#" EnableViewState = "false" Codebehind="Spam.aspx.cs" AutoEventWireup="false" Inherits="CommunityServer.ControlPanel.Blogs.SpamPage" MasterPageFile="~/ControlPanel/Masters/Blogs.master" %>
<%@ Register TagPrefix="CPB" Namespace="CommunityServer.ControlPanel.Blogs" Assembly="CommunityServer.Web" %>
<%@ Import Namespace = "CommunityServer.Components" %>
<%@ Import Namespace = "CommunityServer.Blogs.Components" %>
<%@ Import Namespace = "CommunityServer.ControlPanel" %>

<asp:Content ContentPlaceHolderId="DescriptionRegion" runat="server">
	<CSControl:CSLiteral runat="server" id="CommentTitleLiteral" />
</asp:Content>

<asp:Content ContentPlaceHolderId="TaskRegion" runat="Server">
    <CP:ControlPanelSelectedNavigation SelectedNavItem="Spam" runat="server" id="SelectedNavigation1" />
    <div class="CommonDescription">
	    <CP:ResourceControl runat="server" ResourceName="CP_Blog_Spam_SubTitle" />
    </div>

    <script type = "text/javascript">
    function redirectUrl()
    {
        window.location = window.location; 
    }

    function checkAll(cb, parent)
    {
	    var p =$(parent);
	    var pa = p.getElementsByTagName('INPUT');
	    for(var i=0; i<pa.length; i++)
	    {
		    var e = pa[i];
		    if(e.getAttribute('type') == 'checkbox' && e.name != cb.name)
		    {
		        e.checked = cb.checked;
		    }
	    }
    }

    function bulkEdit(action)
    {
        var result = 'action=' + action + '&postids=';
        var cb = $('master');
	    var pa = $('CommentListing').getElementsByTagName('INPUT');
	    var b = true;
	    for(var i=0; i<pa.length; i++)
	    {
		    var e = pa[i];
		    if(e.getAttribute('type') == 'checkbox' && e.name != cb.name && e.checked)
		    {
		        var delimit = ',';
		        if(b)
		        {
	        	    delimit = '';
	        	    b = false;    
		        }
                result += e.name.replace('cb-',delimit);
		    }
	    }
    	
	    if(window.location.search)
          window.location =   window.location + '&' + result;    
        else
          window.location =   window.location + '?' + result;
    }

    function DeSpamPost(postid)
    {
        Comments.Toggle(postid);
        window.location =  window.location;
    }

    </script>	
    <input type="hidden" id="postId" value="<%= Request.QueryString["pid"] %>" />
    <table cellpadding="0" cellspacing="0" border="0"  width="100%">
	    <tr>
            <td align="left">
                <input style="visibility:<%= MassEditVisibility() %>" type="button" onclick="bulkEdit('despam')" value='<%= CommunityServer.Components.ResourceManager.GetString("CP_Blog_Spam_DeSpamSelected", "ControlPanelResources.xml") %>' />
                <input style="visibility:<%= MassEditVisibility() %>" type="button" onclick="if(confirm('<%= CommunityServer.Components.ResourceManager.GetString("FeedbackEditor_BulkDeleteSelected") %>')){bulkEdit('delete');}" value='<%= CommunityServer.Components.ResourceManager.GetString("FeedbackEditor_DeleteSelected", "ControlPanelResources.xml") %>' />
            </td>
	    </tr>
    </table>
    <div class="CommonListArea">
    <CSControl:WrappedRepeater ShowHeaderFooterOnNone="false" runat = "Server" id="theComments">
    <HeaderTemplate>
        <table id="CommentListing" cellSpacing="0" cellPadding="0" border="0" width="100%">
	        <thead>
		        <tr>
			        <th class="CommonListHeaderLeftMost" width="20px"><input type="checkbox" name="master" id="master" onclick="checkAll(this,'CommentListing');" /></th>
			        <th class="CommonListHeader"><cp:resourcecontrol runat="server" resourcename="CP_Blog_Comments_Comment"/></th>
			        <th class="CommonListHeader PostHeader"><cp:resourcecontrol runat="server" resourcename="CP_Blog_Spam_SpamScore" /></th>											
			        <th class="CommonListHeader">&nbsp;</th>											
		        </tr>
	        </thead>
    </HeaderTemplate>
    <ItemTemplate>
	    <tr>
	    <td class="CommonListCellLeftMost"><input type="checkbox" name="cb-<%# DataBinder.Eval(Container.DataItem,"PostID") %>" /></td>
	    <td class="CommonListCell">
	        <strong><%# DataBinder.Eval(Container.DataItem,"Subject")%></strong><br />
	        <%# DataBinder.Eval(Container.DataItem,"ForceExcerpt") %>
	        <div style="font-size:.8em; color:#959595">
	        <CP:ResourceControl runat="server" ResourceName="CP_Blog_Comments_By" />
	        <%# RenderName( (WeblogPost) Container.DataItem ) %>
	        <CP:ResourceControl runat="server" ResourceName="CP_Blog_Comments_On" />
	        <%# UserTime.ConvertToUserTime((DateTime)DataBinder.Eval(Container.DataItem, "PostDate")).ToString("MMM d, yyyy")%>
	        </div>
	    </td>
	    <td class="CommonListCell Status">
	        <%# DataBinder.Eval(Container.DataItem,"SpamScore") %>
	    </td>
	    <td  class="CommonListCell Status" width="180px">
		    <input id="button-Pub-<%# DataBinder.Eval(Container.DataItem,"PostID") %>" type="button" onclick="DeSpamPost(<%# DataBinder.Eval(Container.DataItem,"PostID") %>)" value="<%# ResourceManager.GetString("CP_Blog_Spam_DeSpam", "ControlPanelResources.xml") %>" />
		    <input type="button" onclick="if(confirm('<%= CommunityServer.ControlPanel.Components.ResourceManager.GetString("CP_Blog_Comments_Delete_Warning") %>')){window.location='<%# GetActionUrl("delete",DataBinder.Eval(Container.DataItem, "PostID"))%>';}" value="<%# ResourceManager.GetString("CP_Blog_GridCol_Delete", "ControlPanelResources.xml")%>" />
	    </td>
	    </tr>
    </ItemTemplate>
    <AlternatingItemTemplate>
	    <tr class="AltListRow">
	    <td class="CommonListCellLeftMost"><input type="checkbox" name="cb-<%# DataBinder.Eval(Container.DataItem,"PostID") %>" /></td>
	    <td class="CommonListCell">
	        <strong><%# DataBinder.Eval(Container.DataItem,"Subject")%></strong><br />
	        <%# DataBinder.Eval(Container.DataItem,"ForceExcerpt") %>
	        <div style="font-size:.8em; color:#959595">
	        <CP:ResourceControl runat="server" ResourceName="CP_Blog_Comments_By" />
	        <%# RenderName( (WeblogPost) Container.DataItem ) %>
	        <CP:ResourceControl runat="server" ResourceName="CP_Blog_Comments_On" />
	        <%# UserTime.ConvertToUserTime((DateTime)DataBinder.Eval(Container.DataItem, "PostDate")).ToString("MMM d, yyyy")%>
	        </div>
	    </td>
	    <td class="CommonListCell Status">
	        <%# DataBinder.Eval(Container.DataItem,"SpamScore") %>
	    </td>
	    <td  class="CommonListCell Status" width="180px">
		    <input id="button-Pub-<%# DataBinder.Eval(Container.DataItem,"PostID") %>" type="button" onclick="DeSpamPost(<%# DataBinder.Eval(Container.DataItem,"PostID") %>)" value="<%# ResourceManager.GetString("CP_Blog_Spam_DeSpam", "ControlPanelResources.xml") %>" />
		    <input type="button" onclick="if(confirm('<%= CommunityServer.ControlPanel.Components.ResourceManager.GetString("CP_Blog_Comments_Delete_Warning") %>')){window.location='<%# GetActionUrl("delete",DataBinder.Eval(Container.DataItem, "PostID"))%>';}" value="<%# ResourceManager.GetString("CP_Blog_GridCol_Delete", "ControlPanelResources.xml")%>" />
	    </td>
	    </tr>
    </AlternatingItemTemplate>	
    <NoneTemplate>
        <div class="CommonMessageWarning">
            <table>
                <tr>
                    <td style="width:35px">
		                <img src="<%=SiteUrls.Instance().Locations["ControlPanel"]%>images/comment/spam.png" />
                    </td>
                    
                    <td>
                        <CP:ResourceControl ID="ResourceControl2" runat="server" ResourceName="CP_Blog_Spam_NoComments" />
                    </td>
                </tr>
            </table>
        </div>
    </NoneTemplate>		
    </CSControl:WrappedRepeater>
    </table>

    <asp:Panel id="HideWhenNoResults" runat="server">
        <div style="margin-top: 5px">
        <table cellpadding="0" cellspacing="0" border="0"  width="100%">
            <tr>
	            <td align="left">
	                <input type="button" onclick="bulkEdit('despam')" value='<%= CommunityServer.Components.ResourceManager.GetString("CP_Blog_Spam_DeSpamSelected", "ControlPanelResources.xml") %>' />
	                <input type="button" onclick="if(confirm('<%= CommunityServer.Components.ResourceManager.GetString("FeedbackEditor_BulkDeleteSelected") %>')){bulkEdit('delete');}" value='<%= CommunityServer.Components.ResourceManager.GetString("FeedbackEditor_DeleteSelected", "ControlPanelResources.xml") %>' />
	            </td>
	            <td align="right">
                    <CSControl:Pager runat="Server" id="csPager" MessageText="More Comments" />
	            </td>
            </tr>
        </table>
        </div>
    </asp:Panel>
    </div>
</asp:Content>