mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 02:31:40 +09:00
Fix #286 Lang object is overwritten by third-party layout
This commit is contained in:
parent
91718ec722
commit
c67dbbc659
1 changed files with 22 additions and 8 deletions
|
|
@ -222,7 +222,6 @@ class Context
|
|||
|
||||
// Set global variables for backward compatibility.
|
||||
$GLOBALS['__Context__'] = $this;
|
||||
$GLOBALS['lang'] = &$this->lang;
|
||||
$this->_COOKIE = $_COOKIE;
|
||||
|
||||
// Set information about the current request.
|
||||
|
|
@ -299,6 +298,7 @@ class Context
|
|||
$this->lang = Rhymix\Framework\Lang::getInstance($this->lang_type);
|
||||
$this->lang->loadDirectory(RX_BASEDIR . 'common/lang', 'common');
|
||||
$this->lang->loadDirectory(RX_BASEDIR . 'modules/module/lang', 'module');
|
||||
$GLOBALS['lang'] = $this->lang;
|
||||
|
||||
// set session handler
|
||||
if(self::isInstalled() && config('session.use_db'))
|
||||
|
|
@ -859,7 +859,7 @@ class Context
|
|||
* Load language file according to language type
|
||||
*
|
||||
* @param string $path Path of the language file
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public static function loadLang($path)
|
||||
{
|
||||
|
|
@ -871,7 +871,16 @@ class Context
|
|||
{
|
||||
$plugin_name = null;
|
||||
}
|
||||
return self::$_instance->lang->loadDirectory($path, $plugin_name);
|
||||
|
||||
if ($GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
|
||||
{
|
||||
return $GLOBALS['lang']->loadDirectory($path, $plugin_name);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -914,9 +923,9 @@ class Context
|
|||
*/
|
||||
public static function getLang($code)
|
||||
{
|
||||
if (self::$_instance->lang)
|
||||
if ($GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
|
||||
{
|
||||
return self::$_instance->lang->get($code);
|
||||
return $GLOBALS['lang']->get($code);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -929,13 +938,18 @@ class Context
|
|||
*
|
||||
* @param string $code Language variable name
|
||||
* @param string $val `$code`s value
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public static function setLang($code, $val)
|
||||
{
|
||||
if (self::$_instance->lang)
|
||||
if ($GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
|
||||
{
|
||||
self::$_instance->lang->set($code, $val);
|
||||
$GLOBALS['lang']->set($code, $val);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue