123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\common\controller;
- use app\common\library\Auth;
- use app\common\model\Configvalue;
- use think\Config;
- use think\Controller;
- use think\Lang;
- class Frontend extends Controller
- {
-
- protected $user = null;
-
- protected $layout = '';
- public function _initialize()
- {
- $modulename = $this->request->module();
- $controllername = strtolower($this->request->controller());
- $actionname = strtolower($this->request->action());
- $path = '/' . $modulename . '/' . str_replace('.', '/', $controllername) . '/' . $actionname;
- $this->user = Auth::instance();
-
- $this->user->setRequestUri($path);
-
- $this->user->init();
-
- $this->view->assign("user", $this->user);
-
- if ($this->layout)
- {
- $this->view->engine->layout('layout/' . $this->layout);
- }
-
- $lang = Lang::detect();
-
- $config = [
- 'site' => Config::get("site"),
- 'upload' => Configvalue::upload(),
- 'modulename' => $modulename,
- 'controllername' => $controllername,
- 'actionname' => $actionname,
- 'jsname' => 'frontend/' . str_replace('.', '/', $controllername),
- 'subdomain' => 0,
- 'language' => $lang
- ];
- Lang::load(APP_PATH . $modulename . '/lang/' . $lang . '/' . str_replace('.', '/', $controllername) . '.php');
- $this->assign('site', Config::get("site"));
- $this->assign('config', $config);
- }
- }
|