aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2018-12-04 00:13:42 +0100
committerVirtualTam <virtualtam@flibidi.net>2019-01-12 23:11:19 +0100
commit349b0144011e25f2b1a727b1d28d49d55b3b2ebb (patch)
tree99cf1746e597672389afc1b9231afa16df65de5a /application
parenta932f486f20f3daf8ad657d8d39a6d6c316e66eb (diff)
downloadShaarli-349b0144011e25f2b1a727b1d28d49d55b3b2ebb.tar.gz
Shaarli-349b0144011e25f2b1a727b1d28d49d55b3b2ebb.tar.zst
Shaarli-349b0144011e25f2b1a727b1d28d49d55b3b2ebb.zip
namespacing: \Shaarli\Netscape\NetscapeBookmarkUtils
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'application')
-rw-r--r--application/netscape/NetscapeBookmarkUtils.php (renamed from application/NetscapeBookmarkUtils.php)27
1 files changed, 16 insertions, 11 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
3namespace Shaarli\Netscape;
4
5use DateTime;
6use DateTimeZone;
7use Exception;
3use Psr\Log\LogLevel; 8use Psr\Log\LogLevel;
4use Shaarli\Bookmark\LinkDB; 9use Shaarli\Bookmark\LinkDB;
5use Shaarli\Config\ConfigManager; 10use 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();