/** * * @param unknown $pid * @param unknown $perms * @param unknown $str * @return number */ public function get_menu_formlist($pid, &$perms, &$str, $ext = 0) { if (empty($this->menuList)) { $this->getMenuArray(); } $menus = array(); foreach ($this->menuList as $k => $v) { if ($v['parent_id'] != $pid) { continue; } $menus[$k] = $v; } if (count($menus) > 0) { $str .= '<ul>'; foreach ($this->menuList as $k => $v) { if ($v['parent_id'] != $pid) { continue; } $str .= '<li><span class="label">' . $v['menu_name'] . ' '; $c_n = $this->get_menu_formlist($v['id'], $perms, $str, $ext); if ($c_n == 0) { //$str.= '<span>'; $str .= ':'; $str .= '</span>'; //if($ext) // $str.= '<input type="checkbox" class="checkbox" name="perm_none['.$v['id'].'][0]" value="0" /><span class="label">禁用,</span>'; foreach (PageAuth::getDefined() as $p => $pname) { if ($v['perm_id'] & $p) { $checkstr = ''; if (isset($perms[$v['id']]) && $perms[$v['id']] & $p) { $checkstr = ' checked'; } $str .= '<input type="checkbox" class="checkbox" name="perm[' . $v['id'] . '][' . $p . ']" value="' . $p . '" ' . $checkstr . ' /><span class="label">' . $pname . '</span>'; } } } $str .= '</span>'; $str .= '</li>'; } $str .= '</ul>'; } //if($n==0)$str=str_replace('<ul></ul>', '', $str); return count($menus); }
/** * 取得表单配置 * @param boolean $isInsert 1 是插入表单配置,0 是修改表单 * @param array $data 修改表单时传入数组 * @return array */ protected function _getFormConfig($isInsert = true, $data = array(), $info = array()) { Doo::loadClassAt('DataExt', 'default'); $dataExt = new DataExt(); Doo::loadClassAt('Menu', 'default'); $menu = new menu(DBproxy::getManage()); // D($info); $name = isset($info['menu_name']) ? $info['menu_name'] : ''; $typeId = isset($info['type_id']) ? $info['type_id'] : 0; $sortId = isset($info['sort_id']) ? $info['sort_id'] : 0; $permId = isset($info['perm_id']) ? $info['perm_id'] : 0; //权限换算 $permList = $menu->getMenuList($permId); $isShow = isset($info['is_show']) ? $info['is_show'] : 1; $pageUrl = isset($info['page_url']) ? $info['page_url'] : ''; $parentId = isset($info['parent_id']) ? $info['parent_id'] : 0; $sep = isset($info['_sep']) ? $info['_sep'] : ''; $menuRecursStr = $menu->getParentidTree(0); $list = array(); $list[0] = '顶层菜单'; foreach ($data as $row => $rowData) { if ($rowData['type_id'] == 1) { continue; } $sep = substr($rowData['_sep'], 1); if ($sep != '') { $sep = str_replace('.', ' ', $sep); $dot = '└─'; if (isset($data[$row + 1])) { if ($data[$row + 1]['parent_id'] == $rowData['parent_id']) { $dot = '├─'; } } //$sep = $sep.$dot; //$dot = ''; } else { $dot = '├─'; } $sep = $sep . $dot; $dot = ''; $list[$rowData['id']] = $sep . $rowData['menu_name']; } $insertForm = array('method' => 'post', 'renderFormat' => 'html', 'action' => '', 'attributes' => array('id' => 'js-form', 'class' => 'form-horizontal'), 'elements' => array('errors' => array('display', array('div' => false, 'label-hide' => true, 'content' => '<div id="js-form-errors" class=""></div><div style="clear:both"></div>')), 'parent_id' => array('select', array('label' => '父类标识:', 'attributes' => array('class' => "m-wrap"), 'multioptions' => $list, 'value' => $parentId)), 'type_id' => array('select', array('label' => '菜单类型:', 'attributes' => array('class' => "m-wrap"), 'multioptions' => array(1 => '页面', 2 => '分类'), 'value' => $typeId)), 'menu_name' => array('text', array('label' => '菜单名称:', 'attributes' => array('class' => "m-wrap"), 'value' => $name, 'help' => '必填项')), 'page_url' => array('text', array('label' => '菜单地址:', 'attributes' => array('class' => "m-wrap"), 'value' => $pageUrl, 'help' => '必填项')), 'permission' => array('MultiCheckbox', array('label' => '菜单权限:', 'multioptions' => PageAuth::getDefined(), 'value' => $permList, 'help' => '<span class="label-warning label">修改菜单地址时将自动勾选</span>')), 'sort_id' => array('text', array('label' => '排序标识:', 'attributes' => array('class' => "m-wrap"), 'value' => $sortId, 'help' => '必填项')), 'is_show' => array('MultiRadio', array('label' => '是否显示:', 'multioptions' => array(1 => '是', 0 => '否'), 'value' => array($isShow))), 'saveAndReutrn' => array('button', array('div' => false, 'left' => '<div class="form-actions js-submitButton">', 'label' => '<i class="icon-arrow-left"></i>保存&返回', 'attributes' => array('class' => "btn blue"), 'value' => 1)), 'saveAndAdd' => array('button', array('div' => false, 'left' => ' ', 'label' => '<i class="icon-plus"></i>保存&新增', 'attributes' => array('class' => "btn blue"), 'value' => 1)), 'cancel' => array('display', array('div' => false, 'left' => ' ', 'content' => '<a class="btn" href="' . $_SERVER['REQUEST_URI'] . '"><i class="icon-undo"></i>取消</a>')), 'cancelAndReturn' => array('display', array('div' => false, 'left' => ' ', 'right' => '</div>', 'content' => '<a class="btn" href="' . MenuController::$dataTableUrl . '"><i class="icon-arrow-left"></i>取消&返回</a>')))); if ($isInsert) { return $insertForm; } else { // 将数据写入表单 foreach ($data as $key => $val) { if (isset($insertForm['elements'][$key])) { $insertForm['elements'][$key][1]['value'] = $val; } } return $insertForm; } }