normal.phtml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <?php
  2. /** @var FreshRSS_View $this */
  3. if (!Minz_Request::paramBoolean('ajax')) {
  4. $this->partial('aside_feed');
  5. $this->partial('nav_menu');
  6. }
  7. call_user_func($this->callbackBeforeEntries, $this);
  8. $display_today = true;
  9. $display_yesterday = true;
  10. $display_others = true;
  11. $hidePosts = !FreshRSS_Context::$user_conf->display_posts;
  12. $lazyload = FreshRSS_Context::$user_conf->lazyload;
  13. $content_width = FreshRSS_Context::$user_conf->content_width;
  14. $MAX_TAGS_DISPLAYED = FreshRSS_Context::$user_conf->show_tags_max;
  15. $today = @strtotime('today');
  16. ?>
  17. <main id="stream" class="normal<?= $hidePosts ? ' hide_posts' : '' ?>">
  18. <h1 class="title_hidden"><?= _t('conf.reading.view.normal') ?></h1>
  19. <div id="new-article">
  20. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  21. </div><?php
  22. $lastEntry = null;
  23. $nbEntries = 0;
  24. /** @var FreshRSS_Entry */
  25. foreach ($this->entries as $item):
  26. $lastEntry = $item;
  27. $nbEntries++;
  28. ob_flush();
  29. /** @var FreshRSS_Entry */
  30. $item = Minz_ExtensionManager::callHook('entry_before_display', $item);
  31. if ($item == null) {
  32. continue;
  33. }
  34. $this->entry = $item;
  35. // We most likely already have the feed object in cache, otherwise make a request
  36. $this->feed = FreshRSS_CategoryDAO::findFeed($this->categories, $this->entry->feedId()) ??
  37. $this->entry->feed() ?? FreshRSS_Feed::example();
  38. if ($display_today && $this->entry->isDay(FreshRSS_Days::TODAY, $today)) {
  39. ?><div class="day" id="day_today"><?php
  40. echo _t('gen.date.today');
  41. ?><span class="date"> — <?= timestamptodate(time(), false) ?></span><?php
  42. ?><span class="name"><?= FreshRSS_Context::$name ?></span><?php
  43. ?></div><?php
  44. $display_today = false;
  45. }
  46. if ($display_yesterday && $this->entry->isDay(FreshRSS_Days::YESTERDAY, $today)) {
  47. ?><div class="day" id="day_yesterday"><?php
  48. echo _t('gen.date.yesterday');
  49. ?><span class="date"> — <?= timestamptodate(time() - 86400, false) ?></span><?php
  50. ?><span class="name"><?= FreshRSS_Context::$name ?></span><?php
  51. ?></div><?php
  52. $display_yesterday = false;
  53. }
  54. if ($display_others && $this->entry->isDay(FreshRSS_Days::BEFORE_YESTERDAY, $today)) {
  55. ?><div class="day" id="day_before_yesterday"><?php
  56. echo _t('gen.date.before_yesterday');
  57. ?><span class="name"><?= FreshRSS_Context::$name ?></span><?php
  58. ?></div><?php
  59. $display_others = false;
  60. }
  61. ?><div class="flux<?= !$this->entry->isRead() ? ' not_read' : ''
  62. ?><?= $this->entry->isFavorite() ? ' favorite' : ''
  63. ?><?= $this->feed->priority() >= FreshRSS_Feed::PRIORITY_IMPORTANT ? ' keep_unread ' : ''
  64. ?>" id="flux_<?= $this->entry->id()
  65. ?>" data-feed="<?= $this->feed->id()
  66. ?>" data-priority="<?= $this->feed->priority()
  67. ?>"><?php
  68. $this->renderHelper('index/normal/entry_header');
  69. $tags = null;
  70. $firstTags = array();
  71. $remainingTags = array();
  72. if (FreshRSS_Context::$user_conf->show_tags === 'h' || FreshRSS_Context::$user_conf->show_tags === 'f' || FreshRSS_Context::$user_conf->show_tags === 'b') {
  73. $tags = $this->entry->tags();
  74. if (!empty($tags)) {
  75. if ($MAX_TAGS_DISPLAYED > 0) {
  76. $firstTags = array_slice($tags, 0, $MAX_TAGS_DISPLAYED);
  77. $remainingTags = array_slice($tags, $MAX_TAGS_DISPLAYED);
  78. } else {
  79. $firstTags = $tags;
  80. }
  81. }
  82. }
  83. ?><article class="flux_content" dir="auto">
  84. <div class="content <?= $content_width ?>">
  85. <header>
  86. <?php if (FreshRSS_Context::$user_conf->show_feed_name === 't') { ?>
  87. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  88. <?php if (FreshRSS_Context::$user_conf->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. <?php if (FreshRSS_Context::$user_conf->show_tags === 'h' || FreshRSS_Context::$user_conf->show_tags === 'b') { ?>
  94. <div class="tags">
  95. <?php
  96. if (!empty($tags)) {
  97. ?><?= _i('tag') ?><ul class="list-tags"><?php
  98. foreach ($firstTags as $tag) {
  99. ?><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
  100. }
  101. if (!empty($remainingTags)) { // more than 7 tags: show dropdown menu ?>
  102. <li class="item tag">
  103. <div class="dropdown">
  104. <div id="dropdown-tags2-<?= $this->entry->id() ?>" class="dropdown-target"></div>
  105. <a class="dropdown-toggle" href="#dropdown-tags2-<?= $this->entry->id() ?>"><?= _i('down') ?></a>
  106. <ul class="dropdown-menu">
  107. <li class="dropdown-header"><?= _t('index.tag.related') ?></li>
  108. <?php
  109. foreach ($remainingTags as $tag) {
  110. ?><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
  111. } ?>
  112. </ul>
  113. <a class="dropdown-close" href="#close">❌</a>
  114. </div>
  115. </li>
  116. <?php
  117. } ?>
  118. </ul><?php
  119. } ?>
  120. </div>
  121. <?php
  122. } ?>
  123. <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>
  124. <?php if (FreshRSS_Context::$user_conf->show_author_date === 'h' || FreshRSS_Context::$user_conf->show_author_date === 'b') { ?>
  125. <div class="subtitle">
  126. <?php if (FreshRSS_Context::$user_conf->show_feed_name === 'a') { ?>
  127. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  128. <?php if (FreshRSS_Context::$user_conf->show_favicons): ?>
  129. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  130. endif; ?><span><?= $this->feed->name() ?></span></a>
  131. </div>
  132. <?php
  133. }
  134. $authors = $this->entry->authors();
  135. if (!empty($authors) && is_array($authors)) {
  136. ?>
  137. <div class="author">
  138. <?= _t('gen.short.by_author') ?>
  139. <?php
  140. foreach ($authors as $author) {
  141. $href = Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:"' . htmlspecialchars_decode($author, ENT_QUOTES) . '"']));
  142. ?>
  143. <a href="<?= $href ?>" title="<?= _t('gen.action.filter') ?>"><?= $author ?></a>
  144. <?php } ?>
  145. </div>
  146. <?php } ?>
  147. <div class="date"><?= $this->entry->date() ?></div>
  148. </div>
  149. <?php } ?>
  150. </header>
  151. <div class="text"><?php
  152. echo $lazyload && $hidePosts ? lazyimg($this->entry->content(true)) : $this->entry->content(true);
  153. ?></div>
  154. <?php
  155. $display_authors_date = FreshRSS_Context::$user_conf->show_author_date === 'f' || FreshRSS_Context::$user_conf->show_author_date === 'b';
  156. $display_tags = FreshRSS_Context::$user_conf->show_tags === 'f' || FreshRSS_Context::$user_conf->show_tags === 'b';
  157. if ($display_authors_date || $display_tags) {
  158. ?>
  159. <footer>
  160. <?php
  161. if ($display_authors_date) { ?>
  162. <div class="subtitle">
  163. <?php if (FreshRSS_Context::$user_conf->show_feed_name === 'a') { ?>
  164. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  165. <?php if (FreshRSS_Context::$user_conf->show_favicons): ?>
  166. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  167. endif; ?><span><?= $this->feed->name() ?></span></a>
  168. </div>
  169. <?php
  170. }
  171. $authors = $this->entry->authors();
  172. if (!empty($authors) && is_array($authors)) {
  173. ?>
  174. <div class="author">
  175. <?= _t('gen.short.by_author') ?>
  176. <?php
  177. foreach ($authors as $author) {
  178. $href = Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:"' . htmlspecialchars_decode($author, ENT_QUOTES) . '"']));
  179. ?>
  180. <a href="<?= $href ?>" title="<?= _t('gen.action.filter') ?>"><?= $author ?></a>
  181. <?php } ?>
  182. </div>
  183. <?php } ?>
  184. <div class="date"><?= $this->entry->date() ?></div>
  185. </div>
  186. <?php
  187. }
  188. if ($display_tags) { ?>
  189. <div class="tags">
  190. <?php
  191. if (!empty($tags)) {
  192. ?><?= _i('tag') ?><ul class="list-tags"><?php
  193. foreach ($firstTags as $tag) {
  194. ?><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
  195. }
  196. if (!empty($remainingTags)) { ?>
  197. <li class="item tag">
  198. <div class="dropdown">
  199. <div id="dropdown-tags3-<?= $this->entry->id() ?>" class="dropdown-target"></div>
  200. <a class="dropdown-toggle" href="#dropdown-tags3-<?= $this->entry->id() ?>"><?= _i('down') ?></a>
  201. <ul class="dropdown-menu">
  202. <li class="dropdown-header"><?= _t('index.tag.related') ?></li>
  203. <?php
  204. foreach ($remainingTags as $tag) {
  205. ?><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
  206. } ?>
  207. </ul>
  208. <a class="dropdown-close" href="#close">❌</a>
  209. </div>
  210. </li>
  211. <?php
  212. } ?>
  213. </ul><?php
  214. } ?>
  215. </div>
  216. <?php
  217. } ?>
  218. </footer>
  219. <?php
  220. } ?>
  221. </div><footer><?php
  222. $this->renderHelper('index/normal/entry_bottom');
  223. ?>
  224. </footer></article>
  225. </div><?php
  226. endforeach;
  227. if ($nbEntries > 0):
  228. call_user_func($this->callbackBeforePagination, $this, $nbEntries, $lastEntry);
  229. $this->renderHelper('stream-footer');
  230. ?>
  231. </main><?php
  232. else:
  233. ob_end_clean(); //Discard the articles headers, as we have no articles
  234. ?>
  235. <main id="stream" class="normal">
  236. <div id="new-article">
  237. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  238. </div>
  239. <div class="prompt alert alert-warn">
  240. <h2 class="alert-head"><?= _t('index.feed.empty') ?></h2>
  241. </div>
  242. </main>
  243. <?php endif; ?>
  244. <?php $class = $this->displaySlider ? ' active' : ''; ?>
  245. <aside id="slider" class="<?= $class ?>">
  246. <a class="toggle_aside" href="#close"><img class="icon" src="../themes/icons/close.svg" loading="lazy" alt="❌"></a>
  247. <div id="slider-content">
  248. </div>
  249. </aside>
  250. <a href="#" id="close-slider" class="<?= $class ?>">
  251. <?= _i('close') ?>
  252. </a>
  253. <?php if ($nbEntries > 0 && FreshRSS_Context::$user_conf->show_nav_buttons) $this->partial('nav_entries'); ?>