]> git.mxchange.org Git - friendica.git/commitdiff
When "local_search" is activated, then point all hashtags to the local server
authorMichael <heluecht@pirati.ca>
Fri, 18 Aug 2017 22:12:40 +0000 (22:12 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 18 Aug 2017 22:12:40 +0000 (22:12 +0000)
include/items.php
include/tags.php

index 8ba41e9e240758265d9e99693269731e24c6e1ed..db426fd82f59d18b78b1240623300c2945e8dbbe 100644 (file)
@@ -1178,13 +1178,14 @@ function item_body_set_hashtags(&$item) {
 
        $URLSearchString = "^\[\]";
 
-       /// @TODO old-lost code?
-       // All hashtags should point to the home server
-       //$item["body"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
-       //              "#[url=".App::get_baseurl()."/search?tag=$2]$2[/url]", $item["body"]);
+       // All hashtags should point to the home server if "local_search" is activated
+       if (Config::get('system', 'local_search')) {
+               $item["body"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+                               "#[url=".App::get_baseurl()."/search?tag=$2]$2[/url]", $item["body"]);
 
-       //$item["tag"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
-       //              "#[url=".App::get_baseurl()."/search?tag=$2]$2[/url]", $item["tag"]);
+               $item["tag"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+                               "#[url=".App::get_baseurl()."/search?tag=$2]$2[/url]", $item["tag"]);
+       }
 
        // mask hashtags inside of url, bookmarks and attachments to avoid urls in urls
        $item["body"] = preg_replace_callback("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
index 6c45a4aee21c4fe63ae07c5660036848892741d4..de716edef0b5d6052af6844c81a7b0284fc20d63 100644 (file)
@@ -8,8 +8,6 @@ function create_tags_from_item($itemid) {
        $profile_base_friendica = $profile_data['host'].$profile_data['path']."/profile/";
        $profile_base_diaspora = $profile_data['host'].$profile_data['path']."/u/";
 
-       $searchpath = App::get_baseurl()."/search?tag=";
-
        $messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `created`, `received`, `title`, `body`, `tag`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
 
        if (!$messages)
@@ -46,7 +44,7 @@ function create_tags_from_item($itemid) {
        $pattern = "/\W\#([^\[].*?)[\s'\".,:;\?!\[\]\/]/ism";
        if (preg_match_all($pattern, $data, $matches))
                foreach ($matches[1] as $match)
-                       $tags["#".strtolower($match)] = ""; // $searchpath.strtolower($match);
+                       $tags["#".strtolower($match)] = "";
 
        $pattern = "/\W([\#@])\[url\=(.*?)\](.*?)\[\/url\]/ism";
        if (preg_match_all($pattern, $data, $matches, PREG_SET_ORDER)) {