mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 03:32:00 +09:00
Merge branch 'develop' into pr/change-object
This commit is contained in:
commit
03d74a984f
19 changed files with 179 additions and 134 deletions
|
|
@ -864,14 +864,11 @@ class moduleAdminController extends module
|
|||
}
|
||||
$output = executeQueryArray('module.getLang', $args);
|
||||
if(!$output->toBool() || !$output->data) return;
|
||||
// Set the cache directory
|
||||
$cache_path = _XE_PATH_.'files/cache/lang_defined/';
|
||||
FileHandler::makeDir($cache_path);
|
||||
|
||||
$langMap = array();
|
||||
foreach($output->data as $val)
|
||||
foreach($output->data as $lang)
|
||||
{
|
||||
$langMap[$val->lang_code][$val->name] = $val->value;
|
||||
$langMap[$lang->lang_code][$lang->name] = $lang->value;
|
||||
}
|
||||
|
||||
$lang_supported = Context::loadLangSelected();
|
||||
|
|
@ -904,17 +901,11 @@ class moduleAdminController extends module
|
|||
|
||||
$langMap[$langCode] += $langMap[$targetLangCode];
|
||||
}
|
||||
|
||||
$buff = array("<?php if(!defined('__XE__')) exit();");
|
||||
foreach($langMap[$langCode] as $code => $value)
|
||||
{
|
||||
$buff[] = sprintf('$lang[%s] = %s;', var_export(strval($code), true), var_export(strval($value), true));
|
||||
}
|
||||
if (!Rhymix\Framework\Storage::write(sprintf('%s/%d.%s.php', $cache_path, $args->site_srl, $langCode), implode(PHP_EOL, $buff)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Rhymix\Framework\Cache::set('site_and_module:user_defined_langs:' . $args->site_srl . ':' . $langCode, $langMap[$langCode], 0, true);
|
||||
}
|
||||
|
||||
return $langMap[Context::getLangType()];
|
||||
}
|
||||
|
||||
public function procModuleAdminSetDesignInfo()
|
||||
|
|
|
|||
|
|
@ -1041,45 +1041,34 @@ class moduleController extends module
|
|||
* @brief Change user-defined language
|
||||
*/
|
||||
function replaceDefinedLangCode(&$output, $isReplaceLangCode = true)
|
||||
{
|
||||
if($isReplaceLangCode)
|
||||
{
|
||||
$output = preg_replace_callback('!\$user_lang->([a-z0-9\_]+)!is', array($this,'_replaceLangCode'), $output);
|
||||
}
|
||||
}
|
||||
|
||||
function _replaceLangCode($matches)
|
||||
{
|
||||
static $lang = null;
|
||||
|
||||
if(is_null($lang))
|
||||
if($isReplaceLangCode)
|
||||
{
|
||||
$cache_file = sprintf('%sfiles/cache/lang_defined/%d.%s.php', _XE_PATH_, 0, Context::getLangType());
|
||||
if(!file_exists($cache_file))
|
||||
if($lang === null)
|
||||
{
|
||||
$oModuleAdminController = getAdminController('module');
|
||||
$oModuleAdminController->makeCacheDefinedLangCode(0);
|
||||
}
|
||||
|
||||
if(file_exists($cache_file))
|
||||
{
|
||||
$moduleAdminControllerMtime = filemtime(_XE_PATH_ . 'modules/module/module.admin.controller.php');
|
||||
$cacheFileMtime = filemtime($cache_file);
|
||||
if($cacheFileMtime < $moduleAdminControllerMtime)
|
||||
$lang = Rhymix\Framework\Cache::get('site_and_module:user_defined_langs:' . $args->site_srl . ':' . Context::getLangType());
|
||||
if($lang === null)
|
||||
{
|
||||
$oModuleAdminController = getAdminController('module');
|
||||
$oModuleAdminController->makeCacheDefinedLangCode(0);
|
||||
$lang = $oModuleAdminController->makeCacheDefinedLangCode($site_module_info->site_srl);
|
||||
}
|
||||
|
||||
require_once($cache_file);
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
if(!Context::get($matches[1]) && $lang[$matches[1]]) return $lang[$matches[1]];
|
||||
|
||||
return str_replace('$user_lang->','',$matches[0]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add and update a file into the file box
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue