articles.phtml 984 B

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