<%@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);
  }

var objv = fnRemoveBrank(theForm.Labelorder.value);
var pattern = /^[0-9]+$/;
  flag = pattern.test(objv);
  if(!flag)
  {
	alert("标签级别要求为数字!请重新输入。");
	theForm.Labelorder.focus();
	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()
LabelID=trim(request.QueryString("LabelID"))
If LabelID<>"" and IsNumeric(LabelID) Then
	sql="select * from JOB_Label where LabelID=" & LabelID
	set rs=server.CreateObject (FR_HR_RS)
	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,"{$GetLink(","")
		LabelContent=Replace(LabelContent,")}","")
		LabelContents=Split(LabelContent,",")
		LabelIntro=Rs("LabelIntro")
		Labelorder=Rs("Labelorder")
	end if
	rs.Close
	Set rs=Nothing
imgs=LabelContents(0)
num=LabelContents(1)
nums=LabelContents(2)
row_num=LabelContents(3)
row_nums=LabelContents(4)
order=LabelContents(5)
font_left=LabelContents(6)
target=LabelContents(7)
tj=LabelContents(8)
else
LabelName=""
LabelIntro="请输入标签介绍..."
Labelorder=0
tj=2
End If
%>
<table width="51%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder">
  <tr>
    <th colspan="2" align="right"><%if LabelID<>"" then:Response.Write("编辑"&LabelName):else:Response.Write("添加友情链接"):end if%>标签</th>
  </tr>
  <form action="?Action=SaveData&LabelID=<%=LabelID%>" method="post" name="labelform" onSubmit="return Juge(this)">
  <tr>
    <td align="right">标签名称：</td>
    <td>{$FR_<input name="LabelName" type="text" size="15" value="<%=LabelName%>" <%if LabelID<>"" and LabelType=<5 then Response.Write("readonly")%> />
      }请输入中文汉字作为标签名称</td>
  </tr>
  <tr>
    <td width="22%" align="right">链接属性：</td>
    <td width="78%"><input name="imgs" type="radio" class="checkbox" value="0" checked>
文字
  <input name="imgs" type="radio" class="checkbox" value="1" <%if imgs=1 then Response.Write("checked")%>>
图片
<input name="imgs" type="radio" class="checkbox" value="2" <%if imgs=2 then Response.Write("checked")%>>
文字+图片</td>
  </tr>
  <tr>
    <td align="right">文字链接个数：</td>
    <td><label>
    <input name="num" type="text" size="4" value="<%=num%>">
      链接属性为图片时,此项不起作用.</label></td>
  </tr>
  <tr>
    <td align="right">文字链接字数：</td>
    <td><input name="font_left" type="text" size="4" value="<%=font_left%>">
      链接属性为图片时,此项不起作用.</td>
  </tr>
  <tr>
    <td align="right">每行显示：</td>
    <td><input name="row_num" type="text" size="4" value="<%=row_num%>">
      个文字链接</td>
  </tr>
  <tr>
    <td align="right">图片链接个数：</td>
    <td><input name="nums" type="text" size="4" value="<%=nums%>">
链接属性为文字时,此项不起作用.</td>
  </tr>
  <tr>
    <td align="right">每行显示：</td>
    <td><input name="row_nums" type="text" size="4" value="<%=row_nums%>">
      个图片链接</td>
  </tr>
  <tr>
    <td align="right">推荐属性：</td>
    <td><input name="tj" type="radio" class="checkbox" value="0" checked>
仅推荐
  <input name="tj" type="radio" class="checkbox" value="1" <%if tj=1 then Response.Write("checked")%>>
仅未推荐
<input name="tj" type="radio" class="checkbox" value="2" <%if tj=2 then Response.Write("checked")%>>
全部</td>
  </tr>
  <tr>
    <td align="right">排序方式：</td>
    <td><label>
      <select name="order">
        <option value="id desc" <%if order="id desc" then Response.Write("selected")%>>按ID正序排列</option>
		<option value="id asc" <%if order="id asc" then Response.Write("selected")%>>按ID反序排列</option>
      </select>
    </label></td>
  </tr>
  <tr>
    <td align="right">打开方式：</td>
    <td><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">标签介绍：</td>
    <td><label>
      <textarea name="LabelIntro" cols="60" rows="4"><%=LabelIntro%></textarea>
    </label></td>
  </tr>
  <tr>
    <td align="right">标签级别：</td>
    <td><input name="Labelorder" type="text" size="4" value="<%=Labelorder%>">
      级别较高标签将被优先转换</td>
  </tr>
  <tr>
    <td colspan="2" align="center"><label>
      <input name="Submit" type="submit" class="inputs" value="保　存">
       　 
      <input name="Submit2" type="reset" class="inputs" value="重　置">　
       <input name="Submit3" type="button" class="inputs" value="取  消" onClick="window.close();">
    </label></td>
  </tr>
  </form>
</table>
<%End Sub%>
</body>
</html>
<%Sub SaveData()
	LabelID=trim(request.QueryString("LabelID"))
	LabelName=Trim(Request.Form("LabelName"))
	If LabelName="" Then
		Response.Write ("<script language=JavaScript>{alert('请输入标签名称！');history.back();}</script>")
		Response.End 
	End If
	LabelName=Replace(LabelName,LabelName,"{$FR_"&LabelName&"}")
	'判断默认方案下是否有同名的标签名称存在
	if LabelID="" then
		sql="select LabelName from job_label where LabelName='"&LabelName&"' and projectid="&DefaultTPID&""
		set rs=Server.CreateObject(FR_HR_RS)
		rs.open sql,conn,1,1
		if not rs.eof then
			Response.Write ("<script language=JavaScript>{alert('同名的标签名称已经存在！');history.back();}</script>")
			Response.End
		end if
		rs.close
		set rs=nothing
	end if
	
	imgs=Trim(Request.Form("imgs"))
	num=Trim(Request.Form("num"))
	if num="" then
		num=20
	end if
	nums=Trim(Request.Form("nums"))
	if nums="" then
		nums=20
	end if
	row_num=Trim(Request.Form("row_num"))
	if row_num="" then
		row_num=8
	end if
	row_nums=Trim(Request.Form("row_nums"))
	if row_nums="" then
		row_nums=8
	end if
	font_left=Trim(Request.Form("font_left"))
	if font_left="" then
		font_left=10
	end if
	order=Trim(Request.Form("order"))
	target=Trim(Request.Form("target"))
	tj=Trim(Request.Form("tj"))
	LabelContent="{$GetLink("&imgs&","&num&","&nums&","&row_num&","&row_nums&","&order&","&font_left&","&target&","&tj&")}"
	LabelIntro=Trim(Request.Form("LabelIntro"))
	Labelorder=Trim(Request.Form("Labelorder"))
	If Labelorder="" then
		Labelorder=0
	end if

	set rs=Server.CreateObject(FR_HR_RS)
	if LabelID<>"" and IsNumeric(LabelID) then
	sql="select * from JOB_Label where LabelID=" & LabelID
	else
	sql="select * from JOB_Label"
	end if
	rs.open sql,conn,1,3
	if LabelID="" then
	rs.AddNew
	rs("LabelType")=6
	rs("Labeladddate")=now()
	end if
	rs("LabelName")=LabelName
	rs("LabelContent")=LabelContent
	rs("LabelIntro")=LabelIntro
	rs("Labelorder")=Labelorder
	rs("Labeleditdate")=now()
	rs("projectid")=DefaultTPID
	rs.update
	rs.close
	set rs=nothing
	Response.Write ("<script language=JavaScript>{alert('操作成功！');window.opener.location.reload();window.close();}</script>")
	Response.End
end sub
%>
