normal.phtml 5.1 KB

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