SettingDefinitions
in package
Application setting definitions.
Provides default values and validation rules for all application settings.
Tags
Table of Contents
Constants
- SCOPE_ADMIN = 'admin'
- Setting scope: admin-only (server-wide).
- SCOPE_USER = 'user'
- Setting scope: user preference (per-user in multi-user mode).
- DEFINITIONS = [ // User preferences: reading 'set-words-to-do-buttons' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_USER], 'set-tooltip-mode' => ["default" => '2', "numeric" => false, "scope" => self::SCOPE_USER], 'set-display-text-frame-term-translation' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_USER], 'set-text-frame-annotation-position' => ["default" => '2', "numeric" => false, "scope" => self::SCOPE_USER], 'set-text-visit-statuses-via-key' => ["default" => '', "numeric" => false, "scope" => self::SCOPE_USER], 'set-show-text-word-counts' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_USER], // User preferences: review 'set-test-main-frame-waiting-time' => ["default" => '0', "numeric" => true, "min" => 0, "max" => 9999, "scope" => self::SCOPE_USER], 'set-test-edit-frame-waiting-time' => ["default" => '500', "numeric" => true, "min" => 0, "max" => 99999999, "scope" => self::SCOPE_USER], 'set-test-sentence-count' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_USER], 'set-term-sentence-count' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_USER], 'set-similar-terms-count' => ["default" => '0', "numeric" => true, "min" => 0, "max" => 9, "scope" => self::SCOPE_USER], 'set-term-translation-delimiters' => ["default" => '/;|', "numeric" => false, "scope" => self::SCOPE_USER], // User preferences: TTS 'set-tts' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_USER], 'set-hts' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_USER], // User preferences: pagination 'set-archived_texts-per-page' => ["default" => '100', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_USER], 'set-texts-per-page' => ["default" => '10', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_USER], 'set-terms-per-page' => ["default" => '100', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_USER], 'set-tags-per-page' => ["default" => '100', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_USER], 'set-articles-per-page' => ["default" => '10', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_USER], 'set-feeds-per-page' => ["default" => '50', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_USER], 'set-ggl-translation-per-page' => ["default" => '100', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_USER], 'set-regex-mode' => ["default" => '', "numeric" => false, "scope" => self::SCOPE_USER], // User preferences: reading layout 'set-reader-width' => ["default" => '100', "numeric" => true, "min" => 40, "max" => 100, "scope" => self::SCOPE_USER], 'set-reader-text-size' => ["default" => '0', "numeric" => true, "min" => 0, "max" => 300, "scope" => self::SCOPE_USER], // User preferences: appearance 'set-theme-dir' => ["default" => '', "numeric" => false, "scope" => self::SCOPE_USER], // User preferences: language/locale 'app_language' => ["default" => 'en', "numeric" => false, "scope" => self::SCOPE_USER], // Admin settings: feed limits 'set-max-articles-with-text' => ["default" => '100', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_ADMIN], 'set-max-articles-without-text' => ["default" => '250', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_ADMIN], 'set-max-texts-per-feed' => ["default" => '20', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_ADMIN], // Admin settings: multi-user 'set-allow-registration' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_ADMIN], // Admin settings: updates 'set-check-for-updates' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_ADMIN], ]
- Setting definitions with defaults, validation rules, and scope.
Methods
- get() : array{default: string, numeric: bool, min?: int, max?: int, scope: string}|null
- Get a specific setting definition.
- getAdminKeys() : array<string|int, string>
- Get all admin-scoped setting keys.
- getAll() : array<string, array{default: string, numeric: bool, min?: int, max?: int, scope: string}>
- Get all setting definitions.
- getDefault() : string|null
- Get the default value for a setting.
- getKeys() : array<string|int, string>
- Get all setting keys.
- getScope() : string
- Get the scope of a setting.
- getUserKeys() : array<string|int, string>
- Get all user-scoped setting keys.
- has() : bool
- Check if a setting is defined.
- isNumeric() : bool
- Check if a setting is numeric.
Constants
SCOPE_ADMIN
Setting scope: admin-only (server-wide).
public
mixed
SCOPE_ADMIN
= 'admin'
SCOPE_USER
Setting scope: user preference (per-user in multi-user mode).
public
mixed
SCOPE_USER
= 'user'
DEFINITIONS
Setting definitions with defaults, validation rules, and scope.
private
array<string, array{default: string, numeric: bool, min?: int, max?: int, scope: string}>
DEFINITIONS
= [
// User preferences: reading
'set-words-to-do-buttons' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_USER],
'set-tooltip-mode' => ["default" => '2', "numeric" => false, "scope" => self::SCOPE_USER],
'set-display-text-frame-term-translation' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_USER],
'set-text-frame-annotation-position' => ["default" => '2', "numeric" => false, "scope" => self::SCOPE_USER],
'set-text-visit-statuses-via-key' => ["default" => '', "numeric" => false, "scope" => self::SCOPE_USER],
'set-show-text-word-counts' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_USER],
// User preferences: review
'set-test-main-frame-waiting-time' => ["default" => '0', "numeric" => true, "min" => 0, "max" => 9999, "scope" => self::SCOPE_USER],
'set-test-edit-frame-waiting-time' => ["default" => '500', "numeric" => true, "min" => 0, "max" => 99999999, "scope" => self::SCOPE_USER],
'set-test-sentence-count' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_USER],
'set-term-sentence-count' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_USER],
'set-similar-terms-count' => ["default" => '0', "numeric" => true, "min" => 0, "max" => 9, "scope" => self::SCOPE_USER],
'set-term-translation-delimiters' => ["default" => '/;|', "numeric" => false, "scope" => self::SCOPE_USER],
// User preferences: TTS
'set-tts' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_USER],
'set-hts' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_USER],
// User preferences: pagination
'set-archived_texts-per-page' => ["default" => '100', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_USER],
'set-texts-per-page' => ["default" => '10', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_USER],
'set-terms-per-page' => ["default" => '100', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_USER],
'set-tags-per-page' => ["default" => '100', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_USER],
'set-articles-per-page' => ["default" => '10', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_USER],
'set-feeds-per-page' => ["default" => '50', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_USER],
'set-ggl-translation-per-page' => ["default" => '100', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_USER],
'set-regex-mode' => ["default" => '', "numeric" => false, "scope" => self::SCOPE_USER],
// User preferences: reading layout
'set-reader-width' => ["default" => '100', "numeric" => true, "min" => 40, "max" => 100, "scope" => self::SCOPE_USER],
'set-reader-text-size' => ["default" => '0', "numeric" => true, "min" => 0, "max" => 300, "scope" => self::SCOPE_USER],
// User preferences: appearance
'set-theme-dir' => ["default" => '', "numeric" => false, "scope" => self::SCOPE_USER],
// User preferences: language/locale
'app_language' => ["default" => 'en', "numeric" => false, "scope" => self::SCOPE_USER],
// Admin settings: feed limits
'set-max-articles-with-text' => ["default" => '100', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_ADMIN],
'set-max-articles-without-text' => ["default" => '250', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_ADMIN],
'set-max-texts-per-feed' => ["default" => '20', "numeric" => true, "min" => 1, "max" => 9999, "scope" => self::SCOPE_ADMIN],
// Admin settings: multi-user
'set-allow-registration' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_ADMIN],
// Admin settings: updates
'set-check-for-updates' => ["default" => '1', "numeric" => false, "scope" => self::SCOPE_ADMIN],
]
Each setting has:
- default: Default value (string). The legacy "dft" key is still accepted on read for backwards compatibility but is deprecated.
- numeric: Whether it holds a numeric value (bool). The legacy "num" key (int 0/1) is still accepted on read but is deprecated.
- min: Minimum value (for numeric settings)
- max: Maximum value (for numeric settings)
- scope: 'admin' or 'user' (defaults to 'user' if not set)
Methods
get()
Get a specific setting definition.
public
static get(string $key) : array{default: string, numeric: bool, min?: int, max?: int, scope: string}|null
Parameters
- $key : string
-
Setting key
Return values
array{default: string, numeric: bool, min?: int, max?: int, scope: string}|nullgetAdminKeys()
Get all admin-scoped setting keys.
public
static getAdminKeys() : array<string|int, string>
Return values
array<string|int, string>getAll()
Get all setting definitions.
public
static getAll() : array<string, array{default: string, numeric: bool, min?: int, max?: int, scope: string}>
Return values
array<string, array{default: string, numeric: bool, min?: int, max?: int, scope: string}>getDefault()
Get the default value for a setting.
public
static getDefault(string $key) : string|null
Reads the "default" field, falling back to the deprecated "dft" field if a definition still uses the legacy key.
Parameters
- $key : string
-
Setting key
Return values
string|null —Default value or null if not defined
getKeys()
Get all setting keys.
public
static getKeys() : array<string|int, string>
Return values
array<string|int, string>getScope()
Get the scope of a setting.
public
static getScope(string $key) : string
Parameters
- $key : string
-
Setting key
Return values
string —Scope ('admin' or 'user')
getUserKeys()
Get all user-scoped setting keys.
public
static getUserKeys() : array<string|int, string>
Return values
array<string|int, string>has()
Check if a setting is defined.
public
static has(string $key) : bool
Parameters
- $key : string
-
Setting key
Return values
boolisNumeric()
Check if a setting is numeric.
public
static isNumeric(string $key) : bool
Reads the "numeric" field, falling back to the deprecated "num" field if a definition still uses the legacy key.
Parameters
- $key : string
-
Setting key
Return values
bool —True if the setting holds a numeric value