When "local_search" is activated, then point all hashtags to the local server

This commit is contained in:
Michael 2017-08-18 22:12:40 +00:00
parent 5c5db12706
commit f8946c9e0a
2 changed files with 8 additions and 9 deletions

View 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",

View 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)) {