diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-12 14:53:02 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-12 14:53:02 +0200 |
commit | a069add71e642f37c6309c3bd7af74761acef929 (patch) | |
tree | 59b3326de202dd5a8bb5e29ae1a626794fb6b349 /controller | |
parent | e8767f75116ff7ef2b7a349480151c9f66bbade0 (diff) |
implement export, needs proper unittests though, fix 31
Diffstat (limited to 'controller')
-rw-r--r-- | controller/exportcontroller.php | 21 | ||||
-rw-r--r-- | controller/feedcontroller.php | 2 |
2 files changed, 19 insertions, 4 deletions
diff --git a/controller/exportcontroller.php b/controller/exportcontroller.php index 013626938..960748d3e 100644 --- a/controller/exportcontroller.php +++ b/controller/exportcontroller.php @@ -28,23 +28,38 @@ namespace OCA\News\Controller; use \OCA\AppFramework\Controller\Controller; use \OCA\AppFramework\Core\API; use \OCA\AppFramework\Http\Request; +use \OCA\AppFramework\Http\TextDownloadResponse; +use \OCA\News\Bl\FeedBl; +use \OCA\News\Bl\FolderBl; +use \OCA\News\Utility\OPMLExporter; class ExportController extends Controller { + private $opmlExporter; + private $folderBl; + private $feedBl; - public function __construct(API $api, Request $request){ + public function __construct(API $api, Request $request, FeedBl $feedBl, + FolderBl $folderBl, OPMLExporter $opmlExporter){ parent::__construct($api, $request); + $this->feedBl = $feedBl; + $this->folderBl = $folderBl; + $this->opmlExporter = $opmlExporter; } /** * @IsAdminExemption * @IsSubAdminExemption - * @Ajax + * @CSRFExemption */ public function opml(){ - // TODO + $user = $this->api->getUserId(); + $feeds = $this->feedBl->findAll($user); + $folders = $this->folderBl->findAll($user); + $opml = $this->opmlExporter->build($folders, $feeds)->saveXML(); + return new TextDownloadResponse($opml, 'subscriptions.opml', 'text/xml'); } diff --git a/controller/feedcontroller.php b/controller/feedcontroller.php index c542ea1d8..5e2a91f24 100644 --- a/controller/feedcontroller.php +++ b/controller/feedcontroller.php @@ -55,7 +55,7 @@ class FeedController extends Controller { */ public function feeds(){ $userId = $this->api->getUserId(); - $result = $this->feedBl->findAllFromUser($userId); + $result = $this->feedBl->findAll($userId); $params = array( 'feeds' => $result |