<?php
/** @var FreshRSS_View $this */
$mark = FreshRSS_Context::$user_conf->mark_when;
$s = FreshRSS_Context::$user_conf->shortcuts;
$extData = Minz_ExtensionManager::callHook('js_vars', []);
echo htmlspecialchars(json_encode(array(
	'context' => array(
		'anonymous' => !FreshRSS_Auth::hasAccess(),
		'auto_remove_article' => !!FreshRSS_Context::isAutoRemoveAvailable(),
		'hide_posts' => !(FreshRSS_Context::$user_conf->display_posts || Minz_Request::actionName() === 'reader'),
		'display_order' => Minz_Request::param('order', FreshRSS_Context::$user_conf->sort_order),
		'display_categories' => FreshRSS_Context::$user_conf->display_categories,
		'auto_mark_article' => !!$mark['article'],
		'auto_mark_site' => !!$mark['site'],
		'auto_mark_scroll' => !!$mark['scroll'],
		'auto_load_more' => !!FreshRSS_Context::$user_conf->auto_load_more,
		'auto_actualize_feeds' => !!Minz_Session::param('actualize_feeds', false),
		'does_lazyload' => !!FreshRSS_Context::$user_conf->lazyload ,
		'sides_close_article' => !!FreshRSS_Context::$user_conf->sides_close_article,
		'sticky_post' => !!FreshRSS_Context::isStickyPostEnabled(),
		'html5_notif_timeout' => FreshRSS_Context::$user_conf->html5_notif_timeout,
		'auth_type' => FreshRSS_Context::$system_conf->auth_type,
		'current_view' => Minz_Request::actionName(),
		'csrf' => FreshRSS_Auth::csrfToken(),
		'mtime' => [
			'extra.js' => @filemtime(PUBLIC_PATH . '/scripts/extra.js'),
			'feed.js' => @filemtime(PUBLIC_PATH . '/scripts/feed.js'),
		],
	),
	'shortcuts' => array(
		'actualize' => @$s['actualize'],
		'mark_read' => @$s['mark_read'],
		'mark_favorite' => @$s['mark_favorite'],
		'go_website' => @$s['go_website'],
		'prev_entry' => @$s['prev_entry'],
		'next_entry' => @$s['next_entry'],
		'next_unread_entry' => @$s['next_unread_entry'],
		'skip_prev_entry' => @$s['skip_prev_entry'],
		'skip_next_entry' => @$s['skip_next_entry'],
		'first_entry' => @$s['first_entry'],
		'last_entry' => @$s['last_entry'],
		'collapse_entry' => @$s['collapse_entry'],
		'load_more' => @$s['load_more'],
		'auto_share' => @$s['auto_share'],
		'focus_search' => @$s['focus_search'],
		'user_filter' => @$s['user_filter'],
		'help' => @$s['help'],
		'close_dropdown' => @$s['close_dropdown'],
		'normal_view' => @$s['normal_view'],
		'global_view' => @$s['global_view'],
		'reading_view' => @$s['reading_view'],
		'rss_view' => @$s['rss_view'],
		'toggle_media' => @$s['toggle_media'],
	),
	'urls' => array(
		'index' => _url('index', 'index'),
		'login' => Minz_Url::display(array('c' => 'auth', 'a' => 'login'), 'php'),
		'logout' => Minz_Url::display(array('c' => 'auth', 'a' => 'logout'), 'php'),
		'help' => FRESHRSS_WIKI,
	),
	'i18n' => array(
		'confirmation_default' => _t('gen.js.confirm_action'),
		'notif_title_articles' => _t('gen.js.feedback.title_new_articles'),
		'notif_body_new_articles' => _t('gen.js.feedback.body_new_articles'),
		'notif_body_unread_articles' => _t('gen.js.feedback.body_unread_articles'),
		'notif_request_failed' => _t('gen.js.feedback.request_failed'),
		'category_empty' => _t('gen.js.category_empty'),
		'language' => FreshRSS_Context::$user_conf->language,
	),
	'icons' => array(
		'read' => rawurlencode(_i('read')),
		'unread' => rawurlencode(_i('unread')),
	),
	'extensions' => $extData,
), JSON_UNESCAPED_UNICODE), ENT_NOQUOTES, 'UTF-8');
