<%@ Control Language="C#" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Config" %>
<%@ Import Namespace="Kesion.Components" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="Kesion.UCenter" %>
<%@ Import Namespace="Kesion.XML" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>
<script runat="server" type="text/C#">

    dynamic __user = HttpContext.Current.Items["user"];                //初始化用户信息
    bool isLoadPage = true;  //定义页面是否加载


    int recordcount, pagecount;
    int CurrPage = new BasicField().GetCurrPage;
    int PageSize = 10;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (KSCMS.S("action") == "delete")
        {
            isLoadPage = false;
            DoDelete();
            return;
        }else  if (KSCMS.S("action") == "del")
        {
            isLoadPage = false;
            delContent();
            return;
        }
    }

    private void DoDelete()
    {
        #region 批量删除
        string ids = Utils.FilterIDs(KSCMS.S("ids"));
        int n = 0;
        if (!string.IsNullOrEmpty(ids))
        {
            using (DataTable dt = DataFactory.GetDataTable("select infoid from KS_InfoList Where verify<>1 and InfoID in(" + ids + ")"))
            {
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        n++;
                        ContentManage.UserDelContent(dr["infoid"].ToString());
                    }
                }
            }
            if (n > 0)
            {
                Msg.Alert("恭喜，成功删除了"+n+"条记录!",KSCMS.GetComeUrl());
            }
            else
            {
                Msg.Alert("对不起，没有记录被删除!",KSCMS.GetComeUrl());
            }
        }
        else
        {
            Msg.Alert("对不起，您没有选择要删除的记录!",KSCMS.GetComeUrl());
        }
        #endregion
    }
    private void delContent()
    {

        string id = Utils.StrToInt(KSCMS.S("id")).ToString();
        if (id.Equals("0")) return;
       
        if (ContentManage.UserDelContent(id).Equals("success"))
        {
            
        }
        KSCMS.Redirect(KSCMS.GetComeUrl());
    }

    public string GetStatus(int verify)
    {
        switch (verify)
        {
            case 0:
                return "<span style='color:red'>未审核</span>";
            case 1:
                return "已审核";
            case 2:
                return "<span style='color:blue'>草稿</span>";
            case 3:
                return "<span style='color:green'>退稿</span>";
            default:
                return "";

        }
    }
</script>
<%
    if (!isLoadPage) return;
%>

<div class="r_tybox nomar">
   <div class="r_title"><h4>发布信息</h4>
        <div class="tabs">	
            
    			<ul>
    				<li ><a href="<%=BasicField.GetUserUrl("space/blogedit") %>">空间参数设置</a></li>
                    <li class='puton'><a href="<%=BasicField.GetUserUrl("content/PostManage") %>">我的文章</a></li>

    			</ul>
        </div>
	</div>
    <div class="top-sort clearfix ">
        <div class=" top-sort-tab fl">
            <li<%if (string.IsNullOrEmpty(KSCMS.S("s"))) Response.Write (" class='puton'"); %>><a href="<%=BasicField.GetUserUrl("content/postmanage") %>">全部</a></li>
               <li<%if (KSCMS.S("s")=="0") Response.Write (" class='puton'"); %>><a href="<%=BasicField.GetUserUrl("content/postmanage","s-0") %>">待审核信息</a></li>
               <li<%if (KSCMS.S("s")=="1") Response.Write (" class='puton'"); %>><a href="<%=BasicField.GetUserUrl("content/postmanage","s-1") %>">已审核信息</a></li>
               <li<%if (KSCMS.S("s")=="2") Response.Write (" class='puton'"); %>><a href="<%=BasicField.GetUserUrl("content/postmanage","s-2") %>">草稿信息</a></li>
               <li<%if (KSCMS.S("s")=="3") Response.Write (" class='puton'"); %>><a href="<%=BasicField.GetUserUrl("content/postmanage","s-3") %>">退稿信息</a></li>
               <li></li>
        </div>
        <div class="top-sort-option rf">
                <a class="green-bt" href="<%=BasicField.GetUserUrl("content/postinfo") %>">发表文章</a>
        </div>

    </div>

  
    <iframe src="about:blank" name="hidframe" style="display:none;width:0px;height:0px"></iframe>
       <form name="myform" action="{$GetCurrUrl}" method="post" id="myform" target="hidframe">
        <input type="hidden" name="action" value="delete"/>
      <table id="tablist" width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
      <tr class="title">
        	<td width="50" align="center">选择</td>
        	<td align="center">标题</td>
            <td align="center" width="110"> 录入 </td>
            <td width="100" align="center"> 更新时间 </td>
            <td align="center" width="50">状态</td>
	        <td align="center" width="120">管理操作</td>
        </tr>
       <%
           string param = " WHERE deltf=0 and Inputer='"+Utils.RemoveXss(Utils.ChkSQL((new TemporaryVar()).UserName))+"'";
           if (!string.IsNullOrEmpty(KSCMS.S("s")))
           {
               param += " And Verify=" + Utils.StrToInt(KSCMS.S("S"));
           }
           using (DataTable dt = DataFactory.GetPage("ChannelID,ClassID,InfoID,Title,Inputer,AddDate,Hits,Verify", "[KS_InfoList]" + param, "Infoid", "order by infoid desc", CurrPage,PageSize, out recordcount, out pagecount))
           {
               if (dt.Rows.Count > 0)
               {
                   foreach(DataRow dr in dt.Rows)
                   {
                       %>
               <tr class="tdbg">
                  <td class="splittd" align="center">
                  <input type="checkbox"<%= Convert.ToString(dr["Verify"].ToString())=="1"?" disabled":"" %> name="ids" value="<%=dr["InfoID"].ToString() %>" /></td>
                  <td class="splittd">
                  <a href='<%=BasicField.GetItemUrl(Utils.StrToInt(dr["channelid"].ToString()),Utils.StrToInt(dr["InfoID"].ToString()),Utils.StrToInt(dr["ClassID"].ToString())) %>' target="_blank"><%=dr["Title"].ToString()%></a>
                  </td>
                  <td class="splittd" align="center"><%=dr["Inputer"].ToString() %></td>
                  <td class="splittd" align="center" style="white-space:nowrap;">
                  <%=Utils.FormatHumanizedTime(Convert.ToDateTime(dr["AddDate"].ToString()))%>
                  </td>
                  <td class="splittd" align="center">
                  <%=GetStatus(Convert.ToInt16(dr["Verify"].ToString())) %>
                  </td>
                  <td class="splittd" align="center">
                      <%= (Convert.ToString(dr["Verify"].ToString())!="1" || (Convert.ToString(dr["Verify"].ToString())=="1" && MyCache.GetCacheModel(Convert.ToInt16(dr["ChannelID"].ToString()),28)!="0"))?@"<a href="""+BasicField.GetUserUrl("content/Postinfo","classid-"+dr["classid"].ToString()+",infoId-"+dr["infoid"].ToString())+@""">修改</a> <a href=""javascript:;"" onclick=""$.dialog.confirm('确定删除吗?',function(){location.href='"+BasicField.GetUserUrl("content/postManage","action-del,id-"+dr["InfoID"].ToString())+@"';},function(){});"">删除</a>":"-"%>
                  </td>
              </tr> 
                       <%

                   }
               }else
               {
                   KSCMS.W(@"  <tr class=""tr-nobor"">
                        <td class=""splittd"" style=""text-align:center"" colspan=""10"">
                          <div class=""empty"">找不到任何记录！</div>
                        </td>
                   </tr><style>.cz_btn{display:none;}</style>");
               }
           }
       %>
    </table>


 </form>
 		<div class="cz_btn">
        <div class="f-left">
          <%
            #region 分页
            string PageStr = "[KS:PageStr2]";
            BasicField.ReplaceFilterPage(ref PageStr, CurrPage, PageSize, pagecount, recordcount);
            KSCMS.W(PageStr);
            #endregion
         %>
        </div>
        <div class="f-right">
             <span class="mt5 allCheck"><input type="checkbox" name="chkall" id="chkall" onclick="CheckAll(this.form);"/>全选</span>
             <span><input type="submit" id="ButtonDel" class="button grey-bt"  onmousedown="return(GetIDS());"  value="删除" /></span>
        </div>

		</div>

          
  
 </div>