<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%Option Explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../HSK_Cls/HSK.CommonCls.asp"-->
<!--#include file="../HSK_Cls/HSK.AdministratorCls.asp"-->
<!--#include file="Include/Session.asp"-->
<%
Dim KSCls
Set KSCls = New admin_Push
KSCls.HSK_Run()
Set KSCls = Nothing

Class Admin_Push
        Dim KS,KSCls,ChannelID,Action
        Private Sub Class_Initialize()
		  Set KS=New PublicCls
		  Set KSCls=New ManageCls
		End Sub
        Private Sub Class_Terminate()
		 Call CloseConn()
		 Set KS=Nothing
		 Set KSCls=Nothing
		End Sub
		Sub Kesion
		    ChannelID=KS.ChkClng(KS.S("ChannelID"))
			Action=KS.G("Action")
			Select Case Action
			 Case "pushToClub" pushToClub
			 Case "doPush" doPush
			End Select
        End Sub
		%>
		<!--#include file="../HSK_Cls/ClubFunction.asp"-->
		<%
	 Sub pushToClub()
	 %>
	 <html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312">
	 <link href="include/admin_Style.CSS" rel="stylesheet" type="text/css">
     <script language="JavaScript" src="../HSK_JS/JQuery.js"></script>
	 </head>
	 <body>
	 <form name="myform" action="Push.asp" method="post">
	 <input name="action" type="hidden" value="doPush">
	 <input name="itemid" type="hidden" value="<%=KS.G("IDS")%>">
	 <input name="channelid" type="hidden" value="<%=channelid%>">
	 <div style="padding:5px;"><strong>选择推送到的论坛版块</strong><span id="navlist1"></span><span id="navlist2"></span><br/><div id="boardlist"><img src="../images/loading.gif" /></div>
	  Tips:收费内容，推送到论坛版块后将失效，建议不要将收费内容推送到论坛版块。
	 </div>
	 </form>
	 <script type="text/javascript">
	  $.get("../plus/ajaxs.asp",{action:"getclubboard",anticache:Math.floor(Math.random()*1000)},function(d){
			setHtml(d);
	   });
	   function loadBoard(v){
		  if (v==''||v=='0') return;
		  var str=$("#pid>option:selected").text();
		   $("#navlist1").html("->"+str);
		   $("#navlist2").html("");
		  $.get("../plus/ajaxs.asp",{action:"getclubboard",pid:v},function(d){
			setHtml(d);
		   });
		}
	  function setHtml(h){
	  	$("#boardlist").html(h);
		$("#btns").html('文档ID号:<%=KS.G("IDS")%><br/><br/><label><input type="checkbox" name="istop" value="1">同时设置为置顶</label><br/><label><input type="checkbox" name="isbest" value="1">同时设置为精华</label><br/><br/><input type="submit" value="推送到选定的版块" onclick="return(check())" class="button"/>');
	  }
	  function check(){
	   var bid=$('#bid>option:selected').val();
		 if (bid!='' && bid!=undefined)
		  return true;
		 else{
		  alert('请选择要推送到的版面!');
          return false;}
	  }
	 </script>
	 </body>
	 </html>
	 <%
	 End Sub
	 Sub DoPush()
	   Dim ItemID:ItemId=KS.FilterIds(KS.S("ItemID"))
	   If ItemId="" Then KS.AlertHintScript "请选择要推送的文档!"
	   Dim BoardID:BoardID=KS.ChkClng(KS.S("Bid"))
	   If BoardID=0 Then KS.AlertHintScript "请选择论坛版块！"
	    Dim Node,O_LastPost,N,TopicID,boardname,TopicList,Content,i,Arr,PicArr
	   If BoardID<>0 Then
		 KS.LoadClubBoard()
		 Set Node=Application(KS.SiteSN&"_ClubBoard").DocumentElement.SelectSingleNode("row[@id=" & boardid &"]")
		 O_LastPost=Node.SelectSingleNode("@lastpost").text
		 boardname=Node.SelectSingleNode("@boardname").text
	   End If
	   Dim IsTop:IsTop=KS.ChkClng(KS.S("IsTop"))
	   Dim IsBest:IsBest=KS.ChkClng(KS.S("IsBest"))
	   Dim RS:Set RS=Server.CreateObject("ADODB.RECORDSET")
	   RS.Open "Select u.userid,i.* From " & KS.C_S(ChannelID,2) &" i inner join ks_user u on i.inputer=u.username Where i.ID in(" & ItemID &")",conn,1,1
	   N=0:TopicID=0
	   Do While Not RS.Eof
	     content=""
	     Select Case KS.C_S(ChannelID,6)
		  case 1 Content=RS("ArticleContent")
		  case 2 
		    arr=split(RS("PicUrls"),"|||")
			for i=0 to ubound(arr)
			  PicArr=split(arr(i),"|")
			  content=content & "[img]" &PicArr(1) & "[/img][br]" & PicArr(0) & "[br]"
			next
		      content=content & RS("PictureContent")
		 end select
	    TopicID=InsertPost(BoardID,0,RS("Inputer"),RS("UserID"),RS("Title"),Content,RS("PhotoUrl"),"",0,0,0,0,0,RS("Hits"),IsTop,IsBest,0,O_LastPost)
		 N=N+1
		TopicList=TopicList & n &"、" & RS("Title") & "  <a href='" & KS.GetClubShowUrl(TopicID) & "' target='_blank'>浏览帖子</a><br/>"
	   RS.MoveNext
	   Loop
	   RS.Close
	   Set RS=Nothing
	   %>
	   <html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312">
		 <link href="include/admin_Style.CSS" rel="stylesheet" type="text/css">
		 <script language="JavaScript" src="../HSK_JS/JQuery.js"></script>
		 </head>
		 <body>
	   <%
	   If IsTop=1 Then MustReLoadTopTopic
	   If N>0 Then
	     KS.Echo "<br/><div class=""attention""><span style=""font-weight:bold"">恭喜，您已成功的推送 <span style='color:red'>" & N & "</span> 篇文档到论坛『" & BoardName &" 』版块!</span><br/>"
		  KS.Echo "<br/><input type='button' value='浏览版块' class=""button"" onclick=""window.open('" &KS.GetClubListUrl(BoardID) &"');""/>"

		 
		  KS.Echo "<br/><br/><strong>您还可以浏览以下推送的文档:</strong><br/>" 
		  KS.echo ("<div style=""*height:160px;overflow-x: hidden; overflow-y: auto;"">")
		  KS.Echo TopicList
		  KS.Echo "</div>"
		 
		 KS.Echo "</div>"
	   End If
	  %>
	   </body>
	   </html>
	  <%
	 End Sub
	  
	
		
End Class
%>