<?php

$error = $input = array();
$catarr=$this->category->index_fetch(array('pid'=>0), array('rank'=>-1), 0, 1000);
if(!$this->form_submit()) {
	$arr = $this->kv->get('index_bbs_show');
	foreach($catarr as &$c){
		$id=$c['id'];
		if(isset($arr[$id])){
			$v=$arr[$id];
			$c['isshow']=1;
			$c['num']=$v['num'];
			$c['max']=$v['max'];
			$c['showtype']=$v['showtype'];
		}else{
			$c['isshow']=0;
			$c['num']=4;
			$c['max']=12;
			$c['showtype']=1;
		}
	}

	$this->view->assign('dir', $dir);
	$this->view->assign('list', $catarr);
	$this->view->display('plugin_view_bbs.htm');
} else {
	$isshow=core::gpc('isshow','P');
	$showtype=core::gpc('showtype','P');
	$num=core::gpc('num','P');
	$max=core::gpc('max','P');
	$arr=array();
	foreach($catarr as $c){
		$id=$c['id'];
		if(isset($isshow[$id]) && $isshow[$id]){
			$arr[$id]=array(
			   'name'=>$c['name'],
			   'showtype'=>intval($showtype[$id]),
			   'num'=>intval($num[$id]),
			   'max'=>intval($max[$id]),
			 );
		}
	}
	$this->kv->set('index_bbs_show',$arr);
	$this->kv->delete('index_forum_list');
	
	$this->message('设置成功！', 1, '?plugin-setting-dir-view_bbs.htm');
	
}

?>