本文整理汇总了PHP中SPLang::setLang方法的典型用法代码示例。如果您正苦于以下问题:PHP SPLang::setLang方法的具体用法?PHP SPLang::setLang怎么用?PHP SPLang::setLang使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPLang
的用法示例。
在下文中一共展示了SPLang::setLang方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param string $task
*/
function __construct($task)
{
SPLoader::loadClass('base.exception');
set_error_handler('SPExceptionHandler');
$this->_err = ini_set('display_errors', 'on');
$this->_mem = memory_get_usage();
$this->_time = microtime();
$this->_task = $task;
/* load all needed classes */
SPLoader::loadClass('base.factory');
SPLoader::loadClass('base.object');
SPLoader::loadClass('base.const');
SPLoader::loadClass('base.filter');
SPLoader::loadClass('base.request');
SPLoader::loadClass('sobi');
SPLoader::loadClass('base.config');
/* authorise access */
$this->checkAccess();
/* initialise mainframe interface to CMS */
$this->_mainframe =& SPFactory::mainframe();
/* get sid if any */
$this->_sid = SPRequest::sid();
/* determine section */
$this->getSection();
/* initialise config */
$this->createConfig();
ini_set('display_errors', Sobi::Cfg('debug.display_errors', false));
$this->_deb = error_reporting(Sobi::Cfg('debug.level', 0));
/* trigger plugin */
Sobi::Trigger('AdminStart');
/* initialise translator and load language files */
SPLoader::loadClass('cms.base.lang');
SPLang::setLang(Sobi::Lang());
try {
SPLang::registerDomain('admin');
} catch (SPException $x) {
Sobi::Error('CoreCtrl', SPLang::e('Cannot register language domain: %s.', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
/* load admin html files */
SPFactory::header()->initBase(true);
/** @noinspection PhpParamsInspection */
if ($this->_section) {
$sectionName = SPLang::translateObject($this->_section, 'name', 'section');
SPFactory::registry()->set('current_section_name', SPLang::clean($sectionName[$this->_section]['value']));
}
if ($this->_section && !Sobi::Cfg('section.template')) {
SPFactory::config()->set('template', SPC::DEFAULT_TEMPLATE, 'section');
}
/* check if it wasn't plugin custom task */
if (!Sobi::Trigger('custom', 'task', array($this, SPRequest::task()))) {
/* if not, start to route */
try {
$this->route();
} catch (SPException $x) {
Sobi::Error('CoreCtrl', SPLang::e('Cannot route: %s.', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
}
}
return true;
}
示例2: __construct
/**
* @param string $task
* @return \SobiProCtrl
*/
function __construct($task)
{
$this->_mem = memory_get_usage();
$this->_time = microtime(true);
SPLoader::loadClass('base.exception');
set_error_handler('SPExceptionHandler');
$this->_err = ini_set('display_errors', 'on');
$this->_task = $task;
/* load all needed classes */
SPLoader::loadClass('base.const');
SPLoader::loadClass('base.factory');
SPLoader::loadClass('base.object');
SPLoader::loadClass('base.filter');
SPLoader::loadClass('base.request');
SPLoader::loadClass('sobi');
SPLoader::loadClass('base.config');
SPLoader::loadClass('cms.base.lang');
/* get sid if any */
$this->_sid = SPRequest::sid();
/* determine section */
$access = $this->getSection();
/* initialise mainframe interface to CMS */
$this->_mainframe = SPFactory::mainframe();
/* initialise config */
$this->createConfig();
ini_set('display_errors', Sobi::Cfg('debug.display_errors', false));
$this->_deb = error_reporting(Sobi::Cfg('debug.level', 0));
/* trigger plugin */
Sobi::Trigger('Start');
/* initialise translator and load language files */
SPLang::setLang(Sobi::Lang(false));
try {
SPLang::registerDomain('site');
} catch (SPException $x) {
Sobi::Error('CoreCtrl', SPLang::e('Cannot register language domain: %s.', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
if (!$access) {
if (Sobi::Cfg('redirects.section_enabled', false)) {
$redirect = Sobi::Cfg('redirects.section_url', null);
$msg = Sobi::Cfg('redirects.section_msg', SPLang::e('UNAUTHORIZED_ACCESS', SPRequest::task()));
$msgtype = Sobi::Cfg('redirects.section_msgtype', 'message');
Sobi::Redirect(Sobi::Url($redirect), Sobi::Txt($msg), $msgtype, true);
} else {
SPFactory::mainframe()->runAway('You have no permission to access this site', 403, null, true);
}
}
/* load css and js files */
SPFactory::header()->initBase();
$sectionName = SPLang::translateObject($this->_section, 'name', 'section');
if ($this->_section) {
SPFactory::registry()->set('current_section_name', SPLang::clean($sectionName[$this->_section]['value']));
}
$start = array($this->_mem, $this->_time);
SPFactory::registry()->set('start', $start);
/* check if it wasn't plugin custom task */
if (!Sobi::Trigger('custom', 'task', array(&$this, SPRequest::task()))) {
/* if not, start to route */
try {
$this->route();
} catch (SPException $x) {
if (defined('SOBI_TESTS')) {
Sobi::Error('CoreCtrl', SPLang::e('Cannot route: %s.', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
} else {
SPFactory::mainframe()->setRedirect(Sobi::Reg('live_site'), SPLang::e('PAGE_NOT_FOUND'), SPC::ERROR_MSG, true);
}
}
}
return true;
}