normal.phtml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?php
  2. declare(strict_types=1);
  3. /** @var FreshRSS_View $this */
  4. if (!Minz_Request::paramBoolean('ajax')) {
  5. $this->partial('aside_feed');
  6. $this->partial('nav_menu');
  7. }
  8. call_user_func($this->callbackBeforeEntries, $this);
  9. $display_today = FreshRSS_Context::$sort === 'id';
  10. $display_yesterday = $display_today;
  11. $display_others = $display_today;
  12. $useKeepUnreadImportant = !FreshRSS_Context::isImportant() && !FreshRSS_Context::isFeed();
  13. $today = @strtotime('today');
  14. ?>
  15. <datalist id="datalist-labels"></datalist>
  16. <template id="share_article_template">
  17. <?php $this->renderHelper('index/normal/entry_share_menu'); ?>
  18. <a class="dropdown-close" href="#close">❌</a>
  19. </template>
  20. <template id="labels_article_template">
  21. <div class="dropdown-menu">
  22. <ul class="dropdown-menu-scrollable scrollbar-thin">
  23. <li class="dropdown-header">
  24. <?= _t('index.menu.mylabels') ?>
  25. <?php if (FreshRSS_Auth::hasAccess()) { ?>
  26. <a href="<?= _url('tag', 'index') ?>"><?= _i('configure') ?></a>
  27. <?php } ?>
  28. </li>
  29. <!-- Ajax -->
  30. </ul>
  31. </div>
  32. <a class="dropdown-close" href="#close">❌</a>
  33. </template>
  34. <main id="stream" class="normal<?= FreshRSS_Context::userConf()->display_posts ? '' : ' hide_posts' ?>">
  35. <h1 class="title_hidden"><?= _t('conf.reading.view.normal') ?></h1>
  36. <div id="new-article" hidden="hidden">
  37. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  38. </div><?php
  39. $lastEntry = null;
  40. $nbEntries = 0;
  41. foreach ($this->entries as $item):
  42. /** @var FreshRSS_Entry|null $item */
  43. $item = Minz_ExtensionManager::callHook('entry_before_display', $item);
  44. if ($item === null) {
  45. continue;
  46. }
  47. ob_flush();
  48. $this->entry = $item;
  49. $lastEntry = $item;
  50. $nbEntries++;
  51. // We most likely already have the feed object in cache, otherwise make a request
  52. $this->feed = FreshRSS_Category::findFeed($this->categories, $this->entry->feedId()) ??
  53. $this->entry->feed() ?? FreshRSS_Feed::default();
  54. if ($display_today && $this->entry->isDay(FreshRSS_Days::TODAY, $today)) {
  55. ?><div class="day" id="day_today"><?= _t('index.feed.received.today') ?>
  56. <span class="date"> — <?= timestamptodate(time(), false) ?></span>
  57. <span class="name"><?= FreshRSS_Context::$name ?></span>
  58. </div><?php
  59. $display_today = false;
  60. }
  61. if ($display_yesterday && $this->entry->isDay(FreshRSS_Days::YESTERDAY, $today)) {
  62. ?><div class="day" id="day_yesterday"><?= _t('index.feed.received.yesterday') ?>
  63. <span class="date"> — <?= timestamptodate(time() - 86400, false) ?></span>
  64. <span class="name"><?= FreshRSS_Context::$name ?></span>
  65. </div><?php
  66. $display_yesterday = false;
  67. }
  68. if ($display_others && $this->entry->isDay(FreshRSS_Days::BEFORE_YESTERDAY, $today)) {
  69. ?><div class="day" id="day_before_yesterday"><?= _t('index.feed.received.before_yesterday') ?>
  70. <span class="name"><?= FreshRSS_Context::$name ?></span>
  71. </div><?php
  72. $display_others = false;
  73. }
  74. ?><div class="flux<?= !$this->entry->isRead() ? ' not_read' : ''
  75. ?><?= $this->entry->isFavorite() ? ' favorite' : ''
  76. ?><?= $useKeepUnreadImportant && ($this->feed->priority() >= FreshRSS_Feed::PRIORITY_IMPORTANT) ? ' keep_unread ' : ''
  77. ?>" id="flux_<?= $this->entry->id()
  78. ?>" data-entry="<?= $this->entry->id()
  79. ?>" data-feed="<?= $this->feed->id()
  80. ?>" data-priority="<?= $this->feed->priority()
  81. ?>"><?php
  82. $this->renderHelper('index/normal/entry_header');
  83. if ($this->feed === null || $this->entry === null) {
  84. throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan
  85. }
  86. ?><article class="flux_content" dir="auto">
  87. <div class="content content_<?= FreshRSS_Context::userConf()->content_width ?>">
  88. <header>
  89. <?php if (FreshRSS_Context::userConf()->show_feed_name === 't') { ?>
  90. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  91. <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
  92. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  93. endif; ?><span><?= $this->feed->name() ?></span></a>
  94. </div>
  95. <?php } ?>
  96. <?php if (FreshRSS_Context::userConf()->show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') {
  97. $this->renderHelper('index/tags');
  98. if ($this->feed === null || $this->entry === null) {
  99. throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan
  100. }
  101. } ?>
  102. <h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?= $this->entry->link() ?>" title="<?= _t('conf.shortcut.see_on_website')?>"><?= $this->entry->title() ?></a></h1>
  103. <?php if (FreshRSS_Context::userConf()->show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?>
  104. <div class="subtitle">
  105. <?php if (FreshRSS_Context::userConf()->show_feed_name === 'a') { ?>
  106. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  107. <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
  108. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  109. endif; ?><span><?= $this->feed->name() ?></span></a>
  110. </div>
  111. <?php }
  112. if (!empty($this->entry->authors())) {
  113. $this->renderHelper('index/authors');
  114. if ($this->feed === null || $this->entry === null) {
  115. throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan
  116. }
  117. }
  118. ?>
  119. <div class="date"><?= $this->entry->date() ?></div>
  120. </div>
  121. <?php } ?>
  122. </header>
  123. <div class="text"><?=
  124. FreshRSS_Context::userConf()->lazyload && !FreshRSS_Context::userConf()->display_posts ? lazyimg($this->entry->content(true)) : $this->entry->content(true)
  125. ?></div>
  126. <?php
  127. $display_authors_date = FreshRSS_Context::userConf()->show_author_date === 'f' || FreshRSS_Context::userConf()->show_author_date === 'b';
  128. $display_tags = FreshRSS_Context::userConf()->show_tags === 'f' || FreshRSS_Context::userConf()->show_tags === 'b';
  129. if ($display_authors_date || $display_tags) {
  130. ?>
  131. <footer>
  132. <?php
  133. if ($display_authors_date) { ?>
  134. <div class="subtitle">
  135. <?php if (FreshRSS_Context::userConf()->show_feed_name === 'a') { ?>
  136. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  137. <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
  138. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  139. endif; ?><span><?= $this->feed->name() ?></span></a>
  140. </div>
  141. <?php }
  142. if (!empty($this->entry->authors())) {
  143. $this->renderHelper('index/authors');
  144. if ($this->feed === null || $this->entry === null) {
  145. throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan
  146. }
  147. }
  148. ?>
  149. <div class="date"><?= $this->entry->date() ?></div>
  150. </div>
  151. <?php
  152. }
  153. if ($display_tags) {
  154. $this->renderHelper('index/tags');
  155. }
  156. ?>
  157. </footer>
  158. <?php
  159. } ?>
  160. </div><footer><?php
  161. $this->renderHelper('index/normal/entry_bottom');
  162. ?>
  163. </footer></article>
  164. </div><?php
  165. endforeach;
  166. if ($nbEntries > 0):
  167. call_user_func($this->callbackBeforePagination, $this, $nbEntries, $lastEntry);
  168. $this->renderHelper('stream-footer');
  169. ?>
  170. </main><?php
  171. else:
  172. ob_end_clean(); //Discard the articles headers, as we have no articles
  173. ?>
  174. <main id="stream" class="normal">
  175. <div id="new-article" hidden="hidden">
  176. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  177. </div>
  178. <div class="prompt alert alert-warn">
  179. <h2 class="alert-head"><?= _t('index.feed.empty') ?></h2>
  180. </div>
  181. </main>
  182. <?php endif; ?>
  183. <?php $class = $this->displaySlider ? ' active' : ''; ?>
  184. <aside id="slider" class="<?= $class ?>">
  185. <a class="toggle_aside" href="#close"><img class="icon" src="../themes/icons/close.svg" loading="lazy" alt="❌"></a>
  186. <div id="slider-content">
  187. </div>
  188. </aside>
  189. <a href="#" id="close-slider" class="<?= $class ?>">
  190. <?= _i('close') ?>
  191. </a>
  192. <?php
  193. if ($nbEntries > 0 && FreshRSS_Context::userConf()->show_nav_buttons) {
  194. $this->partial('nav_entries');
  195. }