aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/importExportController.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-01-16 22:26:43 +0100
committerGravatar GitHub <noreply@github.com> 2019-01-16 22:26:43 +0100
commit743c1b740bd8ec0b70f7058d4b52101b346a5e9c (patch)
tree7d7c3145ee35b7b37dfc7cf0b7848e85bd3343be /app/Controllers/importExportController.php
parent4355849ec36efb3aa4b711912abd71e30cf2d5ee (diff)
Export labels (#2217)
* Export labels https://github.com/FreshRSS/FreshRSS/issues/2196 * Small fixes * Backport code from 1.14.0 https://github.com/FreshRSS/FreshRSS/pull/2199/commits/4888f919f104b2d170302565e481a0b731eb4145 * More fixes
Diffstat (limited to 'app/Controllers/importExportController.php')
-rw-r--r--app/Controllers/importExportController.php36
1 files changed, 21 insertions, 15 deletions
diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php
index 2d8d4e01d..3f2947c7a 100644
--- a/app/Controllers/importExportController.php
+++ b/app/Controllers/importExportController.php
@@ -650,7 +650,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
return $return;
}
- public function exportFile($export_opml = true, $export_starred = false, $export_feeds = array(), $maxFeedEntries = 50, $username = null) {
+ public function exportFile($export_opml = true, $export_starred = false, $export_labelled = false, $export_feeds = array(), $maxFeedEntries = 50, $username = null) {
require_once(LIB_PATH . '/lib_opml.php');
$this->catDAO = new FreshRSS_CategoryDAO($username);
@@ -674,8 +674,11 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
$export_files["feeds_${day}.opml.xml"] = $this->generateOpml();
}
- if ($export_starred) {
- $export_files["starred_${day}.json"] = $this->generateEntries('starred');
+ if ($export_starred || $export_labelled) {
+ $export_files["starred_${day}.json"] = $this->generateEntries(
+ ($export_starred ? 'S' : '') .
+ ($export_labelled ? 'T' : '')
+ );
}
foreach ($export_feeds as $feed_id) {
@@ -683,7 +686,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
if ($feed) {
$filename = "feed_${day}_" . $feed->category() . '_'
. $feed->id() . '.json';
- $export_files[$filename] = $this->generateEntries('feed', $feed, $maxFeedEntries);
+ $export_files[$filename] = $this->generateEntries('f', $feed, $maxFeedEntries);
}
}
@@ -725,6 +728,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
$nb_files = $this->exportFile(
Minz_Request::param('export_opml', false),
Minz_Request::param('export_starred', false),
+ Minz_Request::param('export_labelled', false),
Minz_Request::param('export_feeds', array())
);
} catch (FreshRSS_ZipMissing_Exception $zme) {
@@ -758,27 +762,29 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
/**
* This method returns a JSON file content.
*
- * @param string $type must be "starred" or "feed"
+ * @param string $type must be one of:
+ * 'S' (starred/favourite), 'f' (feed), 'T' (taggued/labelled), 'ST' (starred or labelled)
* @param FreshRSS_Feed $feed feed of which we want to get entries.
* @return string the JSON file content.
*/
private function generateEntries($type, $feed = null, $maxFeedEntries = 50) {
$this->view->categories = $this->catDAO->listCategories();
+ $tagDAO = FreshRSS_Factory::createTagDao();
- if ($type == 'starred') {
+ if ($type === 's' || $type === 'S' || $type === 'T' || $type === 'ST') {
$this->view->list_title = _t('sub.import_export.starred_list');
$this->view->type = 'starred';
- $unread_fav = $this->entryDAO->countUnreadReadFavorites();
- $this->view->entriesRaw = $this->entryDAO->listWhereRaw(
- 's', '', FreshRSS_Entry::STATE_ALL, 'ASC', $unread_fav['all']
- );
- } elseif ($type === 'feed' && $feed != null) {
+ $this->view->entriesId = $this->entryDAO->listIdsWhere($type, '', FreshRSS_Entry::STATE_ALL, 'ASC', -1);
+ $this->view->entryIdsTagNames = $tagDAO->getEntryIdsTagNames($this->view->entriesId);
+ //The following is a streamable query, i.e. must be last
+ $this->view->entriesRaw = $this->entryDAO->listWhereRaw($type, '', FreshRSS_Entry::STATE_ALL, 'ASC', -1);
+ } elseif ($type === 'f' && $feed != null) {
$this->view->list_title = _t('sub.import_export.feed_list', $feed->name());
$this->view->type = 'feed/' . $feed->id();
- $this->view->entriesRaw = $this->entryDAO->listWhereRaw(
- 'f', $feed->id(), FreshRSS_Entry::STATE_ALL, 'ASC',
- $maxFeedEntries
- );
+ $this->view->entriesId = $this->entryDAO->listIdsWhere($type, $feed->id(), FreshRSS_Entry::STATE_ALL, 'ASC', $maxFeedEntries);
+ $this->view->entryIdsTagNames = $tagDAO->getEntryIdsTagNames($this->view->entriesId);
+ //The following is a streamable query, i.e. must be last
+ $this->view->entriesRaw = $this->entryDAO->listWhereRaw($type, $feed->id(), FreshRSS_Entry::STATE_ALL, 'ASC', $maxFeedEntries);
$this->view->feed = $feed;
}