reader.phtml 3.7 KB

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