<!--#include file="../Include/Const.Asp" -->
<!--#include file="../Include/ConnDatabase.asp" -->
<!--#include file="../Include/system_language.asp" -->
<!--#include file="../Include/Version.Asp" -->
<!--#include file="CheckAdmin.Asp"-->
<!--#include file="../Generate/SC_Config.Asp"-->
<!--#include file="../Generate/SC_Function.Asp"-->
<!--#include file="../Generate/SC_Case.Asp"-->
<!--#include file="../Generate/SC_Index.Asp"-->
<%
'*********************************************
'软件名称：博科企业网站内容管理系统（BOKECMS）
'软件开发：博科网络科技工作室
'网    址：http://www.bokew.net
'服务  QQ：530051328
'服务邮箱：bbfhq@163.com
'微信公众号：bokewlkj
'*********************************************
%>
<%
dim Result
Result = request.QueryString("Result")
dim ID, CaseName, ViewFlag, CommendFlag, MobileFlag,IsTop, ClassSeo, SortName, SortID, SortPath
dim SeoKeywords, SeoDescription, SeoTitle
dim SmallPic, BigPic, Sequence,Origin, Content, OtherPic, ClickNumber
ID = request.QueryString("ID")
call CaseEdit()
call SiteInfo
%>
<!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="<%=Bokecms_Lang_Copyright(13)%>">
<meta name="author" content="<%=Bokecms_Lang_Copyright(3)%>">
<title><%=Bokecms_Lang_Copyright(1)%> <%=Soft_Version%></title>
<!--#Include file="BokeCMS_Css.Asp"-->
<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) {
	var editor = K.create('textarea[name="Content"]', {
		cssPath : '../KindEditor/plugins/code/prettify.css',
		uploadJson : '../KindEditor/asp/upload_json.asp?action=case',
		fileManagerJson : '../KindEditor/asp/file_manager_json.asp',
		allowFileManager : true,
		afterBlur : function() {
		this.sync();
		K.ctrl(document, 13, function() {
		K('form[name=editForm]')[0].submit();
		});
		K.ctrl(this.edit.doc, 13, function() {
		K('form[name=editForm]')[0].submit();
		});
		}
	});
	K('#SmallImage').click(function() {
		editor.loadPlugin('image', function() {
			editor.plugin.imageDialog({
				imageUrl : K('#SmallPic').val(),
				clickFn : function(url, title, width, height, border, align) {
					K('#SmallPic').val(url);
					editor.hideDialog();
				}
			});
		});
	});
	K('#BigImage').click(function() {
		editor.loadPlugin('image', function() {
			editor.plugin.imageDialog({
				imageUrl : K('#BigPic').val(),
				clickFn : function(url, title, width, height, border, align) {
					K('#BigPic').val(url);
					editor.hideDialog();
				}
			});
		});
	});
	K('#J_selectImage').click(function() {
		editor.loadPlugin('multiimage', function() {
			var aVal=""
			editor.plugin.multiImageDialog({
				clickFn : function(urlList) {
					var div = K('#OtherPic');
					aVal=div.val()
					K.each(urlList, function(i, data) {
						if (div.val() == "")
							aVal =aVal + data.url
						else
							aVal =aVal + "|" +  data.url
					
						div.val(aVal);
					});
					editor.hideDialog();
				}
			});
		});
	});
});
</script>
</head>
<body>
<!--#Include file="BokeCMS_Top.Asp"-->
<!--#Include file="BokeCMS_Meun.Asp"-->
<div id="wrap">
	<%
	If InStr(CompanyAdminPurview, "|4,") = 0 Then
		response.Write ("<br /><br /><div style='height:100%; text-align:center' class='main'><font style=""color:red; font-size:14px;"")>"&Bokecms_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> <%=Bokecms_Lang_Copyright(14)%></li>
                <li class="active"><a href="">功能模块</a></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="BokeCMS_Funct_CaseEdit.Asp?Result=Add">  
                            <i class="fa fa-picture-o"></i>
                            <div class="title">添加案例</div>
                        </a>					
                        <a class="ShortCut2" href="BokeCMS_Funct_Case.Asp">  
                            <i class="fa fa-th-large"></i>
                            <div class="title">案例列表</div>
                        </a>	
                        <a class="ShortCut3" href="BokeCMS_Funct_CaseSort.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">案例名称：</label>
                            <div class="col-md-6">
                                <input name="CaseName" type="text" id="CaseName"  class="form-control"  value="<%=CaseName%>" >
                                <label class="checkbox-inline" for="ViewFlag">
                                    <input type="checkbox" id="ViewFlag" name="ViewFlag" value="1" <%If Result = "Add" then response.write ("checked")%><%if ViewFlag then response.write ("checked")%>> PC显示
                                </label>
                                <%If mStatus Then%>
                                <label class="checkbox-inline" for="MobileFlag">
                                    <input type="checkbox" id="MobileFlag" name="MobileFlag" value="1" <%If Result = "Add" then response.write ("checked")%><%if MobileFlag then response.write ("checked")%>> 手机显示
                                </label>
                                <%End If%>
                                <label class="checkbox-inline" for="CommendFlag">
                                    <input type="checkbox" id="CommendFlag" name="CommendFlag" value="1" <%if CommendFlag=True then response.write ("checked")%>>是否推荐
                                </label>
                                <label class="checkbox-inline" for="IsTop">
                                    <input type="checkbox" id="IsTop" name="IsTop" value="1" <%if IsTop=True then response.write ("checked")%>> 是否固顶
                                </label> 
                            </div>
                        </div> 
                        <div class="form-group">
                            <label class="col-md-2 control-label">静态文件名：</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">案例关键词：</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">案例描述：</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">  
                                <input name="Origin" type="text"  value="<%=Origin%>" class="form-control" maxlength="100">
                                <a href="javascript:" onClick="document.editForm.Origin.value='网络转载'">网络转载</a> &nbsp; | &nbsp; 
                                <a href="javascript:" onClick="document.editForm.Origin.value='<%=ComName%>'"><%=ComName%></a> 
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">案例类别：</label>
                            <div class="col-md-5">
                                <select size="1" class="form-control" name="SortSelect" id="SortSelect" onChange="AddSort()">
                                <option value="" valuepath="">请选择...</option>
                                <%Call CaseSort(0, 0)%>
                                </select>
                                <span class="help-block">
                                    <input name="SortID" type="hidden" id="SortID" value="<%=SortID%>" readonly class="form-control">
                                    <input name="SortPath" type="hidden" id="SortPath" value="<%=SortPath%>" readonly class="form-control">
                                </span>
                            </div>
                        </div> 
                        <div class="form-group">
                            <label class="col-md-2 control-label">案例大图：</label>
                            <div class="col-md-5">
                            	<div class="input-group">
                                    <input type="text" id="BigPic" name="BigPic" class="form-control" value="<%=BigPic%>" readonly>
                                    <span class="input-group-btn">
                                    	<button type="button" id="BigImage" class="btn btn-default">上传图片</button>
                                    </span>
                                </div>                               
                                <span class="help-block">案例大图主要是做内页显示使用</span>
                            </div>
                        </div>                     
                        <div class="form-group">
                            <label class="col-md-2 control-label">案例小图：</label>
                            <div class="col-md-5">
                            	<div class="input-group">
                                    <input type="text" id="SmallPic" name="SmallPic" class="form-control" value="<%=SmallPic%>" readonly>
                                    <span class="input-group-btn">
                                    <button type="button" id="SmallImage" class="btn btn-default">上传图片</button>
                                    </span>
                                </div>                                 
                                <span class="help-block">小图可以直接使用小图地址：<a href="javascript:void(0)" onClick="document.editForm.SmallPic.value=document.editForm.BigPic.value">点击复制上方大图地址</a></span>
                            </div>
                        </div>  
                        <div class="form-group">
                            <label class="col-md-2 control-label">更多案例图片：</label>
                            <div class="col-md-5">
                                <textarea rows="5" cols="80" name="OtherPic" id="OtherPic" class="form-control"><%=OtherPic%></textarea>
                                <span class="input-group-btn">
                                	<button type="button" id="J_selectImage" class="btn btn-default">批量上传</button>
                                    </span>
                                 <span class="help-block">上传多张案例图片</span>
                            </div>
                        </div>  
                        <div class="form-group">
                            <label class="col-md-2 control-label">案例详细介绍：</label>
                            <div class="col-md-10">
                                <textarea name="Content" style="width:95%;height:400px;visibility:hidden;" class="form-control"><%=Server.HTMLEncode(Content)%></textarea>
								<input type="checkbox" name="T_SaveImg" value="1" /> 保存内容中网络图片到本地
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <%If EnableViews = True Then%>  
                        <div class="form-group">
                            <label class="col-md-2 control-label">案例浏览数：</label>
                            <div class="col-md-3">
                                <input type="text" name="ClickNumber" id="ClickNumber" class="form-control" value="<%=ClickNumber%>" onKeyDown="OnKeyDown()" onchange="OnChange(this, <%=ClickNumber%>)" />
                                <span class="help-block">可以手动输入案例的浏览数量，不输入则为默认</span>
                            </div>
                        </div> 
                        <%End If%>
                        <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, <%=ClickNumber%>)" />
                                
                                <span class="help-block">数字越小排名越靠前</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-2 control-label"></div>
                            <div class="col-md-10">
                                <input name="submitSaveEdit" type="submit" id="submitSaveEdit" class="btn btn-danger btn-lg" value="保存案例信息">
                                <input type="button" class="btn btn-danger btn-lg" value="<%=Bokecms_Lang_System(32)%>" onClick="history.back(-1)">
                            </div>	
                        </div>
                    </form>
                    </div>
				</div>		
			</div>
        </div>
    </div>
    <!-- end: Content -->

	<!--#Include file="BokeCMS_End.Asp"-->				
</div>
<!--#Include file="BokeCMS_Js.Asp"-->
</body>
</html>

<%
Sub CaseEdit()
dim Action, rs, sql
Action = request.QueryString("Action")
if Action = "SaveEdit" then
	set rs = server.createobject("adodb.recordset")
	if len(trim(request.Form("CaseName")))<1 then
		Call SweetAlert("warning", "友情提示", "请填写案例名称！", "false", "history.back(-1)")
		response.end
	end If
	If Trim(request.Form("Origin")) = "" Then
		Call SweetAlert("warning", "友情提示", "请填写案例来源！", "false", "history.back(-1)")
		response.End
	End If
	if Request.Form("SortID")="" and Request.Form("SortPath")="" then
		Call SweetAlert("warning", "友情提示", "请选择所属分类！", "false", "history.back(-1)")
		response.End
	end If
	if ltrim(request.Form("SmallPic")) = "" then
		Call SweetAlert("warning", "友情提示", "请上传案例小图！", "false", "history.back(-1)")
		response.end
	end If
	if ltrim(request.Form("BigPic")) = "" then
		Call SweetAlert("warning", "友情提示", "请上传案例大图！", "false", "history.back(-1)")
		response.end
	end If
	if ltrim(request.Form("Content")) = "" then
		Call SweetAlert("warning", "友情提示", "请填写案例详细介绍！", "false", "history.back(-1)")
		response.end
	end If

    If Result="Add" Then
		sql="select * from BokeCMS_Case"
		rs.open sql,conn,1,3
		rs.addnew
		rs("CaseName") = trim(Request.Form("CaseName"))
		if Request.Form("ViewFlag") = 1 then
			rs("ViewFlag") = Request.Form("ViewFlag")
		else
			rs("ViewFlag") = 0
		end if
		if Request.Form("CommendFlag") = 1 then
			rs("CommendFlag") = Request.Form("CommendFlag")
		else
			rs("CommendFlag") = 0
		end If
		if Request.Form("IsTop") = 1 then
			rs("IsTop") = Request.Form("IsTop")
		else
			rs("IsTop") = 0
		end If		
		if Request.Form("MobileFlag") = 1 then
			rs("MobileFlag") = Request.Form("MobileFlag")
		else
			rs("MobileFlag") = 0
		end if
		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("CaseName"))),200)
		Else
			rs("ClassSeo") = trim(Request.form("ClassSeo"))
		End If
		rs("SortID")=Request.Form("SortID")
		rs("SortPath")=Request.Form("SortPath")
		rs("SmallPic")=trim(Request.Form("SmallPic"))
		rs("BigPic")=trim(Request.Form("BigPic"))
		rs("OtherPic")=trim(Request.Form("OtherPic"))
		rs("Content") = rtrim(Request.Form("Content"))
		rs("AddTime") = now()
		rs("UpdateTime") = now()
		rs("SeoTitle") = trim(Request.Form("SeoTitle"))
		rs("SeoKeywords") = trim(Request.Form("SeoKeywords"))
		rs("SeoDescription") = trim(Request.Form("SeoDescription"))
        rs("Origin") = trim(Request.Form("Origin"))
		If EnableViews Then rs("ClickNumber") = trim(Request.Form("ClickNumber"))
		rs("Sequence") = trim(Request.Form("Sequence"))
		rs.update
		rs.close : set rs = nothing
		
		set rs = server.createobject("adodb.recordset")
		sql="select top 1 ID,ClassSeo from BokeCMS_Case order by ID desc"
		rs.open sql,conn,1,1
		ID = rs("ID")
		rs.close : set rs = nothing
	  
		Call Html_To_Case(ID, "PC")
		If mStatus Then Call Html_To_Case(ID, "Mobile")
		Call html_To_Index("Index", "PC")'生成PC首页
		If mStatus Then Call html_To_Index("Index", "Mobile")'生成WAP首页
	End If
	If Result="Modify" Then
		sql="select * from BokeCMS_Case where ID="&ID
		rs.open sql,conn,1,3
		rs("CaseName") = trim(Request.Form("CaseName"))
		if Request.Form("ViewFlag") = 1 then
			rs("ViewFlag") = Request.Form("ViewFlag")
		else
			rs("ViewFlag") = 0
		end if
		if Request.Form("CommendFlag") = 1 then
			rs("CommendFlag") = Request.Form("CommendFlag")
		else
			rs("CommendFlag") = 0
		end If
		if Request.Form("IsTop") = 1 then
			rs("IsTop") = Request.Form("IsTop")
		else
			rs("IsTop") = 0
		end If		
		if Request.Form("MobileFlag") = 1 then
			rs("MobileFlag") = Request.Form("MobileFlag")
		else
			rs("MobileFlag") = 0
		end if
		rs("SortID") = Request.Form("SortID")
		rs("SortPath") = Request.Form("SortPath")
		rs("SmallPic") = trim(Request.Form("SmallPic"))
		rs("BigPic") = trim(Request.Form("BigPic"))
		rs("OtherPic") = trim(Request.Form("OtherPic"))
		rs("Content") = rtrim(Request.Form("Content"))
		rs("UpdateTime") = now()
		rs("SeoTitle") = trim(Request.Form("SeoTitle"))
		rs("SeoKeywords") = trim(Request.Form("SeoKeywords"))
		rs("SeoDescription") = trim(Request.Form("SeoDescription"))
        rs("Origin") = trim(Request.Form("Origin"))
		If EnableViews Then rs("ClickNumber") = trim(Request.Form("ClickNumber"))
		rs("Sequence") = trim(Request.Form("Sequence"))

		ID = rs("ID")
		rs.update
		rs.close : set rs = nothing
	  
		Call Html_To_Case(ID, "PC")
		If mStatus Then Call Html_To_Case(ID, "Mobile")
		Call html_To_Index("Index", "PC")'生成PC首页
		If mStatus Then Call html_To_Index("Index", "Mobile")'生成WAP首页
	End If

'==========================保存远程图片和添加水印开始===================================
Dim AspJpeg,T_SaveImg,T_UploadDir '建立变量
AspJpeg=Request.Form("AspJpeg")
T_SaveImg=Request.Form("T_SaveImg")
if T_SaveImg="" then T_SaveImg=0
if T_SaveImg=1 then'保存远程图片
T_UploadDir=""&SysRootDir&"UploadFile/Case/"
content=ReplaceRemoteUrl(content,T_UploadDir,AspJpeg)
else
content=content
end If
'==========================保存远程图片、添加水印结束========bokew.net==============
	
    Call SweetAlert("success", "操作成功", "已生成本记录详细页和网站首页，请在“生成静态”中批量生成案例模块栏目及分类页！", "false", "location.replace('BokeCMS_Funct_Case.Asp')")
else
  	if Result = "Modify" then
		set rs = server.createobject("adodb.recordset")
		sql = "select * from BokeCMS_Case where ID="& ID
		rs.open sql, conn, 1, 1
		if rs.bof and rs.eof then
			response.write ("<center>数据库记录读取错误！</center>")
			response.end
		end if
		CaseName = rs("CaseName")
		ViewFlag = rs("ViewFlag")
		MobileFlag = rs("MobileFlag")
		CommendFlag = rs("CommendFlag")
		IsTop= rs("IsTop")
		Sequence = rs("Sequence")
		ClassSeo = rs("ClassSeo")&Separated&rs("ID")
		SortName=SortText(rs("SortID"))
		SortID = rs("SortID")
		SortPath = rs("SortPath")
		SmallPic = rs("SmallPic")
		BigPic = rs("BigPic")
		OtherPic = rs("OtherPic")
		Content = rs("Content")
		ClickNumber = rs("ClickNumber")
		Sequence = rs("Sequence")
		SeoTitle = rs("SeoTitle")
		SeoKeywords = rs("SeoKeywords")
		SeoDescription = rs("SeoDescription")
		Origin=rs("Origin")
		rs.close : set rs = nothing
	else
		ClickNumber = 10
		Sequence = 10
    end if
end if
End Sub

Function SortText(ID)
	Dim rs,sql
	set rs = Server.CreateObject("adodb.recordset")
	sql = "Select * From BokeCMS_CaseSort where ID="&ID
	rs.open sql, conn, 1, 1
	SortText = rs("SortName")
	rs.close : set rs = nothing
End Function

Function CaseSort(ID, ClassNum)
	Dim rs
	set rs = Server.CreateObject("adodb.recordset")
	rs.open "select * from BokeCMS_CaseSort where ParentID="&ID&" Order by ID asc", conn, 1, 2
	Do Until rs.eof
		If SortID = rs("ID") Then
			response.Write "<option value='"&rs("ID")&"' valuepath='"&rs("SortPath")&"' selected>"
		Else
			response.Write "<option value='"&rs("ID")&"' valuepath='"&rs("SortPath")&"'>"
		End If
		For ClassN = 1 to ClassNum
			response.Write "│"
		Next
		response.Write "│├ "&rs("SortName")
		response.Write "</option>"
		Call CaseSort(rs("ID"), ClassNum + 1)
		rs.movenext
	Loop
	rs.close : set rs = nothing
End Function
%>