nav_menu.phtml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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 if (in_array(Minz_Request::actionName(), ['normal', 'global', 'reader'], true)) { ?>
  41. <input type="hidden" name="a" value="<?= Minz_Request::actionName() ?>" />
  42. <?php } if (Minz_Request::paramString('get') !== '') { ?>
  43. <input type="hidden" name="get" value="<?= FreshRSS_Context::currentGet() ?>" />
  44. <?php } if (ctype_upper(Minz_Request::paramString('order'))) { ?>
  45. <input type="hidden" name="order" value="<?= FreshRSS_Context::$order ?>" />
  46. <?php } if (Minz_Request::paramInt('state') !== 0) { ?>
  47. <input type="hidden" name="state" value="<?= FreshRSS_Context::$state ?>" />
  48. <?php } ?>
  49. <div class="stick search">
  50. <input type="search" name="search"
  51. value="<?= htmlspecialchars(htmlspecialchars_decode(FreshRSS_Context::$search->getRawInput(), ENT_QUOTES), ENT_COMPAT, 'UTF-8'); ?>"
  52. placeholder="<?= _t('gen.menu.search') ?>" title="<?= _t('gen.menu.search') ?>" /><button class="btn" type="submit" title="<?= _t('index.menu.search_short') ?>"><?= _i('search') ?></button>
  53. </div>
  54. <p class="help"><?= _i('help') ?> <?= _t('gen.menu.search_help') ?></a></p>
  55. </form>
  56. </span>
  57. </li>
  58. </ul>
  59. <a class="dropdown-close" href="#close">❌</a>
  60. </div>
  61. <div class="dropdown">
  62. <div id="dropdown-query" class="dropdown-target"></div>
  63. <a id="toggle-userqueries" class="dropdown-toggle btn" href="#dropdown-query" title="<?= _t('index.menu.queries') ?>"><?= _i('bookmark-tag') ?></a>
  64. <ul class="dropdown-menu">
  65. <li class="dropdown-header">
  66. <?= _t('index.menu.queries') ?>
  67. <a href="<?= _url('configure', 'queries') ?>"><?= _i('configure') ?></a>
  68. </li>
  69. <?php foreach (FreshRSS_Context::userConf()->queries as $raw_query): ?>
  70. <li class="item query">
  71. <?php if (!empty($raw_query['url'])): ?>
  72. <a href="<?= $raw_query['url'] ?>"><?= $raw_query['name'] ?? $raw_query['url'] ?></a>
  73. <?php else: ?>
  74. <?php $query = new FreshRSS_UserQuery($raw_query, FreshRSS_Context::categories(), FreshRSS_Context::labels()); ?>
  75. <a href="<?= $query->getUrl() ?>"><?= $query->getName() ?></a>
  76. <?php endif; ?>
  77. </li>
  78. <?php endforeach; ?>
  79. <?php
  80. $classSeparator = '';
  81. if (count(FreshRSS_Context::userConf()->queries) > 0) {
  82. $classSeparator = ' separator';
  83. }
  84. $url_query = Minz_Request::currentRequest();
  85. $url_query['c'] = 'configure';
  86. $url_query['a'] = 'bookmarkQuery';
  87. ?>
  88. <li class="item<?= $classSeparator ?>"><a href="<?= Minz_Url::display($url_query) ?>"><?= _i('bookmark-add') ?> <?= _t('index.menu.bookmark_query') ?></a></li>
  89. </ul>
  90. <a class="dropdown-close" href="#close">❌</a>
  91. </div>
  92. </div>
  93. <?php
  94. $get = FreshRSS_Context::currentGet();
  95. $string_mark = _t('index.menu.mark_all_read');
  96. $string_unmark = _t('index.menu.mark_selection_unread');
  97. if ($get[0] === 'f') {
  98. $string_mark = _t('index.menu.mark_feed_read');
  99. } elseif ($get[0] === 'c') {
  100. $string_mark = _t('index.menu.mark_cat_read');
  101. }
  102. $mark_read_url = array(
  103. 'c' => 'entry',
  104. 'a' => 'read',
  105. 'params' => array(
  106. 'get' => $get,
  107. 'nextGet' => FreshRSS_Context::$next_get,
  108. 'idMax' => FreshRSS_Context::$id_max,
  109. 'search' => htmlspecialchars_decode(FreshRSS_Context::$search->getRawInput(), ENT_QUOTES),
  110. 'state' => FreshRSS_Context::$state,
  111. ),
  112. );
  113. $mark_unread_url = $mark_read_url;
  114. $mark_unread_url['params']['is_read'] = '0';
  115. $mark_unread_url['params']['nextGet'] = $get;
  116. ?>
  117. <div class="group stick" id="nav_menu_read_all">
  118. <form id="mark-read-menu" method="post">
  119. <?php $confirm = FreshRSS_Context::userConf()->reading_confirm ? 'confirm" disabled="disabled' : ''; ?>
  120. <button class="read_all btn <?= $confirm ?>"
  121. form="mark-read-menu"
  122. formaction="<?= Minz_Url::display($mark_read_url) ?>"
  123. type="submit"><?= _t('gen.action.mark_read') ?></button>
  124. <div class="dropdown">
  125. <input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
  126. <div id="dropdown-read" class="dropdown-target"></div>
  127. <a class="dropdown-toggle btn" href="#dropdown-read"><?= _i('down') ?></a>
  128. <ul class="dropdown-menu">
  129. <li class="item">
  130. <button class="as-link <?= $confirm ?>"
  131. form="mark-read-menu"
  132. formaction="<?= Minz_Url::display($mark_read_url) ?>"
  133. type="submit"><?= $string_mark ?></button>
  134. </li>
  135. <?php
  136. $today = @strtotime('today');
  137. $mark_before_today = $mark_read_url;
  138. $mark_before_today['params']['idMax'] = $today . '000000';
  139. $mark_before_one_week = $mark_read_url;
  140. $mark_before_one_week['params']['idMax'] = ($today - 604800) . '000000';
  141. $mark_unread_enabled = FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ) or !FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ);
  142. ?>
  143. <li class="item separator">
  144. <button class="as-link <?= $confirm ?>"
  145. form="mark-read-menu"
  146. formaction="<?= Minz_Url::display($mark_before_today) ?>"
  147. type="submit"><?= _t('index.menu.before_one_day') ?></button>
  148. </li>
  149. <li class="item">
  150. <button class="as-link <?= $confirm ?>"
  151. form="mark-read-menu"
  152. formaction="<?= Minz_Url::display($mark_before_one_week) ?>"
  153. type="submit"><?= _t('index.menu.before_one_week') ?></button>
  154. </li>
  155. <li class="item separator">
  156. <button class="as-link <?= $mark_unread_enabled ? $confirm : '" disabled="disabled' ?>"
  157. form="mark-read-menu"
  158. formaction="<?= Minz_Url::display($mark_unread_url) ?>"
  159. type="submit"><?= $string_unmark ?></button>
  160. </li>
  161. </ul>
  162. <a class="dropdown-close" href="#close">❌</a>
  163. </div>
  164. </form>
  165. </div>
  166. <?php } ?>
  167. <?php $url_output = Minz_Request::currentRequest(); ?>
  168. <div class="group" id="nav_menu_views">
  169. <?php
  170. $readingModes = FreshRSS_ReadingMode::getReadingModes();
  171. $readingModes = Minz_ExtensionManager::callHook('nav_reading_modes', $readingModes);
  172. if (!is_iterable($readingModes)) {
  173. $readingModes = FreshRSS_ReadingMode::getReadingModes();
  174. }
  175. /** @var FreshRSS_ReadingMode $mode */
  176. foreach ($readingModes as $mode) {
  177. ?>
  178. <a class="<?= $mode->getId() ?> btn <?php if ($mode->isActive()) { echo 'active'; } ?>" title="<?=
  179. $mode->getTitle() ?>" href="<?= Minz_Url::display($mode->getUrlParams()) ?>">
  180. <?= $mode->getName() ?>
  181. </a>
  182. <?php
  183. }
  184. ?>
  185. </div>
  186. <?php $nav_menu_hooks = Minz_ExtensionManager::callHookString('nav_menu'); ?>
  187. <?php if ($nav_menu_hooks != '') { ?>
  188. <div class="group" id="nav_menu_hooks">
  189. <?= $nav_menu_hooks ?>
  190. </div>
  191. <?php } ?>
  192. <?php
  193. if (FreshRSS_Context::$order === 'DESC') {
  194. $order = 'ASC';
  195. $icon = 'sort-up';
  196. $title = _t('index.menu.older_first');
  197. } else {
  198. $order = 'DESC';
  199. $icon = 'sort-down';
  200. $title = _t('index.menu.newer_first');
  201. }
  202. $url_order = Minz_Request::currentRequest();
  203. $url_order['params']['order'] = $order;
  204. ?>
  205. <div class="group">
  206. <a id="toggle-order" class="btn" href="<?= Minz_Url::display($url_order) ?>" title="<?= $title ?>">
  207. <?= _i($icon) ?>
  208. </a>
  209. </div>
  210. <?php if (FreshRSS_Auth::hasAccess() || FreshRSS_Context::systemConf()->allow_anonymous_refresh) { ?>
  211. <div class="group">
  212. <a id="actualize" class="btn" href="<?= _url('feed', 'actualize') ?>" title="<?= _t('gen.action.actualize') ?>"><?= _i('refresh') ?></a>
  213. </div>
  214. <?php } ?>
  215. </nav>
  216. <?php flush(); ?>