normal.phtml 11 KB

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