normal.phtml 8.0 KB

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