articles.phtml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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->guid(),
  17. 'categories' => array_values($entry->tags()),
  18. 'title' => $entry->title(),
  19. 'author' => $entry->author(),
  20. 'published' => $entry->date(true),
  21. 'updated' => $entry->date(true),
  22. 'alternate' => array(array(
  23. 'href' => $entry->link(),
  24. 'type' => 'text/html'
  25. )),
  26. 'content' => array(
  27. 'content' => $entry->content()
  28. ),
  29. 'origin' => array(
  30. 'streamId' => $feed->id(),
  31. 'title' => $feed->name(),
  32. 'htmlUrl' => $feed->website(),
  33. 'feedUrl' => $feed->url()
  34. )
  35. );
  36. }
  37. $options = 0;
  38. if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
  39. $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
  40. }
  41. echo json_encode($articles, $options);
  42. ?>