normal.phtml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. <ul class="dropdown-menu dropdown-menu-scrollable scrollbar-thin">
  22. <li class="dropdown-header">
  23. <?= _t('index.menu.tags') ?>
  24. <?php if (FreshRSS_Auth::hasAccess()) { ?>
  25. <a href="<?= _url('tag', 'index') ?>"><?= _i('configure') ?></a>
  26. <?php } ?>
  27. </li>
  28. <!-- Ajax -->
  29. </ul>
  30. <a class="dropdown-close" href="#close">❌</a>
  31. </template>
  32. <main id="stream" class="normal<?= FreshRSS_Context::userConf()->display_posts ? '' : ' hide_posts' ?>">
  33. <h1 class="title_hidden"><?= _t('conf.reading.view.normal') ?></h1>
  34. <div id="new-article">
  35. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  36. </div><?php
  37. $lastEntry = null;
  38. $nbEntries = 0;
  39. foreach ($this->entries as $item):
  40. $lastEntry = $item;
  41. $nbEntries++;
  42. ob_flush();
  43. /** @var FreshRSS_Entry */
  44. $item = Minz_ExtensionManager::callHook('entry_before_display', $item);
  45. if ($item == null) {
  46. continue;
  47. }
  48. $this->entry = $item;
  49. // We most likely already have the feed object in cache, otherwise make a request
  50. $this->feed = FreshRSS_Category::findFeed($this->categories, $this->entry->feedId()) ??
  51. $this->entry->feed() ?? FreshRSS_Feed::default();
  52. if ($display_today && $this->entry->isDay(FreshRSS_Days::TODAY, $today)) {
  53. ?><div class="day" id="day_today"><?php
  54. echo _t('gen.date.today');
  55. ?><span class="date"> — <?= timestamptodate(time(), false) ?></span><?php
  56. ?><span class="name"><?= FreshRSS_Context::$name ?></span><?php
  57. ?></div><?php
  58. $display_today = false;
  59. }
  60. if ($display_yesterday && $this->entry->isDay(FreshRSS_Days::YESTERDAY, $today)) {
  61. ?><div class="day" id="day_yesterday"><?php
  62. echo _t('gen.date.yesterday');
  63. ?><span class="date"> — <?= timestamptodate(time() - 86400, false) ?></span><?php
  64. ?><span class="name"><?= FreshRSS_Context::$name ?></span><?php
  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"><?php
  70. echo _t('gen.date.before_yesterday');
  71. ?><span class="name"><?= FreshRSS_Context::$name ?></span><?php
  72. ?></div><?php
  73. $display_others = false;
  74. }
  75. ?><div class="flux<?= !$this->entry->isRead() ? ' not_read' : ''
  76. ?><?= $this->entry->isFavorite() ? ' favorite' : ''
  77. ?><?= $useKeepUnreadImportant && ($this->feed->priority() >= FreshRSS_Feed::PRIORITY_IMPORTANT) ? ' keep_unread ' : ''
  78. ?>" id="flux_<?= $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 <?= 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. }
  113. $authors = $this->entry->authors();
  114. if (!empty($authors) && is_array($authors)) {
  115. ?>
  116. <div class="author">
  117. <?= _t('gen.short.by_author') ?>
  118. <?php
  119. foreach ($authors as $author) {
  120. $href = Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:"' . htmlspecialchars_decode($author, ENT_QUOTES) . '"']));
  121. ?>
  122. <a href="<?= $href ?>" title="<?= _t('gen.action.filter') ?>"><?= $author ?></a>
  123. <?php } ?>
  124. </div>
  125. <?php } ?>
  126. <div class="date"><?= $this->entry->date() ?></div>
  127. </div>
  128. <?php } ?>
  129. </header>
  130. <div class="text"><?=
  131. FreshRSS_Context::userConf()->lazyload && !FreshRSS_Context::userConf()->display_posts ? lazyimg($this->entry->content(true)) : $this->entry->content(true)
  132. ?></div>
  133. <?php
  134. $display_authors_date = FreshRSS_Context::userConf()->show_author_date === 'f' || FreshRSS_Context::userConf()->show_author_date === 'b';
  135. $display_tags = FreshRSS_Context::userConf()->show_tags === 'f' || FreshRSS_Context::userConf()->show_tags === 'b';
  136. if ($display_authors_date || $display_tags) {
  137. ?>
  138. <footer>
  139. <?php
  140. if ($display_authors_date) { ?>
  141. <div class="subtitle">
  142. <?php if (FreshRSS_Context::userConf()->show_feed_name === 'a') { ?>
  143. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  144. <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
  145. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  146. endif; ?><span><?= $this->feed->name() ?></span></a>
  147. </div>
  148. <?php
  149. }
  150. $authors = $this->entry->authors();
  151. if (!empty($authors) && is_array($authors)) {
  152. ?>
  153. <div class="author">
  154. <?= _t('gen.short.by_author') ?>
  155. <?php
  156. foreach ($authors as $author) {
  157. $href = Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:"' . htmlspecialchars_decode($author, ENT_QUOTES) . '"']));
  158. ?>
  159. <a href="<?= $href ?>" title="<?= _t('gen.action.filter') ?>"><?= $author ?></a>
  160. <?php } ?>
  161. </div>
  162. <?php } ?>
  163. <div class="date"><?= $this->entry->date() ?></div>
  164. </div>
  165. <?php
  166. }
  167. if ($display_tags) {
  168. $this->renderHelper('index/tags');
  169. }
  170. ?>
  171. </footer>
  172. <?php
  173. } ?>
  174. </div><footer><?php
  175. $this->renderHelper('index/normal/entry_bottom');
  176. ?>
  177. </footer></article>
  178. </div><?php
  179. endforeach;
  180. if ($nbEntries > 0):
  181. call_user_func($this->callbackBeforePagination, $this, $nbEntries, $lastEntry);
  182. $this->renderHelper('stream-footer');
  183. ?>
  184. </main><?php
  185. else:
  186. ob_end_clean(); //Discard the articles headers, as we have no articles
  187. ?>
  188. <main id="stream" class="normal">
  189. <div id="new-article">
  190. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  191. </div>
  192. <div class="prompt alert alert-warn">
  193. <h2 class="alert-head"><?= _t('index.feed.empty') ?></h2>
  194. </div>
  195. </main>
  196. <?php endif; ?>
  197. <?php $class = $this->displaySlider ? ' active' : ''; ?>
  198. <aside id="slider" class="<?= $class ?>">
  199. <a class="toggle_aside" href="#close"><img class="icon" src="../themes/icons/close.svg" loading="lazy" alt="❌"></a>
  200. <div id="slider-content">
  201. </div>
  202. </aside>
  203. <a href="#" id="close-slider" class="<?= $class ?>">
  204. <?= _i('close') ?>
  205. </a>
  206. <?php
  207. if ($nbEntries > 0 && FreshRSS_Context::userConf()->show_nav_buttons) {
  208. $this->partial('nav_entries');
  209. }