AdminIndexController.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2014 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: Dean <zxxjjforever@163.com>
  8. // +----------------------------------------------------------------------
  9. namespace plugins\demo\controller;
  10. //Demo插件英文名,改成你的插件英文就行了
  11. use app\user\model\UserModel;
  12. use cmf\controller\PluginAdminBaseController;
  13. /**
  14. * Class AdminIndexController.
  15. *
  16. * @adminMenuRoot(
  17. * 'name' =>'演示插件',
  18. * 'action' =>'default',
  19. * 'parent' =>'',
  20. * 'display'=> true,
  21. * 'order' => 0,
  22. * 'icon' =>'dashboard',
  23. * 'remark' =>'演示插件入口'
  24. * )
  25. */
  26. class AdminIndexController extends PluginAdminBaseController
  27. {
  28. protected function initialize()
  29. {
  30. parent::initialize();
  31. $adminId = cmf_get_current_admin_id(); //获取后台管理员id,可判断是否登录
  32. if (!empty($adminId)) {
  33. $this->assign('admin_id', $adminId);
  34. }
  35. }
  36. /**
  37. * 演示插件用户列表
  38. * @adminMenu(
  39. * 'name' => '演示插件用户列表',
  40. * 'parent' => 'default',
  41. * 'display'=> true,
  42. * 'hasView'=> true,
  43. * 'order' => 10000,
  44. * 'icon' => '',
  45. * 'remark' => '演示插件用户列表',
  46. * 'param' => ''
  47. * )
  48. */
  49. public function index()
  50. {
  51. // $result = $this->validate([], 'Demo');
  52. // if ($result !== true) {
  53. // $this->error($result);
  54. // }
  55. $users = UserModel::limit(0, 5)->select();
  56. //$demos = PluginDemoModel::all();
  57. // print_r($demos);
  58. $this->assign('plugin',$this->getPlugin());
  59. $this->assign('users', $users);
  60. return $this->fetch('/admin_index');
  61. }
  62. /**
  63. * 演示插件设置
  64. * @adminMenu(
  65. * 'name' => '演示插件设置',
  66. * 'parent' => 'index',
  67. * 'display'=> false,
  68. * 'hasView'=> true,
  69. * 'order' => 10000,
  70. * 'icon' => '',
  71. * 'remark' => '演示插件设置',
  72. * 'param' => ''
  73. * )
  74. */
  75. public function setting()
  76. {
  77. $users = UserModel::limit(0, 5)->select();
  78. //$demos = PluginDemoModel::all();
  79. // print_r($demos);
  80. $this->assign('users', $users);
  81. $this->assign('users', $users);
  82. return $this->fetch('/admin_index');
  83. }
  84. }