nav_menu.phtml 7.9 KB

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