diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2012-08-05 15:49:25 -0400 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2012-08-05 15:49:25 -0400 |
commit | 12720ebd14f299237fb16858c075436cfa9d55ee (patch) | |
tree | 3cf5121e6e0c3f793ced4dd283346e10782efb52 /ajax/importopml.php | |
parent | 5225272b1cb1c34cc00525e4e05071a663fdd1e5 (diff) |
refactores code of the opml importer
Diffstat (limited to 'ajax/importopml.php')
-rw-r--r-- | ajax/importopml.php | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ajax/importopml.php b/ajax/importopml.php index 89e2a52f0..c2230c8b8 100644 --- a/ajax/importopml.php +++ b/ajax/importopml.php @@ -23,10 +23,6 @@ function bailOut($msg) { exit(); } -function debug($msg) { - OCP\Util::writeLog('news','ajax/importopml.php: '.$msg, OCP\Util::DEBUG); -} - if(!isset($_POST['path'])) { bailOut($l->t('No file path was submitted.')); } @@ -35,10 +31,15 @@ require_once('news/opmlparser.php'); $raw = file_get_contents($_POST['path']); -$parser = new OPMLParser($raw); -$title = $parser->getTitle(); -$data = $parser->parse(); -$count = 0; //number of feeds imported +try { + $parsed = OPMLParser::parse($raw); +} catch (Exception $e) { + bailOut($e->getMessage()); +} + +if ($parsed == null) { + bailOut($l->t('An error occurred while parsing the file.')); +} -OCP\JSON::success(array('data' => array('title'=>$title, 'count'=>$count))); +OCP\JSON::success(array('data' => array('title'=>$parsed->getTitle(), 'count'=>$parsed->getCount()))); |