articles.phtml 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. $username = Minz_Session::param('currentUser', '_');
  3. $articles = array(
  4. 'id' => 'user/' . str_replace('/', '', $username) . '/state/org.freshrss/' . $this->type,
  5. 'title' => $this->list_title,
  6. 'author' => $username,
  7. 'items' => array()
  8. );
  9. foreach ($this->entries as $entry) {
  10. if (!isset($this->feed)) {
  11. $feed = FreshRSS_CategoryDAO::findFeed($this->categories, $entry->feed ());
  12. } else {
  13. $feed = $this->feed;
  14. }
  15. $articles['items'][] = array(
  16. 'id' => $entry->id(),
  17. 'categories' => array_values($entry->tags()),
  18. 'title' => $entry->title(),
  19. 'published' => $entry->date(true),
  20. 'updated' => $entry->date(true),
  21. 'content' => $entry->content(),
  22. 'origin' => array(
  23. 'streamId' => $feed->id(),
  24. 'title' => $feed->name(),
  25. 'htmlUrl' => $feed->website(),
  26. 'feedUrl' => $feed->url()
  27. )
  28. );
  29. }
  30. $options = 0;
  31. if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
  32. $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
  33. }
  34. echo json_encode($articles, $options);
  35. ?>