reader.phtml 3.3 KB

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