global.phtml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 = array_filter($cat->feeds(), fn(FreshRSS_Feed $feed): bool =>
  52. $feed->priority() >= FreshRSS_Feed::PRIORITY_FEED &&
  53. ($this->feedIdsMatching === null || !empty($this->feedIdsMatching[$feed->id()])));
  54. $url_base['params']['get'] = 'c_' . $cat->id();
  55. if (!empty($feeds)) {
  56. $unreadArticles += $cat->nbNotRead();
  57. $catMatchingCount = $cat->nbNotRead();
  58. if ($this->feedIdsMatching !== null) {
  59. $catMatchingCount = 0;
  60. foreach ($feeds as $feed) {
  61. $catMatchingCount += $this->feedIdsMatching[$feed->id()] ?? 0;
  62. }
  63. } elseif ($showTotalArticles) {
  64. $catMatchingCount = 0;
  65. foreach ($feeds as $feed) {
  66. $catMatchingCount += $feed->nbEntries();
  67. }
  68. }
  69. ?>
  70. <div class="box category" data-unread="<?= $catMatchingCount ?>">
  71. <div class="box-title"><a class="title open-panel" data-unread="<?= format_number($catMatchingCount) ?>"
  72. href="<?= Minz_Url::display($url_base) ?>"><h2><?= $cat->name() ?></h2></a></div>
  73. <ul class="box-content scrollbar-thin">
  74. <?php
  75. foreach ($feeds as $feed) {
  76. $feedMatchingCount = $this->feedIdsMatching === null
  77. ? ($showTotalArticles ? $feed->nbEntries() : $feed->nbNotRead())
  78. : ($this->feedIdsMatching[$feed->id()] ?? 0);
  79. $error_class = '';
  80. $error_title = '';
  81. if ($feed->inError() && !$feed->mute()) {
  82. $error_class = ' error';
  83. $error_title = _t('sub.feed.error');
  84. }
  85. $empty_class = '';
  86. $empty_title = '';
  87. if ($feed->nbEntries() == 0) {
  88. $empty_class = ' empty';
  89. $empty_title = _t('sub.feed.empty');
  90. }
  91. $mute_class = $feed->mute() ? ' mute' : '';
  92. $url_base['params']['get'] = 'f_' . $feed->id();
  93. ?>
  94. <li id="f_<?= $feed->id() ?>" class="item feed<?= $error_class, $empty_class, $mute_class ?>" title="<?= $error_title, $empty_title ?>"
  95. data-unread="<?= $feedMatchingCount ?>" data-priority="<?= $feed->priority() ?>">
  96. <?php if (FreshRSS_Context::userConf()->show_favicons): ?><img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" loading="lazy" /><?php endif; ?>
  97. <a class="item-title open-panel" data-unread="<?= format_number($feedMatchingCount) ?>" href="<?= Minz_Url::display($url_base) ?>"><?= $feed->name() ?></a>
  98. </li>
  99. <?php } ?>
  100. </ul>
  101. </div>
  102. <?php
  103. }
  104. }
  105. if ($unreadArticles < 1 && $state_unread) {
  106. ?>
  107. <div id="noArticlesToShow" class="prompt alert alert-warn">
  108. <h2 class="alert-head"><?= _t('index.feed.empty') ?></h2>
  109. </div>
  110. <?php } ?>
  111. </main>
  112. <div id="overlay">
  113. <a class="close" href="#"><?= _i('close') ?></a>
  114. <div id="panel"<?= FreshRSS_Context::userConf()->display_posts ? '' : ' class="hide_posts"' ?>>
  115. </div>
  116. </div>