reader.phtml 9.5 KB

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