nav_menu.phtml 8.1 KB

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