/** * 后台控制器初始化 */ protected function _initialize() { //检查用户登入 if (!session('?' . C('USER_AUTH_KEY'))) { $this->redirect('Public/login'); } //判断是否为超级管理员 若是,则跳过权限检查 if (session('uname') == C('ADMIN_AUTH_KEY')) { return TRUE; } //检查用户权限 $auth = new Auth(); $module_name = CONTROLLER_NAME . '/' . ACTION_NAME; if (!$auth->check($module_name, session(C('USER_AUTH_KEY')))) { $this->error(L('_VALID_ACCESS_')); } // url 语言参数 $this->vl = $vl = LANG_SET == accept_lang() ? '' : C('VAR_LANGUAGE') . '=' . LANG_SET; $this->assign('vl', $vl); //多语言操作html $this->clang = $clang = cookie('lang'); $langs = '<div id="lang"><div class="btn btn-app btn-xs btn-purple ace-settings-btn">'; $langs .= '<span class="glyphicon glyphicon-globe"></span></div><div class="lang-list">'; foreach (S('langs') as $value) { if (I('get.lang')) { $btncolor = I('get.lang') == $value['value'] ? 'btn-primary' : 'btn-light'; } else { if ($clang) { $btncolor = $value['value'] == $clang ? 'btn-primary' : 'btn-light'; } else { $btncolor = $value['value'] == LANG_SET ? 'btn-primary' : 'btn-light'; } } $langs .= '<a class="btn btn-xs ' . $btncolor . ' mr5 mb5" href="' . urlh($vl . '&lang=' . $value['value']) . '" '; $langs .= 'onclick="load(event,this)">' . $value['name'] . '</a>'; } $langs .= '</div></div>'; $this->assign('langs', S('langs') ? $langs : ''); //多语言操作cookie if (array_key_exists('lang', I('get.'))) { cookie('lang', I('get.lang')); } $this->assign('clang', $clang); }
public function _initialize() { $this->vl = $vl = LANG_SET == accept_lang() ? '' : C('VAR_LANGUAGE') . '=' . LANG_SET; $this->assign('vl', $vl); }
function auto_lang() { return cookie('think_language') ? strtolower(cookie('think_language')) : strtolower(accept_lang()); }