summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajax/importopml.php14
-rw-r--r--js/settings.js23
2 files changed, 31 insertions, 6 deletions
diff --git a/ajax/importopml.php b/ajax/importopml.php
index adf14e86e..3573a1069 100644
--- a/ajax/importopml.php
+++ b/ajax/importopml.php
@@ -24,14 +24,18 @@ function bailOut($msg) {
exit();
}
-if(!isset($_POST['path'])) {
- bailOut($l->t('No file path was submitted.'));
+if (isset($_POST['path'])) {
+ $raw = file_get_contents($_POST['path']);
}
-
+elseif (isset($_FILES['file'])) {
+ $raw = file_get_contents($_FILES['file']['tmp_name']);
+}
+else {
+ bailOut($l->t('No file was submitted.'));
+}
+
require_once 'news/opmlparser.php';
-$raw = file_get_contents($_POST['path']);
-
try {
$parsed = OPMLParser::parse($raw);
} catch (Exception $e) {
diff --git a/js/settings.js b/js/settings.js
index 24440d67d..1eedcbfd0 100644
--- a/js/settings.js
+++ b/js/settings.js
@@ -10,6 +10,7 @@ News.Settings={
OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
}
});
+ $('#appsettings_popup').remove();
},
browseFile:function(filelist){
if(!filelist) {
@@ -17,6 +18,27 @@ News.Settings={
return;
}
var file = filelist[0];
+ //check file format/size/...
+ var formData = new FormData();
+ formData.append('file', file);
+ $.ajax({
+ url: OC.filePath('news', 'ajax', 'importopml.php'),
+ data: formData,
+ cache: false,
+ contentType: false,
+ processData: false,
+ type: 'POST',
+ success: function(jsondata){
+ if (jsondata.status == 'success') {
+ var message = jsondata.data.countsuccess + t('news', ' out of ') + jsondata.data.count +
+ t('news', ' feeds imported successfully from ') + jsondata.data.title;
+ OC.dialogs.alert(message, t('news', 'Success'));
+ }
+ else {
+ OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
+ }
+ }
+ });
},
importOpml:function(path){
$.post(OC.filePath('news', 'ajax', 'importopml.php'), { path: path }, function(jsondata){
@@ -42,7 +64,6 @@ $('#cloudlink').click(function() {
* and filepicker doesn't support multiple MIME types filter.
*/
OC.dialogs.filepicker(t('news', 'Select file'), News.Settings.cloudFileSelected, false, '', true);
- $('#appsettings_popup').remove();
});
$('#browselink').click(function() {