<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../../conn/conn.asp" -->
<!--#include file="../../Inc/Commoncode.asp" -->
<!--#include file="../checkvalid.asp"-->
<%
If Not FRAdminLevel(404) Then
	Call ErrorMsg()
End If
Dim Action
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Finereason HRCMS 7.0 后台管理系统</title>
<link href="../css/style<%=sk%>.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../inc/input.js"></script>
<script language="javascript">
<!--
function fnRemoveBrank(strSource)
{
 return strSource.replace(/^\s*/,'').replace(/\s*$/,'');
}
function String.prototype.lenB()
{
return this.replace(/[^\x00-\xff]/g,"**").length;
}
function Juge(theForm)
{
  if (fnRemoveBrank(theForm.LabelName.value) == "")
  {
    alert("请输入标签名称!");
    theForm.LabelName.focus();
    return (false);
  }
  if (fnRemoveBrank(theForm.Labelorder.value) != "")
  {
	var objv = fnRemoveBrank(theForm.Labelorder.value);
	var pattern = /^[0-9]+$/;
	  flag = pattern.test(objv);
	  if(!flag)
	  {
		alert("标签级别要求为数字!请重新输入。");
		theForm.Labelorder.select();
		return (false);
	   }
   } 
 }
-->
</script></head>
<body>
<%
Action=trim(Request("Action"))
select case Action
	Case "Add"
		Call ShowData()
	Case "Modify"
		Call ShowData()
	Case "SaveData"
		Call SaveData()
end select
Sub ShowData()
ChannelID=Request("ChannelID")
LabelID=Request.QueryString("LabelID")
If LabelID<>"" and IsNumeric(LabelID) Then
	sql="select * from JOB_Label where LabelID="&LabelID
	set rs=server.CreateObject ("ADODB.RecordSet")
	rs.open sql,conn,1,1
	if not rs.eof then
		LabelName=Rs("LabelName")
		LabelName=Replace(LabelName,"{$FR_","")
		LabelName=Replace(LabelName,"}","")
		LabelType=Rs("LabelType")
		LabelContent=Rs("LabelContent")
		LabelContent=Replace(LabelContent,"{$GetArticleList(","")
		LabelContent=Replace(LabelContent,")}","")
		LabelContents=Split(LabelContent,",")
		LabelIntro=Rs("LabelIntro")
		Labelorder=Rs("Labelorder")
	end if
	rs.Close
	Set rs=Nothing
	cid=LabelContents(0)
	tid=LabelContents(1)
	imgs=LabelContents(2)
	num=LabelContents(3)
	styles=LabelContents(4)
	iscommand=LabelContents(5)
	ispic=LabelContents(6)
	ishomecommand=LabelContents(7)
	order=LabelContents(8)
	font_left=LabelContents(9)
	target=LabelContents(10)
	istit=LabelContents(11)
	dates=LabelContents(12)
	picw=LabelContents(13)
	pich=LabelContents(14)
	showtype=LabelContents(15)
	con_left=LabelContents(16)
else
	num=10
	con_left=70
	LabelName=""
	LabelIntro="请输入标签介绍..."
	picw=133
	pich=100
	font_left=16
	Labelorder=0
	styles=1
End If
if ChannelID<>"" then cid=ChannelID
%>
<table width="51%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder">
  <tr>
    <th colspan="2">编辑文章列表标签</th>
    </tr>
<form action="?Action=SaveData&LabelID=<%=LabelID%>" method="post" name="labelform" onSubmit="return Juge(this);">
  <tr>
    <td width="29%" align="right" bgcolor="#FFFFFF">标签名称：</td>
    <td width="71%" bgcolor="#FFFFFF">&nbsp;$FR_
      <input name="LabelName" type="text" size="15" value="<%=LabelName%>" />}请输入中文汉字作为标签名称</td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">所属频道：</td>
    <td bgcolor="#FFFFFF">&nbsp;<select name="cid" onChange="javascript:window.location='GetArticleList.asp?Action=<%=Action%>&LabelID=<%=LabelID%>&ChannelID='+this.options[this.selectedIndex].value;">
	<option value="-1" <%if cid="-1" then Response.Write("selected") %>>当前频道</option>
	<option value="0" <%if cid="0" then Response.Write("selected") %>>全部频道</option>
    <%
	sql="select * from JOB_Channel where ModuleType=10"
	set rsw=conn.execute(sql)
	if not rsw.eof then
		do while not rsw.eof%>
      <option value="<%=rsw("ChannelID")%>" <%if cstr(cid)=cstr(trim(rsw("ChannelID"))) then Response.Write("selected") %>><%=rsw("ChannelName")%></option>
    <%
		rsw.movenext
		loop
	end if
	rsw.close
	set rsw=nothing
	%></select></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">所属栏目：</td>
    <td bgcolor="#FFFFFF">&nbsp;<select name="tid">
		<option value="-1" <%if tid="-1" then Response.Write("selected") %>>当前栏目</option>
        <option value="0" <%if tid="0" then Response.Write("selected") %>>所有栏目</option>		
        <%
		if cid<>"" and cid<>0 and cstr(cid)<>"-1" then
		set rsw=conn.execute("select * from JOB_NewsSort where S_cid="&cid&" order by S_cid asc,S_order asc")
		do while not rsw.eof%>
        <option value="<%=rsw("S_id")%>" <%if tid=trim(rsw("S_id")) then Response.Write("selected") %>><%=rsw("S_name")%></option>
		<%rsw.movenext
		loop
		rsw.close
		set rsw=nothing
		end if
		%>
      </select>	</td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">标题图标：</td>
    <td bgcolor="#FFFFFF">&nbsp;<select name="imgs">
        <option value="0" <%if imgs="0" then Response.Write("selected") %>>不显示图标</option>
        <option value="icon.gif" <%if imgs="icon.gif" then Response.Write("selected") %>>小图标1</option>
		<option value="icon1.gif" <%if imgs="icon1.gif" then Response.Write("selected") %>>小图标2</option>
      </select></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">显示效果：</td>
    <td bgcolor="#FFFFFF">&nbsp;<select name="styles" onChange="ChangePic(this.options[this.options.selectedIndex].value)">
          <option value="1" <%if styles=1 then Response.Write("selected") %>>文章标题列表</option>
          <option value="2" <%if styles=2 then Response.Write("selected") %>>图片加下标题</option>
          <option value="3" <%if styles=3 then Response.Write("selected") %>>图片加右上标题加右下内容</option>
          <option value="4" <%if styles=4 then Response.Write("selected") %>>标题加下内容简介</option>
          <option value="5" <%if styles=5 then Response.Write("selected") %>>幻灯片不带文字</option>
		   <option value="6" <%if styles=6 then Response.Write("selected") %>>幻灯片带文字</option>
      </select></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;<img id="pic" src="img/<%=styles%>.gif" width="309" height="182" /></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">图片大小：</td>
    <td bgcolor="#FFFFFF">&nbsp;宽
      <input name="picw" type="text" id="picw" size="4" value="<%=picw%>" />
      px 高
      <input name="pich" type="text" id="pich" size="4" value="<%=pich%>" />
      px</td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">显示篇数：</td>
    <td bgcolor="#FFFFFF">&nbsp;<input name="num" type="text" size="4" value="<%=num%>"></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">标题字数：</td>
    <td bgcolor="#FFFFFF">&nbsp;<input name="font_left" type="text" size="4" value="<%=font_left%>" /></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">完整标题：</td>
    <td bgcolor="#FFFFFF">&nbsp;<input name="istit" type="checkbox" class="checkbox" value="1" <%if istit=1 then Response.Write("checked")%> />
      显示</td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">栏目名称：</td>
    <td bgcolor="#FFFFFF">&nbsp;<input name="showtype" type="checkbox" class="checkbox" value="1" <%if showtype=1 then Response.Write("checked")%> />
      显示</td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">概况字数：</td>
    <td bgcolor="#FFFFFF">&nbsp;<input name="con_left" type="text" size="4" value="<%=con_left%>" /></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">文章属性：</td>
    <td bgcolor="#FFFFFF">&nbsp;<input name="iscommand" type="checkbox" class="checkbox" value="1" <%if iscommand=1 then Response.Write("checked")%>> 小类推荐 <input name="ispic" type="checkbox" class="checkbox" value="1" <%if ispic=1 then Response.Write("checked")%>> 图片资讯 <input name="ishomecommand" type="checkbox" class="checkbox" value="1" <%if ishomecommand=1 then Response.Write("checked")%>> 首页推荐</td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">显示时间：</td>
    <td bgcolor="#FFFFFF">&nbsp;<select name="dates">
          <option value="0" <%if dates=0 then Response.Write("selected")%>>不显示时间</option>
          <option value="1" <%if dates=1 then Response.Write("selected")%>>某年某月某日</option>
          <option value="2" <%if dates=2 then Response.Write("selected")%>>年/月/日</option>
          <option value="3" <%if dates=3 then Response.Write("selected")%>>月/日</option>
          <option value="4" <%if dates=4 then Response.Write("selected")%>>年\月\日</option>
          <option value="8" <%if dates=8 then Response.Write("selected")%>>年-月-日</option>
          <option value="9" <%if dates=9 then Response.Write("selected")%>>月-日</option>
      </select></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">排序方式：</td>
    <td bgcolor="#FFFFFF">&nbsp;<select name="order">
	  <option value="N_id asc" <%if order="N_id asc" then Response.Write("selected")%>>按ID反序排列</option>
      <option value="N_id desc" <%if order="N_id desc" then Response.Write("selected")%>>按ID正序排列</option>
      <option value="N_hits desc" <%if order="N_hits desc" then Response.Write("selected")%>>按点击次数</option>
      <option value="N_addtime desc" <%if order="N_addtime desc" then Response.Write("selected")%>>按时间正序排列</option>
      <option value="N_addtime asc" <%if order="N_addtime asc" then Response.Write("selected")%>>按时间反序排列</option>
    </select></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">打开方式：</td>
    <td bgcolor="#FFFFFF">&nbsp;<select name="target">
      <option value="_blank" <%if target="_blank" then Response.Write("selected")%>>新窗口打开</option>
      <option value="_self" <%if target="_self" then Response.Write("selected")%>>原窗口打开</option>
    </select></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">标签简介：</td>
    <td bgcolor="#FFFFFF">&nbsp;<textarea name="LabelIntro" cols="40" rows="4"><%=LabelIntro%></textarea></td>
  </tr>
  <tr>
    <td align="right">标签级别：</td>
    <td><input name="Labelorder" type="text" size="4" value="<%=Labelorder%>"> 级别较高标签将被优先转换</td>
  </tr>
  <tr class="td30">
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;<input name="Submit" type="submit" class="inputs" value=" 提 交 " /></td>
  </tr>
</form>
</table>
<%End Sub%>
<%Call CloseConn()%>
</body>
</html>
<script language="javascript">
function ChangePic(id)
{
	document.getElementById("pic").src="img/"+id+".gif";
}
</script>
<%Sub SaveData()
	LabelID=trim(request.QueryString("LabelID"))
	LabelName=Trim(Request.Form("LabelName"))
	LabelName=Replace(LabelName,LabelName,"{$FR_"&LabelName&"}")
	
	if LabelID="" then
		sqlp="select LabelName from job_label where LabelName='"&labelname&"' and projectid="&DefaultTPID&""
		set rsp=Server.CreateObject("ADODB.RecordSet")
		rsp.open sqlp,conn,1,1
		if not rsp.eof then
			response.Write("<script>alert(""使用的标签名称"&LabelName&"已经存在！"");history.go(-1);</script>")
			response.End()
		end if
		rsp.close
		set rsp=nothing	
	end if
		
	cid=Trim(Request.Form("cid"))
	tid=Trim(Request.Form("tid"))
	styles=Request.Form("styles")
	
	imgs=Trim(Request.Form("imgs"))
	if imgs="" then	imgs=0	
	
	picw=Trim(Request.Form("picw"))
	if picw="" then	picw=133
	
	pich=Trim(Request.Form("pich"))	
	if pich="" then pich=100	
	
	num=Trim(Request.Form("num"))	
	if num="" then num=10
	
	font_left=Trim(Request.Form("font_left"))
	if font_left="" then font_left=30
	
	istit=Trim(Request.Form("istit"))
	if istit="" then	istit=0	
	
	showtype=Trim(Request.Form("showtype"))
	if showtype="" then	showtype=0	
		
	con_left=Trim(Request.Form("con_left"))
	if con_left="" then con_left=50
	
		
	iscommand=Trim(Request.Form("iscommand"))
	if iscommand="" then iscommand=0

	ispic=Trim(Request.Form("ispic"))
	if ispic="" then ispic=0

	ishomecommand=Trim(Request.Form("ishomecommand"))
	if ishomecommand="" then ishomecommand=0

	order=Trim(Request.Form("order"))
	Labelorder=Request.Form("Labelorder")
	target=Trim(Request.Form("target"))
	dates=Trim(Request.Form("dates"))
	if dates="" then dates=9

	LabelContent="{$GetArticleList("&cid&","&tid&","&imgs&","&num&","&styles&","&iscommand&","&ispic&","&ishomecommand&","&order&","&font_left&","&target&","&istit&","&dates&","&picw&","&pich&","&showtype&","&con_left&")}"
	LabelIntro=Trim(Request.Form("LabelIntro"))

	If LabelName="" Then
		Response.Write ("<script>{alert('请输入标签名称！');history.back();}</script>")
		Response.End 
	End If

	if LabelID="" then
		sql="Insert into JOB_Label(LabelName,LabelType,LabelContent,Labeladddate,LabelIntro,Labelorder,projectid,Labeleditdate) values('"&LabelName&"',6,'"&LabelContent&"','"&now()&"','"&LabelIntro&"','"&Labelorder&"','"&DefaultTPID&"','"&now()&"')"
	else
		sql="Update JOB_Label set LabelName='"&LabelName&"',LabelContent='"&LabelContent&"',Labeleditdate='"&now()&"',LabelIntro='"&LabelIntro&"' where LabelID="&LabelID&""
	end if
	conn.execute(sql)
	Response.Write ("<script>{alert('操作成功！');window.opener.location.reload();window.close();}</script>")
	Response.End
end sub
%>