global.phtml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. declare(strict_types=1);
  3. /** @var FreshRSS_View $this */
  4. $this->partial('nav_menu');
  5. $class = '';
  6. $state_unread = false;
  7. if (FreshRSS_Context::userConf()->hide_read_feeds &&
  8. FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ) &&
  9. !FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ)) {
  10. $class = ' state_unread';
  11. $state_unread = true;
  12. }
  13. ?>
  14. <datalist id="datalist-labels"></datalist>
  15. <template id="share_article_template">
  16. <?php $this->renderHelper('index/normal/entry_share_menu'); ?>
  17. <a class="dropdown-close" href="#close">❌</a>
  18. </template>
  19. <template id="labels_article_template">
  20. <div class="dropdown-menu">
  21. <ul class="dropdown-menu-scrollable scrollbar-thin">
  22. <li class="dropdown-header">
  23. <?= _t('index.menu.mylabels') ?>
  24. <?php if (FreshRSS_Auth::hasAccess()) { ?>
  25. <a href="<?= _url('tag', 'index') ?>"><?= _i('configure') ?></a>
  26. <?php } ?>
  27. </li>
  28. <!-- Ajax -->
  29. </ul>
  30. </div>
  31. <a class="dropdown-close" href="#close">❌</a>
  32. </template>
  33. <main id="stream" class="global<?= $class ?>">
  34. <h1 class="title_hidden"><?= _t('conf.reading.view.global') ?></h1>
  35. <?php
  36. $params = array_filter($_GET, 'is_string', ARRAY_FILTER_USE_KEY);
  37. unset($params['c']);
  38. unset($params['a']);
  39. $params['from'] = 'global';
  40. $url_base = [
  41. 'c' => 'index',
  42. 'a' => 'normal',
  43. 'params' => $params,
  44. ];
  45. $unreadArticles = 0;
  46. // When STATE_ALL is active (both read and unread), show total articles instead of only unread
  47. $showTotalArticles = $this->feedIdsMatching === null && (FreshRSS_Context::$state === 0 || (
  48. FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ) &&
  49. FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ)));
  50. foreach ($this->categories as $cat) {
  51. $feeds = $this->feedIdsMatching === null ? $cat->feeds() :
  52. array_filter($cat->feeds(), fn(FreshRSS_Feed $feed): bool => !empty($this->feedIdsMatching[$feed->id()]));
  53. $url_base['params']['get'] = 'c_' . $cat->id();
  54. if (!empty($feeds)) {
  55. $unreadArticles += $cat->nbNotRead();
  56. $catMatchingCount = $cat->nbNotRead();
  57. if ($this->feedIdsMatching !== null) {
  58. $catMatchingCount = 0;
  59. foreach ($cat->feeds() as $feed) {
  60. $catMatchingCount += $this->feedIdsMatching[$feed->id()] ?? 0;
  61. }
  62. } elseif ($showTotalArticles) {
  63. $catMatchingCount = 0;
  64. foreach ($cat->feeds() as $feed) {
  65. $catMatchingCount += $feed->nbEntries();
  66. }
  67. }
  68. ?>
  69. <div class="box category" data-unread="<?= $catMatchingCount ?>">
  70. <div class="box-title"><a class="title open-panel" data-unread="<?= format_number($catMatchingCount) ?>"
  71. href="<?= Minz_Url::display($url_base) ?>"><h2><?= $cat->name() ?></h2></a></div>
  72. <ul class="box-content scrollbar-thin">
  73. <?php
  74. foreach ($feeds as $feed) {
  75. if ($feed->priority() < FreshRSS_Feed::PRIORITY_FEED) {
  76. continue;
  77. }
  78. $feedMatchingCount = $this->feedIdsMatching === null
  79. ? ($showTotalArticles ? $feed->nbEntries() : $feed->nbNotRead())
  80. : ($this->feedIdsMatching[$feed->id()] ?? 0);
  81. $error_class = '';
  82. $error_title = '';
  83. if ($feed->inError() && !$feed->mute()) {
  84. $error_class = ' error';
  85. $error_title = _t('sub.feed.error');
  86. }
  87. $empty_class = '';
  88. $empty_title = '';
  89. if ($feed->nbEntries() == 0) {
  90. $empty_class = ' empty';
  91. $empty_title = _t('sub.feed.empty');
  92. }
  93. $mute_class = $feed->mute() ? ' mute' : '';
  94. $url_base['params']['get'] = 'f_' . $feed->id();
  95. ?>
  96. <li id="f_<?= $feed->id() ?>" class="item feed<?= $error_class, $empty_class, $mute_class ?>" title="<?= $error_title, $empty_title ?>"
  97. data-unread="<?= $feedMatchingCount ?>" data-priority="<?= $feed->priority() ?>">
  98. <?php if (FreshRSS_Context::userConf()->show_favicons): ?><img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" loading="lazy" /><?php endif; ?>
  99. <a class="item-title open-panel" data-unread="<?= format_number($feedMatchingCount) ?>" href="<?= Minz_Url::display($url_base) ?>"><?= $feed->name() ?></a>
  100. </li>
  101. <?php } ?>
  102. </ul>
  103. </div>
  104. <?php
  105. }
  106. }
  107. if ($unreadArticles < 1 && $state_unread) {
  108. ?>
  109. <div id="noArticlesToShow" class="prompt alert alert-warn">
  110. <h2 class="alert-head"><?= _t('index.feed.empty') ?></h2>
  111. </div>
  112. <?php } ?>
  113. </main>
  114. <div id="overlay">
  115. <a class="close" href="#"><?= _i('close') ?></a>
  116. <div id="panel"<?= FreshRSS_Context::userConf()->display_posts ? '' : ' class="hide_posts"' ?>>
  117. </div>
  118. </div>