From d18ec187847893f94418b29bc6a087d6b2dd9a2d Mon Sep 17 00:00:00 2001 From: winter Date: Fri, 7 Feb 2025 18:26:05 +0000 Subject: localise note timestamps and stuff --- templates/note.php | 14 +++++++------- templates/preferences_form.php | 31 +++++++++++++++---------------- templates/settings_field.php | 8 ++++++++ 3 files changed, 30 insertions(+), 23 deletions(-) (limited to 'templates') diff --git a/templates/note.php b/templates/note.php index b43e63e..db4fbb9 100644 --- a/templates/note.php +++ b/templates/note.php @@ -3,8 +3,10 @@ use Digitigrade\Model\Actor; use Digitigrade\Model\InteractionKind; use Digitigrade\Model\NotePrivacyScope; use Digitigrade\Model\UserAccount; +use Digitigrade\UserSettings; $user = UserAccount::findByCurrentSession(); +$prefs = $user ? new UserSettings($user) : null; $interKinds = []; $actionsDisabled = $user == null; if ($user != null) { @@ -25,13 +27,11 @@ if ($user != null) { href="/@/author->getFullHandle() ?>">author->displayName) ?> @author->getFullHandle() ?> - created->format('Y-m-d \a\t H:i') + created, $prefs?->get('locale.timezone')) . (isset($note->modified) && $note->modified != $note->created - ? ' (edited ' . $note->modified->format('Y-m-d \a\t H:i') . ')' + ? ' (' . format_datetime($note->modified, $prefs?->get('locale.timezone')) . ')' : '' - ) - ?> + ) ?> attachments as $attachment): ?>
- type, 'image/')): ?> + isImage()): ?> <?= htmlspecialchars($attachment->description ?? '') ?> - + description ?? basename($attachment->href)) ?> diff --git a/templates/preferences_form.php b/templates/preferences_form.php index 8c8f203..33418f6 100644 --- a/templates/preferences_form.php +++ b/templates/preferences_form.php @@ -2,27 +2,26 @@ use Digitigrade\UserSettings; $settings = new UserSettings($user); + +function _user_pref(string $id, mixed $value, string $type) { + call_template('settings_field', [ + 'id' => "pref-$id", + 'fieldName' => $id, + 'name' => __("preferences.$id.name"), + 'description' => __("preferences.$id.description"), + 'value' => $value, + 'type' => $type + ]); +} + ?>
'pref-requestToFollow', - 'fieldName' => 'requestToFollow', - 'name' => __('preferences.requestToFollow.name'), - 'description' => __('preferences.requestToFollow.description'), - 'value' => $user->actor->requestToFollow, - 'type' => 'boolean' - ]); - call_template('settings_field', [ - 'id' => 'pref-smallIndicators', - 'fieldName' => 'smallIndicators', - 'name' => __('preferences.smallIndicators.name'), - 'description' => __('preferences.smallIndicators.description'), - 'value' => $settings->getBool('interface.smallUnreadIndicators'), - 'type' => 'boolean' - ]); + _user_pref('requestToFollow', $user->actor->requestToFollow, 'boolean'); + _user_pref('smallIndicators', $settings->getBool('interface.smallUnreadIndicators'), 'boolean'); + _user_pref('timezone', $settings->get('locale.timezone'), 'timezone'); ?>
diff --git a/templates/settings_field.php b/templates/settings_field.php index fe68a52..f9de886 100644 --- a/templates/settings_field.php +++ b/templates/settings_field.php @@ -38,5 +38,13 @@ $fieldName ??= str_replace('.', '', $key); + + + +
\ No newline at end of file -- cgit v1.3