summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2009-07-22 10:23:17 -0400
committerCraig Andrews <candrews@integralblue.com>2009-07-22 10:23:17 -0400
commite70a79d6ab5e9cd8894490d4fc0d3b855e807edc (patch)
tree642a3955ddf938f770d035148f5c2a5d1b534cc1 /classes
parentdb4ffca5350a11835c2c990f8d77d7cabb365a43 (diff)
parentd95f45f0705467cfc7e3650db932e43f0a20e45f (diff)
Merge commit 'br3nda/0.8.x-hashtags' into 0.8.x
Diffstat (limited to 'classes')
-rw-r--r--classes/Notice.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index 101fadb67..7f002d838 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -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;