reader.phtml 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php /** @var FreshRSS_View $this */ ?>
  2. <?php
  3. $this->partial('aside_feed');
  4. $this->partial('nav_menu');
  5. call_user_func($this->callbackBeforeEntries, $this);
  6. $lazyload = FreshRSS_Context::$user_conf->lazyload;
  7. $content_width = FreshRSS_Context::$user_conf->content_width;
  8. ?>
  9. <main id="stream" class="reader">
  10. <div id="new-article">
  11. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  12. </div><?php
  13. $lastEntry = null;
  14. $nbEntries = 0;
  15. /** @var FreshRSS_Entry */
  16. foreach ($this->entries as $item):
  17. $lastEntry = $item;
  18. $nbEntries++;
  19. ob_flush();
  20. /** @var FreshRSS_Entry */
  21. $item = Minz_ExtensionManager::callHook('entry_before_display', $item);
  22. if ($item == null) {
  23. continue;
  24. }
  25. ?><div class="flux<?= !$item->isRead() ? ' not_read' : '' ?><?= $item->isFavorite() ? ' favorite' : '' ?>" id="flux_<?= $item->id() ?>">
  26. <div class="flux_content" dir="auto">
  27. <div class="content <?= $content_width ?>">
  28. <?php
  29. $feed = FreshRSS_CategoryDAO::findFeed($this->categories, $item->feed()); //We most likely already have the feed object in cache
  30. if (empty($feed)) $feed = $item->feed(true);
  31. $favoriteUrl = array('c' => 'entry', 'a' => 'bookmark', 'params' => array('id' => $item->id()));
  32. if ($item->isFavorite()) {
  33. $favoriteUrl['params']['is_favorite'] = 0;
  34. }
  35. $readUrl = array('c' => 'entry', 'a' => 'read', 'params' => array('id' => $item->id()));
  36. if ($item->isRead()) {
  37. $readUrl['params']['is_read'] = 0;
  38. }
  39. ?>
  40. <?php if (FreshRSS_Auth::hasAccess()) { ?>
  41. <a class="read" href="<?= Minz_Url::display($readUrl) ?>" title="<?= _t('conf.shortcut.mark_read') ?>"><?= _i($item->isRead() ? 'read' : 'unread') ?></a>
  42. <a class="bookmark" href="<?= Minz_Url::display($favoriteUrl) ?>" title="<?= _t('conf.shortcut.mark_favorite') ?>"><?= _i($item->isFavorite() ? 'starred' : 'non-starred') ?></a>
  43. <?php } ?>
  44. <a class="website" href="<?= _url('index', 'reader', 'get', 'f_' . $feed->id()) ?>" title="<?= _t('gen.action.filter') ?>"><?php
  45. if (FreshRSS_Context::$user_conf->show_favicons):
  46. ?><img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  47. endif;
  48. ?><span><?= $feed->name() ?></span>
  49. </a>
  50. <h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?= $item->link() ?>"><?= $item->title() ?></a></h1>
  51. <div class="author"><?php
  52. $authors = $item->authors();
  53. if (is_array($authors)):
  54. $first = true;
  55. foreach ($authors as $author):
  56. echo $first ? _t('gen.short.by_author') . ' ' : '· ';
  57. $first = false;
  58. ?>
  59. <em><a href="<?= Minz_Url::display(Minz_Request::modifiedCurrentRequest(
  60. ['search' => 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))])
  61. ) ?>"><?= $author ?></a></em>
  62. <?php
  63. endforeach;
  64. echo ' — ';
  65. endif;
  66. ?><time datetime="<?= $item->machineReadableDate() ?>"><?= $item->date() ?></time></div><div class="text">
  67. <?= $item->content() ?>
  68. </div></div>
  69. </div>
  70. </div><?php
  71. endforeach;
  72. if ($nbEntries > 0):
  73. call_user_func($this->callbackBeforePagination, $this, $nbEntries, $lastEntry);
  74. $this->renderHelper('stream-footer');
  75. ?></main><?php
  76. else:
  77. ob_end_clean(); //Discard the articles headers, as we have no articles
  78. ?>
  79. <main id="stream" class="reader">
  80. <div id="new-article">
  81. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  82. </div>
  83. <div class="prompt alert alert-warn">
  84. <h2 class="alert-head"><?= _t('index.feed.empty') ?></h2>
  85. <?php if (FreshRSS_Auth::hasAccess()) { ?>
  86. <p><a href="<?= _url('subscription', 'add') ?>"><?= _t('index.feed.add') ?></a></p>
  87. <?php } ?>
  88. </div>
  89. </main>
  90. <?php endif; ?>