]> git.mxchange.org Git - friendica.git/commitdiff
allow spaces in @ tags
authorFriendika <info@friendika.com>
Thu, 30 Jun 2011 01:59:05 +0000 (18:59 -0700)
committerFriendika <info@friendika.com>
Thu, 30 Jun 2011 01:59:05 +0000 (18:59 -0700)
boot.php
mod/item.php
mod/photos.php

index 54206d7fe4300d292f78df4fc64ff494d26df286..f66cf4bc0fe39e98f98af7a251fa2506d1c93bb8 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -4,7 +4,7 @@ set_time_limit(0);
 ini_set('pcre.backtrack_limit', 250000);
 
 
-define ( 'FRIENDIKA_VERSION',      '2.2.1025' );
+define ( 'FRIENDIKA_VERSION',      '2.2.1026' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.21'    );
 define ( 'DB_UPDATE_VERSION',      1070      );
 
@@ -2017,7 +2017,7 @@ function get_tags($s) {
 
        $s = preg_replace('/\[code\](.*?)\[\/code\]/sm','',$s);
 
-       if(preg_match_all('/([@#][^ \x0D\x0A,:?]+)([ \x0D\x0A,:?]|$)/',$s,$match)) {
+       if(preg_match_all('/([@#][^ \x0D\x0A,:?]+ [^ \x0D\x0A,:?]+)([ \x0D\x0A,:?]|$)/',$s,$match)) {
                foreach($match[1] as $mtch) {
                        if(strstr($mtch,"]")) {
                                // we might be inside a bbcode color tag - leave it alone
@@ -2030,6 +2030,18 @@ function get_tags($s) {
                }
        }
 
+       if(preg_match_all('/([@#][^ \x0D\x0A,:?]+)([ \x0D\x0A,:?]|$)/',$s,$match)) {
+               foreach($match[1] as $mtch) {
+                       if(strstr($mtch,"]")) {
+                               // we might be inside a bbcode color tag - leave it alone
+                               continue;
+                       }
+                       if(substr($mtch,-1,1) === '.')
+                               $ret[] = substr($mtch,0,-1);
+                       else
+                               $ret[] = $mtch;
+               }
+       }
        return $ret;
 }}
 
index f87b6074a8e736d2616f3890cf0a1e71a7a58d8d..8a4f8293c83a0162f4be6b4e765896de58d550e1 100644 (file)
@@ -244,6 +244,10 @@ function item_post(&$a) {
        }
 
 
+       /**
+        * Next link in any attachment references we find in the post.
+        */
+
        $match = false;
 
        if(preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",$body,$match)) {
@@ -265,10 +269,6 @@ function item_post(&$a) {
                }
        }
 
-
-
-
-
        /**
         * Fold multi-line [code] sequences
         */
@@ -285,13 +285,21 @@ function item_post(&$a) {
 
        $tags = get_tags($body);
 
-       if(($parent_contact) && ($parent_contact['network'] === 'stat') && ($parent_contact['nick']) && (! in_array('@' . $parent_contact['nick'],$tags))) {
+       /**
+        * add a statusnet style reply tag if the original post was from there
+        * and we are replying, and there isn't one already
+        */
+
+       if(($parent_contact) && ($parent_contact['network'] === 'stat') 
+               && ($parent_contact['nick']) && (! in_array('@' . $parent_contact['nick'],$tags))) {
                $body = '@' . $parent_contact['nick'] . ' ' . $body;
                $tags[] = '@' . $parent_contact['nick'];
        }               
 
        if(count($tags)) {
                foreach($tags as $tag) {
+                       if(isset($profile))
+                               unset($profile);
                        if(strpos($tag,'#') === 0) {
                                if(strpos($tag,'[url='))
                                        continue;
@@ -325,7 +333,7 @@ function item_post(&$a) {
                                else {
                                        $newname = $name;
                                        $alias = '';
-                                       if(strstr($name,'_')) {
+                                       if(strstr($name,'_') || strstr($name,' ')) {
                                                $newname = str_replace('_',' ',$name);
                                                $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
                                                        dbesc($newname),
index 2cd4e262282552c706c64bd06aa95473774def18..187eb154ccaa934f7acc82dbbe7e937b35d66de7 100644 (file)
@@ -380,6 +380,8 @@ function photos_post(&$a) {
 
                        if(count($tags)) {
                                foreach($tags as $tag) {
+                                       if(isset($profile))
+                                               unset($profile);
                                        if(strpos($tag,'@') === 0) {
                                                $name = substr($tag,1);
                                                if((strpos($name,'@')) || (strpos($name,'http://'))) {
@@ -401,7 +403,7 @@ function photos_post(&$a) {
                                                }
                                                else {
                                                        $newname = $name;
-                                                       if(strstr($name,'_')) {
+                                                       if(strstr($name,'_') || strstr($name,' ')) {
                                                                $newname = str_replace('_',' ',$name);
                                                                $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
                                                                        dbesc($newname),