<?php
+namespace Shaarli\Netscape;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
use Psr\Log\LogLevel;
use Shaarli\Bookmark\LinkDB;
use Shaarli\Config\ConfigManager;
public static function filterAndFormat($linkDb, $selection, $prependNoteUrl, $indexUrl)
{
// see tpl/export.html for possible values
- if (! in_array($selection, array('all', 'public', 'private'))) {
- throw new Exception(t('Invalid export selection:') .' "'.$selection.'"');
+ if (!in_array($selection, array('all', 'public', 'private'))) {
+ throw new Exception(t('Invalid export selection:') . ' "' . $selection . '"');
}
$bookmarkLinks = array();
$status .= vsprintf(
t(
'was successfully processed in %d seconds: '
- .'%d links imported, %d links overwritten, %d links skipped.'
+ . '%d links imported, %d links overwritten, %d links skipped.'
),
[$duration, $importCount, $overwriteCount, $skipCount]
);
/**
* Imports Web bookmarks from an uploaded Netscape bookmark dump
*
- * @param array $post Server $_POST parameters
- * @param array $files Server $_FILES parameters
- * @param LinkDB $linkDb Loaded LinkDB instance
- * @param ConfigManager $conf instance
- * @param History $history History instance
+ * @param array $post Server $_POST parameters
+ * @param array $files Server $_FILES parameters
+ * @param LinkDB $linkDb Loaded LinkDB instance
+ * @param ConfigManager $conf instance
+ * @param History $history History instance
*
* @return string Summary of the bookmark import status
*/
}
// Overwrite existing links?
- $overwrite = ! empty($post['overwrite']);
+ $overwrite = !empty($post['overwrite']);
// Add tags to all imported links?
if (empty($post['default_tags'])) {
);
$logger = new Logger(
$conf->get('resource.data_dir'),
- ! $conf->get('dev.debug') ? LogLevel::INFO : LogLevel::DEBUG,
+ !$conf->get('dev.debug') ? LogLevel::INFO : LogLevel::DEBUG,
[
'prefix' => 'import.',
'extension' => 'log',
}
// Add a new link - @ used for UNIX timestamps
- $newLinkDate = new DateTime('@'.strval($bkm['time']));
+ $newLinkDate = new DateTime('@' . strval($bkm['time']));
$newLinkDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
$newLink['created'] = $newLinkDate;
$newLink['id'] = $linkDb->getNextId();
"Shaarli\\Exceptions\\": "application/exceptions",
"Shaarli\\Feed\\": "application/feed",
"Shaarli\\Http\\": "application/http",
+ "Shaarli\\Netscape\\": "application/netscape",
"Shaarli\\Render\\": "application/render",
"Shaarli\\Security\\": "application/security",
"Shaarli\\Updater\\": "application/updater",
require_once 'application/http/UrlUtils.php';
require_once 'application/updater/UpdaterUtils.php';
require_once 'application/FileUtils.php';
-require_once 'application/NetscapeBookmarkUtils.php';
require_once 'application/TimeZone.php';
require_once 'application/Utils.php';
require_once 'application/PluginManager.php';
use \Shaarli\Feed\FeedBuilder;
use \Shaarli\History;
use \Shaarli\Languages;
+use \Shaarli\Netscape\NetscapeBookmarkUtils;
use \Shaarli\Render\PageBuilder;
use \Shaarli\Render\ThemeUtils;
use \Shaarli\Router;
<?php
+namespace Shaarli\Netscape;
use Shaarli\Bookmark\LinkDB;
-require_once 'application/NetscapeBookmarkUtils.php';
+require_once 'tests/utils/ReferenceLinkDB.php';
/**
* Netscape bookmark export
*/
-class BookmarkExportTest extends PHPUnit_Framework_TestCase
+class BookmarkExportTest extends \PHPUnit\Framework\TestCase
{
/**
* @var string datastore to test write operations
protected static $testDatastore = 'sandbox/datastore.php';
/**
- * @var ReferenceLinkDB instance.
+ * @var \ReferenceLinkDB instance.
*/
protected static $refDb = null;
*/
public static function setUpBeforeClass()
{
- self::$refDb = new ReferenceLinkDB();
+ self::$refDb = new \ReferenceLinkDB();
self::$refDb->write(self::$testDatastore);
self::$linkDb = new LinkDB(self::$testDatastore, true, false);
}