From d7848b2c9e541920228dcf492b37dda620c967fa Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Mon, 5 Nov 2012 21:50:48 +0000 Subject: [PATCH] Bookmark: set title as domain for export instead of untitled re fix #145 --- export.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/export.php b/export.php index fcf906be..46c932db 100644 --- a/export.php +++ b/export.php @@ -10,6 +10,14 @@ OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('bookmarks'); +function getDomainWithoutExt($name){ + $pos = strripos($name, '.'); + if($pos === false){ + return $name; + }else{ + return substr($name, 0, $pos); + } +} $file = << @@ -21,13 +29,15 @@ Do Not Edit! -->

Bookmarks

EOT; - -$l = new OC_l10n('bookmarks'); -$unamed_label = $l->t('untitled'); $bookmarks = OC_Bookmarks_Bookmarks::findBookmarks(0, 'id', array(), true, -1); foreach($bookmarks as $bm) { + $title = $bm['title']; + if(trim($title) ===''){ + $url_parts = parse_url($bm['url']); + $title = isset($url_parts['host']) ? getDomainWithoutExt($url_parts['host']) : $bm['url']; + } $file .= '

'; - $file .= htmlspecialchars($unamed_label, ENT_QUOTES, 'UTF-8').''; + $file .= htmlspecialchars($title, ENT_QUOTES, 'UTF-8').''; if($bm['description']) $file .= '
'.htmlspecialchars($bm['description'], ENT_QUOTES, 'UTF-8'); }