X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FNetscapeBookmarkUtils.php;h=fdbb0ad7be393df486c6e4b0d0d4f0195e1a6c27;hb=bb4a23aa863b63e6148a085c15dedd7c960b4206;hp=8a296705f469a29c28ea267584a248179d3f540f;hpb=6275a65969a84a360588e0a62b025963e9ec98e0;p=github%2Fshaarli%2FShaarli.git diff --git a/application/NetscapeBookmarkUtils.php b/application/NetscapeBookmarkUtils.php index 8a296705..fdbb0ad7 100644 --- a/application/NetscapeBookmarkUtils.php +++ b/application/NetscapeBookmarkUtils.php @@ -13,17 +13,19 @@ class NetscapeBookmarkUtils * - timestamp link addition date, using the Unix epoch format * - taglist comma-separated tag list * - * @param LinkDB $linkDb The link datastore - * @param string $selection Which links to export: (all|private|public) + * @param LinkDB $linkDb Link datastore + * @param string $selection Which links to export: (all|private|public) + * @param bool $prependNoteUrl Prepend note permalinks with the server's URL + * @param string $indexUrl Absolute URL of the Shaarli index page * * @throws Exception Invalid export selection * * @return array The links to be exported, with additional fields */ - public static function filterAndFormat($linkDb, $selection) + public static function filterAndFormat($linkDb, $selection, $prependNoteUrl, $indexUrl) { // see tpl/export.html for possible values - if (! in_array($selection, array('all','public','private'))) { + if (! in_array($selection, array('all', 'public', 'private'))) { throw new Exception('Invalid export selection: "'.$selection.'"'); } @@ -39,6 +41,11 @@ class NetscapeBookmarkUtils $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); $link['timestamp'] = $date->getTimestamp(); $link['taglist'] = str_replace(' ', ',', $link['tags']); + + if (startsWith($link['url'], '?') && $prependNoteUrl) { + $link['url'] = $indexUrl . $link['url']; + } + $bookmarkLinks[] = $link; }