javascript_vars.phtml 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. declare(strict_types=1);
  3. /** @var FreshRSS_View $this */
  4. $mark = FreshRSS_Context::userConf()->mark_when;
  5. $s = FreshRSS_Context::userConf()->shortcuts;
  6. $extData = Minz_ExtensionManager::callHook(Minz_HookType::JsVars, []);
  7. echo json_encode([
  8. 'context' => [
  9. 'anonymous' => !FreshRSS_Auth::hasAccess(),
  10. 'admin' => FreshRSS_Auth::hasAccess('admin'),
  11. 'suppress_csp_warning' => FreshRSS_Context::systemConf()->suppress_csp_warning,
  12. 'auto_remove_article' => !!FreshRSS_Context::isAutoRemoveAvailable(),
  13. 'hide_posts' => !(FreshRSS_Context::userConf()->display_posts || Minz_Request::actionName() === 'reader'),
  14. 'display_order' => Minz_Request::paramString('order') ?: FreshRSS_Context::userConf()->sort_order,
  15. 'sort' => FreshRSS_Context::$sort,
  16. 'display_categories' => FreshRSS_Context::userConf()->display_categories,
  17. 'auto_mark_article' => !!$mark['article'],
  18. 'auto_mark_site' => !!$mark['site'],
  19. 'auto_mark_scroll' => !!$mark['scroll'],
  20. 'auto_mark_focus' => !!$mark['focus'],
  21. 'auto_load_more' => FreshRSS_Context::userConf()->auto_load_more && FreshRSS_Context::$sort !== 'rand',
  22. 'auto_actualize_feeds' => Minz_Session::paramBoolean('actualize_feeds'),
  23. 'nb_parallel_refresh' => max(1, FreshRSS_Context::systemConf()->nb_parallel_refresh),
  24. 'does_lazyload' => !!FreshRSS_Context::userConf()->lazyload ,
  25. 'sides_close_article' => !!FreshRSS_Context::userConf()->sides_close_article,
  26. 'sidebar_hidden_by_default' => !!FreshRSS_Context::userConf()->sidebar_hidden_by_default,
  27. 'sticky_post' => !!FreshRSS_Context::isStickyPostEnabled(),
  28. 'html5_enable_notif' => FreshRSS_Context::userConf()->html5_enable_notif,
  29. 'html5_notif_timeout' => FreshRSS_Context::userConf()->html5_notif_timeout,
  30. 'closeNotification' => [
  31. 'good' => FreshRSS_Context::userConf()->good_notification_timeout * 1000,
  32. 'bad' => FreshRSS_Context::userConf()->bad_notification_timeout * 1000,
  33. 'mouseLeave' => 3000,
  34. ],
  35. 'auth_type' => FreshRSS_Context::systemConf()->auth_type,
  36. 'current_view' => Minz_Request::actionName(),
  37. 'csrf' => FreshRSS_Auth::csrfToken(),
  38. 'mtime' => [
  39. 'extra.js' => @filemtime(PUBLIC_PATH . '/scripts/extra.js'),
  40. 'feed.js' => @filemtime(PUBLIC_PATH . '/scripts/feed.js'),
  41. ],
  42. 'max_favicon_upload_size' => FreshRSS_Context::systemConf()->limits['max_favicon_upload_size'],
  43. 'version' => FRESHRSS_VERSION,
  44. ],
  45. 'shortcuts' => [
  46. 'actualize' => $s['actualize'] ?? '',
  47. 'mark_read' => $s['mark_read'] ?? '',
  48. 'mark_favorite' => $s['mark_favorite'] ?? '',
  49. 'go_website' => $s['go_website'] ?? '',
  50. 'prev_entry' => $s['prev_entry'] ?? '',
  51. 'next_entry' => $s['next_entry'] ?? '',
  52. 'next_unread_entry' => $s['next_unread_entry'] ?? '',
  53. 'skip_prev_entry' => $s['skip_prev_entry'] ?? '',
  54. 'skip_next_entry' => $s['skip_next_entry'] ?? '',
  55. 'first_entry' => $s['first_entry'] ?? '',
  56. 'last_entry' => $s['last_entry'] ?? '',
  57. 'collapse_entry' => $s['collapse_entry'] ?? '',
  58. 'load_more' => $s['load_more'] ?? '',
  59. 'mylabels' => $s['mylabels'] ?? '',
  60. 'auto_share' => $s['auto_share'] ?? '',
  61. 'focus_search' => $s['focus_search'] ?? '',
  62. 'user_filter' => $s['user_filter'] ?? '',
  63. 'help' => $s['help'] ?? '',
  64. 'close_menus' => $s['close_menus'] ?? '',
  65. 'normal_view' => $s['normal_view'] ?? '',
  66. 'global_view' => $s['global_view'] ?? '',
  67. 'reading_view' => $s['reading_view'] ?? '',
  68. 'rss_view' => $s['rss_view'] ?? '',
  69. 'toggle_media' => $s['toggle_media'] ?? '',
  70. 'toggle_aside' => $s['toggle_aside'] ?? '',
  71. ],
  72. 'urls' => [
  73. 'index' => _url('index', 'index'),
  74. 'login' => Minz_Url::display(['c' => 'auth', 'a' => 'login'], 'php'),
  75. 'logout' => Minz_Url::display(['c' => 'auth', 'a' => 'logout'], 'php'),
  76. 'help' => FRESHRSS_WIKI,
  77. 'shortcuts' => Minz_Url::display(['c' => 'configure', 'a' => 'shortcut'], 'php'),
  78. ],
  79. 'i18n' => [
  80. 'confirmation_default' => _t('gen.js.confirm_action'),
  81. 'confirm_exit_slider' => _t('gen.js.confirm_exit_slider'),
  82. 'notif_title_articles' => _t('gen.js.feedback.title_new_articles'),
  83. 'notif_body_new_articles' => _t('gen.js.feedback.body_new_articles'),
  84. 'notif_body_unread_articles' => _t('gen.js.feedback.body_unread_articles'),
  85. 'notif_request_failed' => _t('gen.js.feedback.request_failed'),
  86. 'category_empty' => _t('gen.js.category_empty'),
  87. 'labels_empty' => _t('gen.js.labels_empty'),
  88. 'favicon_size_exceeded' => _t('feedback.sub.feed.favicon.too_large', format_bytes(FreshRSS_Context::systemConf()->limits['max_favicon_upload_size'])),
  89. 'language' => FreshRSS_Context::userConf()->language,
  90. 'unsafe_csp_header' => _t('gen.js.unsafe_csp_header'),
  91. ],
  92. 'icons' => [
  93. 'read' => rawurlencode(_i('read')),
  94. 'unread' => rawurlencode(_i('unread')),
  95. 'spinner' => '../themes/icons/spinner.svg',
  96. ],
  97. 'extensions' => $extData,
  98. ], JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP);