mirror of https://github.com/wallabag/wallabag.git
[add] upload form for import
This commit is contained in:
parent
4c14936353
commit
31a10069a5
|
@ -1068,13 +1068,7 @@ class Poche
|
|||
Tools::redirect();
|
||||
}
|
||||
|
||||
$targetDefinition = 'IMPORT_' . strtoupper($from) . '_FILE';
|
||||
$targetFile = constant($targetDefinition);
|
||||
|
||||
if (! defined($targetDefinition)) {
|
||||
$this->messages->add('e', _('Incomplete inc/poche/define.inc.php file, please define "' . $targetDefinition . '".'));
|
||||
Tools::redirect();
|
||||
}
|
||||
$targetFile = CACHE . '/' . constant(strtoupper($from) . '_FILE');
|
||||
|
||||
if (! file_exists($targetFile)) {
|
||||
$this->messages->add('e', _('Could not find required "' . $targetFile . '" import file.'));
|
||||
|
@ -1084,6 +1078,22 @@ class Poche
|
|||
$this->$providers[$from]($targetFile);
|
||||
}
|
||||
|
||||
public function uploadFile() {
|
||||
if(isset($_FILES['file']))
|
||||
{
|
||||
$dir = CACHE . '/';
|
||||
$file = basename($_FILES['file']['name']);
|
||||
if(move_uploaded_file($_FILES['file']['tmp_name'], $dir . $file)) {
|
||||
$this->messages->add('s', _('File uploaded. You can now execute import.'));
|
||||
}
|
||||
else {
|
||||
$this->messages->add('e', _('Error while importing file. Do you have access to upload it?'));
|
||||
}
|
||||
}
|
||||
|
||||
Tools::redirect('?view=config');
|
||||
}
|
||||
|
||||
/**
|
||||
* export poche entries in json
|
||||
* @return json all poche entries
|
||||
|
|
|
@ -241,7 +241,6 @@ class Tools
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static function download_db() {
|
||||
header('Content-Disposition: attachment; filename="poche.sqlite.gz"');
|
||||
self::status(200);
|
||||
|
|
|
@ -75,6 +75,8 @@ if (isset($_GET['login'])) {
|
|||
$poche->updateTheme();
|
||||
} elseif (isset($_GET['updatelanguage'])) {
|
||||
$poche->updateLanguage();
|
||||
} elseif (isset($_GET['uploadfile'])) {
|
||||
$poche->uploadFile();
|
||||
} elseif (isset($_GET['feed'])) {
|
||||
if (isset($_GET['action']) && $_GET['action'] == 'generate') {
|
||||
$poche->generateToken();
|
||||
|
|
|
@ -103,13 +103,26 @@
|
|||
{% endif %}
|
||||
|
||||
<h2>{% trans "Import" %}</h2>
|
||||
<p>{% trans "Please execute the import script locally as it can take a very long time." %}</p>
|
||||
<p>{% trans "More info in the official documentation:" %} <a href="http://doc.wallabag.org/doku.php?id=users:migrate">wallabag.org</a></p>
|
||||
<p>1. {% trans "Select a file on your computer and upload it." %}</p>
|
||||
<form method="post" action="?uploadfile" name="uploadfile" enctype="multipart/form-data">
|
||||
<fieldset class="w500p">
|
||||
<div class="row">
|
||||
<label class="col w150p" for="file">{% trans "File:" %}</label>
|
||||
<input class="col" type="file" id="file" name="file" tabindex="4">
|
||||
</div>
|
||||
<div class="row mts txtcenter">
|
||||
<button class="bouton" type="submit" tabindex="4">{% trans "Upload" %}</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="1048576">
|
||||
<input type="hidden" name="returnurl" value="{{ referer }}">
|
||||
</form>
|
||||
<p>2. {% trans "Then, click on the right link below." %}</p>
|
||||
<ul>
|
||||
<li><a href="./?import&from=pocket">{% trans "Import from Pocket" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('POCKET_FILE')) }}</li>
|
||||
<li><a href="./?import&from=readability">{% trans "Import from Readability" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('READABILITY_FILE')) }}</li>
|
||||
<li><a href="./?import&from=instapaper">{% trans "Import from Instapaper" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('INSTAPAPER_FILE')) }}</li>
|
||||
<li><a href="./?import&from=poche">{% trans "Import from wallabag" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('POCHE_FILE')) }}</li>
|
||||
<li><a href="./?import&from=pocket">{% trans "Import from Pocket" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('POCKET_FILE')) }}</li>
|
||||
<li><a href="./?import&from=readability">{% trans "Import from Readability" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('READABILITY_FILE')) }}</li>
|
||||
<li><a href="./?import&from=instapaper">{% trans "Import from Instapaper" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('INSTAPAPER_FILE')) }}</li>
|
||||
<li><a href="./?import&from=poche">{% trans "Import from wallabag" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('POCHE_FILE')) }}</li>
|
||||
</ul>
|
||||
|
||||
<h2>{% trans "Export your wallabag data" %}</h2>
|
||||
|
|
Loading…
Reference in New Issue