normal.phtml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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))) {
  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. <a href="<?= FreshRSS_index_Controller::transitionLink($this->entry) ?>"><?= $transition ?></a>
  61. <?php if (in_array(FreshRSS_Context::$sort, ['id', 'date', 'lastUserModified'], true)): ?>
  62. <a class="transition-next" href="<?= FreshRSS_index_Controller::transitionLink($this->entry, offset: 1) ?>">⏭</a>
  63. <?php endif; ?>
  64. </span>
  65. <span class="name"><?= FreshRSS_Context::$name ?></span>
  66. </div><?php
  67. }
  68. ?><div class="flux<?= !$this->entry->isRead() ? ' not_read' : ''
  69. ?><?= $this->entry->isFavorite() ? ' favorite' : ''
  70. ?><?= $useKeepUnreadImportant && ($this->feed->priority() >= FreshRSS_Feed::PRIORITY_IMPORTANT) ? ' keep_unread ' : ''
  71. ?>" id="flux_<?= $this->entry->id()
  72. ?>" data-entry="<?= $this->entry->id()
  73. ?>" data-category="<?= $this->feed->categoryId()
  74. ?>" data-feed="<?= $this->feed->id()
  75. ?>" data-priority="<?= $this->feed->priority()
  76. ?>" data-link="<?= $this->entry->link()
  77. ?>"><?php
  78. $this->renderHelper('index/normal/entry_header');
  79. if ($this->feed === null || $this->entry === null) {
  80. throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan
  81. }
  82. ?><article class="flux_content" dir="auto">
  83. <div class="content content_<?= FreshRSS_Context::userConf()->content_width ?>">
  84. <header>
  85. <?php if (FreshRSS_Context::userConf()->show_feed_name === 't') { ?>
  86. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  87. <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
  88. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  89. endif; ?><span><?= $this->feed->name() ?></span></a>
  90. </div>
  91. <?php } ?>
  92. <?php if (FreshRSS_Context::userConf()->show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') {
  93. $this->renderHelper('index/tags');
  94. if ($this->feed === null || $this->entry === null) {
  95. throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan
  96. }
  97. } ?>
  98. <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>
  99. <?php if (FreshRSS_Context::userConf()->show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?>
  100. <div class="subtitle">
  101. <?php if (FreshRSS_Context::userConf()->show_feed_name === 'a') { ?>
  102. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  103. <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
  104. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  105. endif; ?><span><?= $this->feed->name() ?></span></a>
  106. </div>
  107. <?php }
  108. if (!empty($this->entry->authors())) {
  109. $this->renderHelper('index/authors');
  110. if ($this->feed === null || $this->entry === null) {
  111. throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan
  112. }
  113. }
  114. ?>
  115. <div class="date"><?= $this->entry->date() ?></div>
  116. </div>
  117. <?php } ?>
  118. </header>
  119. <div class="text"><?=
  120. FreshRSS_Context::userConf()->lazyload && !FreshRSS_Context::userConf()->display_posts ? lazyimg($this->entry->content(true)) : $this->entry->content(true)
  121. ?></div>
  122. <?php
  123. $display_authors_date = FreshRSS_Context::userConf()->show_author_date === 'f' || FreshRSS_Context::userConf()->show_author_date === 'b';
  124. $display_tags = FreshRSS_Context::userConf()->show_tags === 'f' || FreshRSS_Context::userConf()->show_tags === 'b';
  125. if ($display_authors_date || $display_tags) {
  126. ?>
  127. <footer>
  128. <?php
  129. if ($display_authors_date) { ?>
  130. <div class="subtitle">
  131. <?php if (FreshRSS_Context::userConf()->show_feed_name === 'a') { ?>
  132. <div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
  133. <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
  134. <img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php
  135. endif; ?><span><?= $this->feed->name() ?></span></a>
  136. </div>
  137. <?php }
  138. if (!empty($this->entry->authors())) {
  139. $this->renderHelper('index/authors');
  140. if ($this->feed === null || $this->entry === null) {
  141. throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan
  142. }
  143. }
  144. ?>
  145. <div class="date"><?= $this->entry->date() ?></div>
  146. </div>
  147. <?php
  148. }
  149. if ($display_tags) {
  150. $this->renderHelper('index/tags');
  151. }
  152. ?>
  153. </footer>
  154. <?php
  155. } ?>
  156. </div><footer><?php
  157. $this->renderHelper('index/normal/entry_bottom');
  158. ?>
  159. </footer></article>
  160. </div><?php
  161. endforeach;
  162. if ($nbEntries > 0):
  163. call_user_func($this->callbackBeforePagination, $this, $nbEntries, $lastEntry);
  164. $this->renderHelper('stream-footer');
  165. ?>
  166. </main><?php
  167. else:
  168. ob_end_clean(); //Discard the articles headers, as we have no articles
  169. ?>
  170. <main id="stream" class="normal">
  171. <div id="new-article" hidden="hidden">
  172. <a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
  173. </div>
  174. <div class="prompt alert alert-warn">
  175. <h2 class="alert-head"><?= _t('index.feed.empty') ?></h2>
  176. </div>
  177. </main>
  178. <?php endif; ?>
  179. <?php $class = $this->displaySlider ? ' active' : ''; ?>
  180. <aside id="slider" class="<?= $class ?>">
  181. <a class="toggle_aside" href="#close"><?= _i('close') ?></a>
  182. <div id="slider-content">
  183. </div>
  184. </aside>
  185. <a href="#close" id="close-slider" class="<?= $class ?>">
  186. <?= _i('close') ?>
  187. </a>
  188. <?php
  189. if ($nbEntries > 0) {
  190. echo Minz_ExtensionManager::callHookString(Minz_HookType::NavEntries);
  191. if (FreshRSS_Context::userConf()->show_nav_buttons) {
  192. $this->partial('nav_entries');
  193. }
  194. }