normal.phtml 11 KB

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