<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../inc/Cls_Channel.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()
%>
<script src="<%=CmsAdminMapPath%>js/check/channel.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain" onsubmit="return CheckForm();">
  <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>
        <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="text" class="txtInput w200" name="ChannelName" id="ChannelName" autocomplete="off" maxlength="100" />
              <label> *,如：文章咨询,用于左侧显示</label></td>
          </tr>
          <tr>
            <th> 频道简短名称： </th>
            <td class="td2"><input type="text" class="txtInput w150" name="BriefName" id="BriefName" autocomplete="off" maxlength="100" />
              <label> *,如：文章,用于左侧树展开显示</label></td>
          </tr>
          <tr>
            <th> 频道表名： </th>
            <td class="td2"><input type="text" class="txtInput w150" name="TabName" id="TabName" autocomplete="off" onfocus="ChkEnNum(this)" maxlength="100" />
              <label> *,只能包括英文字母、数字和下划线,如：news,系统自动加前缀：HL_,添加后不可编辑</label></td>
          </tr>
          <tr>
            <th> 前台是否显示： </th>
            <td class="td2"><span>
              <input type="radio" name="IsShow" value="1" id="IsShow001" checked="checked" />
              <label for="IsShow001">是</label>
              <input type="radio" name="IsShow" value="0" id="IsShow002" />
              <label for="IsShow002">否</label>
              </span></td>
          </tr>
          <tr>
            <th> 前台访问目录： </th>
            <td class="td2"><input type="text" class="txtInput w200" name="ChannelPath" id="ChannelPath" autocomplete="off" maxlength="100" />
              <label> *,只能包括英文,必须以:/ 开头和结尾,如：/news/</label></td>
          </tr>
          <tr>
            <th> 所属模型： </th>
            <td class="td2"><%=objChannel.GetModelList(0, False)%>
              <label>*,添加后，不可选择</label></td>
          </tr>
          <tr>
            <th> 该频道首页模版[电脑端]： </th>
            <td class="td2"><input type="text" class="txtInput w350" name="CnTemplateIndex" id="CnTemplateIndex" autocomplete="off" maxlength="100" />
              <input type="button" value="选择模板" class="btnSearch" onclick="ShowWin('CnTemplateIndex', '选择该频道首页模版', '../tpl/Admin.Index.Asp?action=sf&ReturnId=CnTemplateIndex', SetDialog.SpecialWidth, SetDialog.SpecialHeight, false);" />
              </td>
          </tr>
          <tr>
            <th> 该频道首页模版[移动端]： </th>
            <td class="td2"><input type="text" class="txtInput w350" name="EnTemplateIndex" id="EnTemplateIndex" autocomplete="off" maxlength="100" />
              <input type="button" value="选择模板" class="btnSearch" onclick="ShowWin('EnTemplateIndex', '选择该频道首页模版', '../tpl/Admin.Index.Asp?action=sf&ReturnId=EnTemplateIndex', SetDialog.SpecialWidth, SetDialog.SpecialHeight, false);" />
              </td>
          </tr>
          <tr>
            <th> 该频道搜索页模版[电脑端]： </th>
            <td class="td2"><input type="text" class="txtInput w350" name="CnTemplateSearch" id="CnTemplateSearch" autocomplete="off" maxlength="100" />
              <input type="button" value="选择模板" class="btnSearch" onclick="ShowWin('CnTemplateSearch', '选择该频道首页模版', '../tpl/Admin.Index.Asp?action=sf&ReturnId=CnTemplateSearch', SetDialog.SpecialWidth, SetDialog.SpecialHeight, false);" /></td>
          </tr>
          <tr>
            <th> 该频道搜索页模版[移动端]： </th>
            <td class="td2"><input type="text" class="txtInput w350" name="EnTemplateSearch" id="EnTemplateSearch" autocomplete="off" maxlength="100" />
              <input type="button" value="选择模板" class="btnSearch" onclick="ShowWin('EnTemplateSearch', '选择该频道首页模版', '../tpl/Admin.Index.Asp?action=sf&ReturnId=EnTemplateSearch', SetDialog.SpecialWidth, SetDialog.SpecialHeight, false);" /></td>
          </tr>
          <tr>
            <th> 频道形象图： </th>
            <td class="td2"><input type="text" class="txtInput w350 left" name="ChannelImg" id="ChannelImg" autocomplete="off" maxlength="100" />
              <a href="javascript:;" class="files">
              <input type="file" id="FileUpload" name="FileUpload" onchange="Upload('../', 'UpFile', 14000, 1, 'ChannelImg', 'FileUpload');" />
              </a> <span class="uploading">正在上传，请稍候...</span>　
              <input type="button" class="btnSearch" value="从已上传中选择" onclick="ShowWin('SiteLogo', '从已上传中选择', '../Admin_File.Asp?action=sf&ChannelId=14000&ReturnId=ChannelImg', SetDialog.PublicWidth, SetDialog.PublicHeight, false);" /></td>
          </tr>
          <tr>
            <th> 标题图为空显示图设置： </th>
            <td class="td2"><input type="text" class="txtInput w350 left" name="ShowPic" id="ShowPic" autocomplete="off" maxlength="100" />
              <a href="javascript:;" class="files">
              <input type="file" id="FileUpload" name="FileUpload" onchange="Upload('../', 'UpFile', 14000, 1, 'ShowPic', 'FileUpload');" />
              </a> <span class="uploading">正在上传，请稍候...</span>　
              <input type="button" class="btnSearch" value="从已上传中选择" onclick="ShowWin('SiteLogo', '从已上传中选择', '../Admin_File.Asp?action=sf&ChannelId=14000&ReturnId=ShowPic', SetDialog.PublicWidth, SetDialog.PublicHeight, false);" /></td>
          </tr>
          <tr>
            <th> 排 序： </th>
            <td class="td2"><input type="text" class="txtInput w50" name="Px" id="Px" maxlength="5" onfocus="ChkNumEric(this)" autocomplete="off" value="10000" />
              <label> *,越小越排前,不可为：0</label></td>
          </tr>
        </tbody>
      </table>
    </div>
    <div class="tab_con">
      <table class="form_table">
        <col width="200px">
        <col>
        <tbody>
          <tr>
            <th> 频道关键词(SEO)： </th>
            <td class="td2"><textarea name="ChannelKey" id="ChannelKey" class="w550"></textarea></td>
          </tr>
          <tr>
            <th> 频道描述(SEO)： </th>
            <td class="td2"><textarea name="ChannelDesc" id="ChannelDesc" class="w550"></textarea></td>
          </tr>
        </tbody>
      </table>
    </div>
    <div class="tab_con">
      <table class="form_table">
        <col width="200px">
        <col>
        <tbody>
          <tr>
            <th>是否生成缩略图： </th>
            <td class="td2"><span>
              <input type="radio" name="IsThumbnail" value="1" id="IsThumbnail01" checked="checked" />
              <label for="IsThumbnail01">是</label>
              <input type="radio" name="IsThumbnail" value="0" id="IsThumbnail02" />
              <label for="IsThumbnail02">否</label>
              </span></td>
          </tr>
          <tr>
            <th>缩略图生成方式：</th>
            <td class="td2"><%=objChannel.LoadThumbMode(1)%></td>
          </tr>
          <tr>
            <th>缩略图宽度：</th>
            <td class="td2"><input type="text" class="txtInput w100" name="ThumbW" id="ThumbW" maxlength="5" onfocus="ChkNumEric(this)" autocomplete="off" value="320" /></td>
          </tr>
          <tr>
            <th>缩略图高度：</th>
            <td class="td2"><input type="text" class="txtInput w100" name="ThumbH" id="ThumbH" maxlength="5" onfocus="ChkNumEric(this)" autocomplete="off" value="240" /></td>
          </tr>
          <tr>
            <th>生成水印开关设置：</th>
            <td class="td2"><span>
              <input type="radio" name="IsWaterMark" value="0" id="IsWaterMark00" />
              <label for="IsWaterMark00">不使用</label>
              <input type="radio" name="IsWaterMark" value="1" id="IsWaterMark01" checked="checked" />
              <label for="IsWaterMark01">图片水印</label>
              <input type="radio" name="IsWaterMark" value="2" id="IsWaterMark02" />
              <label for="IsWaterMark02">文字水印</label>
              </span></td>
          </tr>
          <tr>
            <th>图片水印Logo路径：</th>
            <td class="td2"><input type="text" class="txtInput w350" name="WaterMarkLogo" id="WaterMarkLogo" maxlength="150" autocomplete="off" value="/Images/mark_logo.png" />
              Logo图片的格式必须为：png格式,尺寸：180x60</td>
          </tr>
          <tr>
            <th>Logo图片显示位置：</th>
            <td class="td2"><%=objChannel.LoadLogoMode(4)%></td>
          </tr>
          <tr>
            <th>文字水印文字设置：</th>
            <td class="td2"><input type="text" class="txtInput w350" name="WaterMarkText" id="WaterMarkText" maxlength="50" autocomplete="off" value="图片上传于|张家界新派工作室" />
              包含|则打2边,如：图片上传于|张家界新派工作室,右边的字最好8个字</td>
          </tr>
          <tr>
            <th>文字水印位置：</th>
            <td class="td2"><span>
              <input type="radio" name="WaterMarkTextPos" value="0" id="WaterMarkTextPos00" />
              <label for="WaterMarkTextPos00">左边</label>
              <input type="radio" name="WaterMarkTextPos" value="1" id="WaterMarkTextPos01" checked="checked" />
              <label for="WaterMarkTextPos01">右边(文字设置最好8个字)</label>
              </span> 注：如文字中包含|，则位置设置无效</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()
    ChkSysAdminLevel "sys_channel", "add"
    '=====================================================================
    Dim ChannelName, BriefName, TabName, ModelId, IsShow
    Dim ChannelPath, ChannelKey, ChannelDesc
    Dim CnTemplateIndex, EnTemplateIndex, CnTemplateSearch, EnTemplateSearch, ShowPic
    Dim IsThumbnail, ThumbW, ThumbH, ThumbMode
    Dim IsWaterMark, WaterMarkLogo, WaterLogoPos, WaterMarkTextPos, WaterMarkText
    Dim Px, ChannelImg
    Dim ThisTabName
    '=====================================================================
    ChannelName = Trim(Easp.Post("ChannelName:s"))
    BriefName = Trim(Easp.Post("BriefName:s"))
    TabName = Trim(Easp.Post("TabName:s"))
    ModelId = Easp.Post("ModelId:n:0")
    IsShow = Easp.Post("IsShow:n:0")
    ChannelPath = Trim(Easp.Post("ChannelPath:s"))
    ChannelKey = Easp.Post("ChannelKey:s")
    ChannelDesc = Easp.Post("ChannelDesc:s")
    CnTemplateIndex = Trim(Easp.Post("CnTemplateIndex:s"))
    EnTemplateIndex = Trim(Easp.Post("EnTemplateIndex:s"))
    CnTemplateSearch = Trim(Easp.Post("CnTemplateSearch:s"))
    EnTemplateSearch = Trim(Easp.Post("EnTemplateSearch:s"))
    ShowPic = Trim(Easp.Post("ShowPic:s"))
    IsThumbnail = Easp.Post("IsThumbnail:n:0")
    ThumbW = Easp.Post("ThumbW:n:0")
    ThumbH = Easp.Post("ThumbH:n:0")
    ThumbMode = Easp.Post("ThumbMode:n:0")
    IsWaterMark = Easp.Post("IsWaterMark:n:0")
    WaterMarkLogo = Trim(Easp.Post("WaterMarkLogo:s"))
    WaterLogoPos = Easp.Post("WaterLogoPos:n:0")
    WaterMarkTextPos = Easp.Post("WaterMarkTextPos:n:0")
    WaterMarkText = Trim(Easp.Post("WaterMarkText:s"))
    ChannelImg = Trim(Easp.Post("ChannelImg:s"))
    Px = Easp.Post("Px:n:0")
    '=====================================================================
    If Easp.IsN(ChannelName) Then
        CmsAdmin.JscriptMsg "频道名称必须填写！", "back", "Error", "null"
    End If
    If Easp.IsN(BriefName) Then
        CmsAdmin.JscriptMsg "频道简短名称必须填写！", "back", "Error", "null"
    End If
    If Easp.IsN(TabName) Then
        CmsAdmin.JscriptMsg "频道表名必须填写！", "back", "Error", "null"
    End If
    ThisTabName = TablePrefix & TabName
    If CmsMain.CheckTable(ThisTabName) Then
        CmsAdmin.JscriptMsg "所填写的表:"& TabName &"，已经存在！", "back", "Error", "null"
    End If
    If Easp.IsN(ChannelPath) Then
        CmsAdmin.JscriptMsg "前台访问目录必须填写！", "back", "Error", "null"
    End If
    If ModelId = 0 Then
        CmsAdmin.JscriptMsg "所属模型必须选择！", "back", "Error", "null"
    End If
    If IsThumbnail = 1 Then
        If (ThumbW = 0 Or ThumbH = 0) Then
            CmsAdmin.JscriptMsg "缩略图宽度、高度必须填写，且不能为：0！", "back", "Error", "null"
        End If
    End If
    If IsWaterMark = 1 Then
        If Easp.IsN(WaterMarkLogo) Then
            CmsAdmin.JscriptMsg "图片水印Logo路径必须填写！", "back", "Error", "null"
        End If

    End If
    If IsWaterMark = 2 Then
        If Easp.IsN(WaterMarkText) Then
            CmsAdmin.JscriptMsg "文字水印文字必须填写！", "back", "Error", "null"
        End If
    End If
    '=====================================================================
    Dim List, ResultVal
    Easp.Use "list"
    Set List = Easp.List.New
    List("ChannelName") = ChannelName
    List("BriefName") = BriefName
    List("TabName") = ThisTabName
    List("ModelId") = ModelId
    List("IsShow") = IsShow
    List("ChannelPath") = ChannelPath
    List("ChannelKey") = ChannelKey
    List("ChannelDesc") = ChannelDesc
    List("CnTemplateIndex") = CnTemplateIndex
    List("EnTemplateIndex") = EnTemplateIndex
    List("CnTemplateSearch") = CnTemplateSearch
    List("EnTemplateSearch") = EnTemplateSearch
    List("ShowPic") = ShowPic
    List("IsThumbnail") = IsThumbnail
    List("ThumbW") = ThumbW
    List("ThumbH") = ThumbH
    List("ThumbMode") = ThumbMode
    List("IsWaterMark") = IsWaterMark
    List("WaterMarkLogo") = WaterMarkLogo
    List("WaterLogoPos") = WaterLogoPos
    List("WaterMarkTextPos") = WaterMarkTextPos
    List("WaterMarkText") = WaterMarkText
    List("Px") = Px
    List("ChannelImg") = ChannelImg
    List("AddTime") = Now()
    '=====================================================================
    ResultVal = Easp.db.AR(TablePrefix & "Channel:id", List.Hash)
    '=====================================================================
    Easp.C List
    If ResultVal <> 0 Then
        If objChannel.CreateTableName(ResultVal, ModelId, ThisTabName) Then
            CmsAdmin.JscriptMsg "添加频道成功！", "Admin.Index.Asp", "Success", "parent.loadChannelTree"
        Else
            CmsAdmin.JscriptMsg "添加频道成功，但创建频道表失败！", "Admin.Index.Asp", "Success", "parent.loadChannelTree"
        End If
    End If
    '=====================================================================
End Sub
%>
