normal.phtml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?php
  2. declare(strict_types=1);
  3. /** @var FreshRSS_View $this */
  4. if (!Minz_Request::paramBoolean('ajax')) {
  5. $this->partial('aside_feed');
  6. $this->partial('nav_menu');
  7. }
  8. call_user_func($this->callbackBeforeEntries, $this);
  9. $last_transition = '';
  10. $useKeepUnreadImportant = !FreshRSS_Context::isImportant() && !FreshRSS_Context::isFeed();
  11. $today = @strtotime('today');
  12. ?>
  13. <datalist id="datalist-labels"></datalist>
  14. <template id="share_article_template">
  15. <?php $this->renderHelper('index/normal/entry_share_menu'); ?>
  16. <a class="dropdown-close" href="#close">❌</a>
  17. </template>
  18. <template id="labels_article_template">
  19. <div class="dropdown-menu">
  20. <ul class="dropdown-menu-scrollable scrollbar-thin">
  21. <li class="dropdown-header">
  22. <?= _t('index.menu.mylabels') ?>
  23. <?php if (FreshRSS_Auth::hasAccess()) { ?>
  24. <a href="<?= _url('tag', 'index') ?>"><?= _i('configure') ?></a>
  25. <?php } ?>
  26. </li>
  27. <!-- Ajax -->
  28. </ul>
  29. </div>
  30. <a class="dropdown-close" href="#close">❌</a>
  31. </template>
  32. <main id="stream" class="normal<?= FreshRSS_Context::userConf()->display_posts ? '' : ' hide_posts' ?>">
  33. <h1 class="title_hidden"><?= _t('conf.reading.view.normal') ?></h1>
  34. <div id="new-article" hidden="hidden">
  35. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  36. </div><?php
  37. $lastEntry = null;
  38. $nbEntries = 0;
  39. foreach ($this->entries as $item):
  40. /** @var FreshRSS_Entry|null $item */
  41. $item = Minz_ExtensionManager::callHook(Minz_HookType::EntryBeforeDisplay, $item);
  42. if ($item === null) {
  43. continue;
  44. }
  45. ob_flush();
  46. $this->entry = $item;
  47. $lastEntry = $item;
  48. $nbEntries++;
  49. // We most likely already have the feed object in cache, otherwise make a request
  50. $this->feed = FreshRSS_Category::findFeed($this->categories, $this->entry->feedId()) ??
  51. $this->entry->feed() ?? FreshRSS_Feed::default();
  52. $this->entry->_feed($this->feed);
  53. if ($last_transition !== ($transition = FreshRSS_index_Controller::transition($this->entry, FreshRSS_Context::$sort))) {
  54. $last_transition = $transition;
  55. ?><div class="transition">
  56. <span class="transition-value">
  57. <?php if (FreshRSS_Context::$sort === 'f.name' && FreshRSS_Context::userConf()->show_favicons): ?>
  58. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" />
  59. <?php endif;?>
  60. <?= $transition ?>
  61. </span>
  62. <span class="name"><?= FreshRSS_Context::$name ?></span>
  63. </div><?php
  64. }
  65. ?><div class="flux<?= !$this->entry->isRead() ? ' not_read' : ''
  66. ?><?= $this->entry->isFavorite() ? ' favorite' : ''
  67. ?><?= $useKeepUnreadImportant && ($this->feed->priority() >= FreshRSS_Feed::PRIORITY_IMPORTANT) ? ' keep_unread ' : ''
  68. ?>" id="flux_<?= $this->entry->id()
  69. ?>" data-entry="<?= $this->entry->id()
  70. ?>" data-feed="<?= $this->feed->id()
  71. ?>" data-priority="<?= $this->feed->priority()
  72. ?>" data-link="<?= $this->entry->link()
  73. ?>"><?php
  74. $this->renderHelper('index/normal/entry_header');
  75. if ($this->feed === null || $this->entry === null) {
  76. throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan
  77. }
  78. ?><article class="flux_content" dir="auto">
  79. <div class="content content_<?= FreshRSS_Context::userConf()->content_width ?>">
  80. <header>
  81. <?php if (FreshRSS_Context::userConf()->show_feed_name === 't') { ?>
  82. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  83. <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
  84. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  85. endif; ?><span><?= $this->feed->name() ?></span></a>
  86. </div>
  87. <?php } ?>
  88. <?php if (FreshRSS_Context::userConf()->show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') {
  89. $this->renderHelper('index/tags');
  90. if ($this->feed === null || $this->entry === null) {
  91. throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan
  92. }
  93. } ?>
  94. <h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?= $this->entry->link() ?>" title="<?= _t('conf.shortcut.see_on_website')?>"><?= $this->entry->title() ?></a></h1>
  95. <?php if (FreshRSS_Context::userConf()->show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?>
  96. <div class="subtitle">
  97. <?php if (FreshRSS_Context::userConf()->show_feed_name === 'a') { ?>
  98. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  99. <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
  100. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  101. endif; ?><span><?= $this->feed->name() ?></span></a>
  102. </div>
  103. <?php }
  104. if (!empty($this->entry->authors())) {
  105. $this->renderHelper('index/authors');
  106. if ($this->feed === null || $this->entry === null) {
  107. throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan
  108. }
  109. }
  110. ?>
  111. <div class="date"><?= $this->entry->date() ?></div>
  112. </div>
  113. <?php } ?>
  114. </header>
  115. <div class="text"><?=
  116. FreshRSS_Context::userConf()->lazyload && !FreshRSS_Context::userConf()->display_posts ? lazyimg($this->entry->content(true)) : $this->entry->content(true)
  117. ?></div>
  118. <?php
  119. $display_authors_date = FreshRSS_Context::userConf()->show_author_date === 'f' || FreshRSS_Context::userConf()->show_author_date === 'b';
  120. $display_tags = FreshRSS_Context::userConf()->show_tags === 'f' || FreshRSS_Context::userConf()->show_tags === 'b';
  121. if ($display_authors_date || $display_tags) {
  122. ?>
  123. <footer>
  124. <?php
  125. if ($display_authors_date) { ?>
  126. <div class="subtitle">
  127. <?php if (FreshRSS_Context::userConf()->show_feed_name === 'a') { ?>
  128. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  129. <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
  130. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  131. endif; ?><span><?= $this->feed->name() ?></span></a>
  132. </div>
  133. <?php }
  134. if (!empty($this->entry->authors())) {
  135. $this->renderHelper('index/authors');
  136. if ($this->feed === null || $this->entry === null) {
  137. throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan
  138. }
  139. }
  140. ?>
  141. <div class="date"><?= $this->entry->date() ?></div>
  142. </div>
  143. <?php
  144. }
  145. if ($display_tags) {
  146. $this->renderHelper('index/tags');
  147. }
  148. ?>
  149. </footer>
  150. <?php
  151. } ?>
  152. </div><footer><?php
  153. $this->renderHelper('index/normal/entry_bottom');
  154. ?>
  155. </footer></article>
  156. </div><?php
  157. endforeach;
  158. if ($nbEntries > 0):
  159. call_user_func($this->callbackBeforePagination, $this, $nbEntries, $lastEntry);
  160. $this->renderHelper('stream-footer');
  161. ?>
  162. </main><?php
  163. else:
  164. ob_end_clean(); //Discard the articles headers, as we have no articles
  165. ?>
  166. <main id="stream" class="normal">
  167. <div id="new-article" hidden="hidden">
  168. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  169. </div>
  170. <div class="prompt alert alert-warn">
  171. <h2 class="alert-head"><?= _t('index.feed.empty') ?></h2>
  172. </div>
  173. </main>
  174. <?php endif; ?>
  175. <?php $class = $this->displaySlider ? ' active' : ''; ?>
  176. <aside id="slider" class="<?= $class ?>">
  177. <a class="toggle_aside" href="#close"><img class="icon" src="../themes/icons/close.svg" loading="lazy" alt="❌"></a>
  178. <div id="slider-content">
  179. </div>
  180. </aside>
  181. <a href="#" id="close-slider" class="<?= $class ?>">
  182. <?= _i('close') ?>
  183. </a>
  184. <?php
  185. if ($nbEntries > 0) {
  186. echo Minz_ExtensionManager::callHookString(Minz_HookType::NavEntries);
  187. if (FreshRSS_Context::userConf()->show_nav_buttons) {
  188. $this->partial('nav_entries');
  189. }
  190. }