<!--#include file="../../fy.Function.asp"-->
<!--#include file="../../../fy_inc/cls_pageview.asp"-->
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>网站关键字</title>
<link rel="stylesheet" type="text/css" href="../../css/base.css">
<link rel="stylesheet" type="text/css" href="../../css/content.css">
</head>
<body>
<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 网站关键字管理</div>
    <div class="opers">
    	<a href="?Action=add"  class="btn <%If Request("Action")="add" Or  Request("Action")="edit" Then echo " btn_primary" %>">添加/修改网站关键字</a>
	<a href="?"  class="btn<%If Request("Action")="" Then echo " btn_primary" %>">查看网站关键字</a>

    </div><% If Not fycms.ChkAdmin() Then  Call fycms.Alert("对不起，您没有操作权限！","")
	Dim sql, sqlCount,Sqls,intPageSize, strPageInfo,arrinfo, i,pages,intPageNow,strLocalUrl,Action,Title,url,ifs,OpenType
	dim Num,description,OrderID,repset,repcontent
 	Action=Request("Action")
	Dim ShowErr
		IF Request.QueryString("Action") = "del" Then
		Dim ID:ID = Request("ID")
			IF ID = "" Then
				Call fycms.ActErr("请指定要删除的网站关键字","","1")
				Response.end
			End IF
		If instr(ID,",")>0 then
			ID=replace(ID," ","")
			Sql="delete from Sitelink_fy where ID in (" & rsql(ID) & ")"
		Else
			Sql="delete from Sitelink_fy where ID=" &  ChkNumeric(ID) & ""
		End If
 		Conn.Execute sql:Set Conn=Nothing
		Call fycms.DelCahe("ReplaceSitelink")
			Call fycms.ActErr("网站关键字删除成功","include/plus/fy.SiteLink.ASP","")
 	  End IF
	  
	  Select Case Action
	  		Case "edit","add"
				call edit()
			Case "AddSave","EditSave"
				Call Saves()
			Case "px"
				Call px()
			Case Else
				call main()
		end select
		
		
		
	Sub px()
			Dim i,OrderID
			ID = Split(fycms.s("ID"),","):OrderID = Split(fycms.s("OrderID"),",")
			 For I = LBound(ID) To UBound(ID)
 				 	Conn.execute("Update Sitelink_fy set OrderID="&ChkNumeric(OrderID(I))&"  where  ID = "&ChkNumeric(ID(I))&"")
			Next 
			set conn=Nothing
			Call fycms.ActErr("操作成功","include/fy.SiteLink.ASP","")
	End sub
		
	sub main()
	 Dim ACT_TypeDiY,TypeDiY,Manage
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
	intPageNow = request.QueryString("page")
	intPageSize =20
	sql = "SELECT [ID], [Title], [Url], [IFS], [OpenType],[OrderID],[Num]" & _
		" FROM [Sitelink_fy]" & _
		" ORDER BY OrderID Asc,[ID] DESC"
	sqlCount = "SELECT Count([ID])" & _
			" FROM [Sitelink_fy]"
		Dim clsRecordInfo
		Set clsRecordInfo = New Cls_PageView
			clsRecordInfo.intRecordCount = 2816
			clsRecordInfo.strSqlCount = sqlCount
			clsRecordInfo.strSql = sql
			clsRecordInfo.intPageSize = intPageSize
			clsRecordInfo.intPageNow = intPageNow
			clsRecordInfo.strPageUrl = strLocalUrl
			clsRecordInfo.strPageVar = "page"
		clsRecordInfo.objConn = Conn		
		arrinfo = clsRecordInfo.arrinfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
	 %>
    <form name="Article" method="post" action="?Action=">
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>模型ID</th>
	  <th>模型名称</th>
	  <th>表名</th>
	  <th>描述</th>
	  <th>状态</th>
	  <th>生成Html</th>
	  <th>操作</th>
	  </tr>
    </thead>
     	 <%
		Dim bgColor
		If IsArray(arrinfo) Then
			For i = 0 to UBound(arrinfo, 2)
			bgColor="#FFFFFF"
			if i mod 2=0 then bgColor="#DFEFFF"
	%>
    <tr>
      <td>
	  <input type="checkbox" name="ID" value="<%= arrinfo(0,i) %>">	  </td>
      <td><%= arrinfo(1,i) %></td>
      <td><%= arrinfo(2,i) %></td>
      <td>
	  
	  <input name="OrderID"  type="text" class="Ainput" id="OrderID" value="<%=arrinfo(5,i)%>" size="6" maxlength="20" />
	  
 		 	  </td>
      <td><%= arrinfo(6,i) %></td>
		  
      <td><%If  arrinfo(3,i)="1" Then echo "<font color=green>正常</font>":Else echo "<font color=red>禁用</font>"  %></td>
      <td colspan="2" align="center">
	  <a href="?Action=edit&id=<%= arrinfo(0,i) %>">修改</a>┆
	  <a href="?Action=del&ID=<%= arrinfo(0,i) %>" onClick="return confirm('确认删除此网站关键字吗?')">删除</a>	  </td>
    </tr>

<% 
	Next
	End If
	%>

    <tr >
      <td height="30" colspan="8">
	 <label for=chk>
		<input id="chk" type="checkbox" name="chkall" value="checkbox" onClick="CheckAll(this.form)">选择全部</label>
	  <input type="button" class="btn btn_primary"  name="yd" value="批量删除" onClick="delpost()">
	  <input type="button" class="btn btn_primary"  name="px" value=" 批量更新排序 "  onClick="pxpost()">批量排序不需要选中
	  </td>
    </tr>



    </table></form>
    <div class="pagelist">
    	<%= strPageInfo%>
   </div>
     <script language="javascript">
function CheckAll(form)  
  {  
 for (var i=0;i<form.elements.length;i++)  
    {  
    var e = Article.elements[i];  
   if (e.name != 'chkall')  
      e.checked = Article.chkall.checked;  
   }  
  }
//CSS背景控制
 
 function pxpost(){
    document.Article.method="post";
    document.Article.action="?Action=px";
	this.document.Article.submit();
	}

function delpost(){
    document.Article.method="post";
    document.Article.action="?Action=del";
{
	if(confirm('确认要删除选中的Tags吗?')){
	this.document.Article.submit();
	return true;}return false;
}
	}
</script>
  <% end sub
Sub edit() 
	If Action ="edit" Then 
		Dim Rs,ID,A
		id = ChkNumeric(Request.QueryString("id"))
		Set Rs=fycms.actexe("select * from Sitelink_fy Where id="&id&"")
		If rs.eof Then
			Call fycms.alert("未知错误","")
		Else
			Title=Rs("Title")
			url=Rs("url")
			ifs=Rs("ifs")
			Id=Rs("Id")
			OpenType=Rs("OpenType")
			Num=Rs("Num")
			description=Rs("description")
			OrderID=Rs("OrderID")
			repset=Rs("repset")
 			If RS("repcontent") <> "" Then repcontent=Server.HTMLEncode(RS("repcontent"))
		End If
		A="EditSave"
	Else
		ifs=1:repset=1
		A="AddSave"	
		repcontent="<h1>{$content}</h1>"
	End If 
%>

<form name="form1" method="post" action="?action=<%= A %>&ID=<%= ID %>">
    <div class="divtable"> 
        <dl>
            <dt>替换属性：</dt>
            <dd>
              <input type="radio"  onClick=repsets(1) id="repset22" name="repset" value="1"<%If repset="1" Then echo "checked"%>><label for="repset22">替换关键字</label> <input type="radio" onClick=repsets(0)  id="repset11" name="repset" value="0" <%If repset="0" Then echo "checked"%>><label for="repset11">替换指定代码</label>    
            </dd>
         </dl>
        
        <dl>
            <dt>关键字名称：</dt>
            <dd>
               <input name="Title" type="text" class="Ainput" value="<%= Title %>" size=40>
             </dd>
         </dl>
        <dl  id="repset1" <%If repset=1 Then echo "style=""DISPLAY: none"""%> >
            <dt>替换代码：</dt>
            <dd>
               <textarea name="repcontent" cols="40" rows="5" id="repcontent"><%= repcontent %></textarea>
	要替换的代码请用 <font color=red><b>{$content}</b></font> 标签替换
             </dd>
         </dl>
 
        <dl>
            <dt>替换次数：</dt>
            <dd>
               <input name="Num" type="text" class="Ainput" value="<%= Num %>" size=40>最少是一次
             </dd>
         </dl>
 
        <dl>
            <dt>关键字链接：</dt>
            <dd>
               <input name="url" type="text" class="Ainput" value="<%= url %>" size=40>
             </dd>
         </dl>
 
        <dl>
            <dt>替换顺序：</dt>
            <dd>
               <input name="OrderID" type="text" class="Ainput" value="<%= OrderID %>" size=40>数字越小,越先替换
             </dd>
         </dl>


        <dl>
            <dt>链接描述：</dt>
            <dd>
             <textarea name="description" cols="40" rows="5" id="description"><%= description %></textarea>
      不支持HTML
             </dd>
         </dl>

        <dl  id="repset4">
		 <dt>打开方式：</dt>
            <dd>
               <%dim iftrue:iftrue=false%>
      <input name="OpenType" id="OpenType" type="text" class="Ainput" value="<%=OpenType%>" size="8">
      <select   name="OpenTypes"  onchange="document.form1.OpenType.value=this.value">
        <option value="_blank"   style="color:green"  <%If OpenType="_blank" Then echo "selected":iftrue=true%>>新窗口打开</option>
        <option value="_parent" <%If OpenType="_parent" Then echo "selected":iftrue=true%>>父窗口打开</option>
        <option value="_self" <%If OpenType="_self" Then echo "selected":iftrue=true%>>本窗口打开</option>
        <option value="_top" <%If OpenType="_top" Then echo "selected":iftrue=true%>>主窗口打开</option>
        <option value='' style="color:red"  <%If iftrue=false Then echo "selected"%>>自定义</option>
      </select>
             </dd>
         </dl>
 
        <dl id="repset5">
            <dt>是否开启：</dt>
            <dd>
               	<input type="radio" id="ifs1" name="ifs" value="1" <%If ifs=1 Then echo "checked"%>><label for="ifs1">开启</label>
	<input type="radio" id="ifs2" name="ifs" value="0"<%If ifs=0 Then echo "checked"%>><label for="ifs2">关闭</label>          
             </dd>
         </dl>
 
             <dl>
            <dt class="vhid">提交：</dt>
            <dd>
                <a class="btn btn_primary" href="javascript:void(0);" onclick="CheckForm()">提交</a>
					<input name="Submit2" type="reset" class="btn" value="  重置  ">    
					</dd>
         </dl>
        
    </div>
    </form>





<script type="text/javascript">
<!--
	function repsets(n){
	if (n == 1){
 		repset1.style.display='none';
 		repset2.style.display='';
 		repset3.style.display='';
 		repset4.style.display='';
 		repset5.style.display='';
  	}
	else{
		repset1.style.display='';
 		repset2.style.display='none';
 		repset3.style.display='none';
 		repset4.style.display='none';
 		repset5.style.display='none';
  	}
} 
//-->
</script>
<script language="javascript">repsets("<%=repset%>");</script>





<%end sub 


sub saves()
		dim Rs,RsSql
		 url=fycms.S("url")
		 Title=fycms.S("Title")
		 description=fycms.S("description")
 		 ifs=ChkNumeric(fycms.S("ifs"))
		 ID=ChkNumeric(fycms.S("ID"))
		 Num=ChkNumeric(fycms.S("Num"))
		 OrderID=ChkNumeric(fycms.S("OrderID"))
			
		 repset=ChkNumeric(fycms.S("repset"))
		 repcontent=fycms.S("repcontent")
			
 		 OpenType=fycms.S("OpenType")

		  
		 IF fycms.S("Title") = "" Then
			Call fycms.Alert("请添加关键字名称",""):Exit Sub
		 End If
		 
		If Action="AddSave" Then 
			 If Not fycms.ACTEXE("SELECT Title FROM Sitelink_fy Where Title='" & Title & "' order by ID desc").eof Then
				Call fycms.Alert("系统已存在该关键字名称称!",""):Exit Sub
			 End if

			 Set Rs = Server.CreateObject("adodb.recordset")
			  RsSql = "select * from Sitelink_fy"
			  Rs.Open RsSql, Conn, 1, 3
			  Rs.AddNew
		 	  Rs("Title") = Title
		 	  Rs("url") = url
			  Rs("ifs") =ifs
			  Rs("OrderID") =OrderID
			  Rs("description") =description
			  Rs("Num") =Num
			  Rs("OpenType") =OpenType
			  Rs("repset") =repset
			  Rs("repcontent") =repcontent
  
			  Rs.Update
			  Rs.Close:Set Rs = Nothing			
			  Call fycms.DelCahe("ReplaceSitelink")
			  Call fycms.ActErr("操作成功","include/plus/fy.SiteLink.ASP","")
 		Else
		 	If Not fycms.ACTEXE("SELECT Title FROM Sitelink_fy Where ID <>" & ID & " AND  Title='" & Title & "' order by ID desc").eof Then
				Call fycms.Alert("系统已存在该关键字名称!",""):Exit Sub
			 End if	
			 Set Rs = Server.CreateObject("adodb.recordset")
			  RsSql = "select * from Sitelink_fy Where ID="&ID
			  Rs.Open RsSql, Conn, 1, 3
		 	  Rs("Title") = Title
		 	  Rs("url") = url
			  Rs("ifs") =ifs
			  Rs("OrderID") =OrderID
			  Rs("description") =description
			  Rs("Num") =Num
			  Rs("OpenType") =OpenType
			  Rs("repset") =repset
			  Rs("repcontent") =repcontent
			  Rs.Update
			  Rs.Close:Set Rs = Nothing		
			  Call fycms.DelCahe("ReplaceSitelink")
			  Call fycms.ActErr("操作成功","include/plus/fy.SiteLink.ASP","")
 		End If 
end sub
CloseConn %>
<script language="javascript">
function CheckForm()
{ var form=document.form1;
	
	 if (form.Title.value=='')
		{ alert("请输入关键字!");   
		  form.url.focus();    
		   return false;
		} 
  	    form.submit();
        return true;
	}</script> 

</div>
</body>
</html>
