UserConfiguration.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @property string $apiPasswordHash
  5. * @property array{'keep_period':string|false,'keep_max':int|false,'keep_min':int|false,'keep_favourites':bool,'keep_labels':bool,'keep_unreads':bool} $archiving
  6. * @property bool $auto_load_more
  7. * @property bool $auto_remove_article
  8. * @property bool $bottomline_date
  9. * @property bool $bottomline_favorite
  10. * @property bool $bottomline_link
  11. * @property bool $bottomline_read
  12. * @property bool $bottomline_sharing
  13. * @property bool $bottomline_tags
  14. * @property bool $bottomline_myLabels
  15. * @property string $content_width
  16. * @property-read int $default_state
  17. * @property string $default_view
  18. * @property string|bool $display_categories
  19. * @property string $show_tags
  20. * @property int $show_tags_max
  21. * @property string $show_author_date
  22. * @property string $show_feed_name
  23. * @property bool $display_posts
  24. * @property string $email_validation_token
  25. * @property-read bool $enabled
  26. * @property string $feverKey
  27. * @property bool $hide_read_feeds
  28. * @property int $html5_notif_timeout
  29. * @property-read bool $is_admin
  30. * @property int|null $keep_history_default
  31. * @property string $language
  32. * @property string $timezone
  33. * @property bool $lazyload
  34. * @property string $mail_login
  35. * @property bool $mark_updated_article_unread
  36. * @property array<string,bool|int> $mark_when
  37. * @property int $max_posts_per_rss
  38. * @property-read array<string,int> $limits
  39. * @property int|null $old_entries
  40. * @property bool $onread_jump_next
  41. * @property string $passwordHash
  42. * @property int $posts_per_page
  43. * @property array<array{'get'?:string,'name'?:string,'order'?:string,'search'?:string,'state'?:int,'url'?:string}> $queries
  44. * @property bool $reading_confirm
  45. * @property int $since_hours_posts_per_rss
  46. * @property bool $show_fav_unread
  47. * @property bool $show_favicons
  48. * @property bool $icons_as_emojis
  49. * @property int $simplify_over_n_feeds
  50. * @property bool $show_nav_buttons
  51. * @property 'ASC'|'DESC' $sort_order
  52. * @property array<string,array<string>> $sharing
  53. * @property array<string,string> $shortcuts
  54. * @property bool $sides_close_article
  55. * @property bool $sticky_post
  56. * @property string $theme
  57. * @property string $darkMode
  58. * @property string $token
  59. * @property bool $topline_date
  60. * @property bool $topline_display_authors
  61. * @property bool $topline_favorite
  62. * @property bool $topline_link
  63. * @property bool $topline_read
  64. * @property bool $topline_summary
  65. * @property string $topline_website
  66. * @property string $topline_thumbnail
  67. * @property int $ttl_default
  68. * @property int $dynamic_opml_ttl_default
  69. * @property-read bool $unsafe_autologin_enabled
  70. * @property string $view_mode
  71. * @property array<string,mixed> $volatile
  72. * @property array<string,array<string,mixed>> $extensions
  73. */
  74. final class FreshRSS_UserConfiguration extends Minz_Configuration {
  75. use FreshRSS_FilterActionsTrait;
  76. /** @throws Minz_ConfigurationNamespaceException */
  77. public static function init(string $config_filename, ?string $default_filename = null): FreshRSS_UserConfiguration {
  78. parent::register('user', $config_filename, $default_filename);
  79. return parent::get('user');
  80. }
  81. /**
  82. * @param non-empty-string $key
  83. * @return array<int|string,mixed>|null
  84. */
  85. public function attributeArray(string $key): ?array {
  86. $a = parent::param($key, null);
  87. return is_array($a) ? $a : null;
  88. }
  89. /** @param non-empty-string $key */
  90. public function attributeBool(string $key): ?bool {
  91. $a = parent::param($key, null);
  92. return is_bool($a) ? $a : null;
  93. }
  94. /** @param non-empty-string $key */
  95. public function attributeInt(string $key): ?int {
  96. $a = parent::param($key, null);
  97. return is_numeric($a) ? (int)$a : null;
  98. }
  99. /** @param non-empty-string $key */
  100. public function attributeString(string $key): ?string {
  101. $a = parent::param($key, null);
  102. return is_string($a) ? $a : null;
  103. }
  104. /**
  105. * @param non-empty-string $key
  106. * @param array<string,mixed>|mixed|null $value Value, not HTML-encoded
  107. */
  108. public function _attribute(string $key, $value = null): void {
  109. parent::_param($key, $value);
  110. }
  111. }