mirror of
https://github.com/owncloud/bookmarks.git
synced 2024-11-29 04:24:11 +01:00
Bookmark: set title as domain for export instead of untitled re fix #145
This commit is contained in:
parent
e2a3f79045
commit
d7848b2c9e
18
export.php
18
export.php
@ -10,6 +10,14 @@
|
|||||||
OCP\User::checkLoggedIn();
|
OCP\User::checkLoggedIn();
|
||||||
OCP\App::checkAppEnabled('bookmarks');
|
OCP\App::checkAppEnabled('bookmarks');
|
||||||
|
|
||||||
|
function getDomainWithoutExt($name){
|
||||||
|
$pos = strripos($name, '.');
|
||||||
|
if($pos === false){
|
||||||
|
return $name;
|
||||||
|
}else{
|
||||||
|
return substr($name, 0, $pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$file = <<<EOT
|
$file = <<<EOT
|
||||||
<!DOCTYPE NETSCAPE-Bookmark-file-1>
|
<!DOCTYPE NETSCAPE-Bookmark-file-1>
|
||||||
@ -21,13 +29,15 @@ Do Not Edit! -->
|
|||||||
<H1>Bookmarks</H1>
|
<H1>Bookmarks</H1>
|
||||||
<DL><p>
|
<DL><p>
|
||||||
EOT;
|
EOT;
|
||||||
|
|
||||||
$l = new OC_l10n('bookmarks');
|
|
||||||
$unamed_label = $l->t('untitled');
|
|
||||||
$bookmarks = OC_Bookmarks_Bookmarks::findBookmarks(0, 'id', array(), true, -1);
|
$bookmarks = OC_Bookmarks_Bookmarks::findBookmarks(0, 'id', array(), true, -1);
|
||||||
foreach($bookmarks as $bm) {
|
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 .= '<DT><A HREF="'.$bm['url'].'" TAGS="'.implode(',', $bm['tags']).'">';
|
$file .= '<DT><A HREF="'.$bm['url'].'" TAGS="'.implode(',', $bm['tags']).'">';
|
||||||
$file .= htmlspecialchars($unamed_label, ENT_QUOTES, 'UTF-8').'</A>';
|
$file .= htmlspecialchars($title, ENT_QUOTES, 'UTF-8').'</A>';
|
||||||
if($bm['description'])
|
if($bm['description'])
|
||||||
$file .= '<DD>'.htmlspecialchars($bm['description'], ENT_QUOTES, 'UTF-8');
|
$file .= '<DD>'.htmlspecialchars($bm['description'], ENT_QUOTES, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user