BaseController.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * BaseController.php UTF-8
  4. * 推广后台公共类
  5. *
  6. * @date : 2018/2/27 16:02
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : ouzhongfu <ozf@huosdk.com>
  10. * @version : HUOSDK 7.2
  11. */
  12. namespace agent\common\controller;
  13. use think\Session;
  14. class BaseController extends \cmf\controller\BaseController {
  15. protected $web_info = [];
  16. public function _initialize() {
  17. Session::boot();
  18. $this->common_assign();
  19. parent::_initialize();
  20. }
  21. // 初始化视图配置
  22. protected function _initializeView() {
  23. $cmfAdminThemePath = config('cmf_theme_path');
  24. $cmfAdminDefaultTheme = config('cmf_default_theme');
  25. $themePath = "{$cmfAdminThemePath}{$cmfAdminDefaultTheme}";
  26. $root = cmf_get_root();
  27. //使cdn设置生效
  28. $cdnSettings = cmf_get_option('cdn_settings');
  29. if (empty($cdnSettings['cdn_static_root'])) {
  30. $viewReplaceStr = [
  31. '__ROOT__' => $root,
  32. '__TMPL__' => "{$root}/{$themePath}",
  33. '__STATIC__' => STATICSITE,
  34. '__WEB_ROOT__' => $root
  35. ];
  36. } else {
  37. $cdnStaticRoot = rtrim($cdnSettings['cdn_static_root'], '/');
  38. $viewReplaceStr = [
  39. '__ROOT__' => $root,
  40. '__TMPL__' => "{$cdnStaticRoot}/{$themePath}",
  41. '__STATIC__' => "{$cdnStaticRoot}",
  42. '__WEB_ROOT__' => $cdnStaticRoot
  43. ];
  44. }
  45. $viewReplaceStr = array_merge(config('view_replace_str'), $viewReplaceStr);
  46. config('template.view_base', "$themePath/");
  47. config('view_replace_str', $viewReplaceStr);
  48. }
  49. /**
  50. * 设置通用内容
  51. */
  52. public function common_assign() {
  53. $_path = $this->request->path();
  54. $_selected = [
  55. '1' => 'active',
  56. '2' => '',
  57. '3' => '',
  58. '4' => '',
  59. ];
  60. if (strpos($_path, 'notice/index') !== false) {
  61. $_selected = [
  62. '1' => '',
  63. '2' => '',
  64. '3' => 'active',
  65. '4' => '',
  66. ];
  67. } elseif (strpos($_path, 'management/index') !== false) {
  68. $_selected = [
  69. '1' => '',
  70. '2' => 'active',
  71. '3' => '',
  72. '4' => '',
  73. ];
  74. } elseif (strpos($_path, 'document/index') !== false) {
  75. $_selected = [
  76. '1' => '',
  77. '2' => '',
  78. '3' => '',
  79. '4' => 'active',
  80. ];
  81. } elseif (strpos($_path, 'notice/read') !== false) {
  82. $_selected = [
  83. '1' => '',
  84. '2' => '',
  85. '3' => 'active',
  86. '4' => '',
  87. ];
  88. }
  89. $this->assign('selected', $_selected);
  90. }
  91. }