<!--#include file="../Include/Const.Asp" -->
<!--#include file="../Include/ConnSiteData.Asp" -->
<!--#include file="../Include/System_Language.asp" -->
<!--#include file="../Include/Version.Asp" -->
<!--#include file="CheckAdmin.Asp"-->
<!--#include file="../Html/html_Config.Asp"-->
<!--#include file="../Html/html_Function.Asp"-->
<!--#include file="../Html/html_To_Apage.Asp"-->
<%
'*******************************************************
'软件名称：科蚁企业网站内容管理系统（KEYICMS）
'软件开发：成都神笔天成网络科技有限公司
'网   址：http://www.keyicms.com
'本信息不会影响您网站的正常使用，无论免费用户或是收费用户请保留这里的信息.
'神笔(6)天成网络享有软件著作权，如果您擅自删除这里的版权信息,我们将追究法律责任.
'未经公司同意禁止更改以下代码.
'*******************************************************
Dim Result
Result = request.QueryString("Result")
Dim ID, ApageName, SortID, ClassSeo, ViewFlag, MobileFlag, Content, SeoKeywords, SeoDescription, Sequence, ConType
ID = request.QueryString("ID")
Call ApageEdit()
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="<%=Keyicms_Lang_Copyright(13)%>">
<meta name="author" content="<%=Keyicms_Lang_Copyright(3)%>">
<title><%=Keyicms_Lang_Copyright(1)%> <%=Str_Soft_Version%></title>
<!--#Include file="Keyicms_css.Asp"-->
<script charset="utf-8" src="KEditor_keyicms/kindeditor-min.js"></script>
<script charset="utf-8" src="KEditor_keyicms/lang/zh_CN.js"></script>
<script charset="utf-8" src="KEditor_keyicms/plugins/code/prettify.js"></script>
<script>
KindEditor.ready(function(K) {
	var editor = K.create('[name=Content1]', {
		cssPath : 'KEditor_keyicms/plugins/code/prettify.css',
		uploadJson : 'KEditor_keyicms/asp/upload_json.asp',
		fileManagerJson : 'KEditor_keyicms/asp/file_manager_json.asp',
		allowFileManager : true,
		afterBlur : function() {
			this.sync();
			K.ctrl(document, 13, function() {
				K('form[name=example]')[0].submit();
			});
			K.ctrl(this.edit.doc, 13, function() {
				K('form[name=example]')[0].submit();
			});
		}
	});
	prettyPrint();
});
</script>
</head>

<body>
<!--#Include file="Keyicms_Top.Asp"-->
<div id="wrap">
	<!--#Include file="Keyicms_Meun.Asp"-->
	<%
	If InStr(CompanyAdminPurview, "|1,") = 0 Then
		response.Write ("<br /><br /><div style='height:100%; text-align:center' class='main'><font style=""color:red; font-size:14px;"")>"&Keyicms_Lang_System(26)&"</font></div>")
		response.End
	End If
	%>
    <div class="main">
        <div class="row">
            <ol class="breadcrumb">
                <li><i class="fa fa-home"></i> <%=Keyicms_Lang_Copyright(14)%></li>
                <li><%=Keyicms_Lang_Copyright(2)%></li>
                <li class="active">单页内容管理</li>
            </ol>	
        </div>	
        <div class="row">
            <div class="col-lg-12 hideInIE8">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h2><i class="fa fa-edit"></i><span class="break"></span><strong>单页内容管理</strong></h2> 
                    </div>
                    <div class="panel-body">
                        <a class="ShortCut1" href="Ky_ApageEdit.Asp?Result=Add">  
                            <i class="fa fa-sign-in"></i>
                            <div class="title">添加单页内容</div>
                        </a>					
                        <a class="ShortCut2" href="Ky_Apage.Asp">  
                            <i class="fa fa-list"></i>
                            <div class="title">单页内容列表</div>
                        </a>				
                        <a class="ShortCut3" href="Ky_ApageSort.Asp">  
                            <i class="fa fa-sitemap"></i>
                            <div class="title">单页分类</div>
                        </a>				
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h2><i class="fa fa-gears"></i><span class="break"></span><strong><%If Result = "Add" then%>添加<%ElseIf Result = "Modify" then%>修改<%End If%>单页内容</strong></h2>
                    </div>
                    <div class="panel-body">
                    <form name="editForm" method="post" action="?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>" class="form-horizontal ">
                        <div class="form-group">
                            <label class="col-md-2 control-label" for="text-input">单页名称：</label>
                            <div class="col-md-4">
                                <input name="ApageName" type="text" id="ApageName" class="form-control" value="<%=ApageName%>">
                                <label class="checkbox-inline" for="ViewFlag">
                                    <input type="checkbox" id="ViewFlag" name="ViewFlag" value="1" <%if ViewFlag then response.write ("checked")%>> 显示
                                </label>
                                <%If mStatus Then%>
                                <label class="checkbox-inline" for="MobileFlag">
                                    <input type="checkbox" id="MobileFlag" name="MobileFlag" value="1" <%if MobileFlag then response.write ("checked")%>> 手机显示
                                </label>
                                <%End If%>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label" for="text-input">静态文件名：</label>
                            <div class="col-md-4">
								<%if Result = "Add" then%>
                                <input name="ClassSeo" type="text" id="ClassSeo" class="form-control">
                                <div class="radio">
                                    <label class="radio-inline" for="oAutopinyin_1">
                                        <input name="oAutopinyin" type="radio" id="oAutopinyin_1" value="1" checked="checked"> 自动生成系统默认静态文件名<font color="red">（已填写“静态文件名”则该功能无效）</font>
                                    </label>
                                </div>
                                <%If ClassSeoISPY = True Then%>
                                <div class="radio">
                                    <label class="radio-inline" for="oAutopinyin_2">
                                        <input name="oAutopinyin" type="radio" id="oAutopinyin_2" value="2"> 将标题转换为拼音<font color="red">（已填写“静态文件名”则该功能无效）</font>
                                    </label>
                                </div>
                                <%End If%>
                                <%elseif Result = "Modify" then%>
                                <input type="text" value="<%= ClassSeo %>" class="form-control" readonly>
                                <%end if%>
                                <span class="help-block"></span>
                            </div>
                        </div>
                        
						<%If EnableSeo = True Then%>
                        <div class="form-group">
                            <label class="col-md-2 control-label" for="text-input">关键词：</label>
                            <div class="col-md-6">
                                <input name="SeoKeywords" type="text" id="SeoKeywords" class="form-control" value="<%=SeoKeywords%>" maxlength="250">
                                <span class="help-block">SEO：多个关键词请用“,”半角逗号分开</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label" for="text-input">描述：</label>
                            <div class="col-md-6">
                                <input name="SeoDescription" type="text" id="SeoDescription" class="form-control" value="<%=SeoDescription%>" maxlength="250">
                                <span class="help-block">SEO：请填写描述</span>
                            </div>
                        </div>
						<%End If%>                        
                        <div class="form-group">
                            <label class="col-md-2 control-label">单页类别：</label>
                            <div class="col-md-5">
                                <select size="1" class="form-control" name="SortID" id="SortID">
                                <option value="" valuepath="">请选择...</option>
                                <%Call ApageSort()%>
                                </select>
                            </div>
                        </div> 
                        <div class="form-group">
                            <label class="col-md-2 control-label">内容模式：</label>
                            <div class="col-md-4">
                                <label class="radio-inline" for="ConType2">
                                    <input name="ConType" id="ConType2" type="radio" value="1" data-name="TabData" data-ch="ConType" data-value="1" <%If ConType = 1 Then%> checked<%End If%>> 编辑器模式
                                </label>
                                <label class="radio-inline" for="ConType1">
                                    <input name="ConType" id="ConType1" type="radio" value="2" data-name="TabData" data-ch="ConType" data-value="2" <%If ConType = 2 Then%> checked<%End If%>> HTML代码模式
                                </label>
                                <span class="help-block">开启此功能后，客户的留言会发送到管理员设置好的信箱中。</span>
                            </div>
                        </div>
                        <div class="form-group" data-div='ConType1' <%If ConType = 2 Then response.Write "style='display:none'"%>>
                            <label class="col-md-2 control-label" for="text-input">单页内容：</label>
                            <div class="col-md-10">
                                <textarea name="Content1" class="form-control" style="width:95%; height:300px; visibility:hidden;"><%=Server.HTMLEncode(Content)%></textarea>
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group" data-div='ConType2' <%If ConType = 1 Then response.Write "style='display:none'"%>>
                            <label class="col-md-2 control-label" for="text-input">单页HTML内容：</label>
                            <div class="col-md-10">
                                <textarea name="Content2" class="form-control" style="width:95%; height:300px;"><%=Server.HTMLEncode(Content)%></textarea>
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">排序：</label>
                            <div class="col-md-3">
                                <input name="Sequence" type="text" id="Sequence" class="form-control" value="<%=Sequence%>" onKeyDown="OnKeyDown()" onChange="OnChange(this, <%=Sequence%>)">
                                <span class="help-block">数字越小排名越靠前。</span>
                            </div>
                        </div>
                        <div class="form-group button-container">
                            <div class="col-md-2 control-label"></div>
                            <div class="col-md-10">
                                <input name="submitSaveEdit" type="submit" id="submitSaveEdit" class="btn btn-danger" value="保存单页内容">
                                <input type="button" class="btn btn-success" value="<%=Keyicms_Lang_System(32)%>" onClick="history.back(-1)">
                            </div>	
                        </div>
                    </form>
                    </div>
				</div>		
			</div>
        </div>
    </div>
    <!-- end: Content -->
	<!--#Include file="Keyicms_End.Asp"-->				
</div>
<!--#Include file="Keyicms_js.Asp"-->
</body>
</html>
<%
Sub ApageEdit()
    Dim Action, rsCheckAdd, rs, sql
    Action = request.QueryString("Action")
    If Action = "SaveEdit" Then
        Set rs = server.CreateObject("adodb.recordset")
        If Len(Trim(request.Form("ApageName")))<1 Then
			Call SweetAlert("warning", "友情提示", "请填写信息标题！", "false", "history.back(-1)")
            response.End
        End If
        If RTrim(Request.Form("Content" & Request.Form("ConType"))) = "" Then
			Call SweetAlert("warning", "友情提示", "请填写单页内容！", "false", "history.back(-1)")
            response.End
        End If

        If Trim(request.Form("SortID")) = "" Then
			Call SweetAlert("warning", "友情提示", "请选择单页分类！", "false", "history.back(-1)")
            response.End
        End If

        If Result = "Add" Then
            sql = "select * from keyicms_Apage"
            rs.Open sql, conn, 1, 3
            rs.addnew
			rs("ApageName")=trim(Request.Form("ApageName"))
			If Request.Form("ClassSeo") = "" then
				If Request.Form("oAutopinyin") = "1" then rs("ClassSeo") = TimeToName()
				If Request.Form("oAutopinyin") = "2" then rs("ClassSeo") = Left(Pinyin(trim(request.form("ApageName"))),200)
			Else
				rs("ClassSeo") = trim(Request.form("ClassSeo"))
			End If
            rs("ApageName") = Trim(Request.Form("ApageName"))
            rs("SortID") = Trim(Request.Form("SortID"))
            If Request.Form("ViewFlag") = 1 Then
                rs("ViewFlag") = Request.Form("ViewFlag")
            Else
                rs("ViewFlag") = 0
            End If
            If Request.Form("MobileFlag") = 1 Then
                rs("MobileFlag") = Request.Form("ViewFlag")
            Else
                rs("MobileFlag") = 0
            End If
			rs("SeoKeywords") = trim(Request.Form("SeoKeywords"))
			rs("SeoDescription") = trim(Request.Form("SeoDescription"))
			rs("ConType") = trim(Request.Form("ConType"))
            rs("Content") = RTrim(Request.Form("Content" & Request.Form("ConType")))
			rs("Sequence") = trim(Request.Form("Sequence"))
            rs("AddTime") = Now()
            rs("UpdateTime") = Now()
            rs.update
			rs.close : set rs = nothing
		  
			set rs = server.createobject("adodb.recordset")
            sql = "select top 1 ID,ClassSeo from keyicms_Apage order by ID desc"
            rs.Open sql, conn, 1, 1
            ID = rs("ID")
			rs.close : set rs = nothing
        End If
        If Result = "Modify" Then
            sql = "select * from keyicms_Apage where ID="&ID
            rs.Open sql, conn, 1, 3
            rs("ApageName") = Trim(Request.Form("ApageName"))
            rs("SortID") = Trim(Request.Form("SortID"))
            If Request.Form("ViewFlag") = 1 Then
                rs("ViewFlag") = Request.Form("ViewFlag")
            Else
                rs("ViewFlag") = 0
            End If
            If Request.Form("MobileFlag") = 1 Then
                rs("MobileFlag") = Request.Form("ViewFlag")
            Else
                rs("MobileFlag") = 0
            End If
			rs("SeoKeywords") = trim(Request.Form("SeoKeywords"))
			rs("SeoDescription") = trim(Request.Form("SeoDescription"))
			rs("ConType") = trim(Request.Form("ConType"))
            rs("Content") = RTrim(Request.Form("Content" & Request.Form("ConType")))
			rs("Sequence") = trim(Request.Form("Sequence"))
            rs("UpdateTime") = Now()
	  		ID = rs("ID")
            rs.update
			rs.close : set rs = nothing
        End If

		Call HtmlEdit("Apage", ID)    
		Call SweetAlert("success", "操作成功", "设置成功，相关静态页面已更新！", "false", "location.replace('Ky_Apage.Asp')")
    Else
        If Result = "Modify" Then
            Set rs = server.CreateObject("adodb.recordset")
            sql = "select * from keyicms_Apage where ID="& ID
            rs.Open sql, conn, 1, 1
            ApageName = rs("ApageName")
            ViewFlag = rs("ViewFlag")
            SortID = rs("SortID")
            MobileFlag = rs("MobileFlag")
	        ClassSeo = rs("ClassSeo") & Separated & rs("ID")
            Content = rs("Content")
			SeoKeywords = rs("SeoKeywords")
			SeoDescription = rs("SeoDescription")
			Sequence = rs("Sequence")
			ConType = rs("ConType")
			rs.close : set rs = nothing
		Else
			Sequence = 99
			ConType = 1
        End If
    End If
End Sub

Function ApageSort()
	Dim rs
	set rs = Server.CreateObject("adodb.recordset")
	rs.open "select * from Keyicms_ApageSort Order by ID asc", conn, 1, 2
	Do Until rs.eof
		If SortID = rs("ID") Then
			response.Write "<option value='"&rs("ID")&"' selected>"
		Else
			response.Write "<option value='"&rs("ID")&"'>"
		End If
		response.Write "│├ "&rs("SortName")
		response.Write "</option>"
		rs.movenext
	Loop
	rs.close : set rs = nothing
End Function
%>