normal.phtml 8.5 KB

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