diff options
Diffstat (limited to 'app/views')
| -rw-r--r-- | app/views/helpers/export/articles.phtml | 71 | ||||
| -rw-r--r-- | app/views/helpers/export/opml.phtml | 41 | ||||
| -rw-r--r-- | app/views/importExport/index.phtml | 12 |
3 files changed, 78 insertions, 46 deletions
diff --git a/app/views/helpers/export/articles.phtml b/app/views/helpers/export/articles.phtml index b7df58caf..ffdca1daa 100644 --- a/app/views/helpers/export/articles.phtml +++ b/app/views/helpers/export/articles.phtml @@ -1,30 +1,47 @@ <?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->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->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); +?> diff --git a/app/views/helpers/export/opml.phtml b/app/views/helpers/export/opml.phtml index 2e66e5054..f667d093c 100644 --- a/app/views/helpers/export/opml.phtml +++ b/app/views/helpers/export/opml.phtml @@ -1,15 +1,28 @@ <?php -require_once(LIB_PATH . '/lib_opml.php'); - -echo '<?xml version="1.0" encoding="UTF-8" ?>'; -?> -<!-- Generated by <?php echo Minz_Configuration::title (); ?> --> -<opml version="2.0"> - <head> - <title><?php echo Minz_Configuration::title (); ?> OPML Feed</title> - <dateCreated><?php echo date('D, d M Y H:i:s'); ?></dateCreated> - </head> - <body> -<?php echo opml_export ($this->categories); ?> - </body> -</opml> + +$opml_array = array( + 'head' => array( + 'title' => Minz_Configuration::title(), + 'dateCreated' => date('D, d M Y H:i:s') + ), + 'body' => array() +); + +foreach ($this->categories as $key => $cat) { + $opml_array['body'][$key] = array( + 'text' => $cat['name'], + '@outlines' => array() + ); + + foreach ($cat['feeds'] as $feed) { + $opml_array['body'][$key]['@outlines'][] = array( + 'text' => htmlspecialchars_decode($feed->name()), + 'type' => 'rss', + 'xmlUrl' => $feed->url(), + 'htmlUrl' => $feed->website(), + 'description' => $feed->description() + ); + } +} + +echo libopml_render($opml_array); diff --git a/app/views/importExport/index.phtml b/app/views/importExport/index.phtml index d8c76543e..309058959 100644 --- a/app/views/importExport/index.phtml +++ b/app/views/importExport/index.phtml @@ -19,6 +19,7 @@ </div> </form> + <?php if (count($this->feeds) > 0) { ?> <form method="post" action="<?php echo _url('importExport', 'export'); ?>"> <legend><?php echo Minz_Translate::t ('export'); ?></legend> <div class="form-group"> @@ -33,11 +34,11 @@ <?php echo Minz_Translate::t ('export_starred'); ?> </label> - <label class="checkbox" for="export_all"> - <input type="checkbox" name="export_all" id="export_all" value="1" /> - <?php echo Minz_Translate::t ('export_all'); ?> - <?php echo FreshRSS_Themes::icon('help'); ?> <?php echo Minz_Translate::t('export_all_is_long'); ?> - </label> + <select name="export_feeds[]" size="<?php echo min(10, count($this->feeds)); ?>" multiple="multiple"> + <?php foreach ($this->feeds as $feed) { ?> + <option value="<?php echo $feed->id(); ?>"><?php echo $feed->name(); ?></option> + <?php } ?> + </select> </div> </div> @@ -47,4 +48,5 @@ </div> </div> </form> + <?php } ?> </div> |
