<?php
/**
 * 导航管理模块
 * @copyright reginx.com
 * $Id$
 */
class nav_mod extends admin_mod {

	/**
	 * 列表
	 *
	 */
	public function listAct(){
		$this->assign('atitle' , '导航列表');
		$this->assign('local' , config_lib::$nctype);
		$this->assign('list' , core::getobj('nav_tab')->order("sort desc")->getall());
		$this->display('misc/nav.list.html');
	}

	/**
	 * 新增/修改
	 *
	 */
	public function addAct(){
		$id = intval($this->get('id'));
		$this->assign('atitle' , '新增导航');
		if($id > 0){
			$nav = core::getobj('nav_tab')->where("id = $id ")->get();
			$this->assign('atitle' , "修改 [{$nav['name']}]");
			$this->assign('nav' , $nav);
		}
		$this->assign('local' , config_lib::$nctype);
		$this->assign('cat2' , core::getobj('cat_tab')->getslist( 0 , 2));
		$this->assign('cat3' , core::getobj('cat_tab')->getslist( 0 , 3));
		$this->display('misc/nav.add.html');
	}

	/**
	 *  保存
	 *
	 */
	public function saveAct(){
		$obj = core::getobj('nav_tab');
		if($obj->load()){
			$ret = $obj->save();
			if($ret['code'] === 0){
				$this->showmsg('操作成功' , core::url('nav-list') , 1 ,2);
			}
		}
		$this->showmsg($obj->geterr() , -1 ,1 ,2);
	}

	public function delAct(){
		$id = intval($this->get('id'));
		if($id > 0){
			$nav = core::getobj('nav_tab')->where("id = $id ")->del();
		}
		$this->showmsg('操作成功' , core::url('nav-list') , 1 ,2);
	}
}
?>