nav_menu.phtml 9.3 KB

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