<!--#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>
<% If Not fycms.ChkAdmin() Then '超级管理员检测
	Call fycms.fycmsErr("")
 End If 
	Dim ShowErr,PlusName,PlusIntro,IsUse,PlusID,PlusUrl,Action,OrderID
	Action = fycms.S("A")%>
<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 插件管理</div>
    <div class="opers">
     	<a href="?A=A" class="btn<%If Action="A" Then echo " btn_primary" %>">添加新插件</a>
     </div>
<% 

	Select Case Action
			Case "A","E"
				Call EditAdd()
			Case "AddSave","EditSave"
				Call SavePlus()
			Case "D"
				Call DelPlus()
			Case Else 
				Call main()
	End Select 

	Sub DelPlus()
		Dim id 
		ID=ChkNumeric(fycms.S("ID"))
		fycms.ACTEXE("Delete From Plus_fy Where ID=" & ID)
		Call fycms.ActErr("删除插件成功","include/fy.Plus.asp","")		
 	End Sub 
	Sub SavePlus()
		Dim PlusRS,PlusSql,ID
		 PlusName=fycms.S("PlusName")
		 PlusIntro=fycms.S("PlusIntro")
		 IsUse=ChkNumeric(fycms.S("IsUse"))
		 OrderID=ChkNumeric(fycms.S("OrderID"))
		 ID=ChkNumeric(fycms.S("ID"))
		 PlusID=fycms.S("PlusID")
		 PlusUrl=fycms.S("PlusUrl")
		 IF fycms.S("PlusName") = "" Then
			Call fycms.Alert("请输入插件名称!",""):Exit Sub
		 End if
		 IF fycms.S("PlusUrl") = "" Then
			Call fycms.Alert("请输入管理地址!",""):Exit Sub
		 End if
		If Action="AddSave" Then 
			 IF fycms.S("PlusID") = "" Then
				Call fycms.Alert("请输入插件标识符!",""):Exit Sub
			 End if
			 If Not fycms.ACTEXE("SELECT PlusName FROM Plus_fy Where PlusName='" & PlusName & "' order by ID desc").eof Then
				Call fycms.Alert("系统已存在该插件名称!",""):Exit Sub
			 End if	
			 If Not fycms.ACTEXE("SELECT PlusID FROM Plus_fy Where PlusID='" & PlusID & "' order by ID desc").eof Then
				Call fycms.Alert("系统已存在该插件标识符!",""):Exit Sub
			 End if	
			 Set PlusRS = Server.CreateObject("adodb.recordset")
			  PlusSql = "select * from Plus_fy"
			  PlusRS.Open PlusSql, Conn, 1, 3
			  PlusRS.AddNew
		 	  PlusRS("PlusName") = PlusName
		 	  PlusRS("PlusIntro") = PlusIntro
		 	  PlusRS("IsUse") = IsUse
		 	  PlusRS("PlusUrl") = PlusUrl
			  PlusRS("PlusID")=fycms.S("PlusID")
			  PlusRS("OrderID") = OrderID
			  PlusRS.Update
			  PlusRS.Close:Set PlusRS = Nothing	
			  Call fycms.ActErr("添加成功","include/fy.Plus.asp","")		
 		Else
		 	If Not fycms.ACTEXE("SELECT PlusName FROM Plus_fy Where ID <>" & ID & " AND  PlusName='" & PlusName & "' order by ID desc").eof Then
				Call fycms.Alert("系统已存在该插件名称!",""):Exit Sub
			 End if	
			 Set PlusRS = Server.CreateObject("adodb.recordset")
			  PlusSql = "select * from Plus_fy Where ID="&ID
			  PlusRS.Open PlusSql, Conn, 1, 3
		 	  PlusRS("PlusName") = PlusName
		 	  PlusRS("PlusIntro") = PlusIntro
		 	  PlusRS("IsUse") = IsUse
		 	  PlusRS("PlusUrl") = PlusUrl
			  PlusRS("OrderID") = OrderID
			  PlusRS.Update
			  PlusRS.Close:Set PlusRS = Nothing	
			  Call fycms.ActErr("修改成功","include/fy.Plus.asp","")		
 		End If 
	End Sub 

	Sub main
	Dim strLocalUrl
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
	
	Dim intPageNow
	intPageNow = request.QueryString("page")
	
	Dim intPageSize, strPageInfo
	intPageSize = 30
	
	Dim arrinfo, i
	Dim sql, sqlCount,Sqls,pages
	sql = "SELECT [ID], [PlusName],[PlusIntro], [PlusID],[IsUse],[OrderID]" & _
		" FROM [Plus_fy]" & _
		" Order by [OrderID] desc,[ID] desc"
	sqlCount = "SELECT Count([ID])" & _
			" FROM [Plus_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
	 %>
	
	
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>插件名称 </th><th>插件说明</th><th>是否启用</th><th>管理操作</th>
	  </tr>
    </thead>

      <%
		Dim bgColor
		If IsArray(arrinfo) Then
			For i = 0 to UBound(arrinfo, 2)
	%><tr>
      <td><%= arrinfo(1,i) %></td>
      <td><%= arrinfo(2,i) %></td>
      <td><% IF arrinfo(4,i) = 0 Then echo "<font color=green>正常</font>" else  echo "<font color=red>禁用</font>" %></td>
      <td>
	  <a href="?A=E&ID=<%= arrinfo(0,i) %>">修改</a>┆
	  <a href="?A=D&ID=<%= arrinfo(0,i) %>"  onClick="return confirm('确认删除此插件吗?')">删除</a>
	  </td>
    </tr>
<% 
	Next
	End If
	%>
    </table>
    <div class="pagelist">
    	<%= strPageInfo%>
   </div>
   <%End Sub 
   
   Sub EditAdd()
	If Action ="E" Then 
		Dim Rs,ID,A
		id = ChkNumeric(Request.QueryString("id"))
		Set Rs=fycms.actexe("select * from Plus_fy Where id="&id&"")
		If rs.eof Then
			Call fycms.alert("未知错误","")
		Else
			PlusName=Rs("PlusName")
			PlusIntro=Rs("PlusIntro")
			PlusID=Rs("PlusID")
			PlusUrl=Rs("PlusUrl")
			IsUse=Rs("IsUse")
			Id=Rs("Id")
			OrderID=Rs("OrderID")
		End If
		A="EditSave"
	Else
		A="AddSave"	
		OrderID=10
	End If 
   %>



  <form name="Plus_fy" method="post" action="?A=<%= A %>&ID=<%= ID %>">
    <div class="divtable"> 
        <dl>
            <dt>插件名称：</dt>
            <dd>
               <input name="PlusName" size=40 type="text"  class="Ainput"  id="PlusName" value="<%= PlusName %>">
	 多个管理名称请用 - 号分割  
            </dd>
         </dl>
        
        <dl>
            <dt>插件说明：</dt>
            <dd>
               <textarea name="PlusIntro" cols="50" rows="8" id="PlusIntro"><%= PlusIntro %></textarea>
             </dd>
         </dl>
        <dl>
            <dt>排序：</dt>
            <dd>
               <input name="OrderID"   class="Ainput"  type="text" id="OrderID" value="<%= OrderID %>">
数字越小排得越靠前.如果权重(排列序号)数字相同，就根据ID来排列
             </dd>
         </dl>
        <dl>
            <dt>插件标识符：</dt>
            <dd>
               <input name="PlusID"  class="Ainput"   <% if A="EditSave" then echo "disabled" %>  type="text" id="PlusID" value="<%= PlusID %>">
		 <font color=red>这是你插件的唯一的标识，注意不能有重复的</font>
             </dd>
         </dl>
        <dl>
            <dt>是否启用：</dt>
            <dd>
               <input <% IF IsUse = 0 Then echo "Checked" %>  type="radio" id="IsUse1" name="IsUse" value="0">
		<label for="IsUse1">启用</label>
        <input <% IF IsUse = 1 Then echo "Checked" %>  type="radio" id="IsUse2" name="IsUse" value="1">
		<label for="IsUse2">关闭</label>
             </dd>
         </dl>
        <dl>
            <dt>访问地址：</dt>
            <dd>
               <input name="PlusUrl" size="40" class="Ainput"  type="text" id="PlusUrl" value="<%= PlusUrl %>">
		 多个管理地址请用 - 号分割(和上面要相当应)
             </dd>
         </dl>
     
            <dl>
            <dt class="vhid">提交：</dt>
            <dd>
                <a class="btn btn_primary" href="javascript:void(0);" onclick="CheckForm()">提交</a>
             </dd>
         </dl>
        
    </div>
    </form>






<script language="javascript">
function CheckForm()
{ var form=document.Plus_fy;
	
	 if (form.PlusName.value=='')
		{ alert("请输入插件名称!");   
		  form.PlusName.focus();    
		   return false;
		} 
		 <% if A="AddSave" then %>
	 if (form.PlusID.value=='')
		{ alert("请输入插件标识符!");   
		  form.PlusID.focus();    
		   return false;
		} 
		<%end if %>
	if (form.PlusUrl.value=='')
		{ alert("请输入管理地址!");   
		  form.PlusUrl.focus();    
		   return false;
		} 
	    form.submit();
        return true;
	}</script>


   <%End Sub %>
</div>
</body>
</html>
