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