<?php
$forumset = unserialize($forum->forumset);
?>
<script type="text/javascript">
<!--
function addType(self) {
	
	var html = '<tr><td><?php echo CHtml::textField('topictype[view][]',0,array('size'=>2));?></td><td><?php echo CHtml::textField('topictype[name][]','',array('size'=>10));?></td></tr>';
	$(self).parent().parent().parent().append(html);
}

function deleteType(self, id) {
	$.ajax({
		type: 'GET',
		url: '<?php echo $this->createUrl('/admin/topictypes/delete');?>'+'&fid='+<?php echo $forum->fid;?>+'&id='+id,
		success:function(msg) {
			if (msg != '') {
				alert(msg);
			} else {
				$(self).parent().parent().remove();
			}
		}
	})
}

function editName(id) {
	var name = $('#n_'+id).val();
	$.ajax({
		type: 'POST',
		url: '<?php echo $this->createUrl('/admin/topictypes/editname');?>'+'&fid='+<?php echo $forum->fid;?>+'&id='+id,
		data: 'name='+name,
		success:function(msg) {
			if (msg != '') {
				alert(msg);
			} else {
				$(self).parent().parent().remove();
			}
		}
	})
}

function editViewOrder(id) {
	var o = $('#o_'+id).val();
	$.ajax({
		type: 'GET',
		url: '<?php echo $this->createUrl('/admin/topictypes/editvieworder');?>'+'&fid='+<?php echo $forum->fid;?>+'&id='+id+'&order='+o,
		success:function(msg) {
			if (msg != '') {
				alert(msg);
			} else {
				$(self).parent().parent().remove();
			}
		}
	})
}

function add() {
	
}
//-->
</script>
<table class="tab">
	<tr>
		<th>主题分类控制</th>
		<td><?php echo CHtml::radioButtonList('forum[t_type]', $forum->t_type, array(2=>'强制分类',1=>'允许分类',0=>'关闭分类'), array('separator'=>' '));?></td>
	</tr>
	<tr>
		<th>主题分类管理</th>
		<td>
			<table>
					<tr>
						<td>顺序</td>
						<td>名称</td>
					</tr>
					<?php if (!empty($types)):?>
						<?php foreach ($types as $type):?>
							<tr>
								<td><?php echo CHtml::textField('t['.$type->id.']',$type->vieworder,array('size'=>2,'id'=>'o_'.$type->id,'onchange'=>'editViewOrder('.$type->id.')'));?></td>
								<td><?php echo CHtml::textField('t['.$type->id.']',$type->name,array('size'=>10,'id'=>'n_'.$type->id,'onchange'=>'editName('.$type->id.')'));?> <?php echo CHtml::link('删除','javascript:void(0)',array('confirm'=>'确定要删除？','onclick'=>'deleteType(this,'.$type->id.')'));?></td>
							</tr>
						<?php endforeach;?>
					<?php endif;?>
					<tr>
						<td><?php echo CHtml::textField('topictype[view][]',0,array('size'=>2));?></td>
						<td><?php echo CHtml::textField('topictype[name][]','',array('size'=>10));?>[<?php echo CHtml::link('+','javascript:void(0)',array('onclick'=>'addType(this)'));?>]</td>
					</tr>
			</table>
		</td>
	</tr>
	<tr>
		<th>帖子列表分类显示</th>
		<td><?php echo CHtml::radioButtonList('forum[forumset][topictype]', $forumset['topictype'], array(1=>'开启',0=>'关闭'), array('separator'=>' '));?></td>
	</tr>
</table>