normal.phtml 8.8 KB

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