normal.phtml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. $hidePosts = !FreshRSS_Context::userConf()->display_posts;
  13. $lazyload = FreshRSS_Context::userConf()->lazyload;
  14. $content_width = FreshRSS_Context::userConf()->content_width;
  15. $MAX_TAGS_DISPLAYED = (int)FreshRSS_Context::userConf()->show_tags_max;
  16. $useKeepUnreadImportant = !FreshRSS_Context::isImportant() && !FreshRSS_Context::isFeed();
  17. $today = @strtotime('today');
  18. ?>
  19. <main id="stream" class="normal<?= $hidePosts ? ' 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. /** @var FreshRSS_Entry */
  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_CategoryDAO::findFeed($this->categories, $this->entry->feedId()) ??
  39. $this->entry->feed() ?? FreshRSS_Feed::example();
  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) {
  72. throw new FreshRSS_Context_Exception('Feed not initialised!');
  73. }
  74. $tags = null;
  75. $firstTags = array();
  76. $remainingTags = array();
  77. if (FreshRSS_Context::userConf()->show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'f' || FreshRSS_Context::userConf()->show_tags === 'b') {
  78. $tags = $this->entry->tags();
  79. if (!empty($tags)) {
  80. if ($MAX_TAGS_DISPLAYED > 0) {
  81. $firstTags = array_slice($tags, 0, $MAX_TAGS_DISPLAYED);
  82. $remainingTags = array_slice($tags, $MAX_TAGS_DISPLAYED);
  83. } else {
  84. $firstTags = $tags;
  85. }
  86. }
  87. }
  88. ?><article class="flux_content" dir="auto">
  89. <div class="content <?= $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. <div class="tags">
  100. <?php
  101. if (!empty($tags)) {
  102. ?><?= _i('tag') ?><ul class="list-tags"><?php
  103. foreach ($firstTags as $tag) {
  104. ?><li class="item tag"><a class="link-tag" href="<?= _url('index', 'index', 'search', '#' . str_replace(' ', '+', htmlspecialchars_decode($tag, ENT_QUOTES))) ?>" title="<?= _t('gen.action.filter') ?>">#<?= $tag ?></a></li><?php
  105. }
  106. if (!empty($remainingTags)) { // more than 7 tags: show dropdown menu ?>
  107. <li class="item tag">
  108. <div class="dropdown">
  109. <div id="dropdown-tags2-<?= $this->entry->id() ?>" class="dropdown-target"></div>
  110. <a class="dropdown-toggle" href="#dropdown-tags2-<?= $this->entry->id() ?>"><?= _i('down') ?></a>
  111. <ul class="dropdown-menu">
  112. <li class="dropdown-header"><?= _t('index.tag.related') ?></li>
  113. <?php
  114. foreach ($remainingTags as $tag) {
  115. ?><li class="item"><a href="<?= _url('index', 'index', 'search', '#' . str_replace(' ', '+', htmlspecialchars_decode($tag, ENT_QUOTES))) ?>" title="<?= _t('gen.action.filter') ?>"><?= $tag ?></a></li><?php
  116. } ?>
  117. </ul>
  118. <a class="dropdown-close" href="#close">❌</a>
  119. </div>
  120. </li>
  121. <?php
  122. } ?>
  123. </ul><?php
  124. } ?>
  125. </div>
  126. <?php
  127. } ?>
  128. <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>
  129. <?php if (FreshRSS_Context::userConf()->show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?>
  130. <div class="subtitle">
  131. <?php if (FreshRSS_Context::userConf()->show_feed_name === 'a') { ?>
  132. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  133. <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
  134. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  135. endif; ?><span><?= $this->feed->name() ?></span></a>
  136. </div>
  137. <?php
  138. }
  139. $authors = $this->entry->authors();
  140. if (!empty($authors) && is_array($authors)) {
  141. ?>
  142. <div class="author">
  143. <?= _t('gen.short.by_author') ?>
  144. <?php
  145. foreach ($authors as $author) {
  146. $href = Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:"' . htmlspecialchars_decode($author, ENT_QUOTES) . '"']));
  147. ?>
  148. <a href="<?= $href ?>" title="<?= _t('gen.action.filter') ?>"><?= $author ?></a>
  149. <?php } ?>
  150. </div>
  151. <?php } ?>
  152. <div class="date"><?= $this->entry->date() ?></div>
  153. </div>
  154. <?php } ?>
  155. </header>
  156. <div class="text"><?php
  157. echo $lazyload && $hidePosts ? lazyimg($this->entry->content(true)) : $this->entry->content(true);
  158. ?></div>
  159. <?php
  160. $display_authors_date = FreshRSS_Context::userConf()->show_author_date === 'f' || FreshRSS_Context::userConf()->show_author_date === 'b';
  161. $display_tags = FreshRSS_Context::userConf()->show_tags === 'f' || FreshRSS_Context::userConf()->show_tags === 'b';
  162. if ($display_authors_date || $display_tags) {
  163. ?>
  164. <footer>
  165. <?php
  166. if ($display_authors_date) { ?>
  167. <div class="subtitle">
  168. <?php if (FreshRSS_Context::userConf()->show_feed_name === 'a') { ?>
  169. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  170. <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
  171. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  172. endif; ?><span><?= $this->feed->name() ?></span></a>
  173. </div>
  174. <?php
  175. }
  176. $authors = $this->entry->authors();
  177. if (!empty($authors) && is_array($authors)) {
  178. ?>
  179. <div class="author">
  180. <?= _t('gen.short.by_author') ?>
  181. <?php
  182. foreach ($authors as $author) {
  183. $href = Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:"' . htmlspecialchars_decode($author, ENT_QUOTES) . '"']));
  184. ?>
  185. <a href="<?= $href ?>" title="<?= _t('gen.action.filter') ?>"><?= $author ?></a>
  186. <?php } ?>
  187. </div>
  188. <?php } ?>
  189. <div class="date"><?= $this->entry->date() ?></div>
  190. </div>
  191. <?php
  192. }
  193. if ($display_tags) { ?>
  194. <div class="tags">
  195. <?php
  196. if (!empty($tags)) {
  197. ?><?= _i('tag') ?><ul class="list-tags"><?php
  198. foreach ($firstTags as $tag) {
  199. ?><li class="item tag"><a class="link-tag" href="<?= _url('index', 'index', 'search', '#' . str_replace(' ', '+', htmlspecialchars_decode($tag, ENT_QUOTES))) ?>" title="<?= _t('gen.action.filter') ?>">#<?= $tag ?></a></li><?php
  200. }
  201. if (!empty($remainingTags)) { ?>
  202. <li class="item tag">
  203. <div class="dropdown">
  204. <div id="dropdown-tags3-<?= $this->entry->id() ?>" class="dropdown-target"></div>
  205. <a class="dropdown-toggle" href="#dropdown-tags3-<?= $this->entry->id() ?>"><?= _i('down') ?></a>
  206. <ul class="dropdown-menu">
  207. <li class="dropdown-header"><?= _t('index.tag.related') ?></li>
  208. <?php
  209. foreach ($remainingTags as $tag) {
  210. ?><li class="item"><a href="<?= _url('index', 'index', 'search', '#' . str_replace(' ', '+', htmlspecialchars_decode($tag, ENT_QUOTES))) ?>" title="<?= _t('gen.action.filter') ?>"><?= $tag ?></a></li><?php
  211. } ?>
  212. </ul>
  213. <a class="dropdown-close" href="#close">❌</a>
  214. </div>
  215. </li>
  216. <?php
  217. } ?>
  218. </ul><?php
  219. } ?>
  220. </div>
  221. <?php
  222. } ?>
  223. </footer>
  224. <?php
  225. } ?>
  226. </div><footer><?php
  227. $this->renderHelper('index/normal/entry_bottom');
  228. ?>
  229. </footer></article>
  230. </div><?php
  231. endforeach;
  232. if ($nbEntries > 0):
  233. call_user_func($this->callbackBeforePagination, $this, $nbEntries, $lastEntry);
  234. $this->renderHelper('stream-footer');
  235. ?>
  236. </main><?php
  237. else:
  238. ob_end_clean(); //Discard the articles headers, as we have no articles
  239. ?>
  240. <main id="stream" class="normal">
  241. <div id="new-article">
  242. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  243. </div>
  244. <div class="prompt alert alert-warn">
  245. <h2 class="alert-head"><?= _t('index.feed.empty') ?></h2>
  246. </div>
  247. </main>
  248. <?php endif; ?>
  249. <?php $class = $this->displaySlider ? ' active' : ''; ?>
  250. <aside id="slider" class="<?= $class ?>">
  251. <a class="toggle_aside" href="#close"><img class="icon" src="../themes/icons/close.svg" loading="lazy" alt="❌"></a>
  252. <div id="slider-content">
  253. </div>
  254. </aside>
  255. <a href="#" id="close-slider" class="<?= $class ?>">
  256. <?= _i('close') ?>
  257. </a>
  258. <?php if ($nbEntries > 0 && FreshRSS_Context::userConf()->show_nav_buttons) $this->partial('nav_entries'); ?>