예제 #1
0
 /**
  * 获取菜单
  */
 public function getmenusAction()
 {
     // 请求参数
     $request = $this->getRequest()->getParams();
     // 请求菜单的层级ID
     $parent_id = isset($request['parent_id']) ? $request['parent_id'] : 0;
     $option = isset($request['option']) ? $request['option'] : null;
     $menu = new Home_Model_Menu();
     //echo date('H:i:s').'<br>';
     if ($option == 'treedata') {
         echo Zend_Json::encode($menu->getTreeData($parent_id));
     } else {
         $data = $menu->getMenuData($parent_id);
         /* echo '<pre>';
            print_r($data);
            exit; */
         $json = Zend_Json::encode($data);
         $patterns[0] = '/"disabled":"0"/';
         $patterns[1] = '/"disabled":"1"/';
         $patterns[2] = '/"handler":"menuClick"/';
         $replacements[2] = '"disabled":0';
         $replacements[1] = '"disabled":1';
         $replacements[0] = '"handler":menuClick';
         // 转换JSON中的数据格式(临时解决办法)
         echo preg_replace($patterns, $replacements, $json);
     }
     //echo date('H:i:s').'<br>';
     exit;
 }