reader.phtml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. $lazyload = FreshRSS_Context::$user_conf->lazyload;
  9. $content_width = FreshRSS_Context::$user_conf->content_width;
  10. $MAX_TAGS_DISPLAYED = FreshRSS_Context::$user_conf->show_tags_max;
  11. ?>
  12. <main id="stream" class="reader">
  13. <h1 class="title_hidden"><?= _t('conf.reading.view.reader') ?></h1>
  14. <div id="new-article">
  15. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  16. </div><?php
  17. $lastEntry = null;
  18. $nbEntries = 0;
  19. /** @var FreshRSS_Entry */
  20. foreach ($this->entries as $item):
  21. $lastEntry = $item;
  22. $nbEntries++;
  23. ob_flush();
  24. /** @var FreshRSS_Entry */
  25. $item = Minz_ExtensionManager::callHook('entry_before_display', $item);
  26. if ($item == null) {
  27. continue;
  28. }
  29. $this->entry = $item;
  30. $tags = null;
  31. $firstTags = array();
  32. $remainingTags = array();
  33. if (FreshRSS_Context::$user_conf->show_tags == 'h' || FreshRSS_Context::$user_conf->show_tags == 'f' || FreshRSS_Context::$user_conf->show_tags == 'b') {
  34. $tags = $this->entry->tags();
  35. if (!empty($tags)) {
  36. if ($MAX_TAGS_DISPLAYED > 0) {
  37. $firstTags = array_slice($tags, 0, $MAX_TAGS_DISPLAYED);
  38. $remainingTags = array_slice($tags, $MAX_TAGS_DISPLAYED);
  39. } else {
  40. $firstTags = $tags;
  41. }
  42. }
  43. }
  44. ?><div class="flux<?= !$item->isRead() ? ' not_read' : '' ?><?= $item->isFavorite() ? ' favorite' : '' ?>" id="flux_<?= $item->id() ?>">
  45. <article class="flux_content" dir="auto">
  46. <div class="content <?= $content_width ?>">
  47. <header>
  48. <?php
  49. $feed = FreshRSS_CategoryDAO::findFeed($this->categories, $item->feedId()); //We most likely already have the feed object in cache
  50. if ($feed == null) $feed = $item->feed();
  51. if ($feed == null) continue;
  52. $favoriteUrl = array('c' => 'entry', 'a' => 'bookmark', 'params' => array('id' => $item->id()));
  53. if ($item->isFavorite()) {
  54. $favoriteUrl['params']['is_favorite'] = 0;
  55. }
  56. $readUrl = array('c' => 'entry', 'a' => 'read', 'params' => array('id' => $item->id()));
  57. if ($item->isRead()) {
  58. $readUrl['params']['is_read'] = 0;
  59. }
  60. ?>
  61. <div class="article-header-topline">
  62. <?php if (FreshRSS_Auth::hasAccess()) { ?>
  63. <a class="read" href="<?= Minz_Url::display($readUrl) ?>" title="<?= _t('conf.shortcut.mark_read') ?>"><?= _i($item->isRead() ? 'read' : 'unread') ?></a>
  64. <a class="bookmark" href="<?= Minz_Url::display($favoriteUrl) ?>" title="<?= _t('conf.shortcut.mark_favorite') ?>"><?= _i($item->isFavorite() ? 'starred' : 'non-starred') ?></a>
  65. <?php } ?>
  66. <?php if (FreshRSS_Context::$user_conf->show_feed_name === 't') { ?>
  67. <a class="website" href="<?= _url('index', 'reader', 'get', 'f_' . $feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  68. <?php if (FreshRSS_Context::$user_conf->show_favicons): ?>
  69. <img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  70. endif; ?><span><?= $feed->name() ?></span></a>
  71. <?php } ?>
  72. </div>
  73. <?php if (FreshRSS_Context::$user_conf->show_tags === 'h' || FreshRSS_Context::$user_conf->show_tags === 'b') { ?>
  74. <div class="tags">
  75. <?php
  76. if (!empty($tags)) {
  77. ?><?= _i('tag') ?><ul class="list-tags"><?php
  78. foreach ($firstTags as $tag) {
  79. ?><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
  80. }
  81. if (!empty($remainingTags)) { // more than 7 tags: show dropdown menu ?>
  82. <li class="item tag">
  83. <div class="dropdown">
  84. <div id="dropdown-tags-<?= $this->entry->id() ?>" class="dropdown-target"></div>
  85. <a class="dropdown-toggle" href="#dropdown-tags-<?= $this->entry->id() ?>"><?= _i('down') ?></a>
  86. <ul class="dropdown-menu">
  87. <li class="dropdown-header"><?= _t('index.tag.related') ?></li>
  88. <?php
  89. foreach ($remainingTags as $tag) {
  90. ?><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
  91. } ?>
  92. </ul>
  93. <a class="dropdown-close" href="#close">❌</a>
  94. </div>
  95. </li>
  96. <?php
  97. } ?>
  98. </ul><?php
  99. } ?>
  100. </div>
  101. <?php } ?>
  102. <h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?= $item->link() ?>"><?= $item->title() ?></a></h1>
  103. <?php if (FreshRSS_Context::$user_conf->show_author_date === 'h' || FreshRSS_Context::$user_conf->show_author_date === 'b') { ?>
  104. <div class="subtitle">
  105. <?php if (FreshRSS_Context::$user_conf->show_feed_name === 'a') { ?>
  106. <div class="website"><a href="<?= _url('index', 'reader', 'get', 'f_' . $feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  107. <?php if (FreshRSS_Context::$user_conf->show_favicons): ?>
  108. <img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  109. endif; ?><span><?= $feed->name() ?></span></a></div>
  110. <?php } ?>
  111. <div class="author"><?php
  112. $authors = $item->authors();
  113. if (is_array($authors)) {
  114. foreach ($authors as $author) {
  115. ?>
  116. <a href="<?= Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))])) ?>">
  117. <?= $author ?>
  118. </a>
  119. <?php
  120. }
  121. }
  122. ?>
  123. </div>
  124. <div class="date">
  125. <time datetime="<?= $item->machineReadableDate() ?>"><?= $item->date() ?></time>
  126. </div>
  127. </div>
  128. <?php } ?>
  129. </header>
  130. <div class="text">
  131. <?= $item->content(true) ?>
  132. </div>
  133. <?php
  134. $display_authors_date = FreshRSS_Context::$user_conf->show_author_date === 'f' || FreshRSS_Context::$user_conf->show_author_date === 'b';
  135. $display_tags = FreshRSS_Context::$user_conf->show_tags === 'f' || FreshRSS_Context::$user_conf->show_tags === 'b';
  136. if ($display_authors_date || $display_tags) {
  137. ?>
  138. <footer>
  139. <?php if ($display_authors_date) { ?>
  140. <div class="subtitle">
  141. <?php if (FreshRSS_Context::$user_conf->show_feed_name === 'a') { ?>
  142. <div class="website"><a href="<?= _url('index', 'reader', 'get', 'f_' . $feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  143. <?php if (FreshRSS_Context::$user_conf->show_favicons): ?>
  144. <img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  145. endif; ?><span><?= $feed->name() ?></span></a></div>
  146. <?php } ?>
  147. <div class="author"><?php
  148. $authors = $item->authors();
  149. if (is_array($authors)) {
  150. foreach ($authors as $author) {
  151. ?>
  152. <a href="<?= Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))])) ?>">
  153. <?= $author ?>
  154. </a>
  155. <?php
  156. }
  157. }
  158. ?>
  159. </div>
  160. <div class="date">
  161. <time datetime="<?= $item->machineReadableDate() ?>"><?= $item->date() ?></time>
  162. </div>
  163. </div>
  164. <?php
  165. }
  166. if ($display_tags) { ?>
  167. <div class="tags">
  168. <?php
  169. if (!empty($tags)) {
  170. ?><?= _i('tag') ?><ul class="list-tags"><?php
  171. foreach ($firstTags as $tag) {
  172. ?><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
  173. }
  174. if (!empty($remainingTags)) { // more than 7 tags: show dropdown menu ?>
  175. <li class="item tag">
  176. <div class="dropdown">
  177. <div id="dropdown-tags2-<?= $this->entry->id() ?>" class="dropdown-target"></div>
  178. <a class="dropdown-toggle" href="#dropdown-tags2-<?= $this->entry->id() ?>"><?= _i('down') ?></a>
  179. <ul class="dropdown-menu">
  180. <li class="dropdown-header"><?= _t('index.tag.related') ?></li>
  181. <?php
  182. foreach ($remainingTags as $tag) {
  183. ?><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
  184. } ?>
  185. </ul>
  186. <a class="dropdown-close" href="#close">❌</a>
  187. </div>
  188. </li>
  189. <?php
  190. } ?>
  191. </ul><?php
  192. } ?>
  193. </div>
  194. <?php } ?>
  195. </footer>
  196. <?php
  197. } ?>
  198. </div>
  199. </article>
  200. </div><?php
  201. endforeach;
  202. if ($nbEntries > 0):
  203. call_user_func($this->callbackBeforePagination, $this, $nbEntries, $lastEntry);
  204. $this->renderHelper('stream-footer');
  205. ?></main><?php
  206. else:
  207. ob_end_clean(); //Discard the articles headers, as we have no articles
  208. ?>
  209. <main id="stream" class="reader">
  210. <div id="new-article">
  211. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  212. </div>
  213. <div class="prompt alert alert-warn">
  214. <h2 class="alert-head"><?= _t('index.feed.empty') ?></h2>
  215. <?php if (FreshRSS_Auth::hasAccess()) { ?>
  216. <p><a href="<?= _url('subscription', 'add') ?>"><?= _t('index.feed.add') ?></a></p>
  217. <?php } ?>
  218. </div>
  219. </main>
  220. <?php endif; ?>