<!--<?php
include_once PrintEot('left');
print <<<EOT
-->
<h3>提示信息</h3>
<div class="tr5">预设帖子格式说明功能：您可以设定帖子格式，以便于发此类帖子时可以省时省力，比如发出租信息等。(支持html代码)</div>
<!--
EOT;
if(!$action){ print <<<EOT
-->
<ul class="nav3">
<li><a href="#" class="two">格式列表</a></li>
<li><a href="$basename&action=add">添加帖子格式</a></li>
</ul>
<div class="c"></div>
<form action="$basename" method="post">
<h2>预设帖子格式</h2>
<table width="100%" cellspacing="0" cellpadding="0">
	<tr class="tr3 tac s3">
		<td width="6%">ID</td>
		<td width="*">帖子格式标题</td>
		<td width="10%" class="tal">编辑</td>
		<td width="6%">启用</td>
		<td width="5%">删</td>
	</tr>
<!--
EOT;
$i=0;
foreach($setformdb as $key=>$val){
$checked = ${'c_'.$val[id]};
$i++;
print <<<EOT
-->
	<tr class="tr3 tac">
		<td>$i</td>
		<td align="left">$val[name]</td>
		<td><a class="fourm-two" title="编辑" href="$basename&action=edit&id=$val[id]"><span class="edit"></span></td>
		<td><input type="checkbox" name="ifopen[]" value="$val[id]" $checked /></td>
		<td><input type="checkbox" name="selid[]" value="$val[id]" onclick="pwJsCheck(this)" /></td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
</table><br />
<input type="hidden" name="action" value="del" />
<center><input type="submit" value="提 交" class="btn" /></center></form><br/>
<!--
EOT;
}elseif($action=='add' || $action=='edit'){print <<<EOT
-->
<style type="text/css">
.checkon{background:#CAFFC0;}
</style>
<ul class="nav3">
<li><a href="$basename">格式列表</a></li>
<!--
EOT;
if($action=='add'){print <<<EOT
-->
<li><a href="#" class="two">添加帖子格式</a></li>
<!--
EOT;
}else{print <<<EOT
-->
<li><a href="#" class="two">编辑帖子格式</a></li>
<!--
EOT;
}print <<<EOT
-->
</ul>
<div class="c"></div>

<form action="$basename" name="setform" method="post" onsubmit="return checkform();">
<h2>帖子格式</h2>
<table width="100%" cellspacing="0" cellpadding="0">
	<tr class="tr3">
		<td width="25%">标题</td>
		<td width="*"><input type="text" class="input" name="name" value="$name" size="40" onchange="ShowTitle();" /></td>
	</tr>
	<tr class="tr3">
		<td width="25%">帖子格式</td>
		<td width="*">
			<fieldset id="tagmenu" style="border:1px solid $tdcolor;width:250px;padding:3px;margin:2px 0;float:right"><legend>栏目编辑器</legend><div style="padding:5px">
			<table><tr><td>栏目名称：</td><td><input class="input" type="text" name="title" size="22" /></td></tr>
			<tr><td>栏目类型：</td><td><select name="type" onchange="ShowType(this.value);"><option value="0">文本输入框</option><option value="1">下拉选择框</option></select></td></tr>
			<tr id="e_content" style="display:none;"><td>选项内容：<br />(一行一个)</td><td><textarea name="content" style="height:50px;width:150px;"></textarea></td></tr>
			</table>
			<div style="text-align:center;margin-top:8px"><input type="button" class="btn" value="添 加" onclick="addcol('1');" /> <input type="button" value="修 改" onclick="addcol('2');" class="btn"/> <input type="button" class="btn" value="删 除" onclick="delcol();" /></div>
			</div></fieldset>
			<table width="350" cellspacing="1" cellpadding="3" class="i_table" style="margin:12px 2px">
				<tr class="head" onclick="clearselid();"><td colspan="2" id="s_title"></td></tr>
				<tbody id="s_table">
<!--
EOT;
if($action=='edit'){
foreach($setform as $k=>$v){print <<<EOT
-->
				<tr id="col_$k" class="tr3" onclick="editcol(this.id);"><td>$v[0]</td><td><!--
EOT;
if($v[1]){
$option = explode(',',$v[1]);
print <<<EOT
--><select><!--
EOT;
foreach($option as $v1){print <<<EOT
--><option>$v1</option><!--
EOT;
}print <<<EOT
--></select><!--
EOT;
}else{print <<<EOT
--><input type="text" class="input" /><!--
EOT;
}print <<<EOT
--></td></tr><!--
EOT;
}}print <<<EOT
-->
				</tbody>
			</table>

		</td>
	</tr>
</table><br />
<br />
<input type="hidden" name="action" value="$action" />
<input type="hidden" name="id" value="$id" />
<input type="hidden" name="step" value="3" />
<center><input type="submit" value="提 交" class="btn"/></center></form><br/>
<script language="JavaScript">
var colnum = '$num';
var selid  = '';
function ShowTitle(){
	var v = document.setform.name.value;
	getObj('s_title').innerHTML = v ? v : '<br />';
}
function ShowType(id){
	document.setform.type.options[id].selected = true;
	getObj('e_content').style.display = id==1 ? '' : 'none';
}
function addcol(id){
	if(id==1){
		var s = document.createElement('tr');
		s.className		= 'tr3';
		s.id			= 'col_' + colnum;
		s.onmouseover	= function(){if(this.className!='checkon'){this.className='tr3';};};
		s.onmouseout	= function(){if(this.className!='checkon'){this.className='tr3';};};
		s.onclick		= function(){editcol(this.id);};
		if(selid==''){
			getObj('s_table').appendChild(s);
		} else{
			getObj('s_table').insertBefore(s,getObj(selid));
		}
		colnum ++;
	} else{
		if(selid == '')return;
		var s = getObj(selid);
		while(s.hasChildNodes()){
			s.removeChild(s.firstChild);
		}
	}
	var d = document.createElement('td');
	d.innerHTML = document.setform.title.value;
	s.appendChild(d);
	var d = document.createElement('td');
	var type = document.setform.type.value;
	if(type==0){
		d.innerHTML = '<input type="text" class="input" />';
	} else{
		var content = document.setform.content.value.split("\\n");
		var html    = "<select name=''>";
		for(var i=0;i<content.length;i++){
			html   += '<option>'+content[i]+'</option>';
		}
		html       += "</select>";
		d.innerHTML = html;
	}
	s.appendChild(d);
}
function editcol(id){
	selid = id;
	var ds = get_tags(getObj('s_table'),'tr');
	for(var i=0;i<ds.length;i++){
		ds[i].className = id==ds[i].id ? 'checkon' : 'b';
	}
	var o	= getObj(id);
	var td1 = o.firstChild;
	var td2 = o.lastChild;
	document.setform.title.value = td1.innerHTML;
	if(td2.firstChild.tagName.toLowerCase() == 'input'){
		ShowType('0');
	} else{
		ShowType('1');
		var sel  = td2.firstChild.options;
		var html = '';
		for(var i=0;i<sel.length;i++){
			html += (html ? "\\n" : '')+sel[i].text;
		}
		document.setform.content.value = html;
	}
}
function delcol(){
	if(selid!=''){
		getObj('s_table').removeChild(getObj(selid));
		selid = '';
	}
}
function clearselid(){
	selid = '';
	var ds = get_tags(getObj('s_table'),'tr');
	for(var i=0;i<ds.length;i++){
		ds[i].className = 'tr3';
	}
}
function checkform(){
	if(document.setform.name.value == ''){
		alert('标题不能为空');
		return false;
	}
	var s = getObj('s_table');
	if(s.hasChildNodes()){
		var ds = get_tags(s,'tr');
		var input;
		for(var i=0;i<ds.length;i++){
			input		= document.createElement('input');
			input.type	= 'hidden';
			input.name	= 'value['+i+']';
			input.value	= ds[i].firstChild.innerHTML;
			document.setform.appendChild(input);
			if(ds[i].lastChild.firstChild.tagName.toLowerCase() == 'select'){
				input	= document.createElement('input');
				input.type	= 'hidden';
				input.name	= 'descipt['+i+']';
				var sel  = ds[i].lastChild.firstChild.options;
				var html = '';
				for(var j=0;j<sel.length;j++){
					html += (html ? "," : '')+sel[j].text;
				}
				input.value	= html;
				document.setform.appendChild(input);
			}
		}
		return true;
	} else{
		alert('您没有添加相关栏目');
		return false;
	}
}
ShowTitle();
</script>
<!--
EOT;
}include_once PrintEot('adminbottom');
?>-->