aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorpafcu <pafcu@iki.fi>2015-01-12 21:07:54 +0200
committerpafcu <pafcu@iki.fi>2015-01-12 21:07:54 +0200
commita0134de28abdaf820d14a161a05578c16911cdbd (patch)
treeb2b71519398dbd68e9f641719bc334d087d267a3 /include/text.php
parent55eb6be30885919882f05162f53ea2216ecffac3 (diff)
parentadc9564b5cc5f1fc410220514285927052cdfe4a (diff)
downloadvolse-hubzilla-a0134de28abdaf820d14a161a05578c16911cdbd.tar.gz
volse-hubzilla-a0134de28abdaf820d14a161a05578c16911cdbd.tar.bz2
volse-hubzilla-a0134de28abdaf820d14a161a05578c16911cdbd.zip
Merge pull request #844 from pafcu/moretagging
Refactor mention code to make it more reusable
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/text.php b/include/text.php
index e0bf393e5..035c092a6 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2350,3 +2350,33 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
return array('replaced' => $replaced, 'termtype' => $termtype, 'term' => $newname, 'url' => $url, 'contact' => $r[0]);
}
+
+function linkify_tags($a, &$body, $uid, $profile_uid) {
+ $str_tags = '';
+ $tagged = array();
+ $result = array();
+
+ $tags = get_tags($body);
+ if(count($tags)) {
+ foreach($tags as $tag) {
+ // If we already tagged 'Robert Johnson', don't try and tag 'Robert'.
+ // Robert Johnson should be first in the $tags array
+
+ $fullnametagged = false;
+ for($x = 0; $x < count($tagged); $x ++) {
+ if(stristr($tagged[$x],$tag . ' ')) {
+ $fullnametagged = true;
+ break;
+ }
+ }
+ if($fullnametagged)
+ continue;
+
+ $success = handle_tag($a, $body, $access_tag, $str_tags, ($uid) ? $uid : $profile_uid , $tag);
+ $results[] = array('success' => $success, 'access_tag' => $access_tag);
+ if($success['replaced']) $tagged[] = $tag;
+ }
+ }
+ return $results;
+}
+