Use constants for the BBCode modes

This commit is contained in:
Michael 2020-05-16 16:28:15 +00:00
parent 7b8178e046
commit 0cf517ad76
9 changed files with 48 additions and 52 deletions

View file

@ -644,7 +644,7 @@ class Processor
$title = $matches[3];
}
$title = trim(HTML::toPlaintext(BBCode::convert($title, false, 2, true), 0));
$title = trim(HTML::toPlaintext(BBCode::convert($title, false, BBCode::API, true), 0));
if (strlen($title) > 20) {
$title = substr($title, 0, 20) . '...';

View file

@ -1215,7 +1215,7 @@ class Transmitter
{
$event = [];
$event['name'] = $item['event-summary'];
$event['content'] = BBCode::convert($item['event-desc'], false, 9);
$event['content'] = BBCode::convert($item['event-desc'], false, BBCode::ACTIVITYPUB);
$event['startTime'] = DateTimeFormat::utc($item['event-start'] . '+00:00', DateTimeFormat::ATOM);
if (!$item['event-nofinish']) {
@ -1309,7 +1309,7 @@ class Transmitter
$regexp = "/[@!]\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
$body = preg_replace_callback($regexp, ['self', 'mentionCallback'], $body);
$data['content'] = BBCode::convert($body, false, 9);
$data['content'] = BBCode::convert($body, false, BBCode::ACTIVITYPUB);
}
// The regular "content" field does contain a minimized HTML. This is done since systems like

View file

@ -951,7 +951,7 @@ class DFRN
$htmlbody = "[b]" . $item['title'] . "[/b]\n\n" . $htmlbody;
}
$htmlbody = BBCode::convert($htmlbody, false, 7);
$htmlbody = BBCode::convert($htmlbody, false, BBCode::OSTATUS);
}
$author = self::addEntryAuthor($doc, "author", $item["author-link"], $item);
@ -2428,7 +2428,8 @@ class DFRN
if (($term != "") && ($scheme != "")) {
$parts = explode(":", $scheme);
if ((count($parts) >= 4) && (array_shift($parts) == "X-DFRN")) {
$termurl = implode(":", $parts);
$termurl = array_pop($parts);
$termurl = array_pop($parts) . $termurl;
Tag::store($item['uri-id'], Tag::IMPLICIT_MENTION, $term, $termurl);
}
}

View file

@ -1456,7 +1456,7 @@ class OStatus
XML::addElement($doc, $author, "name", $owner["nick"]);
XML::addElement($doc, $author, "email", $owner["addr"]);
if ($show_profile) {
XML::addElement($doc, $author, "summary", BBCode::convert($owner["about"], false, 7));
XML::addElement($doc, $author, "summary", BBCode::convert($owner["about"], false, BBCode::OSTATUS));
}
$attributes = ["rel" => "alternate", "type" => "text/html", "href" => $owner["url"]];
@ -1483,7 +1483,7 @@ class OStatus
XML::addElement($doc, $author, "poco:preferredUsername", $owner["nick"]);
XML::addElement($doc, $author, "poco:displayName", $owner["name"]);
if ($show_profile) {
XML::addElement($doc, $author, "poco:note", BBCode::convert($owner["about"], false, 7));
XML::addElement($doc, $author, "poco:note", BBCode::convert($owner["about"], false, BBCode::OSTATUS));
if (trim($owner["location"]) != "") {
$element = $doc->createElement("poco:address");
@ -1895,7 +1895,7 @@ class OStatus
if (!$toplevel) {
if (!empty($item['title'])) {
$title = BBCode::convert($item['title'], false, 7);
$title = BBCode::convert($item['title'], false, BBCode::OSTATUS);
} else {
$title = sprintf("New note by %s", $owner["nick"]);
}
@ -1984,7 +1984,7 @@ class OStatus
$body = "[b]".$item['title']."[/b]\n\n".$body;
}
$body = BBCode::convert($body, false, 7);
$body = BBCode::convert($body, false, BBCode::OSTATUS);
XML::addElement($doc, $entry, "content", $body, ["type" => "html"]);