<?
$C_126cmsadmin_tname = 'wnm_config';

include(dirname(__FILE__)."/../global.php");


include("../post_info/form_moudle.php");


@$job = $submitted_vars['job'];
$mid = $submitted_vars['mid'];


if( $job == 'edit' ){

	$_postdb = $_POST['postdb'];
	foreach($_postdb AS $key=>$value){
		$value=stripslashes($value);
		$postdb[$key]=$value;
	}
	updatetofile("../tpl/wn_tpl/post_$mid.htm",$postdb['tpl_post']);
	updatetofile("../tpl/wn_tpl/modify_$mid.htm",$postdb['tpl_modify']);
	updatetofile("../tpl/wn_tpl/list_$mid.htm",$postdb['tpl_list']);
	
	$showmsg = "模板生成成功！";
	$formurl = "makeWNtpl.php?mid=$mid";	 
	include('../showmsg.php');

	exit();
	
}else{

	//模块设置 读取显示
	$query="SELECT * FROM `w6_module` WHERE `module_id`='".$mid."'";
	$result=mysql_query($query);
	$f_module_config       =  mysql_result($result,"0","module_config");
	$f_array = unserialize($f_module_config);
	$field_set = $f_array['field_set'];



	foreach($f_array AS $key=>$rs){

		$wnTpl .= formMoudlePost( $rs );
	
	}
	$tpl_post = read_file('../tpl/mother/post.htm');

	$tpl_post = str_replace('$wnTpl',$wnTpl,$tpl_post);
	$tpl_post = str_replace('"','&quot;',$tpl_post);
	$tpl_post = str_replace("'",'&#39;',$tpl_post);
	$tpl_post = str_replace("<","&lt;",$tpl_post);
	$tpl_post = str_replace(">","&gt;",$tpl_post);



	unset($wnTpl);
	foreach($f_array AS $key=>$rs){

		$wnTpl .= formMoudleModify( $rs );
	
	}

	$tpl_modify = read_file('../tpl/mother/modify.htm');
	$tpl_modify = str_replace('$wnTpl',$wnTpl,$tpl_modify);
	$tpl_modify = str_replace('"','&quot;',$tpl_modify);
	$tpl_modify = str_replace("'",'&#39;',$tpl_modify);
	$tpl_modify = str_replace("<","&lt;",$tpl_modify);
	$tpl_modify = str_replace(">","&gt;",$tpl_modify);




	$tpl_list = read_file('../tpl/mother/list.htm');
	$tpl_list = str_replace('"','&quot;',$tpl_list);
	$tpl_list = str_replace("'",'&#39;',$tpl_list);
	$tpl_list = str_replace("<","&lt;",$tpl_list);
	$tpl_list = str_replace(">","&gt;",$tpl_list);

}

/*

//模块设置 读取显示
  $query="SELECT * FROM `w6_module` WHERE `module_id`='".$mid."'";
  $result=mysql_query($query);
  $f_module_config       =  mysql_result($result,"0","module_config");
  $f_array = unserialize($f_module_config);
  $field_set = $f_array['field_set'];


ob_start();
require('../tpl/mother/post.htm');
$tpl_post = ob_get_contents();
	$tpl_post = str_replace('"','&quot;',$tpl_post);
	$tpl_post = str_replace("'",'&#39;',$tpl_post);
	$tpl_post = str_replace("<","&lt;",$tpl_post);
	$tpl_post = str_replace(">","&gt;",$tpl_post);
ob_end_clean();


ob_start();
require('../tpl/mother/modify.htm');
$tpl_modify = ob_get_contents();
	$tpl_modify = str_replace('"','&quot;',$tpl_modify);
	$tpl_modify = str_replace("'",'&#39;',$tpl_modify);
	$tpl_modify = str_replace("<","&lt;",$tpl_modify);
	$tpl_modify = str_replace(">","&gt;",$tpl_modify);
ob_end_clean();



ob_start();
require('../tpl/mother/list.htm');
$tpl_list = ob_get_contents();
	$tpl_list = str_replace('"','&quot;',$tpl_list);
	$tpl_list = str_replace("'",'&#39;',$tpl_list);
	$tpl_list = str_replace("<","&lt;",$tpl_list);
	$tpl_list = str_replace(">","&gt;",$tpl_list);
ob_end_clean();
*/

?><!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	font-size: 12px;
}
.red {color: #FF0000}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_popupMsg(msg) { //v1.0
  return confirm(msg);
}

function get_obj(obj){
   return document.getElementById(obj);
}
//-->
</SCRIPT>

</head>

<body>
 [<a href="module_list.php">模块分类管理</a>] [<a href="field_list.php?module_id=<?=$mid?>" target="">全部字段</a>] [<a href="field_insert.php?module_id=<?=$mid;?>">添加字段</a><a href="field_insert.php"></a>] [<a href="field_set.php?module_id=<?=$mid;?>">综合设置</a>]<br />

<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#A4B6D7">
    <tr>
      <td height="25" colspan="2" bgcolor="#B1C3D9" background="../images/titlebg.jpg"><span class="font_title">万能模块模板管理</span></td>
    </tr>
    <tr>
      <td width="22%" bgcolor="#FFFFFF">后台发布页模板:</td>
      <td width="78%" bgcolor="#FFFFFF"><textarea name="postdb[tpl_post]" id="postdb[tpl_post]" cols="70" rows="6"><?=$tpl_post?></textarea>
      <br />
      母模板:/tpl/mother/post.htm<br />
      模板将保存在:/tpl/wn_tpl/post_<?=$mid?>.htm</td>
    </tr>
    <!--
    <tr>
      <td bgcolor="#FFFFFF">前台内容页模板:</td>
      <td bgcolor="#FFFFFF"><label>
        <textarea name="tpl_q_show" id="tpl_q_show" cols="45" rows="5"></textarea>
      </label></td>
    </tr>
    //-->
    <tr>
      <td bgcolor="#FFFFFF">后台编辑页模板:</td>
      <td bgcolor="#FFFFFF"><label>
        <textarea name="postdb[tpl_modify]" id="postdb[tpl_modify]" cols="70" rows="6"><?=$tpl_modify?></textarea>
        <br />
        母模板:/tpl/mother/modify.htm<br />
模板将保存在:/tpl/wn_tpl/modify_<?=$mid?>.htm<br />
      </label></td>
    </tr>
    <!--
    <tr>
      <td bgcolor="#FFFFFF">前台列表页模板:</td>
      <td bgcolor="#FFFFFF"><label>
        <textarea name="tpl_q_list" id="tpl_q_list" cols="45" rows="5"></textarea>
      </label></td>
    </tr>
    //-->
    <tr id="field_leng_tr">
      <td bgcolor="#FFFFFF">后台列表页模板:</td>
      <td bgcolor="#FFFFFF"><label>
        <textarea name="postdb[tpl_list]" id="postdb[tpl_list]" cols="70" rows="6"><?=$tpl_list?></textarea>
        <br />
      母模板:/tpl/mother/list.htm<br />
模板将保存在:/tpl/wn_tpl/list_<?=$mid?>.htm</label></td>
    </tr>
    <tr>
      <td colspan="2" align="center" bgcolor="#FFFFFF"><input name="mid" type="hidden" id="mid" value="<?=$mid?>" />
	  
        <input name="job" type="hidden" id="job" value="edit" />
<input type="submit" name="Submit" value="提交" /></td>
    </tr>
    <tr>
      <td colspan="2" align="left" bgcolor="#FFFFFF">注意:<br />
        1.请务必确认 /tpl/wn_tpl/ 这个目录权限可写,否则无法生成模板<br />
      2.母模板存放在   /tpl/mother/   post.htm后台内容发布提交页,list.htm是后台列表页,modify.php是后台编辑页.</td>
    </tr>
  </table>
<SCRIPT LANGUAGE="JavaScript">
<!--
function field_choose(t){
	if(t=='mediumtext'){
		get_obj('field_leng_tr').style.display='none';
	}else{
		get_obj('field_leng_tr').style.display='';
	}
}
field_choose('<?=$array[$field_id]['field_type']?>');


function form_choose(t){
	if(t=='select'||t=='radio'||t=='checkbox'||t=='select'||t=='upphoto'||t=='pingfen'||t=='ieedit'||t=='textarea'){
		get_obj('form_set_tr').style.display='';
	}else{
		get_obj('form_set_tr').style.display='none';
	}
}
form_choose('<?=$array[$field_id]['form_type']?>');
//-->
</SCRIPT>
</form>
</body>
</html>
