diff options
-rw-r--r-- | application/netscape/NetscapeBookmarkUtils.php (renamed from application/NetscapeBookmarkUtils.php) | 27 | ||||
-rw-r--r-- | composer.json | 1 | ||||
-rw-r--r-- | index.php | 2 | ||||
-rw-r--r-- | tests/netscape/BookmarkExportTest.php (renamed from tests/NetscapeBookmarkUtils/BookmarkExportTest.php) | 9 | ||||
-rw-r--r-- | tests/netscape/BookmarkImportTest.php (renamed from tests/NetscapeBookmarkUtils/BookmarkImportTest.php) | 6 | ||||
-rw-r--r-- | tests/netscape/input/empty.htm (renamed from tests/NetscapeBookmarkUtils/input/empty.htm) | 0 | ||||
-rw-r--r-- | tests/netscape/input/internet_explorer_encoding.htm (renamed from tests/NetscapeBookmarkUtils/input/internet_explorer_encoding.htm) | 0 | ||||
-rw-r--r-- | tests/netscape/input/lowercase_doctype.htm (renamed from tests/NetscapeBookmarkUtils/input/lowercase_doctype.htm) | 0 | ||||
-rw-r--r-- | tests/netscape/input/netscape_basic.htm (renamed from tests/NetscapeBookmarkUtils/input/netscape_basic.htm) | 0 | ||||
-rw-r--r-- | tests/netscape/input/netscape_nested.htm (renamed from tests/NetscapeBookmarkUtils/input/netscape_nested.htm) | 0 | ||||
-rw-r--r-- | tests/netscape/input/no_doctype.htm (renamed from tests/NetscapeBookmarkUtils/input/no_doctype.htm) | 0 | ||||
-rw-r--r-- | tests/netscape/input/same_date.htm (renamed from tests/NetscapeBookmarkUtils/input/same_date.htm) | 0 |
12 files changed, 26 insertions, 19 deletions
diff --git a/application/NetscapeBookmarkUtils.php b/application/netscape/NetscapeBookmarkUtils.php index e0022fe1..2bf928c2 100644 --- a/application/NetscapeBookmarkUtils.php +++ b/application/netscape/NetscapeBookmarkUtils.php | |||
@@ -1,5 +1,10 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace Shaarli\Netscape; | ||
4 | |||
5 | use DateTime; | ||
6 | use DateTimeZone; | ||
7 | use Exception; | ||
3 | use Psr\Log\LogLevel; | 8 | use Psr\Log\LogLevel; |
4 | use Shaarli\Bookmark\LinkDB; | 9 | use Shaarli\Bookmark\LinkDB; |
5 | use Shaarli\Config\ConfigManager; | 10 | use Shaarli\Config\ConfigManager; |
@@ -33,8 +38,8 @@ class NetscapeBookmarkUtils | |||
33 | public static function filterAndFormat($linkDb, $selection, $prependNoteUrl, $indexUrl) | 38 | public static function filterAndFormat($linkDb, $selection, $prependNoteUrl, $indexUrl) |
34 | { | 39 | { |
35 | // see tpl/export.html for possible values | 40 | // see tpl/export.html for possible values |
36 | if (! in_array($selection, array('all', 'public', 'private'))) { | 41 | if (!in_array($selection, array('all', 'public', 'private'))) { |
37 | throw new Exception(t('Invalid export selection:') .' "'.$selection.'"'); | 42 | throw new Exception(t('Invalid export selection:') . ' "' . $selection . '"'); |
38 | } | 43 | } |
39 | 44 | ||
40 | $bookmarkLinks = array(); | 45 | $bookmarkLinks = array(); |
@@ -86,7 +91,7 @@ class NetscapeBookmarkUtils | |||
86 | $status .= vsprintf( | 91 | $status .= vsprintf( |
87 | t( | 92 | t( |
88 | 'was successfully processed in %d seconds: ' | 93 | 'was successfully processed in %d seconds: ' |
89 | .'%d links imported, %d links overwritten, %d links skipped.' | 94 | . '%d links imported, %d links overwritten, %d links skipped.' |
90 | ), | 95 | ), |
91 | [$duration, $importCount, $overwriteCount, $skipCount] | 96 | [$duration, $importCount, $overwriteCount, $skipCount] |
92 | ); | 97 | ); |
@@ -97,11 +102,11 @@ class NetscapeBookmarkUtils | |||
97 | /** | 102 | /** |
98 | * Imports Web bookmarks from an uploaded Netscape bookmark dump | 103 | * Imports Web bookmarks from an uploaded Netscape bookmark dump |
99 | * | 104 | * |
100 | * @param array $post Server $_POST parameters | 105 | * @param array $post Server $_POST parameters |
101 | * @param array $files Server $_FILES parameters | 106 | * @param array $files Server $_FILES parameters |
102 | * @param LinkDB $linkDb Loaded LinkDB instance | 107 | * @param LinkDB $linkDb Loaded LinkDB instance |
103 | * @param ConfigManager $conf instance | 108 | * @param ConfigManager $conf instance |
104 | * @param History $history History instance | 109 | * @param History $history History instance |
105 | * | 110 | * |
106 | * @return string Summary of the bookmark import status | 111 | * @return string Summary of the bookmark import status |
107 | */ | 112 | */ |
@@ -117,7 +122,7 @@ class NetscapeBookmarkUtils | |||
117 | } | 122 | } |
118 | 123 | ||
119 | // Overwrite existing links? | 124 | // Overwrite existing links? |
120 | $overwrite = ! empty($post['overwrite']); | 125 | $overwrite = !empty($post['overwrite']); |
121 | 126 | ||
122 | // Add tags to all imported links? | 127 | // Add tags to all imported links? |
123 | if (empty($post['default_tags'])) { | 128 | if (empty($post['default_tags'])) { |
@@ -140,7 +145,7 @@ class NetscapeBookmarkUtils | |||
140 | ); | 145 | ); |
141 | $logger = new Logger( | 146 | $logger = new Logger( |
142 | $conf->get('resource.data_dir'), | 147 | $conf->get('resource.data_dir'), |
143 | ! $conf->get('dev.debug') ? LogLevel::INFO : LogLevel::DEBUG, | 148 | !$conf->get('dev.debug') ? LogLevel::INFO : LogLevel::DEBUG, |
144 | [ | 149 | [ |
145 | 'prefix' => 'import.', | 150 | 'prefix' => 'import.', |
146 | 'extension' => 'log', | 151 | 'extension' => 'log', |
@@ -195,7 +200,7 @@ class NetscapeBookmarkUtils | |||
195 | } | 200 | } |
196 | 201 | ||
197 | // Add a new link - @ used for UNIX timestamps | 202 | // Add a new link - @ used for UNIX timestamps |
198 | $newLinkDate = new DateTime('@'.strval($bkm['time'])); | 203 | $newLinkDate = new DateTime('@' . strval($bkm['time'])); |
199 | $newLinkDate->setTimezone(new DateTimeZone(date_default_timezone_get())); | 204 | $newLinkDate->setTimezone(new DateTimeZone(date_default_timezone_get())); |
200 | $newLink['created'] = $newLinkDate; | 205 | $newLink['created'] = $newLinkDate; |
201 | $newLink['id'] = $linkDb->getNextId(); | 206 | $newLink['id'] = $linkDb->getNextId(); |
diff --git a/composer.json b/composer.json index af763472..c1f47317 100644 --- a/composer.json +++ b/composer.json | |||
@@ -45,6 +45,7 @@ | |||
45 | "Shaarli\\Exceptions\\": "application/exceptions", | 45 | "Shaarli\\Exceptions\\": "application/exceptions", |
46 | "Shaarli\\Feed\\": "application/feed", | 46 | "Shaarli\\Feed\\": "application/feed", |
47 | "Shaarli\\Http\\": "application/http", | 47 | "Shaarli\\Http\\": "application/http", |
48 | "Shaarli\\Netscape\\": "application/netscape", | ||
48 | "Shaarli\\Render\\": "application/render", | 49 | "Shaarli\\Render\\": "application/render", |
49 | "Shaarli\\Security\\": "application/security", | 50 | "Shaarli\\Security\\": "application/security", |
50 | "Shaarli\\Updater\\": "application/updater", | 51 | "Shaarli\\Updater\\": "application/updater", |
@@ -63,7 +63,6 @@ require_once 'application/http/HttpUtils.php'; | |||
63 | require_once 'application/http/UrlUtils.php'; | 63 | require_once 'application/http/UrlUtils.php'; |
64 | require_once 'application/updater/UpdaterUtils.php'; | 64 | require_once 'application/updater/UpdaterUtils.php'; |
65 | require_once 'application/FileUtils.php'; | 65 | require_once 'application/FileUtils.php'; |
66 | require_once 'application/NetscapeBookmarkUtils.php'; | ||
67 | require_once 'application/TimeZone.php'; | 66 | require_once 'application/TimeZone.php'; |
68 | require_once 'application/Utils.php'; | 67 | require_once 'application/Utils.php'; |
69 | require_once 'application/PluginManager.php'; | 68 | require_once 'application/PluginManager.php'; |
@@ -76,6 +75,7 @@ use \Shaarli\Feed\CachedPage; | |||
76 | use \Shaarli\Feed\FeedBuilder; | 75 | use \Shaarli\Feed\FeedBuilder; |
77 | use \Shaarli\History; | 76 | use \Shaarli\History; |
78 | use \Shaarli\Languages; | 77 | use \Shaarli\Languages; |
78 | use \Shaarli\Netscape\NetscapeBookmarkUtils; | ||
79 | use \Shaarli\Render\PageBuilder; | 79 | use \Shaarli\Render\PageBuilder; |
80 | use \Shaarli\Render\ThemeUtils; | 80 | use \Shaarli\Render\ThemeUtils; |
81 | use \Shaarli\Router; | 81 | use \Shaarli\Router; |
diff --git a/tests/NetscapeBookmarkUtils/BookmarkExportTest.php b/tests/netscape/BookmarkExportTest.php index adf854c5..6de9876d 100644 --- a/tests/NetscapeBookmarkUtils/BookmarkExportTest.php +++ b/tests/netscape/BookmarkExportTest.php | |||
@@ -1,13 +1,14 @@ | |||
1 | <?php | 1 | <?php |
2 | namespace Shaarli\Netscape; | ||
2 | 3 | ||
3 | use Shaarli\Bookmark\LinkDB; | 4 | use Shaarli\Bookmark\LinkDB; |
4 | 5 | ||
5 | require_once 'application/NetscapeBookmarkUtils.php'; | 6 | require_once 'tests/utils/ReferenceLinkDB.php'; |
6 | 7 | ||
7 | /** | 8 | /** |
8 | * Netscape bookmark export | 9 | * Netscape bookmark export |
9 | */ | 10 | */ |
10 | class BookmarkExportTest extends PHPUnit_Framework_TestCase | 11 | class BookmarkExportTest extends \PHPUnit\Framework\TestCase |
11 | { | 12 | { |
12 | /** | 13 | /** |
13 | * @var string datastore to test write operations | 14 | * @var string datastore to test write operations |
@@ -15,7 +16,7 @@ class BookmarkExportTest extends PHPUnit_Framework_TestCase | |||
15 | protected static $testDatastore = 'sandbox/datastore.php'; | 16 | protected static $testDatastore = 'sandbox/datastore.php'; |
16 | 17 | ||
17 | /** | 18 | /** |
18 | * @var ReferenceLinkDB instance. | 19 | * @var \ReferenceLinkDB instance. |
19 | */ | 20 | */ |
20 | protected static $refDb = null; | 21 | protected static $refDb = null; |
21 | 22 | ||
@@ -29,7 +30,7 @@ class BookmarkExportTest extends PHPUnit_Framework_TestCase | |||
29 | */ | 30 | */ |
30 | public static function setUpBeforeClass() | 31 | public static function setUpBeforeClass() |
31 | { | 32 | { |
32 | self::$refDb = new ReferenceLinkDB(); | 33 | self::$refDb = new \ReferenceLinkDB(); |
33 | self::$refDb->write(self::$testDatastore); | 34 | self::$refDb->write(self::$testDatastore); |
34 | self::$linkDb = new LinkDB(self::$testDatastore, true, false); | 35 | self::$linkDb = new LinkDB(self::$testDatastore, true, false); |
35 | } | 36 | } |
diff --git a/tests/NetscapeBookmarkUtils/BookmarkImportTest.php b/tests/netscape/BookmarkImportTest.php index 98c989bc..ccafc161 100644 --- a/tests/NetscapeBookmarkUtils/BookmarkImportTest.php +++ b/tests/netscape/BookmarkImportTest.php | |||
@@ -1,7 +1,7 @@ | |||
1 | <?php | 1 | <?php |
2 | namespace Shaarli\Netscape; | ||
2 | 3 | ||
3 | require_once 'application/NetscapeBookmarkUtils.php'; | 4 | use DateTime; |
4 | |||
5 | use Shaarli\Bookmark\LinkDB; | 5 | use Shaarli\Bookmark\LinkDB; |
6 | use Shaarli\Config\ConfigManager; | 6 | use Shaarli\Config\ConfigManager; |
7 | use Shaarli\History; | 7 | use Shaarli\History; |
@@ -28,7 +28,7 @@ function file2array($filename) | |||
28 | /** | 28 | /** |
29 | * Netscape bookmark import | 29 | * Netscape bookmark import |
30 | */ | 30 | */ |
31 | class BookmarkImportTest extends PHPUnit_Framework_TestCase | 31 | class BookmarkImportTest extends \PHPUnit\Framework\TestCase |
32 | { | 32 | { |
33 | /** | 33 | /** |
34 | * @var string datastore to test write operations | 34 | * @var string datastore to test write operations |
diff --git a/tests/NetscapeBookmarkUtils/input/empty.htm b/tests/netscape/input/empty.htm index e69de29b..e69de29b 100644 --- a/tests/NetscapeBookmarkUtils/input/empty.htm +++ b/tests/netscape/input/empty.htm | |||
diff --git a/tests/NetscapeBookmarkUtils/input/internet_explorer_encoding.htm b/tests/netscape/input/internet_explorer_encoding.htm index 18703cf6..18703cf6 100644 --- a/tests/NetscapeBookmarkUtils/input/internet_explorer_encoding.htm +++ b/tests/netscape/input/internet_explorer_encoding.htm | |||
diff --git a/tests/NetscapeBookmarkUtils/input/lowercase_doctype.htm b/tests/netscape/input/lowercase_doctype.htm index 8911ad19..8911ad19 100644 --- a/tests/NetscapeBookmarkUtils/input/lowercase_doctype.htm +++ b/tests/netscape/input/lowercase_doctype.htm | |||
diff --git a/tests/NetscapeBookmarkUtils/input/netscape_basic.htm b/tests/netscape/input/netscape_basic.htm index affe0cf8..affe0cf8 100644 --- a/tests/NetscapeBookmarkUtils/input/netscape_basic.htm +++ b/tests/netscape/input/netscape_basic.htm | |||
diff --git a/tests/NetscapeBookmarkUtils/input/netscape_nested.htm b/tests/netscape/input/netscape_nested.htm index b486fe18..b486fe18 100644 --- a/tests/NetscapeBookmarkUtils/input/netscape_nested.htm +++ b/tests/netscape/input/netscape_nested.htm | |||
diff --git a/tests/NetscapeBookmarkUtils/input/no_doctype.htm b/tests/netscape/input/no_doctype.htm index 766d398b..766d398b 100644 --- a/tests/NetscapeBookmarkUtils/input/no_doctype.htm +++ b/tests/netscape/input/no_doctype.htm | |||
diff --git a/tests/NetscapeBookmarkUtils/input/same_date.htm b/tests/netscape/input/same_date.htm index 9d58a582..9d58a582 100644 --- a/tests/NetscapeBookmarkUtils/input/same_date.htm +++ b/tests/netscape/input/same_date.htm | |||