normal.phtml 7.8 KB

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