Admin/siteconfig

* also rebuild js-locales when updating available locales
 * somewhat unhappy with the access to generated files. need to find a better solution.
This commit is contained in:
Sarjuuk
2017-05-09 19:02:08 +02:00
parent 1bb7fdf89a
commit 7b7ec2d0aa
4 changed files with 35 additions and 37 deletions

View File

@@ -41,6 +41,11 @@ function siteconfig()
case 'static_host':
array_push($updScripts, 'searchplugin', 'power', 'searchboxBody', 'searchboxScript');
break;
case 'locales':
array_push($updScripts, 'locales');
CLISetup::log(' * remember to rebuild all static files for the language you just added.', CLISetup::LOG_INFO);
CLISetup::log(' * you can speed this up by supplying the regionCode to the setup: '.CLISetup::bold('--locales=<regionCodes,> -f'));
break;
case 'profiler_queue':
$fn = function($x) {
if (!$x)

View File

@@ -208,48 +208,36 @@ class FileGen
if ($content = file_get_contents(FileGen::$tplPath.$file.'.in'))
{
if ($dest = @fOpen($destPath.$file, "w"))
// replace constants
$content = strtr($content, FileGen::$txtConstants);
// check for required auxiliary DBC files
foreach ($reqDBC as $req)
if (!CLISetup::loadDBC($req))
continue;
// must generate content
// PH format: /*setup:<setupFunc>*/
$funcOK = true;
if (preg_match_all('/\/\*setup:([\w\-_]+)\*\//i', $content, $m))
{
// replace constants
$content = strtr($content, FileGen::$txtConstants);
// check for required auxiliary DBC files
foreach ($reqDBC as $req)
if (!CLISetup::loadDBC($req))
continue;
// must generate content
// PH format: /*setup:<setupFunc>*/
$funcOK = true;
if (preg_match_all('/\/\*setup:([\w\-_]+)\*\//i', $content, $m))
foreach ($m[1] as $func)
{
foreach ($m[1] as $func)
if (function_exists($func))
$content = str_replace('/*setup:'.$func.'*/', $func(), $content);
else
{
if (function_exists($func))
$content = str_replace('/*setup:'.$func.'*/', $func(), $content);
else
{
$funcOK = false;
CLISetup::log('No function for was registered for placeholder '.$func.'().', CLISetup::LOG_ERROR);
if (!array_reduce(get_included_files(), function ($inArray, $itr) use ($func) { return $inArray || false !== strpos($itr, $func); }, false))
CLISetup::log('Also, expected include setup/tools/filegen/'.$name.'.func.php was not found.');
}
$funcOK = false;
CLISetup::log('No function for was registered for placeholder '.$func.'().', CLISetup::LOG_ERROR);
if (!array_reduce(get_included_files(), function ($inArray, $itr) use ($func) { return $inArray || false !== strpos($itr, $func); }, false))
CLISetup::log('Also, expected include setup/tools/filegen/'.$name.'.func.php was not found.');
}
}
if (fWrite($dest, $content))
{
CLISetup::log(sprintf(ERR_NONE, CLISetup::bold($destPath.$file)), CLISetup::LOG_OK);
if ($content && $funcOK)
$success = true;
}
else
CLISetup::log(sprintf(ERR_WRITE_FILE, CLISetup::bold($destPath.$file)), CLISetup::LOG_ERROR);
fClose($dest);
}
else
CLISetup::log(sprintf(ERR_CREATE_FILE, CLISetup::bold($destPath.$file)), CLISetup::LOG_ERROR);
if ($content && $funcOK)
if (CLISetup::writeFile($destPath.$file, $content))
$success = true;
}
else
CLISetup::log(sprintf(ERR_READ_FILE, CLISetup::bold(FileGen::$tplPath.$file.'.in')), CLISetup::LOG_ERROR);