Config.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Lang;
  4. class Config extends AdminControl {
  5. public function _initialize() {
  6. parent::_initialize();
  7. Lang::load(APP_PATH . 'admin/lang/' . config('default_lang') . '/config.lang.php');
  8. }
  9. /**
  10. * 网站配置
  11. * @return mixed
  12. */
  13. public function index() {
  14. $model_config = model('config');
  15. $allpower = $this->qxhans();
  16. $this->assign('allpower',$allpower);
  17. if (!request()->isPost()) {
  18. $list_config = $model_config->getListConfig();
  19. $this->assign('list_config', $list_config);
  20. $this->setAdminCurItem('index');
  21. return $this->fetch();
  22. } else {
  23. $update_array = array();
  24. // $update_array['cache_open'] = isset($_POST['cache_open']) ? '1' : '';
  25. // $update_array['guest_comment'] = isset($_POST['guest_comment']) ? '1' : '';
  26. // $update_array['words_open'] = isset($_POST['words_open']) ? '1' : '';
  27. // $update_array['img_open'] = isset($_POST['img_open']) ? '1' : '';
  28. // $update_array['voice_open'] = isset($_POST['voice_open']) ? '1' : '';
  29. // $update_array['video_open'] = isset($_POST['video_open']) ? '1' : '';
  30. $update_array['site_state'] = isset($_POST['site_state']) ? '1' : '';
  31. $update_array['site_name'] = $_POST['site_name'];
  32. $update_array['icp_number'] = $_POST['icp_number'];
  33. $update_array['site_phone'] = $_POST['site_phone'];
  34. $update_array['flow_static_code'] = $_POST['flow_static_code'];
  35. $result = $model_config->updateConfig($update_array);
  36. if ($result === true) {
  37. $this->log(lang('ds_edit') . lang('dis_dump'), 1);
  38. $this->success('修改成功', 'Config/index');
  39. } else {
  40. $this->log(lang('ds_edit') . lang('dis_dump'), 0);
  41. $this->error(lang('修改失败'));
  42. }
  43. }
  44. }
  45. /**
  46. * 获取卖家栏目列表,针对控制器下的栏目
  47. */
  48. protected function getAdminItemList() {
  49. $menu_array = array(
  50. array(
  51. 'name' => 'base',
  52. 'text' => lang('site_set'),
  53. 'url' => url('Admin/Config/index')
  54. ),
  55. );
  56. return $menu_array;
  57. }
  58. }