nav_menu.phtml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <?php
  2. declare(strict_types=1);
  3. $actual_view = Minz_Request::actionName();
  4. ?>
  5. <nav class="nav_menu">
  6. <?php if ($actual_view === 'normal' || $actual_view === 'reader') { ?>
  7. <div class="group">
  8. <a class="btn toggle_aside" href="#aside_feed"><?= _i('category') ?></a>
  9. </div>
  10. <?php } ?>
  11. <?php if (FreshRSS_Auth::hasAccess()) { ?>
  12. <div id="nav_menu_actions" class="group">
  13. <?php
  14. $states = array(
  15. 'read' => FreshRSS_Entry::STATE_READ,
  16. 'unread' => FreshRSS_Entry::STATE_NOT_READ,
  17. 'starred' => FreshRSS_Entry::STATE_FAVORITE,
  18. 'non-starred' => FreshRSS_Entry::STATE_NOT_FAVORITE,
  19. );
  20. foreach ($states as $state_str => $state) {
  21. $state_enabled = FreshRSS_Context::isStateEnabled($state);
  22. $url_state = Minz_Request::currentRequest();
  23. $url_state['params']['state'] = FreshRSS_Context::getRevertState($state);
  24. ?>
  25. <a id="toggle-<?= $state_str ?>"
  26. class="btn <?= $state_enabled ? 'active' : '' ?>"
  27. role="checkbox" aria-checked="<?= $state_enabled ? 'true' : 'false' ?>"
  28. title="<?= _t('index.menu.' . $state_str) ?>"
  29. href="<?= Minz_Url::display($url_state) ?>"><?= _i($state_str) ?></a>
  30. <?php } ?>
  31. <div class="dropdown only-mobile" id="dropdown-search-wrapper">
  32. <input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
  33. <div id="dropdown-search" class="dropdown-target"></div>
  34. <a id="toggle-search" class="dropdown-toggle btn<?= (strlen(FreshRSS_Context::$search->getRawInput()) > 0) ? ' active' : ''; ?>" title="<?= _t('gen.menu.search') ?>"
  35. href="#dropdown-search"><?= _i('search') ?></a>
  36. <ul class="dropdown-menu">
  37. <li class="item">
  38. <span>
  39. <form action="<?= _url('index', 'index') ?>" method="get">
  40. <?php $param_a = Minz_Request::actionName(); ?>
  41. <?php if (in_array($param_a, ['normal', 'global', 'reader'], true)) { ?>
  42. <input type="hidden" name="a" value="<?= $param_a ?>" />
  43. <?php } ?>
  44. <?php $get = Minz_Request::paramString('get'); ?>
  45. <?php if ($get !== '') { ?>
  46. <input type="hidden" name="get" value="<?= $get ?>" />
  47. <?php } ?>
  48. <?php $order = Minz_Request::paramString('order'); ?>
  49. <?php if ($order !== '') { ?>
  50. <input type="hidden" name="order" value="<?= $order ?>" />
  51. <?php } ?>
  52. <?php $state = Minz_Request::paramString('state'); ?>
  53. <?php if ($state !== '') { ?>
  54. <input type="hidden" name="state" value="<?= $state ?>" />
  55. <?php } ?>
  56. <div class="stick search">
  57. <input type="search" name="search"
  58. value="<?= htmlspecialchars(htmlspecialchars_decode(FreshRSS_Context::$search->getRawInput(), ENT_QUOTES), ENT_COMPAT, 'UTF-8'); ?>"
  59. placeholder="<?= _t('gen.menu.search') ?>" title="<?= _t('gen.menu.search') ?>" /><button class="btn" type="submit" title="<?= _t('index.menu.search_short') ?>"><?= _i('search') ?></button>
  60. </div>
  61. <p class="help"><?= _i('help') ?> <?= _t('gen.menu.search_help') ?></a></p>
  62. </form>
  63. </span>
  64. </li>
  65. </ul>
  66. <a class="dropdown-close" href="#close">❌</a>
  67. </div>
  68. <div class="dropdown">
  69. <div id="dropdown-query" class="dropdown-target"></div>
  70. <a id="toggle-userqueries" class="dropdown-toggle btn" href="#dropdown-query" title="<?= _t('index.menu.queries') ?>"><?= _i('bookmark-tag') ?></a>
  71. <ul class="dropdown-menu">
  72. <li class="dropdown-header">
  73. <?= _t('index.menu.queries') ?>
  74. <a href="<?= _url('configure', 'queries') ?>"><?= _i('configure') ?></a>
  75. </li>
  76. <?php foreach (FreshRSS_Context::userConf()->queries as $raw_query): ?>
  77. <li class="item query">
  78. <?php if (!empty($raw_query['url'])): ?>
  79. <a href="<?= $raw_query['url'] ?>"><?= $raw_query['name'] ?? $raw_query['url'] ?></a>
  80. <?php else: ?>
  81. <?php $query = new FreshRSS_UserQuery($raw_query); ?>
  82. <a href="<?= $query->getUrl() ?>"><?= $query->getName() ?></a>
  83. <?php endif; ?>
  84. </li>
  85. <?php endforeach; ?>
  86. <?php
  87. $classSeparator = '';
  88. if (count(FreshRSS_Context::userConf()->queries) > 0) {
  89. $classSeparator = ' separator';
  90. }
  91. $url_query = Minz_Request::currentRequest();
  92. $url_query['c'] = 'configure';
  93. $url_query['a'] = 'bookmarkQuery';
  94. ?>
  95. <li class="item<?= $classSeparator ?>"><a href="<?= Minz_Url::display($url_query) ?>"><?= _i('bookmark-add') ?> <?= _t('index.menu.bookmark_query') ?></a></li>
  96. </ul>
  97. <a class="dropdown-close" href="#close">❌</a>
  98. </div>
  99. </div>
  100. <?php
  101. $get = FreshRSS_Context::currentGet();
  102. $string_mark = _t('index.menu.mark_all_read');
  103. $string_unmark = _t('index.menu.mark_selection_unread');
  104. if ($get[0] === 'f') {
  105. $string_mark = _t('index.menu.mark_feed_read');
  106. } elseif ($get[0] === 'c') {
  107. $string_mark = _t('index.menu.mark_cat_read');
  108. }
  109. $mark_read_url = array(
  110. 'c' => 'entry',
  111. 'a' => 'read',
  112. 'params' => array(
  113. 'get' => $get,
  114. 'nextGet' => FreshRSS_Context::$next_get,
  115. 'idMax' => FreshRSS_Context::$id_max,
  116. 'search' => htmlspecialchars_decode(FreshRSS_Context::$search->getRawInput(), ENT_QUOTES),
  117. 'state' => FreshRSS_Context::$state,
  118. ),
  119. );
  120. $mark_unread_url = $mark_read_url;
  121. $mark_unread_url['params']['is_read'] = '0';
  122. $mark_unread_url['params']['nextGet'] = $get;
  123. ?>
  124. <div class="group stick" id="nav_menu_read_all">
  125. <form id="mark-read-menu" method="post">
  126. <?php $confirm = FreshRSS_Context::userConf()->reading_confirm ? 'confirm" disabled="disabled' : ''; ?>
  127. <button class="read_all btn <?= $confirm ?>"
  128. form="mark-read-menu"
  129. formaction="<?= Minz_Url::display($mark_read_url) ?>"
  130. type="submit"><?= _t('gen.action.mark_read') ?></button>
  131. <div class="dropdown">
  132. <input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
  133. <div id="dropdown-read" class="dropdown-target"></div>
  134. <a class="dropdown-toggle btn" href="#dropdown-read"><?= _i('down') ?></a>
  135. <ul class="dropdown-menu">
  136. <li class="item">
  137. <button class="as-link <?= $confirm ?>"
  138. form="mark-read-menu"
  139. formaction="<?= Minz_Url::display($mark_read_url) ?>"
  140. type="submit"><?= $string_mark ?></button>
  141. </li>
  142. <?php
  143. $today = @strtotime('today');
  144. $mark_before_today = $mark_read_url;
  145. $mark_before_today['params']['idMax'] = $today . '000000';
  146. $mark_before_one_week = $mark_read_url;
  147. $mark_before_one_week['params']['idMax'] = ($today - 604800) . '000000';
  148. $mark_unread_enabled = FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ) or !FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ);
  149. ?>
  150. <li class="item separator">
  151. <button class="as-link <?= $confirm ?>"
  152. form="mark-read-menu"
  153. formaction="<?= Minz_Url::display($mark_before_today) ?>"
  154. type="submit"><?= _t('index.menu.before_one_day') ?></button>
  155. </li>
  156. <li class="item">
  157. <button class="as-link <?= $confirm ?>"
  158. form="mark-read-menu"
  159. formaction="<?= Minz_Url::display($mark_before_one_week) ?>"
  160. type="submit"><?= _t('index.menu.before_one_week') ?></button>
  161. </li>
  162. <li class="item separator">
  163. <button class="as-link <?= $mark_unread_enabled ? $confirm : '" disabled="disabled' ?>"
  164. form="mark-read-menu"
  165. formaction="<?= Minz_Url::display($mark_unread_url) ?>"
  166. type="submit"><?= $string_unmark ?></button>
  167. </li>
  168. </ul>
  169. <a class="dropdown-close" href="#close">❌</a>
  170. </div>
  171. </form>
  172. </div>
  173. <?php } ?>
  174. <?php $url_output = Minz_Request::currentRequest(); ?>
  175. <div class="group" id="nav_menu_views">
  176. <?php
  177. $readingModes = FreshRSS_ReadingMode::getReadingModes();
  178. $readingModes = Minz_ExtensionManager::callHook('nav_reading_modes', $readingModes);
  179. if (!is_iterable($readingModes)) {
  180. $readingModes = FreshRSS_ReadingMode::getReadingModes();
  181. }
  182. /** @var FreshRSS_ReadingMode $mode */
  183. foreach ($readingModes as $mode) {
  184. ?>
  185. <a class="<?= $mode->getId() ?> btn <?php if ($mode->isActive()) { echo 'active'; } ?>" title="<?=
  186. $mode->getTitle() ?>" href="<?= Minz_Url::display($mode->getUrlParams()) ?>">
  187. <?= $mode->getName() ?>
  188. </a>
  189. <?php
  190. }
  191. ?>
  192. <?php
  193. $url_output['a'] = 'rss';
  194. if (FreshRSS_Context::userConf()->token) {
  195. $url_output['params']['user'] = Minz_User::name();
  196. $url_output['params']['token'] = FreshRSS_Context::userConf()->token;
  197. }
  198. if (FreshRSS_Context::userConf()->since_hours_posts_per_rss) {
  199. $url_output['params']['hours'] = FreshRSS_Context::userConf()->since_hours_posts_per_rss;
  200. }
  201. ?>
  202. <a class="view-rss btn" target="_blank" rel="noreferrer" title="<?= _t('index.menu.rss_view') ?>" href="<?= Minz_Url::display($url_output) ?>">
  203. <?= _i('rss') ?>
  204. </a>
  205. </div>
  206. <?php $nav_menu_hooks = Minz_ExtensionManager::callHookString('nav_menu'); ?>
  207. <?php if ($nav_menu_hooks != '') { ?>
  208. <div class="group" id="nav_menu_hooks">
  209. <?= $nav_menu_hooks ?>
  210. </div>
  211. <?php } ?>
  212. <?php
  213. if (FreshRSS_Context::$order === 'DESC') {
  214. $order = 'ASC';
  215. $icon = 'sort-up';
  216. $title = _t('index.menu.older_first');
  217. } else {
  218. $order = 'DESC';
  219. $icon = 'sort-down';
  220. $title = _t('index.menu.newer_first');
  221. }
  222. $url_order = Minz_Request::currentRequest();
  223. $url_order['params']['order'] = $order;
  224. ?>
  225. <div class="group">
  226. <a id="toggle-order" class="btn" href="<?= Minz_Url::display($url_order) ?>" title="<?= $title ?>">
  227. <?= _i($icon) ?>
  228. </a>
  229. </div>
  230. <?php if (FreshRSS_Auth::hasAccess() || FreshRSS_Context::systemConf()->allow_anonymous_refresh) { ?>
  231. <div class="group">
  232. <a id="actualize" class="btn" href="<?= _url('feed', 'actualize') ?>" title="<?= _t('gen.action.actualize') ?>"><?= _i('refresh') ?></a>
  233. </div>
  234. <?php } ?>
  235. </nav>
  236. <?php flush(); ?>