From fce2078dfb4a503287cad0ec7e199524b65ed06f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 18 Dec 2010 17:21:40 -0500 Subject: [PATCH] code done on debugging in bookmarks --- plugins/Bookmark/BookmarkPlugin.php | 52 +++++++++++++++++++++++++++++ plugins/Bookmark/newbookmark.php | 16 +++++++-- 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/plugins/Bookmark/BookmarkPlugin.php b/plugins/Bookmark/BookmarkPlugin.php index 2137d0c225..e50e45cade 100644 --- a/plugins/Bookmark/BookmarkPlugin.php +++ b/plugins/Bookmark/BookmarkPlugin.php @@ -87,6 +87,12 @@ class BookmarkPlugin extends Plugin return true; } + function onEndShowStyles($action) + { + $action->style('.bookmark_tags li { display: inline; }'); + return true; + } + /** * Load related modules when needed * @@ -132,6 +138,52 @@ class BookmarkPlugin extends Plugin return true; } + function onStartShowNoticeItem($nli) + { + $nb = Notice_bookmark::staticGet('notice_id', + $nli->notice->id); + + if (!empty($nb)) { + $att = $nli->notice->attachments(); + $nli->out->elementStart('h3'); + $nli->out->element('a', + array('href' => $att[0]->url), + $nb->title); + $nli->out->elementEnd('h3'); + $nli->out->element('p', + array('class' => 'bookmark_description'), + $nb->description); + $nli->out->elementStart('p'); + $nli->out->element('a', array('href' => $nli->profile->profileurl, + 'class' => 'bookmark_author', + 'title' => $nli->profile->getBestName()), + $nli->profile->getBestName()); + $nli->out->elementEnd('p'); + $tags = $nli->notice->getTags(); + $nli->out->elementStart('ul', array('class' => 'bookmark_tags')); + foreach ($tags as $tag) { + if (common_config('singleuser', 'enabled')) { + // regular TagAction isn't set up in 1user mode + $nickname = User::singleUserNickname(); + $url = common_local_url('showstream', + array('nickname' => $nickname, + 'tag' => $tag)); + } else { + $url = common_local_url('tag', array('tag' => $tag)); + } + $nli->out->elementStart('li'); + $nli->out->element('a', array('rel' => 'tag', + 'href' => $url), + $tag); + $nli->out->elementEnd('li'); + $nli->out->text(' '); + } + $nli->out->elementEnd('ul'); + return false; + } + return true; + } + function onPluginVersion(&$versions) { $versions[] = array('name' => 'Sample', diff --git a/plugins/Bookmark/newbookmark.php b/plugins/Bookmark/newbookmark.php index 7352b1b952..466785de8d 100644 --- a/plugins/Bookmark/newbookmark.php +++ b/plugins/Bookmark/newbookmark.php @@ -128,15 +128,25 @@ class NewbookmarkAction extends Action throw new ClientException(_('Bookmark must have an URL.')); } - // XXX: filter "for:nickname" tags + $rawtags = preg_split('/[\s,]+/', $this->_tags); - $tags = array_map('common_canonical_tag', - preg_split('/[\s,]+/', $this->_tags)); + $tags = array(); + + // filter "for:nickname" tags + + foreach ($rawtags as $tag) { + if (0 == mb_stricmp($tag, 'for:', 4)) { + + } else { + $tags[] = common_canonical_tag($tag); + } + } $hashtags = array(); $taglinks = array(); foreach ($tags as $tag) { + $hashtags[] = '#'.$tag; if (common_config('singleuser', 'enabled')) { // regular TagAction isn't set up in 1user mode