FlatlyPage
Version 1.0.1 • 59 files • 798.19 KB
Files
.htaccess
.last_check
admin/account.php
admin/dashboard.php
admin/easyedit.js
admin/extensions.php
admin/generate-hash.php
admin/index.php
admin/lang.php
admin/login_tracking.php
admin/logout.php
admin/popups.php
admin/preview.php
admin/scripts.php
admin/theme-edit/index.php
admin/themes.php
api/get-translate-config.php
api/translate.php
assets/fonts/inter/inter.css
assets/fonts/space-grotesk/space-grotesk.css
assets/js/admin-editor.js
assets/js/admin-theme.js
assets/js/translate.js
config.php
contact-handler.php
contact.php
css/admin.css
css/contact.css
css/styles.css
css/theme.css
css/translate.css
data/.htaccess
data/.index.php
data/.settings.php
data/private/.htaccess
data/sitemap-config.php
data/translate-api.xml
engine/index.html
engine/index.php
engine/renderion.php
extensions-loader.php
favicons.txt
functions.php
index.php
newsletter/.htaccess
newsletter/confirm.php
newsletter/manager.php
newsletter/newsletter-form.js
newsletter/newsletter-styles.css
newsletter/newsletter-unavailable.php
newsletter/newsletter.sql
newsletter/settings.php
newsletter/subscribe.php
newsletter/unsubscribe.php
page.php
robots.txt.php
sitemap.php
updater/index.php
version.txt
admin/lang.php
<?php
// inc/lang.php
function get_page_content($page_id, $lang = 'pl') {
$basePath = __DIR__ . "/../data/{$page_id}.php";
if (!file_exists($basePath)) return [];
$sourceData = include $basePath;
// Jeśli język domyślny, zwracamy oryginał
if ($lang === 'pl') {
return $sourceData;
}
$langPath = __DIR__ . "/../data/{$page_id}_{$lang}.php";
// Jeśli plik języka nie istnieje, tworzymy go na bazie oryginału (1:1)
if (!file_exists($langPath)) {
save_page_content($page_id, $sourceData, $lang);
return $sourceData;
}
$langData = include $langPath;
// Łączymy strukturę oryginału z treścią tłumaczenia (Struktura 1:1)
return merge_recursive_sync($sourceData, $langData);
}
function merge_recursive_sync($source, $translation) {
foreach ($source as $key => $value) {
if (is_array($value)) {
// Rekurencyjnie wchodzimy głębiej (np. w bloki)
$source[$key] = merge_recursive_sync($value, $translation[$key] ?? []);
} else {
// Jeśli w tłumaczeniu istnieje wartość i nie jest pusta, nadpisujemy oryginał
if (isset($translation[$key]) && !empty($translation[$key]) && $key !== 'id' && $key !== 'type') {
$source[$key] = $translation[$key];
}
}
}
return $source;
}
function save_page_content($page_id, $data, $lang = 'pl') {
$suffix = ($lang === 'pl') ? '' : '_' . $lang;
$path = __DIR__ . "/../data/{$page_id}{$suffix}.php";
$content = "<?php\nreturn " . var_export($data, true) . ";";
return file_put_contents($path, $content);
}