<?php 
/*
　* @$Id
　* @
　* @Ver: 2.0
　* @Create: 2009-11-18 8:10
　* @Modify: 
　* @Author: CPWEB http://www.cpweb.net.cn
　* @Copyright (C) 2008 www.cpweb.net.cn. All Rights Reserved.
　* @License CPWEB is free software and use is subject to license terms
　*/
class MenusAction extends GlobalAction 
{
	function _initialize()
	{
		parent::_initialize();
		$this->model='Menu';
	}
	public function index()
	{
		$this->cpweb_list();
		$this->display();
	}
	public function add()
	{
		$map['menu_id']=0;
		$Menu=M('Menu')->where($map)->findall();
		$this->assign('menu',$Menu);
		$this->display();
	}
	public function edit()
	{
		$this->cpweb_read();
		$map['menu_id']=0;
		$Menu=M('Menu')->where($map)->findall();
		$this->assign('menu',$Menu);
		$this->display();
	}
	public function submit(){
		$act=$_REQUEST['act'];
		$id=$_REQUEST['id'];
		if($act=='delete'&&!is_array($id)){//单个删除时才检测栏目的删除权限
			$S=M('Menu')->find($id);
			if (!$id||!$S) $this->error(L('CPWEB_SELECT_NOT_EXIST'));//检测删除的内容是否存在
		}
		$this->_subAction();
	}
	public function getmenu()
	{
		$id=$_REQUEST["id"];
		$map['menu_id']=$id;
		$counter=0;
		$optionsInfo='{';
		$Menu=M('Menu')->where($map)->findall();
		foreach($Menu AS $key => $value){
			if($counter>0){
				$optionsInfo=$optionsInfo.",";
			}
			$optionsInfo=$optionsInfo."'";
			$optionsInfo=$optionsInfo.$value["id"];
			$optionsInfo=$optionsInfo."':'";
			$optionsInfo=$optionsInfo.$value["name"];
			$optionsInfo=$optionsInfo."'";
			$counter++; 
		}
		$optionsInfo=$optionsInfo.'}';
		print($optionsInfo);
	}
}
?>