<%@ LANGUAGE = VBScript.Encode %>
<!--#include file="../Include/conn.asp" -->
<!--#include file="../Include/ConnDatabase.asp" -->
<!--#include file="Admin_htmlconfig.asp"-->
<!--#include file="../Include/RemoteImg_save.asp"-->
<%
'=====================================
'天天企业网站管理系统  TianTianCMS
'天天网络科技工作室版权所有
'官方客服中心 http://www.ip126.com
'微信公众号 ip126com
'QQ:530051328 mail:bbfhq@163.com
'=====================================
%>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312" />
<TITLE>关于我们编辑</TITLE>
<link rel="stylesheet" href="Images/Admin.css">
<script language="javascript" src="../Script/Admin.js"></script>

<!--kindeditor编辑器-->
		<link rel="stylesheet" href="../KindEditor/themes/default/default.css" />
		<script charset="utf-8" src="../KindEditor/kindeditor.js"></script>
		<script charset="utf-8" src="../KindEditor/lang/zh_CN.js"></script>
		<script>
		KindEditor.ready(function(K) {
				K.create('#editor_ch', {
					urlType : 'absolute',
					afterBlur: function(){this.sync();},//失去焦点执行this获得值					
					uploadJson : '../KindEditor/asp/upload_json.asp?action=about'
				});
				K.create('#editor_en', {
					urlType : 'absolute',
					afterBlur: function(){this.sync();},//失去焦点执行this获得值					
					uploadJson : '../KindEditor/asp/upload_json.asp?action=about'
				});
		});
	</script>
<!--kindeditor编辑器END-->

<script language = "JavaScript">
function CheckForm()
{
	if (document.editAboutForm.AboutNameCH.value.length == 0) {
		alert("中文标题没有填写.");
		document.editAboutForm.AboutNameCH.focus();
		return false;
	}
	<%if chinato=1 then%>
	if (document.editAboutForm.AboutNameEN.value.length == 0) {
		alert("英文标题没有填写.");
		document.editAboutForm.AboutNameEN.focus();
		return false;
	}
	<%end if%>
var editor_ch=KindEditor.create('#editor_ch');
if (editor_ch.isEmpty())
	{
	  alert("请填中文内容！")	  
	  return false
	 }
	<%if chinato=1 then%>
var editor_en=KindEditor.create('#editor_en');
if (editor_en.isEmpty())
	{
	  alert("请填英文内容！")	  
	  return false
	 }
	<%end if%>  
	return true;
}
</script>
</HEAD>
<BODY>
<%
if Instr(session("AdminPurview"),"|10,")=0 then
  response.write ("<br><br><div align=""center""><font style=""color:red; font-size:9pt; "")>您没有管理该模块的权限！</font></div>")
  response.end
end if
dim Result
Result=request.QueryString("Result")
dim ID,AboutNameCH,ViewFlagCH,ContentCH,AboutNameEN,ViewFlagEN,ContentEN
dim GroupID,GroupIdName,Exclusive,ChildFlag
ID=request.QueryString("ID")
call AboutEdit()
%>
<br>
<form name="editAboutForm" method="post" action="AboutEdit.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>" onSubmit="return CheckForm()">
<table class="tableborder" width="95%" border="0" align="center" cellpadding="3" cellspacing="1">  
    <tr>
      <th height="22" colspan="2">【<%If Result = "Add" then%>添加<%ElseIf Result = "Modify" then%>修改<%End If%>关于我们】</th>
    </tr>
    <tr>
      <td width="20%" align="right" class="forumRow">中文标题：</td>
      <td width="80%" class="forumRowHighlight"><input name="AboutNameCH" type="text" id="AboutNameCH" style="width: 280" value="<%=AboutNameCH%>" maxlength="100">
        是否显示：<input name="ViewFlagCH" type="checkbox" value="1" checked="checked" <%if ViewFlagCH then response.write ("checked")%>></td>
    </tr>
	<%if chinato=1 then%>
	<tr>
      <td width="20%" align="right" class="forumRow">英文标题：</td>
      <td width="80%" class="forumRowHighlight"><input name="AboutNameEN" type="text" id="AboutNameEN" style="width: 280" value="<%=AboutNameEN%>" maxlength="100">
        是否显示：<input name="ViewFlagEN" type="checkbox" value="1" <%if ViewFlagEN then response.write ("checked")%>></td>
    </tr>
	<%End if%>
	<tr>
      <td width="20%" align="right" class="forumRow"><span class="forumRowHighlight">是否分页：</span></td>
      <td width="80%" class="forumRowHighlight"><input name="ChildFlag2" type="checkbox" value="1" <%if ChildFlag then response.write ("checked")%>>
        <font color="red">*</font></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">阅读权限：</td>
      <td class="forumRowHighlight"><select name="GroupID">
          <% call SelectGroup() %>
        </select>
        <input name="Exclusive" type="radio" value="&gt;=" <%if Exclusive="" or Exclusive=">=" then response.write ("checked")%>>
        隶属
        <input type="radio" <%if Exclusive="=" then response.write ("checked")%> name="Exclusive" value="=">
        专属（隶属：权限值≥可查看，专属：权限值＝可查看）</td>
    </tr>
    <tr>
      <td align="right" class="forumRow">中文内容：</td>
      <td class="forumRowHighlight"><textarea id="editor_ch" name="ContentCH" style="width:670px;height:400px;"><%=ContentCH%></textarea></td>
    </tr>
	<%if chinato=1 then%>
	<tr>
      <td align="right" class="forumRow">英文内容：</td>
      <td class="forumRowHighlight"><textarea id="editor_en" name="ContentEN" style="width:670px;height:400px;"><%=ContentEN%></textarea></td>
    </tr>
	<%End if%>
    <tr>
      <td align="right" class="forumRow"></td>
      <td class="forumRowHighlight"><input type="checkbox" name="T_SaveImg" value="1" /> 保存内容中远程图片到本地&nbsp;&nbsp;<input type="checkbox" name="AspJpeg" value="1" checked/>给上传图片加水印&nbsp;&nbsp;（<font color="red">注:<%if Result="Modify" then%>当距发布时间超过<%=Watermark_interval%>分钟时去掉勾确保图片不重复加水印。<%end if%>上传图片等宽度勿超760像素，否则页面变形</font>）</td>
    </tr>
    <tr>
      <td align="right" class="forumRow"></td>
      <td class="forumRowHighlight"><input name="submitSaveEdit" type="submit" id="submitSaveEdit" value="保存"> <input type="button" value="返回上一页" onClick="history.back(-1)"></td>
    </tr>
  </form>
</table>
</BODY>
</HTML>

<%
sub AboutEdit()
  dim Action,rsCheckAdd,rs,sql
  Action=request.QueryString("Action")
  if Action="SaveEdit" Then
  ContentCh=trim(Request.Form("ContentCh"))
  ContentEn=trim(Request.Form("ContentEn"))
    set rs = server.createobject("adodb.recordset")
    if len(trim(request.Form("AboutNameCh")))<1 Then
    Call Alert ("中文标题为必填项目！","-1")      
      response.end
    end if
    if request.Form("ViewFlagEn")=1 then
      if len(trim(request.Form("AboutNameEn")))<1 then
      Call Alert ("英文标题为必填项目！","-1")
      response.end
      end if
    end If



    if Result="Add" then '添加内容
	  sql="select * from TianTianCMS_About"
      rs.open sql,conn,1,3
      rs.addnew
      rs("AboutNameCh")=trim(Request.Form("AboutNameCh"))
      rs("AboutNameEn")=trim(Request.Form("AboutNameEn"))
	  if Request.Form("ViewFlagCh")=1 then
        rs("ViewFlagCh")=Request.Form("ViewFlagCh")
	  else
        rs("ViewFlagCh")=0
	  end if
	  if Request.Form("ViewFlagEn")=1 then
       rs("ViewFlagEn")=Request.Form("ViewFlagEn")
	  else
       rs("ViewFlagEn")=0
	  end if
	  rs("ContentCh")=ContentCh
	  If ContentEn<>"" Then rs("ContentEn")=ContentEn
      GroupIdName=split(Request.Form("GroupID"),"┎╂┚")
	  rs("GroupID")=GroupIdName(0)
	  rs("Exclusive")=trim(Request.Form("Exclusive"))
	  if Request.Form("ChildFlag")=1 then
        rs("ChildFlag")=Request.Form("ChildFlag")
	    rs("Sequence")=999
	  else
        rs("ChildFlag")=0
	    rs("Sequence")=99
	  end if
	  rs("AddTime")=now()
	  rs("UpdateTime")=now()
	  rs.update
	  rs.close
	  set rs=Nothing
	  set rs=server.createobject("adodb.recordset")
	  sql="select top 1 ID from TianTianCMS_About order by ID desc"
	  rs.open sql,conn,1,1
	  ID=rs("ID")
	  rs.close
	  set rs=Nothing
	  if ISHTML = 1 then
	  call html2("/CH/html/","/CH/",""&AboutName&""&Separated&""&ID&"."&HTMLName&"","About.asp","ID=",ID,"","")
	  if chinato=1 then call html2("/EN/html/","/EN/",""&AboutName&""&Separated&""&ID&"."&HTMLName&"","About.asp","ID=",ID,"","")
	  End If
	end if
	if Result="Modify" then'修改内容
      sql="select * from TianTianCMS_About where ID="&ID
      rs.open sql,conn,1,3
      rs("AboutNameCh")=trim(Request.Form("AboutNameCh"))
      If Request.Form("AboutNameEn")<>"" Then rs("AboutNameEn")=trim(Request.Form("AboutNameEn"))
	  if Request.Form("ViewFlagCh")=1 then
        rs("ViewFlagCh")=Request.Form("ViewFlagCh")
	  else
        rs("ViewFlagCh")=0
	  end if
	  if Request.Form("ViewFlagEn")=1 then
        if chinato=1 then rs("ViewFlagEn")=Request.Form("ViewFlagEn")
	  else
        if chinato=1 then rs("ViewFlagEn")=0
	  end if
	  rs("ContentCh")=ContentCh
	  if chinato=1 then  rs("ContentEn")=ContentEn
      GroupIdName=split(Request.Form("GroupID"),"┎╂┚")
	  rs("GroupID")=GroupIdName(0)
	  rs("Exclusive")=trim(Request.Form("Exclusive"))
	  if Request.Form("ChildFlag")=1 then
        rs("ChildFlag")=Request.Form("ChildFlag")
	    rs("Sequence")=100
	  else
        rs("ChildFlag")=0
	  end if
	  rs("UpdateTime")=now()
	  rs.update
	  rs.close
	  set rs=Nothing
	  if ISHTML = 1 then
	  call html2("/CH/html/","/CH/",""&AboutName&""&Separated&""&ID&"."&HTMLName&"","About.asp","ID=",ID,"","")
	  if chinato=1 then call html2("/EN/html/","/EN/",""&AboutName&""&Separated&""&ID&"."&HTMLName&"","About.asp","ID=",ID,"","")
	  End If
	end if
    if ISHTML = 1 then
    response.write "<script language='javascript'>alert('设置成功，接着生成相关静态页！');location.replace('Admin_htmlindex.asp?htmlsc=Admin_htmlinfo.asp');</script>"
	Else
	response.write "<script language='javascript'>alert('设置成功！');location.replace('AboutEdit.asp?Result="&request.QueryString("Result")&"&ID="&id&"');</script>"
	End If
  else
	if Result="Modify" then
      set rs = server.createobject("adodb.recordset")
      sql="select * from TianTianCMS_About where ID="& ID
      rs.open sql,conn,1,1
	  AboutNameCh=rs("AboutNameCh")
	  AboutNameEn=rs("AboutNameEn")
	  ViewFlagCh=rs("ViewFlagCh")
	  ViewFlagEn=rs("ViewFlagEn")
	  GroupID=rs("GroupID")
	  Exclusive=rs("Exclusive")
      ContentCh=rs("ContentCh")
      ContentEn=rs("ContentEn")
	  ChildFlag=rs("ChildFlag")
	  rs.close
      set rs=nothing
	end if
  end if
end sub

sub SelectGroup()
  dim rs,sql
  set rs = server.createobject("adodb.recordset")
  sql="select GroupID,GroupNameCH from TianTianCMS_MemGroup"
  rs.open sql,conn,1,1
  if rs.bof and rs.eof then
    response.write("未设组别")
  end if
  while not rs.eof
    response.write("<option value='"&rs("GroupID")&"┎╂┚"&rs("GroupNameCH")&"'")
    if GroupID=rs("GroupID") then response.write ("selected")
    response.write(">"&rs("GroupNameCH")&"</option>")
    rs.movenext
  wend
  rs.close
  set rs=nothing
end sub
%>