From 0d840a5ab53ca5a6ac0ed4fd1107b3da86e2c6d6 Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 25 Sep 2023 01:30:28 +0300 Subject: [PATCH] add content language selection #14 --- src/app/controller/page.php | 23 ++++ .../theme/default/page/form/description.phtml | 24 ++++ src/config/locales.json | 104 +++++++++--------- .../assets/theme/default/css/common.css | 1 + 4 files changed, 100 insertions(+), 52 deletions(-) diff --git a/src/app/controller/page.php b/src/app/controller/page.php index 0d0d873..b891592 100644 --- a/src/app/controller/page.php +++ b/src/app/controller/page.php @@ -46,9 +46,32 @@ class AppControllerPage public function renderFormDescription() { + // Prepare locales + $locales = []; + + foreach (Environment::config('locales') as $key => $value) + { + $locales[$key] = (object) + [ + 'key' => $key, + 'value' => $value[0], + 'active' => false !== stripos($_SERVER['HTTP_ACCEPT_LANGUAGE'], $key) ? true : false, + ]; + } + // Init form $form = (object) [ + 'locale' => (object) + [ + 'error' => [], + 'values' => $locales, + 'attribute' => (object) + [ + 'value' => null, + 'placeholder' => _('Page content language'), + ] + ], 'title' => (object) [ 'error' => [], diff --git a/src/app/view/theme/default/page/form/description.phtml b/src/app/view/theme/default/page/form/description.phtml index 33df21b..483f6da 100644 --- a/src/app/view/theme/default/page/form/description.phtml +++ b/src/app/view/theme/default/page/form/description.phtml @@ -13,6 +13,30 @@

+
+ + + + + + + +