<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../inc/Cls_InType.Asp"-->
<!--#include file="../Admin_Check.Asp"-->
<%
Dim CmsAdmin
'=============================================================================
Set CmsAdmin = New Cls_Admin
CmsAdmin.SetAdminTitle = CmsSiteName
CmsAdmin.SetBodyCssName = "mainbody"
CmsAdmin.SetAdminPath = CmsAdminMapPath
CmsAdmin.LoadHead()
'=============================================================================
Dim Action
'=============================================================================
Action = Easp.Get("action")
Select Case Action
    Case "savemain"
        Call SaveMain()
    Case Else
        Call PageLoad()
End Select
CmsAdmin.LoadFooter()
Set CmsAdmin = Nothing

Sub PageLoad()
    Dim oRs, Id, ClassId, Title, Url, Logo, Px
    Id = Easp.Get("id:n:0")
    If Id = 0 Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    Set oRs = Easp.db.GR(TablePrefix & "Link:Id,ClassId,Title,Url,Logo,Px:1", " Id = "& Id &" ", "")
    If Easp.IsN(oRs) Then
        CmsAdmin.JscriptMsg "不存在的数据！", "back", "Error", "null"
    Else
        ClassId = oRs("ClassId")
        Title = oRs("Title")
        Url = oRs("Url")
        Logo = oRs("Logo")
        Px = oRs("Px")
    End If
    Easp.C oRs
%>
<script src="<%=CmsAdminMapPath%>js/check/link.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain">
  <input type="hidden" name="id" value="<%=Id%>" />
  <input type="hidden" name="ToUrl" value="<%=CmsFun.LoadToUrl()%>" />
  <div class="navigation"><a href="Admin.Index.Asp" class="back">友情链接管理</a> 插件管理 &gt; 友情链接管理 &gt; 编辑友情链接 </div>
  <div id="contentTab">
    <div class="content-tab">
      <ul class="tab_nav">
        <li><a onclick="tabs(this);" class="selected" href="javascript:void(0);">编辑友情链接</a></li>
      </ul>
    </div>
    <div class="tab_con" style="display: block;">
      <table class="form_table">
        <col width="200px">
          </col>
        
        <tbody>
          <tr>
            <th> 所属分类： </th>
            <td class="td2"><%=GetLinkType(ClassId, "")%><span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 链接名称： </th>
            <td class="td2"><input type="text" class="txtInput w350" name="Title" id="Title" maxlength="100" value="<%=Title%>" autocomplete="off" datatype="*4-150" nullmsg="链接名称必须填写" errormsg="至少4个字符,最多150个字符!" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 链接URL： </th>
            <td class="td2"><input type="text" class="txtInput w350" name="Url" id="Url" maxlength="100" value="<%=Url%>" autocomplete="off" datatype="url" nullmsg="链接URL必须填写" errormsg="URL必须以:http//开头.域名后缀结尾,最多150个字符!" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 链接Logo： </th>
            <td class="td2"><input type="text" class="txtInput w350 left" name="Logo" id="Logo" maxlength="100" value="<%=Logo%>" autocomplete="off" datatype="*0-150" errormsg="最多150个字符!" />
              <a href="javascript:;" class="files">
              <input type="file" id="FileUpload" name="FileUpload" onchange="Upload('../', 'UpFile', 11000, 1, 'Logo');" />
              </a> <span class="uploading">正在上传，请稍候...</span>　
              <input type="button" class="btnSearch" value="从已上传中选择" onclick="ShowWin('Logo', '从已上传中选择', '../Admin_File.Asp?action=sf&ChannelId=11000&ReturnId=Logo', SetDialog.PublicWidth, SetDialog.PublicHeight, false);" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 链接排序： </th>
            <td class="td2"><input type="text" class="txtInput w100" name="Px" id="Px" autocomplete="off" value="<%=Px%>" datatype="px" nullmsg="排序必须填写" errormsg="只能是数字越小越排前,不可为：0,最多5位数" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th></th>
            <td><input type="submit" class="btnSubmit" value="提交保存" />
              &nbsp;
              <input name="重置" type="reset" class="btnSubmit" value="重 置" /></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</form>
<%
End Sub

Sub SaveMain()
    ChkSysAdminLevel "sys_link", "edit"
    '=====================================================================
    Dim Id, ClassId, Title, Url, Logo, Px, ToUrl
    Id = Easp.Post("id:n:0")
    ClassId = Easp.Post("ClassId:n:0")
    Title = Trim(Easp.Post("Title:s"))
    Url = Trim(Easp.Post("Url:s"))
    Logo = Trim(Easp.Post("Logo:s"))
    Px = Easp.Post("Px:n:0")
    ToUrl = Trim(Easp.Post("ToUrl:s"))
	If Id = 0 Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    '=====================================================================
    If ClassId = 0 Then
        CmsAdmin.JscriptMsg "所属分类必须选择！", "back", "Error", "null"
    End If
    If Easp.IsN(Title) Then
        CmsAdmin.JscriptMsg "链接名称必须填写！", "back", "Error", "null"
    End If
    If Easp.IsN(Url) Then
        CmsAdmin.JscriptMsg "链接URL必须填写！", "back", "Error", "null"
    End If
    If Px = 0 Then
        CmsAdmin.JscriptMsg "排序必须填写！", "back", "Error", "null"
    End If
    '=====================================================================
    Dim List, ResultVal
    Easp.Use "list"
    Set List = Easp.List.New
    List("ClassId") = ClassId
    List("Title") = Title
    List("Url") = Url
    List("Logo") = Logo
    List("Px") = Px
    '=====================================================================
    ResultVal = Easp.db.UR(TablePrefix & "Link", " Id = "& Id &" ", List.Hash)
    '=====================================================================
    Easp.C List
    If ResultVal <> 0 Then
        CmsAdmin.LoadCreateIndex()
        CmsAdmin.JscriptMsg "编辑友情链接成功！", Easp.IIf(Easp.IsN(ToUrl), "Admin.Index.Asp", ToUrl), "Success", "null"
    End If
    '=====================================================================
End Sub
%>
