From d6030714f3bbdfa63053040ca86655f4b4a6c83f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 19 Dec 2010 10:18:07 -0500 Subject: [PATCH] Use Notice_bookmark::saveNew() from NewbookmarkAction --- plugins/Bookmark/newbookmark.php | 71 +++----------------------------- 1 file changed, 5 insertions(+), 66 deletions(-) diff --git a/plugins/Bookmark/newbookmark.php b/plugins/Bookmark/newbookmark.php index 466785de8d..079babccd4 100644 --- a/plugins/Bookmark/newbookmark.php +++ b/plugins/Bookmark/newbookmark.php @@ -128,73 +128,12 @@ class NewbookmarkAction extends Action throw new ClientException(_('Bookmark must have an URL.')); } - $rawtags = 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 - $nickname = User::singleUserNickname(); - $url = common_local_url('showstream', - array('nickname' => $nickname, - 'tag' => $tag)); - } else { - $url = common_local_url('tag', array('tag' => $tag)); - } - $attrs = array('href' => $url, - 'rel' => $tag, - 'class' => 'tag'); - $taglinks[] = XMLStringer::estring('a', $attrs, $tag); - } - - $content = sprintf(_('"%s" %s %s %s'), - $this->_title, - File_redirection::makeShort($this->_url, $this->_user), - $this->_description, - implode(' ', $hashtags)); - - $rendered = sprintf(_(''. - '%s '. - '%s '. - '%s'. - ''), - htmlspecialchars($this->_url), - htmlspecialchars($this->_title), - htmlspecialchars($this->_description), - implode(' ', $taglinks)); - - $options = array('urls' => array($this->_url), - 'rendered' => $rendered, - 'tags' => $tags); - - $saved = Notice::saveNew($this->_user->id, - $content, - 'web', - $options); - - if (!empty($saved)) { - $nb = new Notice_bookmark(); - $nb->notice_id = $saved->id; - $nb->title = $this->_title; - $nb->description = $this->_description; - $nb->insert(); - } + $saved = Notice_bookmark::saveNew($this->_user, + $this->_title, + $this->_url, + $this->_tags, + $this->_description); } catch (ClientException $ce) { $this->_error = $ce->getMessage(); -- 2.39.5