From 4c0ee7f41ffb614e0e25d9838d1dc0cc8c05ad1d Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 5 Oct 2011 20:48:00 -0700 Subject: [PATCH] bug 173 --- include/diaspora.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/include/diaspora.php b/include/diaspora.php index 33b8336f3a..d4edc3f113 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -515,6 +515,26 @@ function diaspora_post($importer,$xml) { $body = diaspora2bb($xml->raw_message); $datarray = array(); + + $str_tags = ''; + + $tags = get_tags($body); + + if(count($tags)) { + foreach($tags as $tag) { + if(strpos($tag,'#') === 0) { + if(strpos($tag,'[url=')) + continue; + $basetag = str_replace('_',' ',substr($tag,1)); + $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body); + if(strlen($str_tags)) + $str_tags .= ','; + $str_tags .= '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]'; + continue; + } + } + } + $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $contact['id']; $datarray['wall'] = 0; @@ -530,6 +550,7 @@ function diaspora_post($importer,$xml) { $datarray['author-link'] = $contact['url']; $datarray['author-avatar'] = $contact['thumb']; $datarray['body'] = $body; + $datarray['tag'] = $str_tags; $datarray['app'] = 'Diaspora'; $message_id = item_store($datarray); @@ -633,6 +654,26 @@ function diaspora_comment($importer,$xml,$msg) { $message_id = $diaspora_handle . ':' . $guid; $datarray = array(); + + $str_tags = ''; + + $tags = get_tags($body); + + if(count($tags)) { + foreach($tags as $tag) { + if(strpos($tag,'#') === 0) { + if(strpos($tag,'[url=')) + continue; + $basetag = str_replace('_',' ',substr($tag,1)); + $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body); + if(strlen($str_tags)) + $str_tags .= ','; + $str_tags .= '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]'; + continue; + } + } + } + $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $contact['id']; $datarray['wall'] = $parent_item['wall']; @@ -653,6 +694,7 @@ function diaspora_comment($importer,$xml,$msg) { $datarray['author-link'] = $person['url']; $datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']); $datarray['body'] = $body; + $datarray['tag'] = $str_tags; $datarray['app'] = 'Diaspora'; $message_id = item_store($datarray);