reader.phtml 3.8 KB

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