aboutsummaryrefslogtreecommitdiff
path: root/app/layout/nav_menu.phtml
blob: debc06611514cef6ec4afba021d55690c0353969 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<?php
	declare(strict_types=1);
	$actual_view = Minz_Request::actionName();
?>
<nav class="nav_menu">
	<?php if ($actual_view === 'normal' || $actual_view === 'reader') { ?>
		<div id="nav_menu_toggle_aside" class="group">
			<button class="btn<?= $actual_view === 'normal' ? ' active' : '' ?>" title="<?= _t('conf.shortcut.toggle_aside') ?>">
				<?= _i('category') ?>
			</button>
		</div>
	<?php } ?>

	<?php if (FreshRSS_Auth::hasAccess()) { ?>
	<div id="nav_menu_actions" class="group">
		<?php
			$states = [
				'read' => FreshRSS_Entry::STATE_READ,
				'unread' => FreshRSS_Entry::STATE_NOT_READ,
				'starred' => FreshRSS_Entry::STATE_FAVORITE,
				'non-starred' => FreshRSS_Entry::STATE_NOT_FAVORITE,
			];

			foreach ($states as $state_str => $state) {
				$state_enabled = FreshRSS_Context::isStateEnabled($state);
				$url_state = Minz_Request::currentRequest();
				$reverted_state = FreshRSS_Context::getRevertState($state);
				$reverted_state &= FreshRSS_Entry::STATE_ANDS;	// Keep only the AND states
				$url_state['params']['state'] = $reverted_state;
		?>
		<a id="toggle-<?= $state_str ?>"
			class="btn <?= $state_enabled ? 'active' : '' ?>"
			role="checkbox" aria-checked="<?= $state_enabled ? 'true' : 'false' ?>"
			title="<?= _t('index.menu.' . $state_str) ?>"
			href="<?= Minz_Url::display($url_state) ?>"><?= _i($state_str) ?></a>
		<?php } ?>

		<div id="dropdown-search-wrapper" class="dropdown only-mobile">
			<input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
			<div id="dropdown-search" class="dropdown-target"></div>

			<a id="toggle-search" class="dropdown-toggle btn<?= FreshRSS_Context::$search->toString() !== '' ? ' active' : ''; ?>" title="<?= _t('gen.menu.search') ?>"
				href="#dropdown-search"><?= _i('search') ?></a>
			<ul class="dropdown-menu">
				<li class="item">
					<span>
						<form action="<?= _url('index', 'index') ?>" method="get">
							<?php if (in_array(Minz_Request::actionName(), ['normal', 'global', 'reader'], true)) { ?>
							<input type="hidden" name="a" value="<?= Minz_Request::actionName() ?>" />
							<?php } if (Minz_Request::paramString('get') !== '') { ?>
							<input type="hidden" name="get" value="<?= FreshRSS_Context::currentGet() ?>" />
							<?php } if (ctype_upper(Minz_Request::paramString('order'))) { ?>
							<input type="hidden" name="order" value="<?= FreshRSS_Context::$order ?>" />
							<?php } if (Minz_Request::paramInt('state') !== 0) { ?>
							<input type="hidden" name="state" value="<?= FreshRSS_Context::$state ?>" />
							<?php } ?>
							<div class="stick search">
								<input type="search" name="search"
									value="<?= htmlspecialchars(FreshRSS_Context::$search->toString(), ENT_COMPAT, 'UTF-8') ?>"
									placeholder="<?= _t('gen.menu.search') ?>" title="<?= _t('gen.menu.search') ?>" /><button class="btn" type="submit" title="<?= _t('index.menu.search_short') ?>"><?= _i('search') ?></button>
							</div>
							<p class="help"><?= _i('help') ?> <a href="<?= _url('search', 'index') ?>"><?= _t('gen.menu.advanced_search') ?></a></p>
						</form>
					</span>
				</li>
			</ul>
			<a class="dropdown-close" href="#close">❌</a>
		</div>

		<div id="nav_menu_queries" class="dropdown">
			<div id="dropdown-query" class="dropdown-target"></div>

			<a id="toggle-userqueries" class="dropdown-toggle btn" href="#dropdown-query" title="<?= _t('index.menu.queries') ?>"><?= _i('bookmark-tag') ?></a>
			<ul class="dropdown-menu">
				<li class="dropdown-header">
					<?= _t('index.menu.queries') ?>
					<a href="<?= _url('configure', 'queries') ?>"><?= _i('configure') ?></a>
				</li>

				<?php foreach (FreshRSS_Context::userConf()->queries as $raw_query): ?>
					<li class="item query">
						<?php if (!empty($raw_query['url'])): ?>
							<a href="<?= $raw_query['url'] ?>"><?= $raw_query['name'] ?? $raw_query['url'] ?></a>
						<?php else: ?>
						<?php $query = new FreshRSS_UserQuery($raw_query, FreshRSS_Context::categories(), FreshRSS_Context::labels()); ?>
							<a href="<?= $query->getUrl() ?>"><?= $query->getName() ?></a>
						<?php endif; ?>
					</li>
				<?php endforeach; ?>

				<?php
					$classSeparator = '';
					if (count(FreshRSS_Context::userConf()->queries) > 0) {
						$classSeparator = ' separator';
					}

					$url_query = Minz_Request::currentRequest();
					$url_query['c'] = 'configure';
					$url_query['a'] = 'bookmarkQuery';
				?>
				<li class="item<?= $classSeparator ?>"><button class="as-link" form="post-csrf" formaction="<?= Minz_Url::display($url_query) ?>" type="submit"><?= _i('bookmark-add') ?> <?= _t('index.menu.bookmark_query') ?></button></li>
			</ul>
			<a class="dropdown-close" href="#close">❌</a>
		</div>
	</div>

	<?php
		$get = FreshRSS_Context::currentGet();
		$string_mark = _t('index.menu.mark_all_read');
		$string_unmark = _t('index.menu.mark_selection_unread');
		if ($get[0] === 'f') {
			$string_mark = _t('index.menu.mark_feed_read');
		} elseif ($get[0] === 'c') {
			$string_mark = _t('index.menu.mark_cat_read');
		}

		$mark_read_url = [
			'c' => 'entry',
			'a' => 'read',
			'params' => [
				'get' => $get,
				'nextGet' => FreshRSS_Context::$next_get,
				'idMax' => FreshRSS_Context::$id_max,
				'search' => FreshRSS_Context::$search->toString(),
				'state' => FreshRSS_Context::$state,
				'sort' => FreshRSS_Context::$sort,
				'order' => FreshRSS_Context::$order,
			],
		];

		$mark_unread_url = $mark_read_url;
		$mark_unread_url['params']['is_read'] = '0';
		$mark_unread_url['params']['nextGet'] = $get;
	?>

	<div id="nav_menu_read_all" class="group stick">
		<form id="mark-read-menu" method="post">
		<?php $confirm = FreshRSS_Context::userConf()->reading_confirm ? 'confirm" disabled="disabled' : ''; ?>
		<button class="read_all btn <?= $confirm ?>"
			form="mark-read-menu"
			formaction="<?= Minz_Url::display($mark_read_url) ?>"
			type="submit"><?= _t('gen.action.mark_read') ?></button>

		<div id="nav_menu_read" class="dropdown">
			<input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
			<div id="dropdown-read" class="dropdown-target"></div>

			<a class="dropdown-toggle btn" href="#dropdown-read"><?= _i('down') ?></a>
			<ul class="dropdown-menu">
				<li class="item">
					<button class="as-link <?= $confirm ?>"
						form="mark-read-menu"
						formaction="<?= Minz_Url::display($mark_read_url) ?>"
						type="submit"><?= $string_mark ?></button>
				</li>
<?php
	$mark_read_enabled = in_array(FreshRSS_Context::$sort, ['id', 'date'], true);
	$today = @strtotime('today');
	$mark_before_today = $mark_read_url;
	$mark_before_one_week = $mark_read_url;
	switch (FreshRSS_Context::$sort) {
		case 'id':
			$mark_before_today['params']['idMax'] = $today . '000000';
			$mark_before_one_week['params']['idMax'] = ($today - 604800) . '000000';
			break;
		case 'date':
			$mark_before_today['params']['maxPubDate'] = $today;
			$mark_before_one_week['params']['maxPubDate'] = $today - 604800;
			break;
	}
	$mark_unread_enabled = FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ) ||
		(!FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ) && !FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_OR_NOT_READ));
?>
				<li class="item separator">
					<button class="as-link <?= $mark_read_enabled ? $confirm : '" disabled="disabled' ?>"
						form="mark-read-menu"
						formaction="<?= Minz_Url::display($mark_before_today) ?>"
						type="submit"><?= _t('index.menu.before_one_day') ?></button>
				</li>
				<li class="item">
					<button class="as-link <?= $mark_read_enabled ? $confirm : '" disabled="disabled' ?>"
						form="mark-read-menu"
						formaction="<?= Minz_Url::display($mark_before_one_week) ?>"
						type="submit"><?= _t('index.menu.before_one_week') ?></button>
				</li>
				<li class="item separator">
					<button class="as-link <?= $mark_unread_enabled ? $confirm : '" disabled="disabled' ?>"
						form="mark-read-menu"
						formaction="<?= Minz_Url::display($mark_unread_url) ?>"
						type="submit"><?= $string_unmark ?></button>
				</li>
			</ul>
			<a class="dropdown-close" href="#close">❌</a>
		</div>
		</form>
	</div>
	<?php } ?>

	<?php $url_output = Minz_Request::currentRequest(); ?>
	<div id="nav_menu_views" class="group">
		<?php
		$readingModes = FreshRSS_ReadingMode::getReadingModes();
		$readingModes = Minz_ExtensionManager::callHook(Minz_HookType::NavReadingModes, $readingModes);
		if (!is_iterable($readingModes)) {
			$readingModes = FreshRSS_ReadingMode::getReadingModes();
		}

		/** @var FreshRSS_ReadingMode $mode */
		foreach ($readingModes as $mode) {
			?>
			<a class="<?= $mode->getId() ?> btn <?= $mode->isActive() ? 'active' : '' ?>" title="<?=
				$mode->getTitle() ?>" href="<?= Minz_Url::display($mode->getUrlParams()) ?>">
				<?= $mode->getName() ?>
			</a>
			<?php
		}
		?>
	</div>

	<?php $nav_menu_hooks = Minz_ExtensionManager::callHookString(Minz_HookType::NavMenu); ?>
	<?php if ($nav_menu_hooks != '') { ?>
	<div id="nav_menu_hooks" class="group">
		<?= $nav_menu_hooks ?>
	</div>
	<?php } ?>

	<?php
		if (FreshRSS_Context::$order === 'ASC') {
			$icon = 'sort-up';
			$title = _t('index.menu.older_first');
		} else {
			$icon = 'sort-down';
			$title = _t('index.menu.newer_first');
		}
		$url_order = Minz_Request::currentRequest();
	?>
	<div id="nav_menu_sort" class="group">
		<div class="dropdown">
			<div id="dropdown-sort" class="dropdown-target"></div>
			<a id="toggle-order" class="dropdown-toggle btn" href="#dropdown-sort" title="<?= _t('index.menu.sort') ?>"><?= _i($icon) ?></a>
			<ul class="dropdown-menu" role="radiogroup">
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'DESC' && FreshRSS_Context::$sort === 'id' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'id', 'order' => 'DESC']]) ?>"><?= _t('index.menu.sort.id_desc') ?></a></li>
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'DESC' && FreshRSS_Context::$sort === 'date' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'date', 'order' => 'DESC']]) ?>"><?= _t('index.menu.sort.date_desc') ?></a></li>
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'DESC' && FreshRSS_Context::$sort === 'lastUserModified' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'lastUserModified', 'order' => 'DESC']]) ?>"><?= _t('index.menu.sort.user_modified_desc') ?></a></li>
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'DESC' && FreshRSS_Context::$sort === 'length' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'length', 'order' => 'DESC']]) ?>"><?= _t('index.menu.sort.length_desc') ?></a></li>
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'DESC' && FreshRSS_Context::$sort === 'link' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'link', 'order' => 'DESC']]) ?>"><?= _t('index.menu.sort.link_desc') ?></a></li>
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'DESC' && FreshRSS_Context::$sort === 'title' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'title', 'order' => 'DESC']]) ?>"><?= _t('index.menu.sort.title_desc') ?></a></li>
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'DESC' && FreshRSS_Context::$sort === 'f.name' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'f.name', 'order' => 'DESC']]) ?>"><?= _t('index.menu.sort.f.name_desc') ?></a></li>
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'DESC' && FreshRSS_Context::$sort === 'c.name' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'c.name', 'order' => 'DESC']]) ?>"><?= _t('index.menu.sort.c.name_desc') ?></a></li>
				<li class="item separator" role="radio" aria-checked="<?= FreshRSS_Context::$sort === 'rand' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'rand', 'order' => null]]) ?>"><?= _t('index.menu.sort.rand') ?></a></li>
				<li class="item separator" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'ASC' && FreshRSS_Context::$sort === 'id' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'id', 'order' => 'ASC']]) ?>"><?= _t('index.menu.sort.id_asc') ?></a></li>
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'ASC' && FreshRSS_Context::$sort === 'date' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'date', 'order' => 'ASC']]) ?>"><?= _t('index.menu.sort.date_asc') ?></a></li>
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'ASC' && FreshRSS_Context::$sort === 'lastUserModified' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'lastUserModified', 'order' => 'ASC']]) ?>"><?= _t('index.menu.sort.user_modified_asc') ?></a></li>
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'ASC' && FreshRSS_Context::$sort === 'length' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'length', 'order' => 'ASC']]) ?>"><?= _t('index.menu.sort.length_asc') ?></a></li>
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'ASC' && FreshRSS_Context::$sort === 'link' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'link', 'order' => 'ASC']]) ?>"><?= _t('index.menu.sort.link_asc') ?></a></li>
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'ASC' && FreshRSS_Context::$sort === 'title' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'title', 'order' => 'ASC']]) ?>"><?= _t('index.menu.sort.title_asc') ?></a></li>
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'ASC' && FreshRSS_Context::$sort === 'f.name' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'f.name', 'order' => 'ASC']]) ?>"><?= _t('index.menu.sort.f.name_asc') ?></a></li>
				<li class="item" role="radio" aria-checked="<?= FreshRSS_Context::$order === 'ASC' && FreshRSS_Context::$sort === 'c.name' ? 'true' : 'false' ?>">
					<a href="<?= Minz_Url::display($url_order, amend: ['params' => ['sort' => 'c.name', 'order' => 'ASC']]) ?>"><?= _t('index.menu.sort.c.name_asc') ?></a></li>
			</ul>
			<a class="dropdown-close" href="#close">❌</a>
		</div>
	</div>

	<?php if (FreshRSS_Auth::hasAccess() || FreshRSS_Context::systemConf()->allow_anonymous_refresh) { ?>
		<div id="nav_menu_actualize" class="group">
			<a id="actualize" class="btn" href="<?= _url('feed', 'actualize') ?>" title="<?= _t('gen.action.actualize') ?>"><?= _i('refresh') ?></a>
		</div>
	<?php } ?>
</nav>
<?php flush(); ?>