From 9d87f2f0aa8306c3e07a79d1a100b4d41ea8bc72 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 27 Mar 2014 20:36:51 +0100 Subject: Export is fully implemented - Export list of feeds (OPML) - Export list of favourites (JSON) - Export list of articles per feed (JSON) --- app/views/helpers/export/articles.phtml | 64 +++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 27 deletions(-) (limited to 'app/views/helpers/export') diff --git a/app/views/helpers/export/articles.phtml b/app/views/helpers/export/articles.phtml index b7df58caf..71ac22f44 100644 --- a/app/views/helpers/export/articles.phtml +++ b/app/views/helpers/export/articles.phtml @@ -1,30 +1,40 @@ { - "id": "user//state/org.freshrss/", - "title": "", - "author": "", - "items": [ - 1 ? ', ': ''; ?>{ - "id": "id(); ?>", - "categories": [], - "title": "title()); ?>", - "published": date(true); ?>, - "updated": date(true); ?>, - "content": "content()); ?>", - "origin": { - - "streamId": "", - "title": "", - "htmlUrl": "", - "feedUrl": "" - } + + $articles = array( + 'id' => 'user/' . str_replace('/', '', $username) . '/state/org.freshrss/' . $this->type, + 'title' => $this->list_title, + 'author' => $username, + 'items' => array() + ); + + foreach ($this->entries as $entry) { + if (!isset($this->feed)) { + $feed = FreshRSS_CategoryDAO::findFeed($this->categories, $entry->feed ()); + } else { + $feed = $this->feed; } - - ] -} \ No newline at end of file + + $articles['items'][] = array( + 'id' => $entry->id(), + 'categories' => array_values($entry->tags()), + 'title' => $entry->title(), + 'published' => $entry->date(true), + 'updated' => $entry->date(true), + 'content' => $entry->content(), + 'origin' => array( + 'streamId' => $feed->id(), + 'title' => $feed->name(), + 'htmlUrl' => $feed->website(), + 'feedUrl' => $feed->url() + ) + ); + } + + $options = 0; + if (version_compare(PHP_VERSION, '5.4.0') >= 0) { + $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; + } + + echo json_encode($articles, $options); +?> -- cgit v1.2.3