AdminIndexController.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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('users', $users);
  59. return $this->fetch('/admin_index');
  60. }
  61. /**
  62. * 演示插件设置
  63. * @adminMenu(
  64. * 'name' => '演示插件设置',
  65. * 'parent' => 'index',
  66. * 'display'=> false,
  67. * 'hasView'=> true,
  68. * 'order' => 10000,
  69. * 'icon' => '',
  70. * 'remark' => '演示插件设置',
  71. * 'param' => ''
  72. * )
  73. */
  74. public function setting()
  75. {
  76. $users = UserModel::limit(0, 5)->select();
  77. //$demos = PluginDemoModel::all();
  78. // print_r($demos);
  79. $this->assign('users', $users);
  80. $this->assign('users', $users);
  81. return $this->fetch('/admin_index');
  82. }
  83. }