<!--#include file="../../conn.asp"-->
<!--#include file="setup.asp"-->
<!--#include file="const.asp"-->
<!--#include file="check.asp"-->
<%
Admin_header
'=====================================================================
' 软件名称：新云网站管理系统
' 当前版本：NewAsp Content Management System Version 4.0
' 文件名称：getTags.asp
' 更新日期：2008-06-16
' 官方网站：新云网络(www.NewAsp.net www.NewAsp.cn) QQ：94022511
'=====================================================================
' Copyright 2003-2008 NewAsp.net - All Rights Reserved.
' newasp is a trademark of NewAsp.net
'=====================================================================
Dim maxperpage,totalrec,Pcount,pagelinks,showmode,pagenow,topcount,count,Taglist
Dim Action,i,iCount,lCount
maxperpage=100
Action = LCase(Request("action"))
Select Case Trim(Action)
Case "del"
	Call delTag()
Case Else
	Call showmain()
End Select
If FoundErr = True Then
	ReturnError(ErrMsg)
End If
Admin_footer
NewAsp.PageEnd

Sub showmain()
	Dim Rs,SQL,n,ii
	pagenow=NewAsp.ChkNumeric(Request("page"))
	If pagenow=0 Then pagenow=1
	count=NewAsp.ChkNumeric(Request("count"))
	If count=0 Then
		totalrec=NewAsp.Execute("SELECT COUNT(*) FROM NC_Tags WHERE ChannelID="&ChannelID)(0)
	Else
		totalrec=count
	End If
%>
<table  border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<tr>
	<th colspan="5">选择标签</th>
</tr>
<tr>
	<td colspan="5" class="tablerow1">已插入标签：<input id="Knowntag" type="text" size="80"> <input type="button" name="close_button" onclick="top.close()" value="关闭窗口" class="button"></td>
</tr>
<%
	Pcount = CLng(totalrec / maxperpage)
	If Pcount < totalrec / maxperpage Then Pcount = Pcount + 1
	If pagenow>Pcount Then pagenow=1
	Set Rs=NewAsp.CreateAXObject("ADODB.Recordset")
	SQL="SELECT TagID,Tagname,Tagcount FROM NC_Tags WHERE ChannelID="&ChannelID&" ORDER BY TagID DESC"
	Rs.Open SQL,Conn,1,1
	If pagenow >1 Then
		Rs.Move (pagenow-1) * maxperpage
	End If
	If Not (Rs.BOF And Rs.EOF) Then
		Taglist=Rs.GetRows(maxperpage)
	Else
		Taglist=Null
	End If
	Rs.close()
	Set Rs=Nothing

	pagelinks="?channelid="&ChannelID&"&count="&totalrec&"&"
	iCount=2:lCount=2:n=0
	If IsArray(Taglist) Then
		For i=0 To Ubound(Taglist,2)
			If Not Response.IsClientConnected Then Response.End
			If (i Mod 2) = 0 Then iCount=2 Else iCount=1
			If i=0 Then Response.Write "<tr align=""center"">" & vbNewLine
			Response.Write "<td class=""tablerow"&iCount&""">"
			Response.Write "<a href=""#"" onClick=""addTags('"&Taglist(1,i)&"')"" title=""点击名称自动插入"">" &Taglist(1,i)& "(" &Taglist(2,i)& ")</a>"
			Response.Write "</td>" & vbNewLine
			n=n+1
			If (n Mod 5) = 0 Then
				Response.Write "</tr>" & vbNewLine
				If n<maxperpage And n<totalrec Then Response.Write "<tr align=""center"">" & vbNewLine
			End If
		Next
		If (n Mod 5) > 0 Then
			For ii=1 To 5-(n Mod 5)
				If (i Mod 2) = 0 Then iCount=2 Else iCount=1
				i=i+1
				Response.Write "<td class=""tablerow"&iCount&""">&nbsp;</td>" & vbNewLine
			Next
			Response.Write "</tr>" & vbNewLine
		End If
	End If
%>
<tr>
	<td class="tablerow2" width="20%"><input type="button" name="closeButton" onclick="top.close()" value="关闭窗口" class="button"></td>
	<td colspan="4" class="tablerow2"><%Call showpage(pagenow,Pcount,maxperpage,totalrec,pagelinks)%></td>
</tr>
</table>
<script language= JavaScript>
function return_value(txt){
	if(!detectMacXFF()){
		window.returnValue=txt;
	}else{
	   parent.opener.document.myform.Tagstring.value=txt;
   }
   top.close();
}
if(!detectMacXFF()){
	var tagObj=window.dialogArguments.document.getElementById("Tagstring");
}else{
	var tagObj=opener.document.getElementById("Tagstring");
}
document.getElementById("Knowntag").value=tagObj.value;
function addTags(tagName) {
	var tags;
	if (tagObj.value.length>0) {
		tags=tagObj.value.split(" ")
		for (i=0;i<tags.length;i++){
			if (tags[i].toLowerCase()==tagName.toLowerCase()) {alert("此标签已经插入："+tagName);return;}
		}
		tagObj.value+=" "+tagName;
	}
	else{
		tagObj.value+=tagName;
	}
	document.getElementById("Knowntag").value=tagObj.value;
	{if(confirm('你已成功插入标签：'+tagName+'\n\n点击确定完成标签插入，点击取消继续。')){top.close();}return false;}
}
</script>
<%
End Sub

Sub delTag()
	Dim tagidlist
	tagidlist = NewAsp.CheckIDlist(Request("tagid"))
	NewAsp.Execute ("DELETE FROM NC_Tags WHERE TagID in ("&tagidlist&")")
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub

%>
