normal.phtml 4.4 KB

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