From f8946c9e0a409dc8874836cd412e5d411fa2c9b0 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 18 Aug 2017 22:12:40 +0000 Subject: [PATCH] When "local_search" is activated, then point all hashtags to the local server --- include/items.php | 13 +++++++------ include/tags.php | 4 +--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/items.php b/include/items.php index 8ba41e9e24..db426fd82f 100644 --- a/include/items.php +++ b/include/items.php @@ -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", diff --git a/include/tags.php b/include/tags.php index 6c45a4aee2..de716edef0 100644 --- a/include/tags.php +++ b/include/tags.php @@ -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)) { -- 2.39.5