aside_feed.phtml 9.9 KB

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