nav_menu.phtml 9.2 KB

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