本文整理汇总了PHP中Translator::getLang方法的典型用法代码示例。如果您正苦于以下问题:PHP Translator::getLang方法的具体用法?PHP Translator::getLang怎么用?PHP Translator::getLang使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translator
的用法示例。
在下文中一共展示了Translator::getLang方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTrans
public function testTrans()
{
$trans = new Translator('en');
$trans->register(array('test' => 'test-en'));
$trans->register(array('test2' => 'test2-en'), 'en');
$trans->register(array('test' => 'test-fr'), 'fr');
$this->assertEquals('en', $trans->getLang());
$this->assertEquals('test-en', $trans->trans('test'));
$this->assertEquals('test2-en', $trans->trans('test2'));
$this->assertEquals('test-fr', $trans->trans('test', array(), 'fr'));
}
示例2: __construct
public function __construct()
{
$lang = cookie::get('jq_session_language');
Translator::setLang($lang ?: 'ru');
$const_data = constData::load(BASEDIR . '/caru/config.php');
$request = coreInput::getCleanInput();
$output = coreOutput::getInstance();
$output->assign('SERVER_URL', SERVER_URL);
$output->assign('SITE_PATH', SITE_PATH);
$output->assign('erp_flag', defined('SECTIONS') && SECTIONS == 'erp');
$output->assign('const_data', $const_data);
$output->assign('cache', cache::getInstance());
$output->assign('language', Translator::getLang());
$output->setDir(BASEDIR . '/caru/');
$postfix = !defined('SECTIONS') || SECTIONS != 'terminal' ? "/" : "/terminal";
$output->setDir(BASEDIR . '/caru/', $postfix);
$output->setTemplate('blank');
$this->section = isset($request['section']) ? $request['section'] : null;
$this->act = isset($request['act']) ? $request['act'] : null;
//-----------------
// Авторизация
//-----------------
/*
// для обратной совместимости с логином CashAssist
if($this->act=='ext_login') {
if(empty($request['login']) || empty($request['pass']))
die(0);
die($this->externalLogin($request['login'],$request['pass']));
}
*/
$session = user_bo::session();
if (!$session) {
// #36015
$backurl = filter_input(INPUT_SERVER, 'REQUEST_URI') ? filter_input(INPUT_SERVER, 'REQUEST_URI') : '';
$output->setTemplate('login');
$output->toTemplate('backurl', $backurl);
$output->display();
return false;
}
// удаленным - нет
if (in_array('deleted', user_bo::getSessionUserGroups())) {
header('HTTP/1.1 403 Forbidden, please log in');
LogErrors::add("\n-------BEGIN-----\n" . "\n{$_SERVER['REQUEST_URI']}\n" . 'Case 3 (deleted). s_user: ' . print_r($s_user, true) . "\n" . print_r($_COOKIE, true) . "\nGET: " . print_r($_GET, true) . "\nPOST: " . print_r($_POST, true) . "\n-------END-----", 'session_false.log');
user_bo::logout();
$output->setTemplate('login');
$output->display();
return false;
}
if (!$this->checkAccess()) {
LogErrors::add("\n-------BEGIN-----\n" . "\n{$_SERVER['REQUEST_URI']}\n" . 'Case 5 (no access). s_user: ' . print_r($s_user, true) . "\n" . print_r($_COOKIE, true) . "\nGET: " . print_r($_GET, true) . "\nPOST: " . print_r($_POST, true) . "\n-------END-----", 'session_false.log');
header('HTTP/1.1 403 Forbidden, please log in');
return false;
}
if ($this->section && $this->act) {
$output->setTemplate($this->section . "/" . $this->act);
}
//-----------------
// Подключаем контроллер
//-----------------
try {
if (class_exists($this->section . "_controller")) {
$cont_class = $this->section . "_controller";
$cont = new $cont_class($this);
} else {
$cont = new Controller($this);
}
if ($this->act && is_callable(array($cont, $this->act))) {
call_user_func(array($cont, $this->act));
}
} catch (Exception $e) {
$output->setTemplate('_error');
$output->assign('exeption', $e);
}
$user = user_bo::getSessionUser();
$sections = $this->getAllowedSections();
$user['groups'] = user_bo::getSessionUserGroups();
$output->assign('sections', $sections);
$output->assign('user', $user);
$output->assign('section', $this->section ? $sections[$this->section] : null);
$output->assign('act', $this->act);
$output->assign('title', $this->act ? $sections[$this->section]['items'][$this->act] : null);
$output->display();
return true;
}