4
0

normal.phtml 8.2 KB

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