/** * 单个微+插件主页 * @param $name 插件名称 * @author jry <*****@*****.**> */ public function adminList($name, $tab = 1) { //获取插件实例 $addon_class = get_addon_class($name); if (!class_exists($addon_class)) { $this->error('插件不存在'); } else { $addon = new $addon_class(); } //获取插件的$admin_list配置 $admin_list = $addon->admin_list; $tab_list = array(); foreach ($admin_list as $key => $val) { $tab_list[$key]['title'] = $val['title']; $tab_list[$key]['href'] = U('Home/Addon/adminList/name/' . $name . '/tab/' . $key); } $admin = $admin_list[$tab]; $param = D('Addons://' . $name . '/' . $admin['model'] . '')->adminList; if ($param) { //搜索 $keyword = (string) I('keyword'); $condition = array('like', '%' . $keyword . '%'); $map['id|' . $param['search_key']] = array($condition, $condition, '_multi' => true); //获取数据列表 $data_list = M($param['model'])->page(!empty($_GET["p"]) ? $_GET["p"] : 1, C('ADMIN_PAGE_ROWS'))->where($map)->field(true)->order($param['order'])->select(); $page = new \Common\Util\Page(M($param['model'])->where($map)->count(), C('ADMIN_PAGE_ROWS')); //使用Builder快速建立列表页面。 $builder = new \Common\Builder\ListBuilder(); $builder->setMetaTitle($addon->info['title'])->AddTopButton('addnew', array('href' => U('Home/Addon/adminAdd/name/' . $name . '/tab/' . $tab)))->AddTopButton('resume', array('model' => $param['model']))->AddTopButton('forbid', array('model' => $param['model']))->setSearch('请输入关键字', U('Home/Addon/adminList/name/' . $name, array('tab' => $tab)))->SetTabNav($tab_list, $tab)->setTableDataList($data_list)->setTableDataPage($page->show()); //数据列表分页 //根据插件的list_grid设置后台列表字段信息 foreach ($param['list_grid'] as $key => $val) { $builder->addTableColumn($key, $val['title'], $val['type']); } //根据插件的right_button设置后台列表右侧按钮 foreach ($param['right_button'] as $key => $val) { $builder->addRightButton('self', $val); } //定义编辑按钮 $attr = array(); $attr['title'] = '编辑'; $attr['class'] = 'label label-info'; $attr['href'] = U('Home/Addon/adminEdit', array('name' => $name, 'tab' => $tab, 'id' => '__data_id__')); //显示列表 $builder->addTableColumn('right_button', '操作', 'btn')->addRightButton('self', $attr)->addRightButton('forbid', array('model' => $param['model']))->addRightButton('delete', array('model' => $param['model']))->setTemplate('_Builder/listbuilder_addon')->display(); } else { $this->error('插件列表信息不正确'); } }
/** * 单个微+插件主页 * @param $name 插件名称 * @author jry <*****@*****.**> */ public function weijia($name, $tab = 1) { //获取插件实例 $addon_class = get_addon_class($name); if (!class_exists($addon_class)) { $this->error('插件不存在'); } else { $addon = new $addon_class(); } //获取插件的$admin_list配置 $admin_list = $addon->admin_list; $tab_list = array(); foreach ($admin_list as $key => $val) { $tab_list[$key] = $val['title']; } $admin = $admin_list[$tab]; $param = D('Addons://' . $name . '/' . $admin['model'] . '')->adminList; if ($param) { //搜索 $keyword = (string) I('keyword'); $condition = array('like', '%' . $keyword . '%'); $map['id|' . $param['search_key']] = array($condition, $condition, '_multi' => true); //获取数据列表 $data_list = M($param['model'])->page(!empty($_GET["p"]) ? $_GET["p"] : 1, C('ADMIN_PAGE_ROWS'))->where($map)->field(true)->order($param['order'])->select(); $page = new \Common\Util\Page(M($param['model'])->where($map)->count(), C('ADMIN_PAGE_ROWS')); //使用Builder快速建立列表页面。 $builder = new \Common\Builder\ListBuilder(); $builder->title($addon->info['title'])->AddNewButton('Addon/weijiaAdd/name/' . $name . '/tab/' . $tab)->addResumeButton($param['model'])->addForbidButton($param['model'])->setSearch('请输入关键字', U('Addon/weijia/name/' . $name, array('tab' => $tab)))->SetTablist($tab_list)->setTabUrl('Addon/weijia/name/' . $name)->SetCurrentTab($tab)->setPage($page->show())->dataList($data_list); //数据列表 //根据插件的list_grid设置后台列表字段信息 foreach ($param['list_grid'] as $key => $val) { $builder->addField($key, $val['title'], $val['type']); } //根据插件的right_button设置后台列表右侧按钮 foreach ($param['right_button'] as $key => $val) { $attr['title'] = $val['title']; $attr['target'] = $val['target'] ?: '_self'; $attr['addon'] = true; $attr['href'] = $name . '://' . $val['href']; $builder->addRightButton('self', $attr); } $attr = array(); $attr['title'] = '编辑'; $attr['href'] = 'Addon/weijiaEdit/name/' . $name . '/tab/' . $tab . '/id/'; //显示列表 $builder->addField('right_button', '操作', 'btn')->addRightButton('self', $attr)->addRightButton('forbid', $param['model'])->addRightButton('delete', $param['model'])->setTemplate('Builder/listbuilder_addon')->display(); } else { $this->error('插件列表信息不正确'); } }