public function before() { Request::$theme = 'mobile'; parent::before(); $is_weixin = false; $ua = strtolower($_SERVER['HTTP_USER_AGENT']); if (strpos($ua, 'micromessenger') !== false) { $is_weixin = true; } $auth = Auth::instance('member'); $this->user = $auth->get_user(); $curr_theme = 'cyan-red'; if (isset($_COOKIE['apptheme']) && in_array($_COOKIE['apptheme'], array_keys($this->theme_list))) { $curr_theme = $_COOKIE['apptheme']; } $theme_color = $this->theme_list[$curr_theme]; if ($this->auto_render === TRUE) { View::bind_global('is_weixin', $is_weixin); View::bind_global('user', $this->user); View::bind_global('theme_list', $this->theme_list); View::bind_global('theme_color', $theme_color); View::bind_global('curr_theme', $curr_theme); if ($is_weixin) { $wx_js_api = new WeixinJSAPI('test'); $wx_jsapi_config = $wx_js_api->get_jsapi_config(); View::bind_global('wx_jsapi_config', $wx_jsapi_config); } } }
public function before() { if ($this->request->user_agent('mobile')) { Request::$theme = 'mobile'; } parent::before(); if ($this->auto_render === TRUE) { View::bind_global('uri', $this->request->uri); View::bind_global('controller', $this->request->controller); View::bind_global('action', $this->request->action); View::bind_global('title', $this->title); View::bind_global('content', $this->content); } }