Example #1
0
 /**
  * 获取配置列表与ThinkPHP配置合并
  * @return array 配置数组
  * @author jry <*****@*****.**>
  */
 public function lists()
 {
     $map['status'] = array('eq', 1);
     $list = $this->where($map)->field('name,value,type')->select();
     foreach ($list as $key => $val) {
         switch ($val['type']) {
             case 'array':
                 $config[$val['name']] = \Common\Util\Think\Str::parseAttr($val['value']);
                 break;
             case 'checkbox':
                 $config[$val['name']] = explode(',', $val['value']);
                 break;
             default:
                 $config[$val['name']] = $val['value'];
                 break;
         }
     }
     return $config;
 }
 /**
  * 获取某个分组的配置参数
  * @author jry <*****@*****.**>
  */
 public function group($group = 1)
 {
     //根据分组获取配置
     $map['status'] = array('egt', '0');
     // 禁用和正常状态
     $map['group'] = array('eq', $group);
     $data_list = D('Config')->where($map)->order('sort asc,id asc')->select();
     // 设置Tab导航数据列表
     $config_group_list = C('CONFIG_GROUP_LIST');
     // 获取配置分组
     foreach ($config_group_list as $key => $val) {
         $tab_list[$key]['title'] = $val;
         $tab_list[$key]['href'] = U('group', array('group' => $key));
     }
     // 构造表单名、解析options
     foreach ($data_list as &$data) {
         $data['name'] = 'config[' . $data['name'] . ']';
         $data['options'] = \Common\Util\Think\Str::parseAttr($data['options']);
     }
     // 使用FormBuilder快速建立表单页面。
     $builder = new \Common\Builder\FormBuilder();
     $builder->setMetaTitle('系统设置')->SetTabNav($tab_list, $group)->setPostUrl(U('groupSave'))->setExtraItems($data_list)->display();
 }