<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../Admin_Check.Asp"-->
<%
Dim CmsAdmin
'=============================================================================
Set CmsAdmin = New Cls_Admin
CmsAdmin.SetAdminTitle = CmsSiteName
CmsAdmin.SetBodyCssName = "mainbody"
CmsAdmin.SetAdminPath = CmsAdminMapPath
CmsAdmin.LoadInfoHead()
'=============================================================================
Dim ChannelId, ChannelName, BriefName, TabName, ChannelPath, ModelId
Dim objType, TypeArrayList, SelectList
ChannelId = Easp.Get("ChannelId:n:0")
If ChannelId = 0 Then
    CmsAdmin.JscriptMsg "频道参数错误！", "back", "Error", "null"
End If
' 读取频道信息
Dim ArrayChannel
ArrayChannel = GetCaCheChannelInfo("Channel", ChannelId, ChannelField)
If Easp.IsN(ArrayChannel) Then
    CmsAdmin.JscriptMsg "不存在的频道！", "back", "Error", "null"
Else
    ChannelName = ArrayChannel(0)
    BriefName = ArrayChannel(1)
    TabName = ArrayChannel(2)
    ModelId = ArrayChannel(3)
    ChannelPath = ArrayChannel(4)
End If
'=============================================================================
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()
%>
<script src="<%=CmsAdminMapPath%>js/check/topic.check.js"></script>
<script>
var ChannelId = <%=ChannelId%>;
var editor;
$(function() {
    // txtWaterMarkFontColor
    SearchColor('TitleColor', 'hidColorMode', 'TitleColor');
    // 加载编辑器
    editor = LoadCmsEditor('<%=CmsAdminMapPath%>', 'Content', ChannelId);
    // 添加页面先清除浏览器保留的值
    ClearVal();
});
</script>
<form name="myform" id="myform" method="post" action="?action=savemain&ChannelId=<%=ChannelId%>">
  <div class="navigation"><a href="Admin.Index.Asp?ChannelId=<%=ChannelId%>" 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>
        <li><a onclick="tabs(this);" href="javascript:void(0);">SEO设置</a></li>
        <li><a onclick="tabs(this);" 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"><input type="hidden" name="ColorMode" id="hidColorMode" />
              <input name="Title" type="text" id="Title" class="txtInput w350" autocomplete="off" datatype="*2-150" nullmsg="专题标题必须填写" errormsg="至少2个字符,最多150个字符!" />
              <img id="TitleColor" title="标题颜色" class="imgcolorpicker" src="<%=CmsAdminMapPath%>images/colorpicker.gif" style="border-width:0px;" /> <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 专题副标题： </th>
            <td class="td2"><input name="SubTitle" type="text" id="SubTitle" class="txtInput w350" autocomplete="off" datatype="*0-150" errormsg="最多150个字符!" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 特殊属性： </th>
            <td class="td2"><span id="cblItem">
              <input id="cblItem_0" type="checkbox" name="DataIsTop" value="1" />
              <label for="cblItem_0">置顶</label>
              <input id="cblItem_1" type="checkbox" name="DataIsBest" value="1" />
              <label for="cblItem_1">推荐</label>
              <input id="cblItem_2" type="checkbox" name="DataIsHot" value="1" />
              <label for="cblItem_2">热门</label>
              <input id="cblItem_3" type="checkbox" name="FontMode" value="1" />
              <label for="cblItem_3">粗体</label>
              </span></td>
          </tr>
          <tr>
            <th> 封面大图： </th>
            <td class="td2"><input type="text" class="txtInput w350 left" name="BigPic" id="BigPic" autocomplete="off" datatype="*0-150" errormsg="最多150个字符!" />
              <a href="javascript:;" class="files">
              <input type="file" id="FileBigPic" name="FileBigPic" onchange="Upload('<%=CmsAdminMapPath%>', 'UpFile', <%=ChannelId%>, 1, 'BigPic');" />
              </a> <span class="uploading">正在上传，请稍候...</span>　
              <input type="button" class="btnSearch" value="从已上传中选择" onclick="ShowWin('BigPic', '从已上传中选择', '<%=CmsAdminMapPath%>Admin_File.Asp?action=sf&ChannelId=<%=ChannelId%>&ReturnId=BigPic', SetDialog.PublicWidth, SetDialog.PublicHeight, false);" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 封面小图： </th>
            <td class="td2"><input type="text" class="txtInput w350 left" name="SmallPic" id="SmallPic" autocomplete="off" datatype="*0-150" errormsg="最多150个字符!" />
              <a href="javascript:;" class="files">
              <input type="file" id="FileSmallPic" name="FileSmallPic" onchange="Upload('<%=CmsAdminMapPath%>', 'UpFile', <%=ChannelId%>, 1, 'SmallPic');" />
              </a> <span class="uploading">正在上传，请稍候...</span>　
              <input type="button" class="btnSearch" value="从已上传中选择" onclick="ShowWin('SmallPic', '从已上传中选择', '<%=CmsAdminMapPath%>Admin_File.Asp?action=sf&ChannelId=<%=ChannelId%>&ReturnId=SmallPic', SetDialog.PublicWidth, SetDialog.PublicHeight, false);" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> Banner图： </th>
            <td class="td2"><input type="text" class="txtInput w350 left" name="BannerPic" id="BannerPic" autocomplete="off" datatype="*0-150" errormsg="最多150个字符!" />
              <a href="javascript:;" class="files">
              <input type="file" id="FileBannerPic" name="FileBannerPic" onchange="Upload('<%=CmsAdminMapPath%>', 'UpFile', <%=ChannelId%>, 1, 'BannerPic');" />
              </a> <span class="uploading">正在上传，请稍候...</span>　
              <input type="button" class="btnSearch" value="从已上传中选择" onclick="ShowWin('BannerPic', '从已上传中选择', '<%=CmsAdminMapPath%>Admin_File.Asp?action=sf&ChannelId=<%=ChannelId%>&ReturnId=BannerPic', SetDialog.PublicWidth, SetDialog.PublicHeight, false);" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 专题模版： </th>
            <td class="td2"><input name="TemplateView" type="text" id="TemplateView" class="txtInput w350" autocomplete="off" datatype="*6-50" nullmsg="专题模版必须填写" errormsg="至少6个字符,最多50个字符!" />
              <input type="button" value="选择模版" class="btnSearch" onclick="ShowWin('TemplateFile', '选择内容模版', '<%=CmsAdminMapPath%>tpl/Admin.Index.Asp?action=sf&ReturnId=TemplateView', SetDialog.SpecialWidth, SetDialog.SpecialHeight, 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="10000" datatype="px" nullmsg="排序必须填写" errormsg="只能是数字越小越排前,不可为：0,最多5位数" />
              <span class="Validform_checktip">*,越小越排前,不可为：0</span></td>
          </tr>
      </table>
    </div>
    <div class="tab_con">
      <table class="form_table">
        <col width="200px">
        <col>
        <tbody>
          <tr>
            <th> 外部连接URL： </th>
            <td class="td2"><input type="text" name="UrlLink" id="UrlLink" class="txtInput w450" autocomplete="off" datatype="*0-150" errormsg="最多150个字符!" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 自定义URL： </th>
            <td class="td2"><input type="text" name="HtmlFile" id="HtmlFile" class="txtInput w450" autocomplete="off" datatype="*0-150" errormsg="最多150个字符!" />
              <span class="Validform_checktip">不需要加：.html</span></td>
          </tr>
          <tr>
            <th></th>
            <td class="td2"><input type="button" value="转换专题标题首字母" class="btnSearch" id="HtmlFile_6" onclick="GetPy('<%=CmsAdminMapPath%>', 'Title', 'HtmlFile', 6, '', '');" />
              <input type="button" value="转换专题标题全拼音" class="btnSearch" id="HtmlFile_3" onclick="GetPy('<%=CmsAdminMapPath%>', 'Title', 'HtmlFile', 3, '', '');" /></td>
          </tr>
          <tr>
            <th> SEO关健字： </th>
            <td class="td2"><textarea name="MetaKey" id="MetaKey" class="w450" datatype="*0-500" errormsg="最多500个字符!"></textarea>
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> SEO描述： </th>
            <td class="td2"><textarea name="MetaDesc" id="MetaDesc" class="w450" datatype="*0-500" errormsg="最多500个字符!"></textarea>
              <span class="Validform_checktip"></span></td>
          </tr>
        </tbody>
      </table>
    </div>
    <div class="tab_con">
      <table class="form_table">
        <col width="200px">
        <col>
        <tbody>
          <tr>
            <th> 详细描述： </th>
            <td class="td2"><textarea name="Content" id="Content" class="big" style="height:350px;width:99%;"></textarea></td>
          </tr>
        </tbody>
      </table>
    </div>
    <div class="foot_btn_box">
      <input type="submit" class="btnSubmit" value="提交保存" />
      &nbsp;
      <input name="重置" type="reset" class="btnSubmit" value="重 置" />
    </div>
  </div>
</form>
<%
End Sub

Sub SaveMain()
    ChkChannelAdminLevel ChannelId, "add"
    '===========================================================================================
    Dim Title, SubTitle, MetaKey, MetaDesc, ColorMode, FontMode
    Dim DataIsTop, DataIsBest, DataIsHot, UrlLink, HtmlFile
    Dim BigPic, SmallPic, BannerPic, Content, TemplateView, Px, AddTime
    '===========================================================================================
    Title = Trim(Easp.Post("Title:s"))
    SubTitle = Trim(Easp.Post("SubTitle:s"))
    MetaKey = Trim(Easp.Post("MetaKey:s"))
    MetaDesc = Trim(Easp.Post("MetaDesc:s"))
    ColorMode = Trim(Easp.Post("ColorMode:s"))
    FontMode = Easp.Post("FontMode:n:0")
    DataIsTop = Easp.Post("DataIsTop:n:0")
    DataIsBest = Easp.Post("DataIsBest:n:0")
    DataIsHot = Easp.Post("DataIsHot:n:0")
    UrlLink = Trim(Easp.Post("UrlLink:s"))
    HtmlFile = Trim(Easp.Post("HtmlFile:s"))
    BigPic = Trim(Easp.Post("BigPic:s"))
    SmallPic = Trim(Easp.Post("SmallPic:s"))
    BannerPic = Trim(Easp.Post("BannerPic:s"))
    Content = Trim(Easp.Post("Content:s"))
    TemplateView = Trim(Easp.Post("TemplateView:s"))
    Px = Easp.Post("Px:n:0")
    '===========================================================================================
    If Easp.IsN(Title) Then
        CmsAdmin.JscriptMsg "专题标题不能为空！", "back", "Error", "null"
    End If
    If Easp.IsN(TemplateView) Then
        CmsAdmin.JscriptMsg "专题模版不能为空！", "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("ChannelId") = ChannelId
    List("Title") = Title
    List("SubTitle") = SubTitle
    List("MetaKey") = MetaKey
    List("MetaDesc") = MetaDesc
    List("ColorMode") = ColorMode
    List("FontMode") = FontMode
    List("DataIsTop") = DataIsTop
    List("DataIsBest") = DataIsBest
    List("DataIsHot") = DataIsHot
    List("UrlLink") = UrlLink
    List("HtmlFile") = HtmlFile
    List("BigPic") = BigPic
    List("SmallPic") = SmallPic
    List("BannerPic") = BannerPic
    List("Content") = Content
    List("TemplateView") = TemplateView
    List("Px") = Px
    List("UpTime") = Now()
    List("AddTime") = Now()
    ResultVal = Easp.db.AR(TablePrefix & "Topic:id", List.Hash)
    Easp.C List
    If ResultVal <> 0 Then
        CmsAdmin.LoadCreatePage "../create/Admin.Pc.Html.Asp?action=topic&id=" & ResultVal & ""
        CmsAdmin.JscriptMsg "添加专题成功！", "Admin.Index.Asp?ChannelId="& ChannelId &"", "Success", "null"
    End If
    '===========================================================================================
End Sub
%>
