articles.phtml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. $username = Minz_Session::param('currentUser', '_');
  3. $options = 0;
  4. if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
  5. $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
  6. }
  7. $articles = array(
  8. 'id' => 'user/' . str_replace('/', '', $username) . '/state/org.freshrss/' . $this->type,
  9. 'title' => $this->list_title,
  10. 'author' => $username,
  11. 'items' => array(),
  12. );
  13. echo rtrim(json_encode($articles, $options), " ]}\n\r\t");
  14. $first = true;
  15. foreach ($this->entriesRaw as $entryRaw) {
  16. $entry = FreshRSS_EntryDAO::daoToEntry($entryRaw);
  17. if (!isset($this->feed)) {
  18. $feed = FreshRSS_CategoryDAO::findFeed($this->categories, $entry->feed ());
  19. } else {
  20. $feed = $this->feed;
  21. }
  22. $article = array(
  23. 'id' => $entry->guid(),
  24. 'categories' => array_values($entry->tags()),
  25. 'title' => $entry->title(),
  26. 'author' => $entry->author(),
  27. 'published' => $entry->date(true),
  28. 'updated' => $entry->date(true),
  29. 'alternate' => array(array(
  30. 'href' => $entry->link(),
  31. 'type' => 'text/html',
  32. )),
  33. 'content' => array(
  34. 'content' => $entry->content(),
  35. ),
  36. 'origin' => array(
  37. 'streamId' => $feed->id(),
  38. 'title' => $feed->name(),
  39. 'htmlUrl' => $feed->website(),
  40. 'feedUrl' => $feed->url(),
  41. )
  42. );
  43. if ($first) {
  44. $first = false;
  45. } else {
  46. echo ",\n";
  47. }
  48. echo json_encode($article, $options);
  49. }
  50. echo "\n]}\n";