articles.phtml 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /** @var FreshRSS_View $this */
  3. $username = Minz_Session::param('currentUser', '_');
  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. if (isset($this->entryIdsTagNames['e_' . $entry->id()])) {
  23. $entry->_tags($this->entryIdsTagNames['e_' . $entry->id()]);
  24. }
  25. $article = $entry->toGReader('freshrss');
  26. $line = json_encode($article, $options);
  27. if ($line != '') {
  28. if ($first) {
  29. $first = false;
  30. } else {
  31. echo ",\n";
  32. }
  33. echo $line;
  34. }
  35. }
  36. echo "\n]}\n";