Changeset View
Changeset View
Standalone View
Standalone View
src/resources/build/before.php
Show All 31 Lines | if (is_array($content)) { | ||||
$file = "{$rootDir}/resources/build/js/{$matches[1]}.json"; | $file = "{$rootDir}/resources/build/js/{$matches[1]}.json"; | ||||
$opts = JSON_PRETTY_PRINT | JSON_INVALID_UTF8_SUBSTITUTE | JSON_UNESCAPED_UNICODE; | $opts = JSON_PRETTY_PRINT | JSON_INVALID_UTF8_SUBSTITUTE | JSON_UNESCAPED_UNICODE; | ||||
file_put_contents($file, json_encode($content, $opts)); | file_put_contents($file, json_encode($content, $opts)); | ||||
} | } | ||||
} | } | ||||
foreach (glob("{$rootDir}/resources/themes/*/lang/*/ui.php") as $file) { | |||||
$content = include $file; | |||||
if (is_array($content)) { | |||||
preg_match('|([a-zA-Z]+)/lang/([a-z]+)/ui\.php$|', $file, $matches); | |||||
$theme = $matches[1]; | |||||
$file = "{$rootDir}/resources/build/js/{$theme}-{$matches[2]}.json"; | |||||
$opts = JSON_PRETTY_PRINT | JSON_INVALID_UTF8_SUBSTITUTE | JSON_UNESCAPED_UNICODE; | |||||
file_put_contents($file, json_encode($content, $opts)); | |||||
} | |||||
} | |||||
echo "OK\n"; | echo "OK\n"; | ||||
// Move some theme-specific resources from resources/themes/ to public/themes/ | // Move some theme-specific resources from resources/themes/ to public/themes/ | ||||
echo "Theme resources... "; | echo "Theme resources... "; | ||||
if (!file_exists("{$rootDir}/public/themes")) { | if (!file_exists("{$rootDir}/public/themes")) { | ||||
mkdir("{$rootDir}/public/themes"); | mkdir("{$rootDir}/public/themes"); | ||||
} | } | ||||
foreach (glob("{$rootDir}/resources/themes/*", GLOB_ONLYDIR) as $file) { | foreach (glob("{$rootDir}/resources/themes/*", GLOB_ONLYDIR) as $file) { | ||||
$path = explode('/', $file); | $path = explode('/', $file); | ||||
$theme = $path[count($path)-1]; | $theme = $path[count($path)-1]; | ||||
if (!file_exists("{$rootDir}/public/themes/{$theme}")) { | if (!file_exists("{$rootDir}/public/themes/{$theme}")) { | ||||
mkdir("{$rootDir}/public/themes/{$theme}"); | mkdir("{$rootDir}/public/themes/{$theme}"); | ||||
} | } | ||||
if (!file_exists("{$rootDir}/public/themes/{$theme}/images")) { | // TODO: Public dirs (glob patterns) should be in theme's meta.json | ||||
mkdir("{$rootDir}/public/themes/{$theme}/images"); | |||||
foreach (['images', 'fonts'] as $subDir) { | |||||
if (file_exists("{$rootDir}/resources/themes/{$theme}/{$subDir}")) { | |||||
if (!file_exists("{$rootDir}/public/themes/{$theme}/{$subDir}")) { | |||||
mkdir("{$rootDir}/public/themes/{$theme}/{$subDir}"); | |||||
} | } | ||||
foreach (glob("{$file}/images/*") as $file) { | foreach (glob("{$rootDir}/resources/themes/{$theme}/{$subDir}/*") as $file) { | ||||
$path = explode('/', $file); | $filename = pathinfo($file, PATHINFO_BASENAME); | ||||
$image = $path[count($path)-1]; | copy($file, "{$rootDir}/public/themes/{$theme}/{$subDir}/{$filename}"); | ||||
copy($file, "{$rootDir}/public/themes/{$theme}/images/{$image}"); | } | ||||
} | |||||
} | } | ||||
} | } | ||||
echo "OK\n"; | echo "OK\n"; |