Merge pull request #6414 from MrPetovan/bug/4609-add-support-hubzilla-forum-link
Add support for Hubzilla forum mentions (starting with !)
This commit is contained in:
commit
4f5fb40202
2 changed files with 13 additions and 7 deletions
|
@ -1809,6 +1809,9 @@ class BBCode extends BaseObject
|
||||||
* @brief Callback function to replace a Friendica style mention in a mention for Diaspora
|
* @brief Callback function to replace a Friendica style mention in a mention for Diaspora
|
||||||
*
|
*
|
||||||
* @param array $match Matching values for the callback
|
* @param array $match Matching values for the callback
|
||||||
|
* [1] = Mention type (! or @)
|
||||||
|
* [2] = Name
|
||||||
|
* [3] = Address
|
||||||
* @return string Replaced mention
|
* @return string Replaced mention
|
||||||
*/
|
*/
|
||||||
private static function bbCodeMention2DiasporaCallback($match)
|
private static function bbCodeMention2DiasporaCallback($match)
|
||||||
|
@ -1823,7 +1826,7 @@ class BBCode extends BaseObject
|
||||||
return $match[0];
|
return $match[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$mention = '@{' . $match[2] . '; ' . $contact['addr'] . '}';
|
$mention = $match[1] . '{' . $match[2] . '; ' . $contact['addr'] . '}';
|
||||||
return $mention;
|
return $mention;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1908,7 +1911,7 @@ class BBCode extends BaseObject
|
||||||
if ($for_diaspora) {
|
if ($for_diaspora) {
|
||||||
$url_search_string = "^\[\]";
|
$url_search_string = "^\[\]";
|
||||||
$text = preg_replace_callback(
|
$text = preg_replace_callback(
|
||||||
"/([@]\[(.*?)\])\(([$url_search_string]*?)\)/ism",
|
"/([@!])\[(.*?)\]\(([$url_search_string]*?)\)/ism",
|
||||||
['self', 'bbCodeMention2DiasporaCallback'],
|
['self', 'bbCodeMention2DiasporaCallback'],
|
||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
|
|
|
@ -44,27 +44,30 @@ class Markdown extends BaseObject
|
||||||
* @brief Callback function to replace a Diaspora style mention in a mention for Friendica
|
* @brief Callback function to replace a Diaspora style mention in a mention for Friendica
|
||||||
*
|
*
|
||||||
* @param array $match Matching values for the callback
|
* @param array $match Matching values for the callback
|
||||||
|
* [1] = mention type (@ or !)
|
||||||
|
* [2] = name (optional)
|
||||||
|
* [3] = address
|
||||||
* @return string Replaced mention
|
* @return string Replaced mention
|
||||||
*/
|
*/
|
||||||
private static function diasporaMention2BBCodeCallback($match)
|
private static function diasporaMention2BBCodeCallback($match)
|
||||||
{
|
{
|
||||||
if ($match[2] == '') {
|
if ($match[3] == '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = Contact::getDetailsByAddr($match[2]);
|
$data = Contact::getDetailsByAddr($match[3]);
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = $match[1];
|
$name = $match[2];
|
||||||
|
|
||||||
if ($name == '') {
|
if ($name == '') {
|
||||||
$name = $data['name'];
|
$name = $data['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return '@[url=' . $data['url'] . ']' . $name . '[/url]';
|
return $match[1] . '[url=' . $data['url'] . ']' . $name . '[/url]';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -93,7 +96,7 @@ class Markdown extends BaseObject
|
||||||
|
|
||||||
$s = self::convert($s);
|
$s = self::convert($s);
|
||||||
|
|
||||||
$regexp = "/@\{(?:([^\}]+?); )?([^\} ]+)\}/";
|
$regexp = "/([@!])\{(?:([^\}]+?); ?)?([^\} ]+)\}/";
|
||||||
$s = preg_replace_callback($regexp, ['self', 'diasporaMention2BBCodeCallback'], $s);
|
$s = preg_replace_callback($regexp, ['self', 'diasporaMention2BBCodeCallback'], $s);
|
||||||
|
|
||||||
$s = str_replace('#', '#', $s);
|
$s = str_replace('#', '#', $s);
|
||||||
|
|
Loading…
Reference in a new issue