UserConfiguration.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 string $show_article_icons
  24. * @property bool $display_posts
  25. * @property string $email_validation_token
  26. * @property-read bool $enabled
  27. * @property string $feverKey
  28. * @property bool $hide_read_feeds
  29. * @property int $html5_notif_timeout
  30. * @property int $good_notification_timeout
  31. * @property int $bad_notification_timeout
  32. * @property-read bool $is_admin
  33. * @property int|null $keep_history_default
  34. * @property string $language
  35. * @property string $timezone
  36. * @property bool $lazyload
  37. * @property string $mail_login
  38. * @property bool $mark_updated_article_unread
  39. * @property array<string,bool|int> $mark_when
  40. * @property int $max_posts_per_rss
  41. * @property-read array<string,int> $limits
  42. * @property int|null $old_entries
  43. * @property bool $onread_jump_next
  44. * @property string $passwordHash
  45. * @property int $posts_per_page
  46. * @property array<int,array{get?:string,name?:string,order?:string,search?:string,state?:int,url?:string,token?:string}> $queries
  47. * @property bool $reading_confirm
  48. * @property int $since_hours_posts_per_rss
  49. * @property bool $show_fav_unread
  50. * @property bool $show_favicons
  51. * @property bool $icons_as_emojis
  52. * @property int $simplify_over_n_feeds
  53. * @property bool $show_nav_buttons
  54. * @property 'big'|'small'|'none' $mark_read_button
  55. * @property 'ASC'|'DESC' $sort_order
  56. * @property 'id'|'c.name'|'date'|'f.name'|'link'|'title'|'rand' $sort
  57. * @property array<int,array<string,string>> $sharing
  58. * @property array<string,string> $shortcuts
  59. * @property bool $sides_close_article
  60. * @property bool $sticky_post
  61. * @property string $theme
  62. * @property string $darkMode
  63. * @property string $token
  64. * @property bool $topline_date
  65. * @property bool $topline_display_authors
  66. * @property bool $topline_favorite
  67. * @property bool $topline_myLabels
  68. * @property bool $topline_sharing
  69. * @property bool $topline_link
  70. * @property bool $topline_read
  71. * @property bool $topline_summary
  72. * @property string $topline_website
  73. * @property string $topline_thumbnail
  74. * @property int $ttl_default
  75. * @property int $dynamic_opml_ttl_default
  76. * @property-read bool $unsafe_autologin_enabled
  77. * @property string $view_mode
  78. * @property array<string,bool|int|string> $volatile
  79. * @property array<string,array<string,mixed>> $extensions
  80. * @property bool $retrieve_extension_list
  81. */
  82. final class FreshRSS_UserConfiguration extends Minz_Configuration {
  83. use FreshRSS_FilterActionsTrait;
  84. /** @throws Minz_FileNotExistException */
  85. public static function init(string $config_filename, ?string $default_filename = null): FreshRSS_UserConfiguration {
  86. parent::register('user', $config_filename, $default_filename);
  87. try {
  88. return parent::get('user');
  89. } catch (Minz_ConfigurationNamespaceException $ex) {
  90. FreshRSS::killApp($ex->getMessage());
  91. }
  92. }
  93. /**
  94. * Access the default configuration for users.
  95. * @throws Minz_FileNotExistException
  96. */
  97. public static function default(): FreshRSS_UserConfiguration {
  98. /** @var FreshRSS_UserConfiguration|null $default_user_conf */
  99. static $default_user_conf = null;
  100. if ($default_user_conf === null) {
  101. $namespace = 'user_default';
  102. FreshRSS_UserConfiguration::register($namespace, '_', FRESHRSS_PATH . '/config-user.default.php');
  103. $default_user_conf = FreshRSS_UserConfiguration::get($namespace);
  104. }
  105. return $default_user_conf;
  106. }
  107. }