normal.phtml 11 KB

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