aboutsummaryrefslogtreecommitdiff
path: root/app/views/helpers/export/articles.phtml
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/helpers/export/articles.phtml')
-rw-r--r--app/views/helpers/export/articles.phtml66
1 files changed, 66 insertions, 0 deletions
diff --git a/app/views/helpers/export/articles.phtml b/app/views/helpers/export/articles.phtml
new file mode 100644
index 000000000..49c370023
--- /dev/null
+++ b/app/views/helpers/export/articles.phtml
@@ -0,0 +1,66 @@
+<?php
+$username = Minz_Session::param('currentUser', '_');
+
+$options = 0;
+if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
+ $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
+}
+
+$articles = array(
+ 'id' => 'user/' . str_replace('/', '', $username) . '/state/org.freshrss/' . $this->type,
+ 'title' => $this->list_title,
+ 'author' => $username,
+ 'items' => array(),
+);
+
+echo rtrim(json_encode($articles, $options), " ]}\n\r\t"), "\n";
+$first = true;
+
+foreach ($this->entriesRaw as $entryRaw) {
+ if (empty($entryRaw)) {
+ continue;
+ }
+ $entry = FreshRSS_EntryDAO::daoToEntry($entryRaw);
+ if (!isset($this->feed)) {
+ $feed = FreshRSS_CategoryDAO::findFeed($this->categories, $entry->feed());
+ if ($feed == null) {
+ $feed = $entry->feed(true);
+ }
+ } else {
+ $feed = $this->feed;
+ }
+
+ $article = array(
+ 'id' => $entry->guid(),
+ 'categories' => array_values($entry->tags()),
+ 'title' => $entry->title(),
+ 'author' => $entry->author(),
+ 'published' => $entry->date(true),
+ 'updated' => $entry->date(true),
+ 'alternate' => array(array(
+ 'href' => $entry->link(),
+ 'type' => 'text/html',
+ )),
+ 'content' => array(
+ 'content' => $entry->content(),
+ ),
+ 'origin' => array(
+ 'streamId' => $feed == null ? '' : $feed->id(),
+ 'title' => $feed == null ? '' : $feed->name(),
+ 'htmlUrl' => $feed == null ? '' : $feed->website(),
+ 'feedUrl' => $feed == null ? '' : $feed->url(),
+ )
+ );
+
+ $line = json_encode($article, $options);
+ if ($line != '') {
+ if ($first) {
+ $first = false;
+ } else {
+ echo ",\n";
+ }
+ echo $line;
+ }
+}
+
+echo "\n]}\n";