articles.phtml 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. declare(strict_types=1);
  3. /** @var FreshRSS_View $this */
  4. $username = Minz_User::name() ?? Minz_User::INTERNAL_USER;
  5. $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
  6. $articles = [
  7. 'id' => 'user/' . str_replace('/', '', $username) . '/state/org.freshrss/' . $this->type,
  8. 'title' => $this->list_title,
  9. 'author' => $username,
  10. 'items' => [],
  11. ];
  12. echo rtrim(json_encode($articles, $options) ?: '', " ]}\n\r\t"), "\n";
  13. $first = true;
  14. if (empty($this->entryIdsTagNames)) {
  15. $this->entryIdsTagNames = [];
  16. }
  17. foreach ($this->entries as $entry) {
  18. if (!$this->internal_rendering) {
  19. /** @var FreshRSS_Entry */
  20. $entry = Minz_ExtensionManager::callHook('entry_before_display', $entry);
  21. }
  22. if ($entry == null) {
  23. continue;
  24. }
  25. $feed = $this->feed ?? FreshRSS_Category::findFeed($this->categories, $entry->feedId());
  26. $entry->_feed($feed);
  27. $article = $entry->toGReader('freshrss', $this->entryIdsTagNames['e_' . $entry->id()] ?? []);
  28. $line = json_encode($article, $options);
  29. if ($line != '') {
  30. if ($first) {
  31. $first = false;
  32. } else {
  33. echo ",\n";
  34. }
  35. echo $line;
  36. }
  37. }
  38. echo "\n]}\n";