From 66bdcf04f431d615b5fac93e7677e7304888e90c Mon Sep 17 00:00:00 2001 From: winter Date: Sat, 18 Jan 2025 20:02:39 +0000 Subject: implement settings editor page --- templates/global_settings_page.php | 6 ++++++ templates/settings_editor.php | 27 +++++++++++++++++++++++++++ templates/settings_field.php | 31 +++++++++++++++++++++++++++++++ templates/skeleton.php | 23 +++++++++++++---------- 4 files changed, 77 insertions(+), 10 deletions(-) create mode 100644 templates/global_settings_page.php create mode 100644 templates/settings_editor.php create mode 100644 templates/settings_field.php (limited to 'templates') diff --git a/templates/global_settings_page.php b/templates/global_settings_page.php new file mode 100644 index 0000000..fcaf7ab --- /dev/null +++ b/templates/global_settings_page.php @@ -0,0 +1,6 @@ + sprintf(__('globalSettings.pageTitle'), $prefix) +], function () { + global $prefix; + call_template('settings_editor', ['prefix' => $prefix]); +}); \ No newline at end of file diff --git a/templates/settings_editor.php b/templates/settings_editor.php new file mode 100644 index 0000000..1bf72b7 --- /dev/null +++ b/templates/settings_editor.php @@ -0,0 +1,27 @@ + +
+ getAllInPrefix($prefix) as $key => $value) { + $info = $settings->getInfo($key); + call_template('settings_field', [ + 'key' => $key, + 'value' => $value, + 'name' => $info['name'] ?? $key, + 'description' => $info['description'] ?? '', + 'options' => $info['options'] ?? null, + 'type' => $info['type'] ?? 'string' + ]); + } ?> +
+
+ + + +
+ +
+
\ No newline at end of file diff --git a/templates/settings_field.php b/templates/settings_field.php new file mode 100644 index 0000000..15b6c71 --- /dev/null +++ b/templates/settings_field.php @@ -0,0 +1,31 @@ +', $key); +?> +
+ + + + + + + + + + + + +
\ No newline at end of file diff --git a/templates/skeleton.php b/templates/skeleton.php index b274484..3aaf132 100644 --- a/templates/skeleton.php +++ b/templates/skeleton.php @@ -1,5 +1,6 @@ @@ -28,7 +29,7 @@ $user = Digitigrade\Model\UserAccount::findByCurrentSession(); ]); call_template('navigation_links', ['links' => $links]); ?> - + get('instance.name') ?> [ @@ -47,15 +48,17 @@ $user = Digitigrade\Model\UserAccount::findByCurrentSession(); [ - [ - 'href' => '/followrequests', - 'icon' => 'person_add', - 'label' => __('navigation.followRequests'), - 'unreadCount' => FollowRelation::countWhere("object = ? AND status = 'pending'", [$user->actor->id]) - ], - ['href' => '/logout', 'icon' => 'logout', 'label' => __('navigation.logout')] - ]]); + $links = [[ + 'href' => '/followrequests', + 'icon' => 'person_add', + 'label' => __('navigation.followRequests'), + 'unreadCount' => FollowRelation::countWhere("object = ? AND status = 'pending'", [$user->actor->id]) + ]]; + if ($user->isAdmin) { + $links[] = ['href' => '/admin/settings/instance', 'icon' => 'settings', 'label' => __('navigation.instanceSettings')]; + } + $links[] = ['href' => '/logout', 'icon' => 'logout', 'label' => __('navigation.logout')]; + call_template('side_navigation', ['links' => $links]); } ?> -- cgit v1.3