javascript_vars.phtml 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. 'sticky_post' => !!FreshRSS_Context::isStickyPostEnabled(),
  27. 'html5_enable_notif' => FreshRSS_Context::userConf()->html5_enable_notif,
  28. 'html5_notif_timeout' => FreshRSS_Context::userConf()->html5_notif_timeout,
  29. 'closeNotification' => [
  30. 'good' => FreshRSS_Context::userConf()->good_notification_timeout * 1000,
  31. 'bad' => FreshRSS_Context::userConf()->bad_notification_timeout * 1000,
  32. 'mouseLeave' => 3000,
  33. ],
  34. 'auth_type' => FreshRSS_Context::systemConf()->auth_type,
  35. 'current_view' => Minz_Request::actionName(),
  36. 'csrf' => FreshRSS_Auth::csrfToken(),
  37. 'mtime' => [
  38. 'extra.js' => @filemtime(PUBLIC_PATH . '/scripts/extra.js'),
  39. 'feed.js' => @filemtime(PUBLIC_PATH . '/scripts/feed.js'),
  40. ],
  41. 'max_favicon_upload_size' => FreshRSS_Context::systemConf()->limits['max_favicon_upload_size'],
  42. 'version' => FRESHRSS_VERSION,
  43. ],
  44. 'shortcuts' => [
  45. 'actualize' => $s['actualize'] ?? '',
  46. 'mark_read' => $s['mark_read'] ?? '',
  47. 'mark_favorite' => $s['mark_favorite'] ?? '',
  48. 'go_website' => $s['go_website'] ?? '',
  49. 'prev_entry' => $s['prev_entry'] ?? '',
  50. 'next_entry' => $s['next_entry'] ?? '',
  51. 'next_unread_entry' => $s['next_unread_entry'] ?? '',
  52. 'skip_prev_entry' => $s['skip_prev_entry'] ?? '',
  53. 'skip_next_entry' => $s['skip_next_entry'] ?? '',
  54. 'first_entry' => $s['first_entry'] ?? '',
  55. 'last_entry' => $s['last_entry'] ?? '',
  56. 'collapse_entry' => $s['collapse_entry'] ?? '',
  57. 'load_more' => $s['load_more'] ?? '',
  58. 'mylabels' => $s['mylabels'] ?? '',
  59. 'auto_share' => $s['auto_share'] ?? '',
  60. 'focus_search' => $s['focus_search'] ?? '',
  61. 'user_filter' => $s['user_filter'] ?? '',
  62. 'help' => $s['help'] ?? '',
  63. 'close_menus' => $s['close_menus'] ?? '',
  64. 'normal_view' => $s['normal_view'] ?? '',
  65. 'global_view' => $s['global_view'] ?? '',
  66. 'reading_view' => $s['reading_view'] ?? '',
  67. 'rss_view' => $s['rss_view'] ?? '',
  68. 'toggle_media' => $s['toggle_media'] ?? '',
  69. 'toggle_aside' => $s['toggle_aside'] ?? '',
  70. ],
  71. 'urls' => [
  72. 'index' => _url('index', 'index'),
  73. 'login' => Minz_Url::display(['c' => 'auth', 'a' => 'login'], 'php'),
  74. 'logout' => Minz_Url::display(['c' => 'auth', 'a' => 'logout'], 'php'),
  75. 'help' => FRESHRSS_WIKI,
  76. 'shortcuts' => Minz_Url::display(['c' => 'configure', 'a' => 'shortcut'], 'php'),
  77. ],
  78. 'i18n' => [
  79. 'confirmation_default' => _t('gen.js.confirm_action'),
  80. 'confirm_exit_slider' => _t('gen.js.confirm_exit_slider'),
  81. 'notif_title_articles' => _t('gen.js.feedback.title_new_articles'),
  82. 'notif_body_new_articles' => _t('gen.js.feedback.body_new_articles'),
  83. 'notif_body_unread_articles' => _t('gen.js.feedback.body_unread_articles'),
  84. 'notif_request_failed' => _t('gen.js.feedback.request_failed'),
  85. 'category_empty' => _t('gen.js.category_empty'),
  86. 'labels_empty' => _t('gen.js.labels_empty'),
  87. 'favicon_size_exceeded' => _t('feedback.sub.feed.favicon.too_large', format_bytes(FreshRSS_Context::systemConf()->limits['max_favicon_upload_size'])),
  88. 'language' => FreshRSS_Context::userConf()->language,
  89. 'unsafe_csp_header' => _t('gen.js.unsafe_csp_header'),
  90. ],
  91. 'icons' => [
  92. 'read' => rawurlencode(_i('read')),
  93. 'unread' => rawurlencode(_i('unread')),
  94. 'spinner' => '../themes/icons/spinner.svg',
  95. ],
  96. 'extensions' => $extData,
  97. ], JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP);