Base.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\admin\controller\wwh;
  3. use app\common\controller\Backend;
  4. class Base extends Backend
  5. {
  6. public function _initialize()
  7. {
  8. parent::_initialize();
  9. $addon_config = get_addon_config("wwh");
  10. $switch_lang = $addon_config['switch_lang'];
  11. $this->assignconfig('switch_lang',$switch_lang);
  12. $this->view->assign('switch_lang', $switch_lang);
  13. }
  14. /**
  15. * 查看
  16. */
  17. public function index()
  18. {
  19. //当前是否为关联查询
  20. $this->relationSearch = false;
  21. //设置过滤方法
  22. $this->request->filter(['strip_tags', 'trim']);
  23. if ($this->request->isAjax()) {
  24. //如果发送的来源是Selectpage,则转发到Selectpage
  25. if ($this->request->request('keyField')) {
  26. return $this->selectpage();
  27. }
  28. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  29. //获取是否启用英文配置
  30. $addon_config = get_addon_config("wwh");
  31. $switch_lang = $addon_config['switch_lang'];
  32. if ($switch_lang == 1){
  33. $lang = '1,2';
  34. }else{
  35. $lang = '1';
  36. }
  37. $list = $this->model
  38. ->where($where)
  39. ->whereIn('lang',$lang)
  40. ->order($sort, $order)
  41. ->paginate($limit);
  42. $result = array("total" => $list->total(), "rows" => $list->items());
  43. return json($result);
  44. }
  45. return $this->view->fetch();
  46. }
  47. }