<!--#include file="sdcms_check.asp"-->
<%
set sdcms=new Sdcms_Admin
sdcms.Check_admin
sdcms.Check_lever 15
set sdcms=nothing
title="标签管理"
sd_table="sd_tags"
sdcms_head
%>

<div class="sdcms_notice"><span>管理操作：</span><a href="?">标签管理</a></div>
<br>
<ul id="sdcms_sub_title">
	<li class="sub"><%=title%></li> 
</ul>
<div id="sdcms_right_b">
<%
select case action
case "del":del
case "edit":edit
case "save":save
case else:main
end select
closedb
sub main
%>
  <table border="0" align="center" cellpadding="3" cellspacing="1" class="table_b">
    <form name="add" action="?" method="post"  onSubmit="return confirm('确定要执行选定的操作吗？');">
	<tr>
	  <td class="title_bg">选择</td>
      <td class="title_bg">I　D</td>
      <td class="title_bg" width="300">标签</td>
      <td class="title_bg">使用次数</td>
      <td class="title_bg">管理</td>
    </tr>
	<%
	page=request.querystring("page")
	if page="" or not isnumeric(page) then
	page=1
	end if
	pages = 20
	set rs=server.CreateObject("adodb.recordset")
	sql="select id,title,followid,tag_font,tag_size,tag_color from "&sd_table&" order by followid desc"
	rs.open sql,conn,1,1	
	if rs.eof then
	else
	rs.pagesize = pages
	maxpagecount=rs.pagecount
	rs.absolutepage = page 
	rcount1=0
	pagestart=page-5
	pageend=page+5
	if pagestart<1 then
	pagestart=1
	end if
	if pageend>maxpagecount then
	pageend=maxpagecount
	end if
	rcount=rs.RecordCount
	do while not rs.eof and rcount1 <rs.pagesize  
	%>
    <tr onmouseover=this.bgColor='#EBFFDC'; onmouseout=this.bgColor='#ffffff';  bgcolor='#ffffff'>
	 <td align="center"><input name="id"  type="checkbox" onClick="unselectall()"   value="<%=rs(0)%>"></td>
      <td align="center"><%=rs(0)%></td>
	  <td align="center"><span style="font:<%=rs(4)%> <%=rs(3)%>;color:<%=rs(5)%>"><%=rs(1)%></span></td>
	  <td align="center"><%=rs(2)%></td>
	  <td align="center"><a href="?action=edit&id=<%=rs(0)%>">编辑</a> <a <%if rs(2)=0 then%>href="?action=del&id=<%=rs(0)%>" onclick='return confirm("真的要删除?不可恢复!");'<%else%>title="此标签不能被删除"<%end if%>>删除</a></td>
    </tr>
	<%
	rs.movenext
	rcount1=rcount1+1
	loop
	end if         
	%>
	<tr>
      <td colspan="5" class="tdbg" >
	  <span class="right">转到第
		 <select onChange="location.href='?page='+this.value+''">
		 <%for i=1 to maxpagecount%>
		 <option value="<%=i%>" <%if clng(page)=clng(i) then echo "selected" end if%>><%=i%></option>
		 <%next%>
		 </select>页</span>　<input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox"> 全选 
              <select name="action">
			  <option>→操作</option>
			  <option value="del">删除</option>
			  </select> 
             
      <input type="submit" class="bnt01" value="执行"></td>
    </tr>
	<%if rcount>0 then%>
	<tr>
      <td colspan="5" class="tdbg" align="center"><%
if page<>"1" then
echo "<a href=?page="&page-1&">上一页</a> "
else
echo "上一页 "
end if
for i=pagestart to pageend
if i=0 then 
i=1
end if
if i=clng(page) then
str="<font color=red><b>"&i&"</b></font>"
else
str=i
end if
strurl="[<a href=?page="&i&">"&str&"</a>]"
echo strurl
next
if page=maxpagecount then
echo " 下一页"
elseif  page<>""&maxpagecount&"" then
echo " <a href=?page="&page+1&"&stype="&stype&"&classid="&classid&">下一页</a>"
else
echo " 下一页"
end if
echo " 页次:"&page&"/"&maxpagecount&" 页   每页: "&pages&" 条  总数: "&rcount&" 条"
%></td>
	  </tr>
	  <%end if%>
	</form>
  </table>

<%
end sub

Sub Edit
set rs=conn.execute("select id,title,tag_font,tag_size,tag_color from "&sd_table&" where id="&id&"")
if rs.eof then
echo "请勿非法提交参数":Died
end if
%>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1">
  <form name="add" method="post" action="?action=save&id=<%=id%>" onSubmit='return checkadd()'>
    <tr>
      <td width="12%" align="center" class="tdbg">标签效果：      </td>
      <td class="tdbg"><span id="tags" style="font:<%=rs(3)%> <%=rs(2)%>;color:<%=rs(4)%>"><%=rs(1)%></span></td>
    </tr>
    <tr class="tdbg">
      <td align="center">字体选择：      </td>
      <td><select name="t0" id="t0" onchange="$('tags').style.fontFamily=this.value;">
        <option value="宋体" <%=w_select(rs(2),"宋体")%>>宋体</option>
        <option value="黑体" <%=w_select(rs(2),"黑体")%>>黑体</option>
        <option value="雅黑" <%=w_select(rs(2),"雅黑")%>>雅黑</option>
      </select>
      </td>
    </tr>
    <tr class="tdbg">
      <td align="center">字体大小：      </td>
      <td><select name="t1" id="t1" onchange="$('tags').style.fontSize=this.value;">
	  <%for i=12 to 20 step 2%>
          <option value="<%=i%>px" <%=w_select(rs(3),i&"px")%>><%=i%>px</option>
	  <%next%>
      </select>
      </td>
    </tr>
	<tr class="tdbg">
      <td align="center">字体颜色：      </td>
      <td><select name="t2" id="t2" onchange="$('tags').style.color=this.value;">
	  <%all_color="#000|#ff0|#f00|#fff|#00f|#0f0"
	  all_color=split(all_color,"|")
	  for k=0 to ubound(all_color)%>
          <option style="background:<%=all_color(k)%>;color:#333;" value="<%=all_color(k)%>" <%=w_select(rs(4),all_color(k))%>><%=all_color(k)%></option>
	  <%next%>
      </select>
      </td>
    </tr>
    <tr class="tdbg">
	  <td>&nbsp;</td>
      <td><input name="Submit" type="submit" class="bnt" value="保 存">
        <input type="button" onClick="history.go(-1)" class="bnt" value="返 回"></td>
    </tr>
	</form>
  </table>
<%
End Sub

Sub Save
t0=trim(request("t0"))
t1=trim(request("t1"))
t2=trim(request("t2"))

set rs=server.CreateObject("adodb.recordset")
sql="select tag_font,tag_size,tag_color from "&sd_table&"  where id="&id&""
rs.open sql,conn,1,3
rs.update
rs(0)=left(t0,4)
rs(1)=left(t1,4)
rs(2)=left(t2,4)
rs.update
rs.close
set rs=nothing
response.Redirect("?")
End Sub
 
sub del
if id<>"" then
	if instr(id,", ")>0 then
	id=split(id,", ")
		for i=0 to ubound(id)
			conn.execute("Insert into sd_log (sdcms_name,ip,content) values('"&sdcms_adminname&"','"&sdcms_adminip&"','删除标签：编号为"&id(i)&"')")
			conn.execute("delete from "&sd_table&" where id="&id(i)&" and followid=0")
		Next
	Else
		conn.execute("Insert into sd_log (sdcms_name,ip,content) values('"&sdcms_adminname&"','"&sdcms_adminip&"','删除标签：编号为"&id&"')")
		conn.execute("delete from "&sd_table&" where id="&id&" and followid=0")
	End If
end if
	response.Redirect("?")
end sub
%>  
</div>
</body>
</html>