diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/NetscapeBookmarkUtils.php | 34 | ||||
-rw-r--r-- | application/Updater.php | 17 |
2 files changed, 42 insertions, 9 deletions
diff --git a/application/NetscapeBookmarkUtils.php b/application/NetscapeBookmarkUtils.php index e7148d00..ab346f81 100644 --- a/application/NetscapeBookmarkUtils.php +++ b/application/NetscapeBookmarkUtils.php | |||
@@ -1,7 +1,13 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Psr\Log\LogLevel; | ||
4 | use Shaarli\Config\ConfigManager; | ||
5 | use Shaarli\NetscapeBookmarkParser\NetscapeBookmarkParser; | ||
6 | use Katzgrau\KLogger\Logger; | ||
7 | |||
3 | /** | 8 | /** |
4 | * Utilities to import and export bookmarks using the Netscape format | 9 | * Utilities to import and export bookmarks using the Netscape format |
10 | * TODO: Not static, use a container. | ||
5 | */ | 11 | */ |
6 | class NetscapeBookmarkUtils | 12 | class NetscapeBookmarkUtils |
7 | { | 13 | { |
@@ -85,14 +91,14 @@ class NetscapeBookmarkUtils | |||
85 | /** | 91 | /** |
86 | * Imports Web bookmarks from an uploaded Netscape bookmark dump | 92 | * Imports Web bookmarks from an uploaded Netscape bookmark dump |
87 | * | 93 | * |
88 | * @param array $post Server $_POST parameters | 94 | * @param array $post Server $_POST parameters |
89 | * @param array $files Server $_FILES parameters | 95 | * @param array $files Server $_FILES parameters |
90 | * @param LinkDB $linkDb Loaded LinkDB instance | 96 | * @param LinkDB $linkDb Loaded LinkDB instance |
91 | * @param string $pagecache Page cache | 97 | * @param ConfigManager $conf instance |
92 | * | 98 | * |
93 | * @return string Summary of the bookmark import status | 99 | * @return string Summary of the bookmark import status |
94 | */ | 100 | */ |
95 | public static function import($post, $files, $linkDb, $pagecache) | 101 | public static function import($post, $files, $linkDb, $conf) |
96 | { | 102 | { |
97 | $filename = $files['filetoupload']['name']; | 103 | $filename = $files['filetoupload']['name']; |
98 | $filesize = $files['filetoupload']['size']; | 104 | $filesize = $files['filetoupload']['size']; |
@@ -119,10 +125,20 @@ class NetscapeBookmarkUtils | |||
119 | $defaultPrivacy = 0; | 125 | $defaultPrivacy = 0; |
120 | 126 | ||
121 | $parser = new NetscapeBookmarkParser( | 127 | $parser = new NetscapeBookmarkParser( |
122 | true, // nested tag support | 128 | true, // nested tag support |
123 | $defaultTags, // additional user-specified tags | 129 | $defaultTags, // additional user-specified tags |
124 | strval(1 - $defaultPrivacy) // defaultPub = 1 - defaultPrivacy | 130 | strval(1 - $defaultPrivacy), // defaultPub = 1 - defaultPrivacy |
131 | $conf->get('resource.data_dir') // log path, will be overridden | ||
132 | ); | ||
133 | $logger = new Logger( | ||
134 | $conf->get('resource.data_dir'), | ||
135 | ! $conf->get('dev.debug') ? LogLevel::INFO : LogLevel::DEBUG, | ||
136 | [ | ||
137 | 'prefix' => 'import.', | ||
138 | 'extension' => 'log', | ||
139 | ] | ||
125 | ); | 140 | ); |
141 | $parser->setLogger($logger); | ||
126 | $bookmarks = $parser->parseString($data); | 142 | $bookmarks = $parser->parseString($data); |
127 | 143 | ||
128 | $importCount = 0; | 144 | $importCount = 0; |
@@ -179,7 +195,7 @@ class NetscapeBookmarkUtils | |||
179 | $importCount++; | 195 | $importCount++; |
180 | } | 196 | } |
181 | 197 | ||
182 | $linkDb->save($pagecache); | 198 | $linkDb->save($conf->get('resource.page_cache')); |
183 | return self::importStatus( | 199 | return self::importStatus( |
184 | $filename, | 200 | $filename, |
185 | $filesize, | 201 | $filesize, |
diff --git a/application/Updater.php b/application/Updater.php index 27cb2f0a..fd7e2073 100644 --- a/application/Updater.php +++ b/application/Updater.php | |||
@@ -1,6 +1,7 @@ | |||
1 | <?php | 1 | <?php |
2 | use Shaarli\Config\ConfigJson; | 2 | use Shaarli\Config\ConfigJson; |
3 | use Shaarli\Config\ConfigPhp; | 3 | use Shaarli\Config\ConfigPhp; |
4 | use Shaarli\Config\ConfigManager; | ||
4 | 5 | ||
5 | /** | 6 | /** |
6 | * Class Updater. | 7 | * Class Updater. |
@@ -363,6 +364,22 @@ class Updater | |||
363 | 364 | ||
364 | return true; | 365 | return true; |
365 | } | 366 | } |
367 | |||
368 | /** | ||
369 | * Add 'http://' to Piwik URL the setting is set. | ||
370 | * | ||
371 | * @return bool true if the update is successful, false otherwise. | ||
372 | */ | ||
373 | public function updateMethodPiwikUrl() | ||
374 | { | ||
375 | if (! $this->conf->exists('plugins.PIWIK_URL') || startsWith($this->conf->get('plugins.PIWIK_URL'), 'http')) { | ||
376 | return true; | ||
377 | } | ||
378 | |||
379 | $this->conf->set('plugins.PIWIK_URL', 'http://'. $this->conf->get('plugins.PIWIK_URL')); | ||
380 | $this->conf->write($this->isLoggedIn); | ||
381 | return true; | ||
382 | } | ||
366 | } | 383 | } |
367 | 384 | ||
368 | /** | 385 | /** |