aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2016-05-06 21:50:55 +0200
committerVirtualTam <virtualtam@flibidi.net>2016-05-06 21:50:55 +0200
commit00be05aaf5fc0238bbc27cec61341fc0fa0a8424 (patch)
treed4a484ca0eef729f5c02d95e0b20cc40e120853a /application
parent6275a65969a84a360588e0a62b025963e9ec98e0 (diff)
parentbb4a23aa863b63e6148a085c15dedd7c960b4206 (diff)
downloadShaarli-00be05aaf5fc0238bbc27cec61341fc0fa0a8424.tar.gz
Shaarli-00be05aaf5fc0238bbc27cec61341fc0fa0a8424.tar.zst
Shaarli-00be05aaf5fc0238bbc27cec61341fc0fa0a8424.zip
Merge pull request #554 from virtualtam/fix/bookmark-export
Export: allow prepending notes with the Shaarli instance's URL
Diffstat (limited to 'application')
-rw-r--r--application/NetscapeBookmarkUtils.php15
1 files changed, 11 insertions, 4 deletions
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
13 * - timestamp link addition date, using the Unix epoch format 13 * - timestamp link addition date, using the Unix epoch format
14 * - taglist comma-separated tag list 14 * - taglist comma-separated tag list
15 * 15 *
16 * @param LinkDB $linkDb The link datastore 16 * @param LinkDB $linkDb Link datastore
17 * @param string $selection Which links to export: (all|private|public) 17 * @param string $selection Which links to export: (all|private|public)
18 * @param bool $prependNoteUrl Prepend note permalinks with the server's URL
19 * @param string $indexUrl Absolute URL of the Shaarli index page
18 * 20 *
19 * @throws Exception Invalid export selection 21 * @throws Exception Invalid export selection
20 * 22 *
21 * @return array The links to be exported, with additional fields 23 * @return array The links to be exported, with additional fields
22 */ 24 */
23 public static function filterAndFormat($linkDb, $selection) 25 public static function filterAndFormat($linkDb, $selection, $prependNoteUrl, $indexUrl)
24 { 26 {
25 // see tpl/export.html for possible values 27 // see tpl/export.html for possible values
26 if (! in_array($selection, array('all','public','private'))) { 28 if (! in_array($selection, array('all', 'public', 'private'))) {
27 throw new Exception('Invalid export selection: "'.$selection.'"'); 29 throw new Exception('Invalid export selection: "'.$selection.'"');
28 } 30 }
29 31
@@ -39,6 +41,11 @@ class NetscapeBookmarkUtils
39 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); 41 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
40 $link['timestamp'] = $date->getTimestamp(); 42 $link['timestamp'] = $date->getTimestamp();
41 $link['taglist'] = str_replace(' ', ',', $link['tags']); 43 $link['taglist'] = str_replace(' ', ',', $link['tags']);
44
45 if (startsWith($link['url'], '?') && $prependNoteUrl) {
46 $link['url'] = $indexUrl . $link['url'];
47 }
48
42 $bookmarkLinks[] = $link; 49 $bookmarkLinks[] = $link;
43 } 50 }
44 51