<!--#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="../inc/Cls_Type.Asp"-->
<!--#include file="../inc/Cls_Info.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
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)
    objChannel.CreateChannelView ChannelId, TabName
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()
    ' 读取分类
    Dim objType, TypeArrayList, SelectList
    Set objType = New Cls_Type
    SelectList = objType.ShowSelectList("选择分类", ChannelId, 0, 0)
    Set objType = Nothing
%>
<script src="<%=CmsAdminMapPath%>js/check/info.check.js"></script>
<script>
var ChannelId = <%=ChannelId%>;
var SiteDir = '<%=SiteWebFilePath%>';
var AdminMapPath = '<%=CmsAdminMapPath%>';
var UpLoadSize = '<%=CmsUpImagesSize%>';
var editor;
$(function() {
    $('#myform').initValidform();
    // 初始化批量上传图片
    InitSwfUpload(AdminMapPath, ChannelId, UpLoadSize, SiteDir + 'Scripts/Editor/plugins/multiimage/images/swfupload.swf');
    // 加载编辑器
    editor = LoadCmsEditor(AdminMapPath, 'Content', ChannelId);
    // KindEditor颜色组件
    SearchColor('TitleColor', 'hidColorMode', 'TitleColor');
    // 添加页面先清除浏览器保留的值
    ClearVal();
    $('#Title').blur(function() {
        getCheckTitle(AdminMapPath, ChannelId, 0, 'TitleTip', '<font style="color:#F00;">信息标题已存在</font>', ' *');
    })
});
</script>
<form name="myform" id="myform" method="post" action="?action=savemain&ChannelId=<%=ChannelId%>" onsubmit="return CheckForm();">
  <input type="hidden" name="UpImagesListVal" id="UpImagesListVal" value="" />
  <div class="navigation"><a href="Admin.Index.Asp?ChannelId=<%=ChannelId%>" class="back"><%=BriefName%>管理</a> 频道管理 &gt; <%=BriefName%>管理 &gt; 添加<%=BriefName%> </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>
        <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"><%=SelectList%><span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 所属专题： </th>
            <td class="td2"><%=objInfo.GetTopicList(ChannelId,0)%><span class="Validform_checktip"></span></td>
          </tr>
          <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" id="TitleTip">*</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_1" type="checkbox" name="DataIsMsg" value="1" checked="checked" />
              <label for="cblItem_1">允许评论</label>
              <input id="cblItem_2" type="checkbox" name="DataIsSlide" value="1" />
              <label for="cblItem_2">幻灯</label>
              <input id="cblItem_3" type="checkbox" name="DataIsTop" value="1" />
              <label for="cblItem_3">置顶</label>
              <input id="cblItem_4" type="checkbox" name="DataIsBest" value="1" />
              <label for="cblItem_4">推荐</label>
              <input id="cblItem_5" type="checkbox" name="DataIsHot" value="1" />
              <label for="cblItem_5">热门</label>
              <input id="cblItem_6" type="checkbox" name="FontMode" value="1" />
              <label for="cblItem_6">粗体</label>
              </span></td>
          </tr>
          <tr>
            <th> 自定义封面： </th>
            <td class="td2"><input name="ImageUrl" type="text" id="ImageUrl" class="txtInput w350 left" autocomplete="off" datatype="*0-150" errormsg="最多150个字符!" />
              <a href="javascript:;" class="files">
              <input type="file" id="FileUploadImg" name="FileUploadImg" onchange="Upload('<%=CmsAdminMapPath%>', 'UpFile', <%=ChannelId%>, 1, 'ImageUrl');" />
              </a> <span class="uploading">正在上传，请稍候...</span>　
              <input type="button" class="btnSearch" value="从已上传中选择" onclick="ShowWin('PicUrl', '从已上传中选择', '<%=CmsAdminMapPath%>Admin_File.Asp?action=sf&ChannelId=<%=ChannelId%>&ReturnId=ImageUrl', SetDialog.PublicWidth, SetDialog.PublicHeight, false);" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 信息Tag： </th>
            <td class="td2"><input name="Tag" type="text" id="Tag" class="txtInput w350" autocomplete="off" datatype="*0-50" errormsg="最多50个字符!" />
              <span class="Validform_checktip">以英文逗号隔开,如：微软,Win,Win8</span></td>
          </tr>
          <tr>
            <th> <%=BriefName%>排序： </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">*</span></td>
          </tr>
          <tr>
            <th valign="top" style="padding-top: 10px;"> 图片相册： </th>
            <td><div class="upload_btn"> <span id="upload"></span> </div>
              <label> 可以上传多张图片。</label>
              <div class="clear"> </div>
              
              <!--上传提示.开始-->
              
              <div id="show"> </div>
              
              <!--上传提示.结束--> 
              <!--图片列表.开始-->
              
              <div id="show_list">
                <ul>
                </ul>
              </div>
              
              <!--图片列表.结束--></td>
          </tr>
        </tbody>
      </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> 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>
          <%=objInfo.LoadFieldInfo(ChannelId, null, CmsAdminMapPath)%>
        </tbody>
      </table>
    </div>
    <div class="tab_con">
      <table class="form_table">
        <col width="200px">
        <col>
        <tbody>
          <tr>
            <th> 内容摘要： </th>
            <td class="td2"><textarea name="ZhaiYao" id="ZhaiYao" class="w450" datatype="*0-1000" errormsg="最多1000个字符!"></textarea>
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 内容描述： </th>
            <td><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" value="提交保存" class="btnSubmit" />
      <input type="reset" class="btnSubmit" value="重 置" />
    </div>
  </div>
</form>
<%
End Sub

Sub SaveMain()
    ChkChannelAdminLevel ChannelId, "add"
    '=====================================================================
    Dim ClassId, TopicId, Title, SubTitle, MetaKey, MetaDesc, ColorMode
    Dim FontMode, DataIsMsg, DataIsSlide, DataIsTop, DataIsBest, DataIsHot
    Dim ImageUrl, UrlLink, HtmlFile, Tag, Content, ZhaiYao, Px
    '=====================================================================
    ClassId = Easp.Post("ClassId:n:0")
    TopicId = Easp.Post("TopicId:n:0")
    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")
    DataIsMsg = Easp.Post("DataIsMsg:n:0")
    DataIsSlide = Easp.Post("DataIsSlide:n:0")
    DataIsTop = Easp.Post("DataIsTop:n:0")
    DataIsBest = Easp.Post("DataIsBest:n:0")
    DataIsHot = Easp.Post("DataIsHot:n:0")
    ImageUrl = Trim(Easp.Post("ImageUrl:s"))
    UrlLink = Trim(Easp.Post("UrlLink:s"))
    HtmlFile = Trim(Easp.Post("HtmlFile:s"))
    Tag = Replace(Replace(Trim(Easp.Post("Tag:s")) & "", "，", ",") & "", "，", ",")
    ZhaiYao = Easp.Post("ZhaiYao:s")
    Content = Easp.Post("Content:s")
    Px = Easp.Post("Px:n:0")
    '=====================================================================
    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(Content) Then
        CmsAdmin.JscriptMsg "详细描述必须填写！", "back", "Error", "null"
    End If
    If Px = 0 Then
        CmsAdmin.JscriptMsg "信息排序必须填写，且不能为：0！", "back", "Error", "null"
    End If
    '=====================================================================
    Dim List, ResultVal
    Easp.Use "list"
    Set List = Easp.List.New
    List("ClassId") = ClassId
    List("TopicId") = TopicId
    List("Title") = Title
    List("SubTitle") = SubTitle
    List("MetaKey") = MetaKey
    List("MetaDesc") = MetaDesc
    List("ColorMode") = ColorMode
    List("FontMode") = FontMode
    List("DataIsMsg") = DataIsMsg
    List("DataIsSlide") = DataIsSlide
    List("DataIsTop") = DataIsTop
    List("DataIsBest") = DataIsBest
    List("DataIsHot") = DataIsHot
    List("ImageUrl") = ImageUrl
    List("UrlLink") = UrlLink
    List("HtmlFile") = HtmlFile
    List("Tag") = Tag
    List("ZhaiYao") = ZhaiYao
    List("Content") = Content
    List("Px") = Px
    List("Hits") = 1
    List("DayHits") = 1
    List("WeekHits") = 1
    List("MonthHits") = 1
    List("HitsTime") = Now()
    List("MsgNum") = 0
    List("UserId") = 0
    List("UpTime") = Now()
    List("AddTime") = Now()
    ' 自定义字段信息
    objInfo.GetFieldVal ChannelId, List
    ' 开始保存
    ResultVal = Easp.db.AR(TabName & ":Id", List.Hash)
    '=====================================================================
    Easp.C List
    If ResultVal <> 0 Then
        '================================================================= 保存图片
        objInfo.SwfUpLoadAdd ChannelId, ResultVal
        ' 更新分类统计
        CmsAdmin.UpdateTypeNum ChannelId, TabName, ClassId
        ' 更新Tag
        objInfo.UpdateTag ChannelId, TabName, Tag
        '=================================================================
        CmsAdmin.LoadCreatePage "../create/Admin.Pc.Html.Asp?action=info&ChannelId="& ChannelId &"&id=" & ResultVal & ""
        CmsAdmin.JscriptMsg "添加信息成功！", "Admin.Index.Asp?ChannelId="& ChannelId &"", "Success", "null"
    End If
    '=====================================================================
End Sub
%>
