]> git.mxchange.org Git - friendica.git/commitdiff
add contact-id to auto-complete response to resolve duplicates
authorFriendika <info@friendika.com>
Fri, 28 Oct 2011 02:12:30 +0000 (19:12 -0700)
committerFriendika <info@friendika.com>
Fri, 28 Oct 2011 02:12:30 +0000 (19:12 -0700)
include/bb2diaspora.php
js/fk.autocomplete.js
mod/item.php
mod/photos.php
mod/search.php

index f7398067b9f0f2527e584bc7c1c56b1e680e73a6..efbf3475870b2ecf7f5107eb089d8f59838774d3 100644 (file)
@@ -17,11 +17,36 @@ function diaspora2bb($s) {
        $s = preg_replace("/\[url\=?(.*?)\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism",'[vimeo]$2[/vimeo]',$s); 
        $s = preg_replace("/\[url\=https?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism",'[vimeo]$1[/vimeo]',$s); 
        $s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url]$2$3$4[/url]',$s);
-
+       $s = scale_diaspora_images($s);
        return $s;
 }
 
 
+function scale_diaspora_images($s) {
+
+       $matches = null;
+       $c = preg_match_all('/\[img\](.*?)\[\/img\]/ism',$s,$matches,PREG_SET_ORDER);
+       if($c) {
+               require_once('include/Photo.php');
+               foreach($matches as $mtch) {
+                       $i = fetch_url($mtch[1]);
+                       if($i) {
+                               $ph = new Photo($i);
+                               if($ph->is_valid()) {
+                                       if($ph->getWidth() > 600 || $ph->getHeight() > 600) {
+                                               $ph->scaleImage(600);
+                                               $new_width = $ph->getWidth();
+                                               $new_height = $ph->getHeight();
+                                               $s = str_replace($mtch[0],'[img=' . $new_width . 'x' . $new_height. ']' . $mtch[1] . '[/img]'
+                                                       . "\n" . '[url=' . $mtch[1] . ']' . t('view full size') . '[/url]' . "\n",$s);
+                                       }
+                               }
+                       }
+               }
+       }
+       return $s;
+}
+
 function stripdcode_br_cb($s) {
        return '[code]' . str_replace('<br />', "\n\t", $s[1]) . '[/code]';
 }
index 6a1f1965aa9b429ab357f10bf1cacd3f479c50e1..c17d61fc575c627b03f1805dd226e0115f2a4ade 100644 (file)
@@ -65,7 +65,7 @@ ACPopup.prototype._search = function(){
                                that.cont.show();
                                $(data.items).each(function(){
                                        html = "<img src='{0}' height='16px' width='16px'>{1} ({2})".format(this.photo, this.name, this.nick)
-                                       that.add(html, this.nick + ' - ' + this.link);
+                                       that.add(html, this.nick + '+' + this.id + ' - ' + this.link);
                                });                     
                        } else {
                                that.cont.hide();
index 0e855d54d91d3315cbf950a39d6971065ca152ca..2c8704a31598dcb101b9f5c041708d0fb3f847af 100644 (file)
@@ -407,7 +407,17 @@ function item_post(&$a) {
                                else {
                                        $newname = $name;
                                        $alias = '';
-                                       if(strstr($name,'_') || strstr($name,' ')) {
+                                       $tagcid = 0;
+                                       if(strrpos($newname,'+'))
+                                               $tagcid = intval(substr($newname,strrpos($newname,'+') + 1));
+
+                                       if($tagcid) {
+                                               $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+                                                       intval($tagcid),
+                                                       intval($profile_uid)
+                                               );
+                                       }
+                                       elseif(strstr($name,'_') || strstr($name,' ')) {
                                                $newname = str_replace('_',' ',$name);
                                                $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
                                                        dbesc($newname),
index 663d0a40cbaa8d1ec65cdddb3c61dd79bb0eb230..63bd46a6cbde1ddeb63795dfe7580e1a561bdf14 100644 (file)
@@ -408,7 +408,18 @@ function photos_post(&$a) {
                                                }
                                                else {
                                                        $newname = $name;
-                                                       if(strstr($name,'_') || strstr($name,' ')) {
+                                                       $alias = '';
+                                                       $tagcid = 0;
+                                                       if(strrpos($newname,'+'))
+                                                               $tagcid = intval(substr($newname,strrpos($newname,'+') + 1));
+
+                                                       if($tagcid) {
+                                                               $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+                                                                       intval($tagcid),
+                                                                       intval($profile_uid)
+                                                               );
+                                                       }
+                                                       elseif(strstr($name,'_') || strstr($name,' ')) {
                                                                $newname = str_replace('_',' ',$name);
                                                                $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
                                                                        dbesc($newname),
index e2c365fd3ace99bbff38ebb5475db0411e70e265..819100204c3bdfd875fce1d533e9840695c49442 100644 (file)
@@ -96,10 +96,11 @@ function search_content(&$a) {
        // Only public wall posts can be shown
        // OR your own posts if you are a logged in member
 
+       $escaped_search = str_replace(array('[',']'),array('\\[','\\]'),$search);
 
 //     $s_bool  = sprintf("AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )", dbesc($search));
        $s_regx  = sprintf("AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' )", 
-               dbesc($search), dbesc('\\]' . $search . '\\['));
+               dbesc($escaped_search), dbesc('\\]' . $escaped_search . '\\['));
 
 //     if(mb_strlen($search) >= 3)
 //             $search_alg = $s_bool;