reader.phtml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. <div 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. $firstEntry = null;
  13. $lastEntry = null;
  14. $nbEntries = 0;
  15. foreach ($this->entries as $item):
  16. if ($nbEntries === 0) {
  17. $firstEntry = $item;
  18. }
  19. $lastEntry = $item;
  20. $nbEntries++;
  21. ob_flush();
  22. $item = Minz_ExtensionManager::callHook('entry_before_display', $item);
  23. if ($item == null) {
  24. continue;
  25. }
  26. ?><div class="flux<?= !$item->isRead() ? ' not_read' : '' ?><?= $item->isFavorite() ? ' favorite' : '' ?>" id="flux_<?= $item->id() ?>">
  27. <div class="flux_content" dir="auto">
  28. <div class="content <?= $content_width ?>">
  29. <?php
  30. $feed = FreshRSS_CategoryDAO::findFeed($this->categories, $item->feed()); //We most likely already have the feed object in cache
  31. if (empty($feed)) $feed = $item->feed(true);
  32. $favoriteUrl = array('c' => 'entry', 'a' => 'bookmark', 'params' => array('id' => $item->id()));
  33. if ($item->isFavorite()) {
  34. $favoriteUrl['params']['is_favorite'] = 0;
  35. }
  36. $readUrl = array('c' => 'entry', 'a' => 'read', 'params' => array('id' => $item->id()));
  37. if ($item->isRead()) {
  38. $readUrl['params']['is_read'] = 0;
  39. }
  40. ?>
  41. <a class="read" href="<?= Minz_Url::display($readUrl) ?>">
  42. <?= _i($item->isRead() ? 'read' : 'unread') ?>
  43. </a>
  44. <a class="bookmark" href="<?= Minz_Url::display($favoriteUrl) ?>">
  45. <?= _i($item->isFavorite() ? 'starred' : 'non-starred') ?>
  46. </a>
  47. <a class="website" href="<?= _url('index', 'reader', 'get', 'f_' . $feed->id()) ?>">
  48. <img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" /> <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="<?= _url('index', 'index', 'search', 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))) ?>"><?= $author ?></a></em>
  60. <?php
  61. endforeach;
  62. echo ' — ';
  63. endif;
  64. echo $item->date();
  65. ?></div>
  66. <?= $item->content() ?>
  67. </div>
  68. </div>
  69. </div><?php
  70. endforeach;
  71. if ($nbEntries > 0):
  72. call_user_func($this->callbackBeforePagination, $this, $nbEntries, $firstEntry, $lastEntry);
  73. $this->renderHelper('pagination');
  74. ?></div><?php
  75. else:
  76. ob_end_clean(); //Discard the articles headers, as we have no articles
  77. ?>
  78. <div id="stream" class="prompt alert alert-warn reader">
  79. <h2><?= _t('index.feed.empty') ?></h2>
  80. <a href="<?= _url('subscription', 'index') ?>"><?= _t('index.feed.add') ?></a><br /><br />
  81. </div>
  82. <?php endif; ?>