]> git.mxchange.org Git - friendica.git/commitdiff
bug 173
authorFriendika <info@friendika.com>
Thu, 6 Oct 2011 03:48:00 +0000 (20:48 -0700)
committerFriendika <info@friendika.com>
Thu, 6 Oct 2011 03:48:00 +0000 (20:48 -0700)
include/diaspora.php

index 33b8336f3af562593335cc411d20481630748f69..d4edc3f11363579cbb1336bccc7efa76e50f78c0 100644 (file)
@@ -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);