normal.phtml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /** @var FreshRSS_View $this */
  3. $this->partial('aside_feed');
  4. $this->partial('nav_menu');
  5. call_user_func($this->callbackBeforeEntries, $this);
  6. $display_today = true;
  7. $display_yesterday = true;
  8. $display_others = true;
  9. $hidePosts = !FreshRSS_Context::$user_conf->display_posts;
  10. $lazyload = FreshRSS_Context::$user_conf->lazyload;
  11. $content_width = FreshRSS_Context::$user_conf->content_width;
  12. $today = @strtotime('today');
  13. ?>
  14. <main id="stream" class="normal<?= $hidePosts ? ' hide_posts' : '' ?>">
  15. <div id="new-article">
  16. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  17. </div><?php
  18. $lastEntry = null;
  19. $nbEntries = 0;
  20. /** @var FreshRSS_Entry */
  21. foreach ($this->entries as $item):
  22. $lastEntry = $item;
  23. $nbEntries++;
  24. ob_flush();
  25. /** @var FreshRSS_Entry */
  26. $item = Minz_ExtensionManager::callHook('entry_before_display', $item);
  27. if ($item == null) {
  28. continue;
  29. }
  30. $this->entry = $item;
  31. // We most likely already have the feed object in cache
  32. $this->feed = FreshRSS_CategoryDAO::findFeed($this->categories, $this->entry->feed());
  33. if ($this->feed == null) {
  34. $this->feed = $this->entry->feed(true);
  35. if ($this->feed == null) {
  36. $this->feed = FreshRSS_Feed::example();
  37. }
  38. }
  39. if ($display_today && $this->entry->isDay(FreshRSS_Days::TODAY, $today)) {
  40. ?><div class="day" id="day_today"><?php
  41. echo _t('gen.date.today');
  42. ?><span class="date"> — <?= timestamptodate(time(), false) ?></span><?php
  43. ?><span class="name"><?= FreshRSS_Context::$name ?></span><?php
  44. ?></div><?php
  45. $display_today = false;
  46. }
  47. if ($display_yesterday && $this->entry->isDay(FreshRSS_Days::YESTERDAY, $today)) {
  48. ?><div class="day" id="day_yesterday"><?php
  49. echo _t('gen.date.yesterday');
  50. ?><span class="date"> — <?= timestamptodate(time() - 86400, false) ?></span><?php
  51. ?><span class="name"><?= FreshRSS_Context::$name ?></span><?php
  52. ?></div><?php
  53. $display_yesterday = false;
  54. }
  55. if ($display_others && $this->entry->isDay(FreshRSS_Days::BEFORE_YESTERDAY, $today)) {
  56. ?><div class="day" id="day_before_yesterday"><?php
  57. echo _t('gen.date.before_yesterday');
  58. ?><span class="name"><?= FreshRSS_Context::$name ?></span><?php
  59. ?></div><?php
  60. $display_others = false;
  61. }
  62. ?><div class="flux<?= !$this->entry->isRead() ? ' not_read' : ''
  63. ?><?= $this->entry->isFavorite() ? ' favorite' : ''
  64. ?>" id="flux_<?= $this->entry->id()
  65. ?>" data-feed="<?= $this->feed->id()
  66. ?>"><?php
  67. $this->renderHelper('index/normal/entry_header');
  68. ?><div class="flux_content" dir="auto">
  69. <div class="content <?= $content_width ?>">
  70. <h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?= $this->entry->link() ?>"><?= $this->entry->title() ?></a></h1>
  71. <div class="subtitle">
  72. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>: <?= $this->feed->name() ?>">
  73. <?php if (FreshRSS_Context::$user_conf->show_favicons): ?>
  74. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" />
  75. <?php endif; ?>
  76. <span><?= $this->feed->name() ?></span></a>
  77. </div>
  78. <div class="date"><?= $this->entry->date() ?></div>
  79. <?php
  80. $authors = $this->entry->authors();
  81. if (!empty($authors) && is_array($authors)):
  82. $first = true;
  83. ?>
  84. <div class="author"><?php
  85. foreach ($authors as $author):
  86. echo $first ? _t('gen.short.by_author') . ' ' : '· ';
  87. $first = false;
  88. ?>
  89. <em><a href="<?= Minz_Url::display(Minz_Request::modifiedCurrentRequest(
  90. ['search' => 'author:"' . htmlspecialchars_decode($author, ENT_QUOTES) . '"'])
  91. ) ?>"><?= $author ?></a></em>
  92. <?php endforeach; ?>
  93. </div><?php endif; ?>
  94. </div>
  95. <div class="text"><?php
  96. echo $lazyload && $hidePosts ? lazyimg($this->entry->content()) : $this->entry->content();
  97. ?></div>
  98. </div><?php
  99. $this->renderHelper('index/normal/entry_bottom');
  100. ?></div>
  101. </div><?php
  102. endforeach;
  103. if ($nbEntries > 0):
  104. call_user_func($this->callbackBeforePagination, $this, $nbEntries, $lastEntry);
  105. $this->renderHelper('stream-footer');
  106. ?></main><?php
  107. else:
  108. ob_end_clean(); //Discard the articles headers, as we have no articles
  109. ?>
  110. <main id="stream" class="normal">
  111. <div id="new-article">
  112. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  113. </div>
  114. <div class="prompt alert alert-warn">
  115. <h2 class="alert-head"><?= _t('index.feed.empty') ?></h2>
  116. <?php if (FreshRSS_Auth::hasAccess()) { ?>
  117. <p><a href="<?= _url('subscription', 'add') ?>"><?= _t('index.feed.add') ?></a></p>
  118. <?php } ?>
  119. </div>
  120. </main>
  121. <?php endif; ?>
  122. <?php if ($nbEntries > 0 && FreshRSS_Context::$user_conf->show_nav_buttons) $this->partial('nav_entries'); ?>