Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
Vincent Malley 2015-06-02 11:09:37 -04:00
commit 900f2a9160
8 changed files with 60 additions and 19 deletions

View file

@ -732,23 +732,45 @@ class Poche
$html->load_file($_FILES['file']['tmp_name']);
$data = array();
$read = 0;
foreach (array('ol','ul') as $list) {
foreach ($html->find($list) as $ul) {
foreach ($ul->find('li') as $li) {
$tmpEntry = array();
$a = $li->find('a');
$tmpEntry['url'] = $a[0]->href;
$tmpEntry['tags'] = $a[0]->tags;
$tmpEntry['is_read'] = $read;
if ($tmpEntry['url']) {
$data[] = $tmpEntry;
if (Tools::get_doctype($html)->innertext == "<!DOCTYPE NETSCAPE-Bookmark-file-1>") {
// Firefox-bookmarks HTML
foreach (array('DL','ul') as $list) {
foreach ($html->find($list) as $ul) {
foreach ($ul->find('DT') as $li) {
$tmpEntry = array();
$a = $li->find('A');
$tmpEntry['url'] = $a[0]->href;
$tmpEntry['tags'] = $a[0]->tags;
$tmpEntry['is_read'] = $read;
if ($tmpEntry['url']) {
$data[] = $tmpEntry;
}
}
}
# the second <ol/ul> is for read links
$read = ((sizeof($data) && $read)?0:1);
# the second <ol/ul> is for read links
$read = ((sizeof($data) && $read)?0:1);
}
}
}
}
} else {
// regular HTML
foreach (array('ol','ul') as $list) {
foreach ($html->find($list) as $ul) {
foreach ($ul->find('li') as $li) {
$tmpEntry = array();
$a = $li->find('a');
$tmpEntry['url'] = $a[0]->href;
$tmpEntry['tags'] = $a[0]->tags;
$tmpEntry['is_read'] = $read;
if ($tmpEntry['url']) {
$data[] = $tmpEntry;
}
}
# the second <ol/ul> is for read links
$read = ((sizeof($data) && $read)?0:1);
}
}
}
}
// for readability structure
@ -766,7 +788,7 @@ class Poche
$urlsInserted = array(); //urls of articles inserted
foreach($data as $record) {
$url = trim(isset($record['article__url']) ? $record['article__url'] : (isset($record['url']) ? $record['url'] : ''));
if ($url and !in_array($url, $urlsInserted)) {
if (filter_var($url, FILTER_VALIDATE_URL) and !in_array($url, $urlsInserted)) {
$title = (isset($record['title']) ? $record['title'] : _('Untitled - Import - ') . '</a> <a href="./?import">' . _('click to finish import') . '</a><a>');
$body = (isset($record['content']) ? $record['content'] : '');
$isRead = (isset($record['is_read']) ? intval($record['is_read']) : (isset($record['archive']) ? intval($record['archive']) : 0));

View file

@ -141,7 +141,7 @@ class Routing
$pdf->producePDF();
} elseif (isset($_GET['import'])) {
$import = $this->wallabag->import();
$tplVars = array_merge($this->vars, $import);
$this->vars = array_merge($this->vars, $import);
} elseif (isset($_GET['empty-cache'])) {
Tools::emptyCache();
} elseif (isset($_GET['export'])) {

View file

@ -420,4 +420,23 @@ final class Tools
return str_replace('+', '', $token);
}
/**
*
* Returns the doctype for an HTML document (used for Mozilla Bookmarks)
* @param simple_html_dom $doc
* @return doctype $el
*
*/
public static function get_doctype($doc)
{
$els = $doc->find('unknown');
foreach ($els as $e => $el)
if ($el->parent()->tag == 'root')
return $el;
return NULL;
}
}

View file

@ -36,8 +36,6 @@ if (isset($_SERVER['HTTP_COOKIE'])) {
if (isset($_SESSION['poche_user'])) {
unset($_SESSION['poche_user']);
}
session_destroy();
if (isset($_GET['clean'])) {
if (is_dir('install')){

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -2,11 +2,13 @@
<!--
$(document).ready(function() {
$("body").css("cursor", "wait");
$("#content").css("display", "none");
setTimeout(function(){
window.location = './?import';
}, {{ import.delay }} );
});
//-->
</script>
<div class="messages warning">