normal.phtml 8.3 KB

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