aside_feed.phtml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. declare(strict_types=1);
  3. /** @var FreshRSS_View $this */
  4. $actual_view = Minz_Request::actionName();
  5. $class = '';
  6. if (FreshRSS_Context::userConf()->hide_read_feeds &&
  7. FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ) &&
  8. !FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ)) {
  9. $class = ' state_unread';
  10. }
  11. $state_filter_manual = Minz_Request::paramString('state');
  12. if ($state_filter_manual !== '') {
  13. $state_filter_manual = '&state=' . $state_filter_manual;
  14. }
  15. ?>
  16. <nav class="nav aside aside_feed<?= $class ?>" id="aside_feed">
  17. <a class="toggle_aside" href="#close"><?= _i('close') ?></a>
  18. <?php if (FreshRSS_Auth::hasAccess()) { ?>
  19. <div class="stick configure-feeds">
  20. <a id="btn-subscription" class="btn btn-important" href="<?= _url('subscription', 'index') ?>"><?= _t('index.menu.subscription') ?></a>
  21. <a id="btn-add" class="btn btn-important" href="<?= _url('subscription', 'add') ?>"><?= _i('add') ?></a>
  22. </div>
  23. <?php } elseif (FreshRSS_Auth::accessNeedsLogin()) { ?>
  24. <a href="<?= _url('index', 'about') ?>" class="about"><?= _t('index.menu.about') ?></a>
  25. <?php } ?>
  26. <form id="mark-read-aside" method="post">
  27. <input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
  28. <ul id="sidebar" class="tree scrollbar-thin">
  29. <li class="tree-folder category all<?= FreshRSS_Context::isCurrentGet('a') ? ' active' : '' ?>">
  30. <a class="tree-folder-title" data-unread="<?= format_number(FreshRSS_Context::$total_unread) ?>" href="<?= _url('index', $actual_view) . $state_filter_manual ?>">
  31. <?= _i('all') ?><span class="title" data-unread="<?= format_number(FreshRSS_Context::$total_unread) ?>"><?= _t('index.menu.main_stream') ?></span>
  32. </a>
  33. </li>
  34. <li class="tree-folder category important<?= FreshRSS_Context::isCurrentGet('i') ? ' active' : '' ?>">
  35. <a class="tree-folder-title" data-unread="<?= format_number(FreshRSS_Context::$total_important_unread) ?>" href="<?= _url('index', $actual_view, 'get', 'i') . $state_filter_manual ?>">
  36. <?= _i('important') ?><span class="title" data-unread="<?= format_number(FreshRSS_Context::$total_important_unread) ?>"><?= _t('index.menu.important') ?></span>
  37. </a>
  38. </li>
  39. <li class="tree-folder category favorites<?= FreshRSS_Context::isCurrentGet('s') ? ' active' : '' ?>">
  40. <a class="tree-folder-title" data-unread="<?= format_number(FreshRSS_Context::$total_starred['unread']) ?>" href="<?= _url('index', $actual_view, 'get', 's') . $state_filter_manual ?>">
  41. <?= _i('starred') ?><span class="title" data-unread="<?= format_number(FreshRSS_Context::$total_starred['unread']) ?>"><?= _t('index.menu.favorites', format_number(FreshRSS_Context::$total_starred['all'])) ?></span>
  42. </a>
  43. </li>
  44. <?php
  45. $t_active = FreshRSS_Context::isCurrentGet('T');
  46. $t_show = ($t_active && in_array(FreshRSS_Context::userConf()->display_categories, ['active', 'remember'], true)) || FreshRSS_Context::userConf()->display_categories === 'all';
  47. ?>
  48. <li id="tags" class="tree-folder category tags<?= $t_active ? ' active' : '' ?>" data-unread="<?= format_number($this->nbUnreadTags) ?>">
  49. <a href="<?= _url('index', $actual_view, 'get', 'T') . $state_filter_manual ?>" class="tree-folder-title">
  50. <button class="dropdown-toggle" title="<?= _t('sub.category.expand') ?>"><?= _i($t_show ? 'up' : 'down') ?></button><span class="title" title="<?= _t('sub.category.open') ?>" data-unread="<?= format_number($this->nbUnreadTags) ?>"><?= _t('index.menu.tags') ?></span>
  51. </a>
  52. <ul class="tree-folder-items<?= $t_show ? ' active' : '' ?>">
  53. <?php
  54. foreach ($this->tags as $tag):
  55. ?>
  56. <li id="t_<?= $tag->id() ?>" class="item feed<?= FreshRSS_Context::isCurrentGet('t_' . $tag->id()) ? ' active' : '' ?>" data-unread="<?= $tag->nbUnread() ?>">
  57. <div class="dropdown no-mobile">
  58. <div id="dropdown-t-<?= $tag->id() ?>" class="dropdown-target"></div>
  59. <a class="dropdown-toggle" href="#dropdown-t-<?= $tag->id() ?>"><?= _i('configure') ?></a>
  60. <?php /* tag_config_template */ ?>
  61. </div>
  62. <a class="item-title" data-unread="<?= format_number($tag->nbUnread()) ?>" href="<?=
  63. _url('index', $actual_view, 'get', 't_' . $tag->id()) . $state_filter_manual ?>"><?= _i('label') ?> <?= $tag->name() ?></a>
  64. </li>
  65. <?php endforeach; ?>
  66. </ul>
  67. </li>
  68. <?php
  69. $nbFeedsTotal = 0;
  70. foreach ($this->categories as $cat) {
  71. $nbFeedsTotal += $cat->nbFeeds();
  72. }
  73. foreach ($this->categories as $cat):
  74. $feeds = $cat->feeds();
  75. $position = $cat->attributeInt('position');
  76. if (!empty($feeds)) {
  77. $c_active = FreshRSS_Context::isCurrentGet('c_' . $cat->id());
  78. $c_show = ($c_active && in_array(FreshRSS_Context::userConf()->display_categories, ['active', 'remember'], true))
  79. || FreshRSS_Context::userConf()->display_categories === 'all';
  80. ?>
  81. <li id="c_<?= $cat->id() ?>" class="tree-folder category<?= $c_active ? ' active' : '' ?>"<?=
  82. null === $position ? '' : " data-position='$position'" ?> data-unread="<?= $cat->nbNotRead() ?>">
  83. <a href="<?= _url('index', $actual_view, 'get', 'c_' . $cat->id()) . $state_filter_manual ?>" class="tree-folder-title">
  84. <button class="dropdown-toggle" title="<?= _t('sub.category.expand') ?>"><?= _i($c_show ? 'up' : 'down') ?></button><span title="<?= _t('sub.category.open') ?>" class="title<?= $cat->hasFeedsWithError() ? ' error' : '' ?>" data-unread="<?=
  85. format_number($cat->nbNotRead()) ?>" ><?=
  86. $cat->name()
  87. ?><?php if ($cat->kind() == FreshRSS_Category::KIND_DYNAMIC_OPML) { echo _i('opml-dyn'); } ?></span>
  88. </a>
  89. <ul class="tree-folder-items<?= $c_show ? ' active' : '' ?>">
  90. <?php
  91. // NB: Reduce whitespace in that loop
  92. $show_favicon = FreshRSS_Context::userConf()->show_favicons && $nbFeedsTotal < FreshRSS_Context::userConf()->simplify_over_n_feeds;
  93. foreach ($feeds as $feed):
  94. $f_active = FreshRSS_Context::isCurrentGet('f_' . $feed->id());
  95. $f_active_class = $f_active ? ' active' : '';
  96. $error_class = '';
  97. $error_title = '';
  98. if ($feed->inError() && !$feed->mute()) {
  99. $error_class = ' error';
  100. $error_title = _t('sub.feed.error');
  101. }
  102. $empty_class = '';
  103. $empty_title = '';
  104. if ($feed->nbEntries() <= 0) {
  105. $empty_class = ' empty';
  106. $empty_title = _t('sub.feed.empty');
  107. }
  108. $mute_class = $feed->mute() ? ' mute' : '';
  109. ?>
  110. <li id="f_<?= $feed->id() ?>" class="item feed<?= $f_active_class, $mute_class, $error_class, $empty_class ?>"
  111. data-unread="<?= $feed->nbNotRead() ?>" data-priority="<?= $feed->priority() ?>"><?php
  112. if ($f_active || $nbFeedsTotal < FreshRSS_Context::userConf()->simplify_over_n_feeds):
  113. ?><div class="dropdown no-mobile">
  114. <div id="dropdown-<?= $feed->id() ?>" class="dropdown-target"></div><a href="#dropdown-<?= $feed->id() ?>" class="dropdown-toggle" title="<?= _t('gen.action.menu.open') ?>" data-fweb="<?= $feed->website() ?>"><?= _i('configure') ?></a><?php /* feed_config_template */ ?>
  115. </div><?php
  116. endif;
  117. $title = _t('sub.feed.open_feed', $feed->name());
  118. $title .= $error_title !== '' ? '&#13;⚠ ' . $error_title : '';
  119. $title .= $empty_title !== '' ? '&#13;' . $empty_title : '';
  120. $title .= $feed->mute() ? '&#13;🔇 ' . _t('sub.feed.mute.state_is_muted') : '';
  121. ?><a class="item-title" title="<?= $title ?>"
  122. data-unread="<?= format_number($feed->nbNotRead()) ?>" href="<?=
  123. _url('index', $actual_view, 'get', 'f_' . $feed->id()) . $state_filter_manual ?>">
  124. <?php
  125. if ($show_favicon || $f_active) { ?><img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" loading="lazy" /><?php }
  126. ?><span class="title"><?= $feed->name() ?></span></a></li>
  127. <?php
  128. endforeach;
  129. ?>
  130. </ul>
  131. </li>
  132. <?php
  133. }
  134. endforeach;
  135. ?>
  136. <li class="tree-bottom"></li>
  137. </ul>
  138. </form>
  139. </nav>
  140. <a class="close-aside" href="#close">❌</a>
  141. <div id="first_load" class="loading"></div>
  142. <?php flush(); ?>
  143. <script id="tag_config_template" type="text/html">
  144. <ul class="dropdown-menu">
  145. <li class="item">
  146. <a class="configure open-slider" href="<?= _url('tag', 'update', 'id', '------') ?>"><?= _t('gen.action.manage') ?></a>
  147. </li>
  148. </ul>
  149. <a class="dropdown-close" href="#close">❌</a>
  150. </script>
  151. <script id="feed_config_template" type="text/html">
  152. <ul class="dropdown-menu">
  153. <li class="item"><a href="<?= _url('index', $actual_view, 'get', 'f_------') ?>"><?= _t('gen.action.filter') ?></a></li>
  154. <?php if (FreshRSS_Auth::hasAccess()) { ?>
  155. <li class="item"><a href="<?= _url('stats', 'repartition', 'id', '------') ?>"><?= _t('index.menu.stats') ?></a></li>
  156. <?php } ?>
  157. <li class="item link website"><a target="_blank" rel="noreferrer" href="http://example.net/"><?= _t('gen.action.see_website') ?></a></li>
  158. <?php if (FreshRSS_Auth::hasAccess()) {
  159. $get = Minz_Request::paramString('get');
  160. if ($get === '') {
  161. $url = _url('subscription', 'feed', 'id', '------', 'from', $actual_view);
  162. } else {
  163. $url = _url('subscription', 'feed', 'id', '------', 'get', $get, 'from', $actual_view);
  164. }
  165. ?>
  166. <li class="item"><a class="configure open-slider" href="<?= $url ?>"><?= _t('gen.action.manage') ?></a></li>
  167. <li class="item"><a href="<?= _url('feed', 'actualize', 'id', '------') ?>"><?= _t('gen.action.actualize') ?></a></li>
  168. <li class="item">
  169. <?php $confirm = FreshRSS_Context::userConf()->reading_confirm ? 'confirm" disabled="disabled' : ''; ?>
  170. <button class="read_all as-link <?= $confirm ?>"
  171. form="mark-read-aside"
  172. formaction="<?= _url('entry', 'read', 'get', 'f_------') ?>"
  173. type="submit"><?= _t('index.menu.mark_feed_read') ?></button>
  174. </li>
  175. <?php } ?>
  176. </ul>
  177. <a class="dropdown-close" href="#close">❌</a>
  178. </script>