articles.phtml 1006 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 = array(
  7. 'id' => 'user/' . str_replace('/', '', $username) . '/state/org.freshrss/' . $this->type,
  8. 'title' => $this->list_title,
  9. 'author' => $username,
  10. 'items' => array(),
  11. );
  12. echo rtrim(json_encode($articles, $options) ?: '', " ]}\n\r\t"), "\n";
  13. $first = true;
  14. if (empty($this->entryIdsTagNames)) {
  15. $this->entryIdsTagNames = array();
  16. }
  17. foreach ($this->entries as $entry) {
  18. if ($entry == null) {
  19. continue;
  20. }
  21. $feed = $this->feed ?? FreshRSS_Category::findFeed($this->categories, $entry->feedId());
  22. $entry->_feed($feed);
  23. $article = $entry->toGReader('freshrss', $this->entryIdsTagNames['e_' . $entry->id()] ?? []);
  24. $line = json_encode($article, $options);
  25. if ($line != '') {
  26. if ($first) {
  27. $first = false;
  28. } else {
  29. echo ",\n";
  30. }
  31. echo $line;
  32. }
  33. }
  34. echo "\n]}\n";