normal.phtml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. $firstEntry = null;
  18. $lastEntry = null;
  19. $nbEntries = 0;
  20. foreach ($this->entries as $item):
  21. if ($nbEntries === 0) {
  22. $firstEntry = $item;
  23. }
  24. $lastEntry = $item;
  25. $nbEntries++;
  26. ob_flush();
  27. $this->entry = Minz_ExtensionManager::callHook('entry_before_display', $item);
  28. if ($this->entry == null) {
  29. continue;
  30. }
  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<?php echo !$this->entry->isRead() ? ' not_read' : '';
  63. ?><?php echo $this->entry->isFavorite() ? ' favorite' : '';
  64. ?>" id="flux_<?php echo $this->entry->id();
  65. ?>" data-feed="<?php echo $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="author"><?php
  72. $authors = $this->entry->authors();
  73. if (is_array($authors)):
  74. $first = true;
  75. foreach ($authors as $author):
  76. echo $first ? _t('gen.short.by_author') . ' ' : '· ';
  77. $first = false;
  78. ?>
  79. <em><a href="<?= _url('index', 'index', 'search', 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))) ?>"><?= $author ?></a></em>
  80. <?php endforeach; ?>
  81. </div><?php
  82. endif;
  83. echo $lazyload && $hidePosts ? lazyimg($this->entry->content()) : $this->entry->content();
  84. ?>
  85. </div><?php
  86. $this->renderHelper('index/normal/entry_bottom');
  87. ?></div>
  88. </div><?php
  89. endforeach;
  90. if ($nbEntries > 0):
  91. call_user_func($this->callbackBeforePagination, $this, $nbEntries, $firstEntry, $lastEntry);
  92. $this->renderHelper('pagination');
  93. ?></div><?php
  94. else:
  95. ob_end_clean(); //Discard the articles headers, as we have no articles
  96. ?>
  97. <div id="stream" class="prompt alert alert-warn normal">
  98. <h2><?= _t('index.feed.empty') ?></h2>
  99. <a href="<?= _url('subscription', 'index') ?>"><?= _t('index.feed.add') ?></a><br /><br />
  100. </div>
  101. <?php endif; ?>
  102. <?php if ($nbEntries > 0 && FreshRSS_Context::$user_conf->show_nav_buttons) $this->partial('nav_entries'); ?>