diff options
| author | 2014-03-27 20:36:51 +0100 | |
|---|---|---|
| committer | 2014-03-27 20:36:51 +0100 | |
| commit | 9d87f2f0aa8306c3e07a79d1a100b4d41ea8bc72 (patch) | |
| tree | f7685e6c6dff2dc4c75b8d4b1b1dd16f69b8bd57 /app/views/helpers/export/articles.phtml | |
| parent | c8aa451c768a3d4dfce3d19648f3c8420dedb74c (diff) | |
Export is fully implemented
- Export list of feeds (OPML)
- Export list of favourites (JSON)
- Export list of articles per feed (JSON)
Diffstat (limited to 'app/views/helpers/export/articles.phtml')
| -rw-r--r-- | app/views/helpers/export/articles.phtml | 64 |
1 files changed, 37 insertions, 27 deletions
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 @@ <?php - // TODO: A lot have to be done! $username = Minz_Session::param('currentUser', '_'); - $type_id = "TODO"; - $title = Minz_Translate::t("TODO"); - $entries = []; -?>{ - "id": "user/<?php echo str_replace("\"", "", $username); ?>/state/org.freshrss/<?php echo $type_id; ?>", - "title": "<?php echo addslashes($title); ?>", - "author": "<?php echo addslashes($username); ?>", - "items": [ - <?php $i = 0; foreach($entries as $entry) { $i++; - echo $i > 1 ? ', ': ''; ?>{ - "id": "<?php echo $entry->id(); ?>", - "categories": [<?php /* TODO */ ?>], - "title": "<?php echo addslashes($entry->title()); ?>", - "published": <?php echo $entry->date(true); ?>, - "updated": <?php echo $entry->date(true); ?>, - "content": "<?php echo addslashes($entry->content()); ?>", - "origin": { - <?php /* TODO */ ?> - "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; } - <?php } ?> - ] -}
\ 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); +?> |
