📄 admin_templates_editor.asp
字号:
<!--#include file="../Conn.asp"-->
<!--#include file="../inc/Cl_ClsSysTem.asp"-->
<!--#Include File="../inc/Cl_ClsTempLate.asp"-->
<%
if Not Cl.ChkAdminLogin then
Response.write "<li>您未登录或者您无此操作权限!</li>"
Response.end
end If
Dim ChannelID
Dim Rs,TemplateID,CssID,Module,TemplateStr,TemplateNum,txtRun,TempContent
Dim sHTML,sInsTallDir,MainStr
Cl.Get_WebSetting()
TemplateID = Cl.GetClng(Request("TemplateID"))
sInsTallDir = "http://"&Request.servervariables("Server_name") & Cl.WebDir
TempContent = ""
If TemplateID>0 Then
Set Rs=Cl.Execute("Select TemplateContent,ProjectID From Cl_Template Where TemplateId="&TemplateID)
If Not Rs.Eof Then
TempContent = Rs(0)
Cl.ProjectID = Rs(1)
If Rs(1)<>Cl.ProjectID Then
Cl.ProjectID=Rs(1)
Set Rs=Nothing
Set Rs=Cl.Execute("Select CssID From Cl_CssID Where IsDefault=True and ProjectId="&Cl.ProjectID)
If Not Rs.Eof Then
CssID = Rs(0)
Cl.CssID = Rs(0)
End if
End if
End if
Set Rs=Nothing
End if
If InStr(TempContent,"{$showhead}")>0 Then
TempContent = Replace(TempContent,"{$showhead}","<!--clhead-->" & Template.Head & "<!--clheadend-->")
End If
If InStr(TempContent,"{$showfooter}")>0 Then
TempContent = Replace(TempContent,"{$showfooter}","<!--clfooter-->" & Template.Bottom & "<!--clfooterend-->")
End If
If InStr(TempContent,"</body>")>0 Then TempContent = Replace(TempContent,"</body>","<" & "!--/body-->")
If InStr(TempContent,"</html>")>0 Then TempContent = Replace(TempContent,"</html>","<" & "!--/html-->")
If InStr(TempContent,"</textarea>")>0 Then TempContent = Replace(TempContent,"</textarea>","[/textarea]")
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>创力网站管理系统模板编辑</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link rel="stylesheet" type="text/css" href="../Skins/Css/Admin.Css" />
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
<form name="FormEdit" id="FormEdit">
<tr><td align="center" class="title" colspan="4" height="25"><b>创 力 网 站 管 理 系 统 模 板 编 辑 窗 口(v4)</b></td></tr>
<tr><td align="center" width="100%" colspan="4">
<iframe id="editor" src="../Editor/Editor.asp?id=EditorTemp&style=Template&cid=0&CssID=<%=CssID%>" frameborder="0" scrolling="No" width="100%" height="0"></iframe>
</td></tr>
<tr><td align="center" width="100%" colspan="4">
<textarea id="Content" name="Content" rows="30" style="width:100%" onmouseout="setContent('get');" onmouseup=""><%=Server.HtmlEnCode(TempContent)%></textarea>
</td></tr>
<tr><td align="center" width="100%" colspan="4">
<textarea id="EditorTemp" name="EditorTemp" style="display:none"></textarea>
</td></tr>
<tr>
<td height="22" width="30%"><input id="isshowcode" name="isshowcode" type="checkbox" value="1" onclick="showcode()" checked="checked" /><span id="showc">关闭代码</span>
<input id="isshowedit" name="isshowedit" type="checkbox" value="1" onclick="showedit()" /><span id="showe">可视编辑</span></td>
<td height="22" align="center" width="40%">
<input type="button" name="editbutton" value=" [保存修改] " onclick="SaveContent();SelfEdit()" />
<input type="button" name="editbutton" value=" [应用修改] " onclick="SaveContent();SelfEdit()" />
<input type="button" name="close" value=" [关 闭] " onclick="window.close()" /> </td>
<td height="22" align="right" width="30%"><a href="javascript:sizeChange('-')"><img src="images/minus.gif" unselectable="on" border="0" alt="" /></a> <a href="javascript:sizeChange('+')"><img src="images/plus.gif" unselectable="on" border="0" alt="" /></a> </td>
</tr>
</form></table>
<script language="JavaScript" type="text/javascript">
<!--
<%if TemplateID=0 then%>
document.FormEdit.Content.value = opener.document.getElementById('TemplateContent').value;
document.FormEdit.EditorTemp.value = opener.document.getElementById('TemplateContent').value;
<%end if%>
function SelfEdit(){
if (editor.ModeEdit.value!='EDIT'){
alert('请先转到编辑模式!');
return false;
}
var pp=opener.document.getElementById('TemplateContent');
//pp.value=editor.Editor.document.body.innerHTML;
pp.value=document.FormEdit.Content.value
opener.document.TemplateEdit.submit()
self.close();
}
function showcode(){
if (document.getElementById('isshowcode').checked == true) {
document.FormEdit.Content.style.display='';
document.getElementById('showc').innerText='关闭代码';
}else{
document.FormEdit.Content.style.display='none';
document.getElementById('showc').innerText='显示代码';
document.getElementById('isshowedit').checked = true;
document.getElementById('editor').style.height=520;
document.getElementById('showe').innerText='关闭编辑';
}
}
function showedit(){
if (document.getElementById('isshowedit').checked == true) {
document.getElementById('editor').style.height=520;
document.getElementById('showe').innerText='关闭编辑';
}else{
document.getElementById('editor').style.height=0;
document.getElementById('showe').innerText='可视编辑';
document.getElementById('isshowcode').checked = true;
document.FormEdit.Content.style.display='';
document.getElementById('showc').innerText='关闭代码';
}
}
function sizeChange(st){
if (document.getElementById('isshowedit').checked == true) {
var obj=document.getElementById('editor');
var sh=parseInt(obj.style.height);
if (st=="+"){
obj.style.height=sh+100;
}
else if (sh>200) {
obj.style.height=sh-100;
}
}else if (document.getElementById('isshowcode').checked == true){
var obj=document.FormEdit.Content
var sc=parseInt(obj.rows);
if (st=="+"){
obj.rows=sc+10;
}
else if (sc>15) {
obj.rows=sc-10;
}
}
}
//-->
</script>
<script language="VBScript" type="text/vbscript">
Dim regEx, Match, Matches, StrBody,strTemp,strTemp2,strMatch,arrMatch,i
Dim Content1,Content2,TemplateContent,TemplateContent2,arrContent
setContent("editortemp")
Function setContent(sType)
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
if sType="set" then
TemplateContent = document.FormEdit.Content.value
TemplateContent2 = editor.Editor.document.body.innerHTML
if TemplateContent2="" then Exit function
regEx.Pattern = "\<IMG(.[^\<]*)\$\>"
Set Matches = regEx.Execute(TemplateContent2)
For Each Match In Matches
regEx.Pattern = "\#(.*)\#"
Set strTemp = regEx.Execute(Match.Value)
For Each Match2 In strTemp
strTemp2 = Replace(Match2.Value, "&", "&")
strTemp2 = Replace(strTemp2, "#", "")
'strTemp2 = Replace(strTemp2, "$}", "}")
strTemp2 = Replace(strTemp2,"&13;&10;",vbCrLf)
strTemp2 = Replace(strTemp2,"&9;",vbTab)
strTemp2 = Replace(strTemp2, "[!", "<")
strTemp2 = Replace(strTemp2, "!]", ">")
TemplateContent2=Replace(TemplateContent2, Match.Value, strTemp2)
Next
Next
TemplateContent2=Replace(TemplateContent2, "$}", "}")
TemplateContent2=Replace(TemplateContent2,"<%=sInsTallDir & Cl.CssPicUrl%>","{$csspicurl}")
TemplateContent2=Replace(TemplateContent2, "<%=sInsTallDir%>","{$webdir}")
TemplateContent2=Replace(TemplateContent2,"[$uploaddir$]","{$uploaddir}")
TemplateContent2=Replace(TemplateContent2,"[$channelid$]","{$channelid}")
TemplateContent2=Replace(TemplateContent2,"[$classid$]","{$classid}")
TemplateContent2=Replace(TemplateContent2,"{$webdir}Editor/","")
TemplateContent2=Replace(TemplateContent2,"[/textarea]","</textarea>")
TemplateContent2=Resumeblank(TemplateContent2)
if TemplateContent="" then document.FormEdit.Content.value=TemplateContent2 : Exit Function
if Instr(TemplateContent,"<body>")=0 then
regEx.Pattern = "(\<body)(.[^\<]*)(\>)"
Set Matches = regEx.Execute(TemplateContent)
For Each Match In Matches
StrBody = Match.Value
Next
If StrBody = "" Then
document.FormEdit.Content.value=TemplateContent2
Exit Function
else
arrContent = Split(TemplateContent, StrBody)
Content1 = arrContent(0) & StrBody
Content2 = arrContent(1)
End If
Else
arrContent = Split(TemplateContent, "<body>")
Content1 = arrContent(0) & "<body>"
Content2 = arrContent(1)
End if
document.FormEdit.Content.value=Content1& vbCrLf &TemplateContent2
Else
TemplateContent= document.FormEdit.Content.value
if TemplateContent="" then Exit function
if Instr(TemplateContent,"<body>")=0 then
StrBody = ""
regEx.Pattern = "(\<body)(.[^\<]*)(\>)"
Set Matches = regEx.Execute(TemplateContent)
For Each Match In Matches
StrBody = Match.Value
Next
If StrBody = "" Then
Content1 = ""
Content2 = TemplateContent
else
arrContent = Split(TemplateContent, StrBody)
Content1 = arrContent(0) & StrBody
Content2 = arrContent(1)
End If
Else
arrContent = Split(TemplateContent, "<body>")
Content1 = arrContent(0) & "<body>"
Content2 = arrContent(1)
End if
Content2 = Replace(Content2,"{$webdir}","<%=sInsTallDir%>")
Content2 = Replace(Content2,"{$uploaddir}","[$uploaddir$]")
Content2 = Replace(Content2,"{$csspicurl}","<%=sInsTallDir & Cl.CssPicUrl%>")
Content2 = Replace(Content2,"{$channelid}","[$channelid$]")
Content2 = Replace(Content2,"{$classid}","[$classid$]")
Content2 = Replace(Content2,"</textarea>","[/textarea]")
'图片替换JS
regEx.Pattern = "(\<" & "Script)(.[^\<]*)(\<\/Script\>)"
Set Matches = regEx.Execute(Content2)
For Each Match In Matches
strTemp = Replace(Match.Value, "<", "[!")
strTemp = Replace(strTemp, ">", "!]")
strTemp = Replace(strTemp, "'", """")
strTemp = "<IMG alt='#" & strTemp & "#' src=""<%=Cl.WebDir%>Editor/Images/Template/Js.gif"" border=0 $>"
Content2 = Replace(Content2, Match.Value, strTemp)
Next
'图片替换超级标签
regEx.Pattern = "(\{\%ShowArticle|\{\%ShowSoft|\{\%ShowPhoto|\{\%ShowMovie|\{\%ShowProduct|\{\%ShowPicArticle|\{\%ShowPicSoft|\{\%ShowPicPhoto|\{\%ShowPicMovie|\{\%ShowPicProduct)\((.[^(\{\%)]*)\)\}"
Content2 = regEx.Replace(Content2, "<IMG alt='#$1($2)$}#' src=""<%=Cl.WebDir%>Editor/Images/Template/Label.gif"" border=0 $>")
'图片替换其它标签(带参数的)
'regEx.Pattern = "(\{\%([^{$}])*)}"
regEx.Pattern = "(\{$)(.[^\{]*)(\})"
Set Matches = regEx.Execute(Content2)
For Each Match In Matches
if Instr(Match.Value,"(")>0 and Instr(Match.Value,")")>0 then
strTemp = Replace(Match.Value, "<", "[!")
strTemp = Replace(strTemp, ">", "!]")
strTemp = "<IMG alt='#" & Match.Value & "#' src=""<%=Cl.WebDir%>Editor/Images/Template/Label2.gif"" border=0 $>"
Content2 = Replace(Content2, Match.Value, strTemp)
end if
Next
if sType="editortemp" then
document.FormEdit.EditorTemp.value=Content2
else
editor.Editor.document.body.innerHTML=Content2
editor.showBorders()
end if
End if
End function
Function SaveContent()
Dim TContent
Content = document.FormEdit.Content.value
if Content="" then Exit function
Content = Replace(Content,"[/textarea]","</textarea>")
Content = Replace(Content,"<!--/body-->","</body>")
Content = Replace(Content,"<!--/html-->","</html>")
if Instr(Content,"<!--clhead-->")>0 and Instr(Content,"<!--clheadend-->")>0 then
TContent=Split(Content,"<!--clheadend-->")
if Ubound(TContent) > 0 then
Content="{$showhead}" & TContent(1)
end if
end if
if Instr(Content,"<!--clfooter-->")>0 and Instr(Content,"<!--clfooterend-->")>0 then
TContent=Split(Content,"<!--clfooter-->")
if Ubound(TContent) > 0 then
Content=TContent(0) & "{$showfooter}"
end if
elseif Instr(Content,"{$showfooter}")=0 and (Instr(Content,"{$showhead}")>0 or Instr(Lcase(Content),"<html")>0) then
Content=Replace(Content,"</body>","")
Content=Replace(Content,"</html>","")
Content=Content & Vbcrlf & "</body>" & Vbcrlf & "</html>"
end if
document.FormEdit.Content.value=Content
End Function
Function Resumeblank(byval Content)
Dim strHtml,strHtml2,Num,Numtemp,Strtemp
Dim regEx,Match,Matches,TempValue
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
regEx.Pattern = "<(\/?a|br|img|\/?font|\/?strong|\/?div|\/?ul|\/li|\/?table|\/?tbody|\/?tr|\/?th|\/?td|\/?select|\/?option|input|\/?script|\/?form|\/?textarea)"
strHtml=Content
Set Matches = regEx.Execute(strHtml)
For Each Match in Matches
strHtml = Replace(strHtml,Match.Value,LCase(Match.Value))
Next
Set regEx = nothing
strHtml=Replace(strHtml, "&","&")
arrContent = Split(strHtml,vbCrLf)
For i = 0 To UBound(arrContent)
Numtemp=false
if Instr(arrContent(i),"<table")>0 then
Numtemp=True
if Strtemp<>"<table" and Strtemp <>"</table>" then
Num=Num+2
End if
Strtemp="<table"
elseif Instr(arrContent(i),"<tr")>0 then
Numtemp=True
if Strtemp<>"<tr" and Strtemp<>"</tr>" then
Num=Num+2
End if
Strtemp="<tr"
elseif Instr(arrContent(i),"<td")>0 then
Numtemp=True
if Strtemp<>"<td" and Strtemp<>"</td>" then
Num=Num+2
End if
Strtemp="<td"
elseif Instr(arrContent(i),"</table>")>0 then
Numtemp=True
if Strtemp<>"</table>" and Strtemp<>"<table" then
Num=Num-2
End if
Strtemp="</table>"
elseif Instr(arrContent(i),"</tr>")>0 then
Numtemp=True
if Strtemp<>"</tr>" and Strtemp<>"<tr" then
Num=Num-2
End if
Strtemp="</tr>"
elseif Instr(arrContent(i),"</td>")>0 then
Numtemp=True
if Strtemp<>"</td>" and Strtemp<>"<td" then
Num=Num-2
End if
Strtemp="</td>"
elseif Instr(arrContent(i),"<" & "!--")>0 then
Numtemp=True
End if
if Num< 0 then Num = 0
if trim(arrContent(i))<>"" then
if i=0 then
strHtml2= string(Num," ") & arrContent(i)
elseif Numtemp=True then
strHtml2= strHtml2 & vbCrLf & string(Num," ") & arrContent(i)
else
strHtml2= strHtml2 & vbCrLf & arrContent(i)
end if
end if
Next
Resumeblank=strHtml2
End function
</script>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -