<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="java.sql.*,gbase.db.*" %>
<%@ include file="../checkLogin.jsp" %>
<SCRIPT language="JavaScript" src="../js/util.js"></SCRIPT>
<LINK href="../css/css.css" rel=stylesheet>
<%
String file_name=request.getParameter("file_name")==null?"page_top":request.getParameter("file_name");
String page_name=request.getParameter("page_name")==null?"网页头部修改":request.getParameter("page_name");
String web_template_type_id=request.getParameter("web_template_type_id")==null?"":request.getParameter("web_template_type_id");
DBOperation theDBOperation = new DBOperation();
String web_project_id="";
String web_project_name="";
String web_project_sys_account="";
String id="";
String sql = "select a.*,b.title as web_project_name,b.sys_account from web_template a,web_project b where a.web_project_id=b.id and a.web_template_type_id="+web_template_type_id+" and a.flag=0 and a.web_account='"+web_account+"'";
ResultSet rs =theDBOperation.getResultSet(sql);
if(rs.next())
{
web_project_id=rs.getString("web_project_id")==null?"":rs.getString("web_project_id");
web_project_name=rs.getString("web_project_name")==null?"":rs.getString("web_project_name");
web_project_sys_account=rs.getString("sys_account")==null?"":rs.getString("sys_account");
id=rs.getString("id")==null?"":rs.getString("id");
}
String action="update";
String title="";
String title_desc="";
String test_desc="";
String content="";
String flag="1";
if(action.equals("update") || action.equals("view"))
{
sql = "select * from web_template  where id="+id+" and web_account='"+web_account+"'";
rs =theDBOperation.getResultSet(sql);
if(rs.next())
{
title=rs.getString("title")==null?"":rs.getString("title");
title_desc=rs.getString("title_desc")==null?"":rs.getString("title_desc");
test_desc=rs.getString("test_desc")==null?"":rs.getString("test_desc");
//web_template_type_id=rs.getString("web_template_type_id")==null?"":rs.getString("web_template_type_id");
content=rs.getString("content")==null?"":rs.getString("content");
flag=rs.getString("flag")==null?"":rs.getString("flag");
}
else
action="";
}
%>
<html>
<head>
<title>
<%=page_name%>
</title>
</head>
<body leftmargin="0" topmargin="0">

<!--导航-->
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
       <tr>
		<td width="100%" height="20"  bgcolor="#eeeeee" class="p2">您当前所在的位置>><%=page_name%></td>
	   </tr>
       <tr>
          <td width="100%" height="2"> <img border="0" src="../images/spacer.gif" width="1" height="3"></td>
       </tr>
    </table>
<!--标题-->
  <div align="center">
   <table border="0" width="100%" cellspacing="0" cellpadding="0" height="34">
	<tr>
		<td width="159" background="../images/back_board2.gif" nowrap valign="bottom"><span class="title01">&nbsp;<span class="style1"><%=page_name%></span></span></td>
		<td valign="bottom" align="right" width="642"></td>
	</tr>
	<tr>
		<td bgcolor="#2C9CC4" colspan="2"><img border="0" src="../images/bline_3.gif" width="1" height="2"></td>
	</tr>
</table>
</div><br>
<form name="main" method="post" action="page_top_save.jsp">
<input name="action" type="hidden" value="<%=action%>">
<input name="id" type="hidden" value="<%=id%>">
<input name="web_template_type_id" type="hidden" value="<%=web_template_type_id%>">
<input name="web_project_id" type="hidden" value="<%=web_project_id%>">
<input name="web_project_name" type="hidden" value="<%=web_project_name%>">
<input name="flag" type="hidden" value="<%=flag%>">
<input name="file_name" type="hidden" value="<%=file_name%>">
<input name="title" type="hidden" value="<%=title%>">
<input name="title_desc" type="hidden" value="<%=title_desc%>">
<input name="test_desc" type="hidden" value="<%=test_desc%>">
<input name="page_name" type="hidden" value="<%=page_name%>">
<input name="content" type="hidden">
<div align="center">
<table width="90%" class="p1" border="0" cellSpacing="1" cellPadding="3" align="center" bgColor="#cccccc">
        <tr>
		<td align="right"  bgColor=#e9f0f4 width=12%">模板图片库：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp;
	            <a href="javascript:openWin('../edit/dialog/browse.htm?return=input&type=image&style=coolblue','740','620');">查看模板图片使用路径</a>
                </td>
	</tr>
        <tr>
	    <td colspan="2" align="left"  bgColor=#e9f0f4>&nbsp;&nbsp;&nbsp;&nbsp;网页头部(在线编辑器)</td>
	</tr>
	<tr>
	   <td colspan="2">
	   <textarea name="content1" style="display:none"><%=content%></textarea>
              <table width="100%" border="0" cellspacing="1" cellpadding="0" align="center">
                <tr>
                  <td>
                  <IFRAME ID="onlineEditor" src="../htmledit_template/ewebeditor.htm?id=content1&style=standard600&skin=office2003&web_account=<%=web_account%>" frameborder="0" scrolling="no" width="100%" height="408"></IFRAME>
                  <br/>
		  </td>
                </tr>
             </table>
	   </td>
	</tr>
	
</table>

<table border="0" cellpadding="3" class="p1" width="90%" bordercolor="#D7D7D7" style="border-collapse: collapse" cellspacing="0">
	<tr>
		<td  height="0" align="center">
		        <input border="0" type="button" value="保  存" onclick = "javascript: if(check_validate(main,'<%=web_account%>')){main.submit();}">
		        &nbsp;&nbsp;&nbsp;&nbsp;<input border="0" type="button" value="重  填" onclick = "document.main.reset();">
		        &nbsp;&nbsp;&nbsp;&nbsp;<input border="0" type="button" value="模板自测" onclick = "window.location='web_template_test.jsp?id=<%=id%>&flag=<%=flag%>'">
		        &nbsp;&nbsp;&nbsp;&nbsp;<input border="0" type="button" value="恢复初始模板" onclick = "if(confirm('真的要恢复初始模板吗？'))window.location='web_template_old1.jsp?id=<%=id%>&flag=<%=flag%>&file_name=<%=file_name%>&web_project_sys_account=<%=web_project_sys_account%>&page_name=<%=page_name%>&web_template_type_id=<%=web_template_type_id%>'">
		</td>
	</tr>
	<tr>
		<td  height="0" align="center">
		        <B>对模板的修改，保存后,要进行“模板自测”以验证模板是否合法，
		        <BR>
		        如果模板自测报错，表示模板修改有非法的地方，请进行重新修改保存与“模板自测”.<B>
		</td>
	</tr>
</table>
</div>
</form>
</body>
<Script Language="javaScript">
    function  check_validate(theForm,web_account) {
        
        if (isSpace(theForm.title.value)) {
            alert("模板名称不能为空！");
            theForm.title.focus();
            return false;
        }
        onlineEditor.doSubmit();
        var content_html=theForm.content1.value;
        var new_replace = new RegExp("(/"+web_account+"/my_cms_images/)","g");
        content_html=content_html.replace(new_replace,'/my_cms_images/');
        theForm.content.value=content_html;
        return true;
    }
    
</Script>
<Script>
function openWin (path ,w ,h) {
	var feature = "" ;
	var winWidth = 300;
	var winHeight =100 ;
	if ( w != "" ){
		winWidth = w ;
	}
	if ( h != "" ){
		winHeight = h ;	
	}
	var left = (window.screen.width - winWidth )/2;
	var top = (window.screen.height - winHeight)/2;
	feature += "height=";
	feature += winHeight ;
	feature += ",width=";
	feature += winWidth;
	feature += ",left=";
	feature += left ;
	feature += ",top=";
	feature += top;
	window.open (path,"",feature);
}
</script>
</html>
