mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 18:21:39 +09:00
Clean up ModuleController::replaceDefinedLangCode()
This commit is contained in:
parent
2e6e097272
commit
f8859769e8
15 changed files with 64 additions and 77 deletions
|
|
@ -1080,35 +1080,14 @@ class moduleController extends module
|
|||
/**
|
||||
* @brief Change user-defined language
|
||||
*/
|
||||
function replaceDefinedLangCode(&$output, $isReplaceLangCode = true)
|
||||
public static function replaceDefinedLangCode(&$output, $replace = true)
|
||||
{
|
||||
static $lang = null;
|
||||
|
||||
if($isReplaceLangCode)
|
||||
if ($replace)
|
||||
{
|
||||
if($lang === null)
|
||||
{
|
||||
$lang = Rhymix\Framework\Cache::get('site_and_module:user_defined_langs:0:' . Context::getLangType());
|
||||
if($lang === null)
|
||||
{
|
||||
$oModuleAdminController = getAdminController('module');
|
||||
$lang = $oModuleAdminController->makeCacheDefinedLangCode(0);
|
||||
}
|
||||
}
|
||||
|
||||
$output = preg_replace_callback('/\$user_lang->([a-z0-9\_]+)/is', function($matches) use($lang) {
|
||||
if(isset($lang[$matches[1]]) && !Context::get($matches[1]))
|
||||
{
|
||||
return $lang[$matches[1]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return str_replace('$user_lang->', '', $matches[0]);
|
||||
}
|
||||
}, $output);
|
||||
$output = Context::replaceUserLang($output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add and update a file into the file box
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue