]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge commit 'br3nda/0.8.x-hashtags' into 0.8.x
authorCraig Andrews <candrews@integralblue.com>
Wed, 22 Jul 2009 14:23:17 +0000 (10:23 -0400)
committerCraig Andrews <candrews@integralblue.com>
Wed, 22 Jul 2009 14:23:17 +0000 (10:23 -0400)
classes/Notice.php
lib/router.php
lib/util.php

index 101fadb6743ed8b5ca923801e85cf1b2c470ef0a..7f002d838c6e4a095ead2587c3708d34522dcbc5 100644 (file)
@@ -97,13 +97,21 @@ class Notice extends Memcached_DataObject
     function saveTags()
     {
         /* extract all #hastags */
-        $count = preg_match_all('/(?:^|\s)#([A-Za-z0-9_\-\.]{1,64})/', strtolower($this->content), $match);
+        $count = preg_match_all('/(?:^|\s)#([\pL\pN_\-\.]{1,64})/', strtolower($this->content), $match);
         if (!$count) {
             return true;
         }
+        
+        //turn each into their canonical tag
+        //this is needed to remove dupes before saving e.g. #hash.tag = #hashtag
+        $hashtags = array();
+        for($i=0; $i<count($match[1]); $i++) {
+             $hashtags[] = common_canonical_tag($match[1][$i]);
+        }
 
         /* Add them to the database */
-        foreach(array_unique($match[1]) as $hashtag) {
+        foreach(array_unique($hashtags) as $hashtag) {
             /* elide characters we don't want in the tag */
             $this->saveTag($hashtag);
         }
@@ -112,8 +120,6 @@ class Notice extends Memcached_DataObject
 
     function saveTag($hashtag)
     {
-        $hashtag = common_canonical_tag($hashtag);
-
         $tag = new Notice_tag();
         $tag->notice_id = $this->id;
         $tag->tag = $hashtag;
index 5e0fcfc9465e0cc2feac4d5e5b612271e3b7ee88..8e48364979a3ff9c59a51f5d325164ced8ccd249 100644 (file)
@@ -211,7 +211,7 @@ class Router
                     array('tag' => '[a-zA-Z0-9]+'));
         $m->connect('tag/:tag',
                     array('action' => 'tag'),
-                    array('tag' => '[a-zA-Z0-9]+'));
+                    array('tag' => '[\pL\pN_\-\.]{1,64}'));
 
         $m->connect('peopletag/:tag',
                     array('action' => 'peopletag'),
index f23f10e2c0879a479b9d895826c31b388e2fd179..c7c82dba29fd7197e68397c8124e1420c54218dc 100644 (file)
@@ -404,7 +404,7 @@ function common_render_text($text)
 
     $r = preg_replace('/[\x{0}-\x{8}\x{b}-\x{c}\x{e}-\x{19}]/', '', $r);
     $r = common_replace_urls_callback($r, 'common_linkify');
-    $r = preg_replace('/(^|\(|\[|\s+)#([A-Za-z0-9_\-\.]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r);
+    $r = preg_replace('/(^|\(|\[|\s+)#([\pL\pN_\-\.]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r);
     // XXX: machine tags
     return $r;
 }