normal.phtml 4.7 KB

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