Uiset.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. /**
  3. * 易优CMS
  4. * ============================================================================
  5. * 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.eyoucms.com
  7. * ----------------------------------------------------------------------------
  8. * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
  9. * ============================================================================
  10. * Author: 小虎哥 <1105415366@qq.com>
  11. * Date: 2018-4-3
  12. */
  13. namespace app\admin\controller;
  14. use think\Page;
  15. class Uiset extends Base
  16. {
  17. public $theme_style;
  18. public $templateArr = array();
  19. /*
  20. * 初始化操作
  21. */
  22. public function _initialize() {
  23. parent::_initialize();
  24. $this->theme_style = 'pc';
  25. /*模板列表*/
  26. if (file_exists(ROOT_PATH.'template/pc/uiset.txt')) {
  27. array_push($this->templateArr, 'pc');
  28. }
  29. if (file_exists(ROOT_PATH.'template/mobile/uiset.txt')) {
  30. array_push($this->templateArr, 'mobile');
  31. }
  32. /*--end*/
  33. /*权限控制 by 小虎哥*/
  34. $admin_info = session('admin_info');
  35. if (0 < intval($admin_info['role_id'])) {
  36. $auth_role_info = $admin_info['auth_role_info'];
  37. $permission = $auth_role_info['permission'];
  38. $auth_rule = get_auth_rule();
  39. $all_auths = []; // 系统全部权限对应的菜单ID
  40. $admin_auths = []; // 用户当前拥有权限对应的菜单ID
  41. $diff_auths = []; // 用户没有被授权的权限对应的菜单ID
  42. foreach($auth_rule as $key => $val){
  43. $all_auths = array_merge($all_auths, explode(',', $val['menu_id']), explode(',', $val['menu_id2']));
  44. if (in_array($val['id'], $permission['rules'])) {
  45. $admin_auths = array_merge($admin_auths, explode(',', $val['menu_id']), explode(',', $val['menu_id2']));
  46. }
  47. }
  48. $all_auths = array_unique($all_auths);
  49. $admin_auths = array_unique($admin_auths);
  50. $diff_auths = array_diff($all_auths, $admin_auths);
  51. if(in_array(2002, $diff_auths)){
  52. $this->error('您没有操作权限,请联系超级管理员分配权限');
  53. }
  54. }
  55. /*--end*/
  56. }
  57. /**
  58. * PC调试外观
  59. */
  60. public function pc()
  61. {
  62. // 支持子目录
  63. $index_url = ROOT_DIR.'/index.php?m=home&c=Index&a=index&uiset=on&v=pc&lang='.$this->admin_lang;
  64. $this->redirect($index_url);
  65. }
  66. /**
  67. * 手机调试外观
  68. */
  69. public function mobile()
  70. {
  71. // 支持子目录
  72. $index_url = ROOT_DIR.'/index.php?m=home&c=Index&a=index&uiset=on&v=mobile&lang='.$this->admin_lang;
  73. $this->redirect($index_url);
  74. }
  75. /**
  76. * 调试外观
  77. */
  78. public function index()
  79. {
  80. return $this->fetch();
  81. }
  82. /**
  83. * 数据列表
  84. */
  85. public function ui_index()
  86. {
  87. $condition = array();
  88. // 获取到所有GET参数
  89. $param = input('param.');
  90. /*模板主题*/
  91. $param['theme_style'] = $this->theme_style = input('param.theme_style/s', 'pc');
  92. /*--end*/
  93. // 应用搜索条件
  94. foreach (['keywords','theme_style'] as $key) {
  95. if (isset($param[$key]) && $param[$key] !== '') {
  96. if ($key == 'keywords') {
  97. $condition['a.page|a.type|a.name'] = array('eq', "%{$param[$key]}%");
  98. } else {
  99. $condition['a.'.$key] = array('eq', $param[$key]);
  100. }
  101. }
  102. }
  103. /*多语言*/
  104. $condition['a.lang'] = $this->admin_lang;
  105. /*--end*/
  106. $list = array();
  107. $uiconfigM = M('ui_config');
  108. $count = $uiconfigM->alias('a')->where($condition)->count('id');// 查询满足要求的总记录数
  109. $Page = $pager = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
  110. $list = $uiconfigM->alias('a')->where($condition)->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
  111. $show = $Page->show();// 分页显示输出
  112. $this->assign('page',$show);// 赋值分页输出
  113. $this->assign('list',$list);// 赋值数据集
  114. $this->assign('pager',$pager);// 赋值分页对象
  115. $this->assign('theme_style',$this->theme_style);// 模板主题
  116. $this->assign('templateArr',$this->templateArr);// 模板列表
  117. return $this->fetch();
  118. }
  119. /**
  120. * 删除
  121. */
  122. public function del()
  123. {
  124. $id_arr = input('del_id/a');
  125. $id_arr = eyIntval($id_arr);
  126. if(!empty($id_arr)){
  127. $result = M('ui_config')->where("id",'IN',$id_arr)->getAllWithIndex('name');
  128. $r = M('ui_config')->where("id",'IN',$id_arr)->delete();
  129. if($r){
  130. \think\Cache::clear('ui_config');
  131. delFile(RUNTIME_PATH.'ui/'.$result['theme_style']);
  132. adminLog('删除可视化数据 e-id:'.implode(array_keys($result)));
  133. $this->success('删除成功');
  134. }else{
  135. $this->error('删除失败');
  136. }
  137. }else{
  138. $this->error('参数有误');
  139. }
  140. }
  141. }