mirror of
https://github.com/friendica/friendica
synced 2025-04-25 13:50:10 +00:00
API: We now can post statuses via API
This commit is contained in:
parent
d9bfd78bd4
commit
1cc341033f
4 changed files with 251 additions and 11 deletions
|
@ -2115,6 +2115,32 @@ class BBCode
|
|||
return array_unique($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand tags to URLs
|
||||
*
|
||||
* @param string $body
|
||||
* @return string body with expanded tags
|
||||
*/
|
||||
public static function expandTags(string $body)
|
||||
{
|
||||
return preg_replace_callback("/([!#@])([^\^ \x0D\x0A,;:?\']*[^\^ \x0D\x0A,;:?!\'.])/",
|
||||
function ($match) {
|
||||
switch ($match[1]) {
|
||||
case '!':
|
||||
case '@':
|
||||
$contact = Contact::getByURL($match[2]);
|
||||
if (!empty($contact)) {
|
||||
return $match[1] . '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
|
||||
} else {
|
||||
return $match[1] . $match[2];
|
||||
}
|
||||
break;
|
||||
case '#':
|
||||
return $match[1] . '[url=' . 'https://' . DI::baseUrl() . '/search?tag=' . $match[2] . ']' . $match[2] . '[/url]';
|
||||
}
|
||||
}, $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a custom function on a text after having escaped blocks enclosed in the provided tag list.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue